=======================================================================================
Examples of issuing commands to GuildFTPD from within mIRC
=======================================================================================

<< Kick a user based on an IP address, hostname, or GuildFTPD UserID >>
/dde openftp kickuser "" 192.168.1.1
/dde openftp kickuser "" dynamic123.adelphia.net
/dde openftp kickuser "" 37

<< Ban a user permanently (for last 1, they must be logged on) >>
/dde openftp banuser "" 192.168.1.1 #hash
/dde openftp banuser "" dynamic123.adelphia.net
/dde openftp banuser "" 37

<< Ban a user based on an IP address, for 15 minutes >>
/dde openftp banuser "" 192.168.1.1 15 #hash

<< Change the port >>
/dde openftp setport "" 1999

NOTE: if #hash is present, then the user will be banned or unbanned only if it is the
correct hash.  the correct hash should come from the aliases below from another siteop.
If you parse the hash from their messages then put the # on the front then send in the
command, you should have some protection.  If you don't put the # then it is a ban or
unban with no checking.

=======================================================================================
Format for the aliases which GuildFTPD will call.  These all must be defined in mIRC
if DDE is enabled in GuildFTPD
=======================================================================================

---------------------------------------------------------------------------------------
/oftpConnection IPADDR HOSTNAME
---------------------------------------------------------------------------------------
  
  Called for every new connection attempt.

  IPADDR : IP Address
  HOSTNAME : Hostname

---------------------------------------------------------------------------------------
/oftpLogon ACCTNAME IPADDR HOSTNAME CONNECTS CONNECTSFROMIP MAXCONNECTS MAXCONNECTSFROMIP
---------------------------------------------------------------------------------------

  Called for every new logon.
  
  ACCTNAME : Account name.
  IPADDR : IP Address
  HOSTNAME : Hostname
  CONNECTS : Number of connects to this account (inluding this one)
  CONNECTSFROMIP : Number of connects to this account from this IP (inluding this one)
  MAXCONNECTS : Maximum of allowed connects for this account.
  MAXCONNECTSFROMIP : Maximum number of connects allowed from one IP to this account.

---------------------------------------------------------------------------------------
/oftpLogoff ACCTNAME IPADDR HOSTNAME CONNECTS MAXCONNECTS
---------------------------------------------------------------------------------------

  Called for every logoff.

  ACCTNAME : Account name.
  IPADDR : IP Address
  HOSTNAME : Hostname
  CONNECTS : Number of connects to this account (inluding this one)
  MAXCONNECTS : Maximum of allowed connects for this account.

---------------------------------------------------------------------------------------
/oftpConnUpdate INTERNALNO ACCTNAME IPADDR HOSTNAME ACTION
---------------------------------------------------------------------------------------

  Called once every 5 minutes for every logged on user.  5 minutes will be programmable 
  in future releases.

  INTERNALNO : Unique number to identify user.  This may be used for future commands.
  IPADDR : IP Address
  ACCTNAME : Account name.
  HOSTNAME : Hostname
  ACTION : Text description of what the user is doing.  Could contain spaces ( use $5- )

---------------------------------------------------------------------------------------
/oftpStart VERSION PORTNO STATUS
---------------------------------------------------------------------------------------

  Called at start of server

  VERSION : Version number (xx.yy)
  PORTNO : Port which the server is operating on.
  STATUS : "Listening" or "Failure"

---------------------------------------------------------------------------------------
/oftpUpdate PORTNO TOTALCONNECTIONS STATUS
---------------------------------------------------------------------------------------

  Called once every 5 minutes

  PORTNO : Port which the server is operating on.
  TOTALCONNECTIONS : Total number of logged on users.
  STATUS : "Listening" or "Failure"

---------------------------------------------------------------------------------------
/oftpBannedIP IPADDR HOSTNAME DURATION HASH
---------------------------------------------------------------------------------------

  Called whenever a user is banned.  Not called when a user is banned by DDE to prevent
  circular loops.

  IPADDR : IP Address
  HOSTNAME : Hostname
  DURATION : Time in minutes of the BAN
  HASH : Unique string that can be provided back to another OpenFTP in ban commands to 
         authenticate.

---------------------------------------------------------------------------------------
/oftpUnbannedIP IPADDR HOSTNAME HASH
---------------------------------------------------------------------------------------

  Called whenever a user is unbanned.  Not called when a user is unbanned by DDE to prevent
  circular loops.

  IPADDR : IP Address
  HOSTNAME : Hostname
  HASH : Unique string that can be provided back to another OpenFTP in unban commands to 
         authenticate.

=======================================================================================
These are examples of using some of the aliases which GuildFTPD will call.
=======================================================================================

/oftpLogon { 
  echo 4 Logon to account $1 from IP $2, host $3.  $4 of $6 connections for this account.  $5 of $7 connections for this IP.
}

/oftpLogoff {
  echo 4 User $1 from IP $2 host $3 logged off.
}

/oftpConnUpdate {
  echo  ConnUpdate:  No: $1 IP: $2 Name: $3  Host: $4 Action: $5-
}

/oftpUpdate {
  echo Update Port $1 Total Connections $2 Status: $3
}

/oftpBannedIP {
  /openftplog BannedIP IP: $1 Duration: $2 Hash: $3
}

/oftpUnbannedIP {
  /openftplog UnbannedIP IP: $1 Hash: $2
}

=======================================================================================
Here are some commands that may help out in resolving nick names if you do your own
scripting.
=======================================================================================

/hostToNick {
  /set %tsting2 *!*@ $1
  %tsting2 = $remove(%tsting2,$chr(32))
  return $ial( %tsting2 , 1 ).nick
}

/hostToNickChanCount {
  /set %tsting2 *!*@ $1
  %tsting2 = $remove(%tsting2,$chr(32))
  return $ialchan( %tsting2, $2 , 0 )
}

=======================================================================================
SAMPLE to make it all work.  Pick and choose what you want.
Does kicking if not in #warezguild and port hopping (changing port every so often)
=======================================================================================


---------------------------------------------------------------------------------------
Make an alias to put your siteup (if you want it)
Sets up a timer for my ad and one for changing the port.
---------------------------------------------------------------------------------------

/siteup {
  /openftplog  9Site going up
  /timer8 0 1000 /dowarezmsg
  /timer9 -o 0 14400 /porthopper
}

/sitedown {
  /openftplog  9Site going down
  timer8 off
  timer9 off
}

---------------------------------------------------------------------------------------
This shows the message but also only changes ports just before message.
---------------------------------------------------------------------------------------

/dowarezmsg {
  if %newport == 1 {  /openftplog 4Changing to port: %mynewport }
  if %newport == 1 { /dde openftp setport "" %mynewport }
  /set %newport 0
  /warezmsg #warezguild
}

---------------------------------------------------------------------------------------
Common stuff to convert IPs to Nicks
---------------------------------------------------------------------------------------

/hostToNick {
  /set %tsting2 *!*@ $1
  %tsting2 = $remove(%tsting2,$chr(32))
  return $ial( %tsting2 , 1 ).nick
}

/hostToNickCount {
  /set %tsting2 *!*@ $1
  %tsting2 = $remove(%tsting2,$chr(32))
  return $ial( %tsting2 , 0 )
}

/hostToNickChanCount {
  /set %tsting2 *!*@ $1
  %tsting2 = $remove(%tsting2,$chr(32))
  return $ialchan( %tsting2 , $2 , 0 )
}

---------------------------------------------------------------------------------------
Change this alias to customize where and how you want the window of openftp events
---------------------------------------------------------------------------------------

/openftplog {
  window -bk @openftp
  aline @openftp $asctime(hh:nn:ss) - $1-
}

---------------------------------------------------------------------------------------
This changes the ports (keeps it between 2000 and 7000)
---------------------------------------------------------------------------------------

/porthopper {
  /set %mynewport %myport
  /inc %mynewport
  /openftplog  9Preparing to change port to %mynewport
  if %myport > 7000 { /set %mynewport 2000 }
  if %myport < 2000 { /set %mynewport 2000 }
  /set %newport 1
}

---------------------------------------------------------------------------------------
Just does some logging
---------------------------------------------------------------------------------------

/oftpConnection {
  /hostToNick $2
  /set %oftpNick $result
  /hostToNickCount $2
  /set %oftpNickCount $result

  if %oftpNickCount <= 0 {
    /hostToNick $2
    /set %oftpNick $result
    /hostToNickCount $2
    /set %oftpNickCount $result
  }

  /openftplog  Attempted connection by %oftpNick
}

/oftpConnUpdate {
  /hostToNick $4 
  /set %oftpNick $result
  ;  /openftplog  ConnUpdate:  No: $1 IP: $2 Name: $3  Host: $4 Action: $5-
  ;  /openftplog  ConnUpdate:  No: $1 IP: $2 Name: $3  Host: $4-
}

---------------------------------------------------------------------------------------
This changes the port if the server says it is not listening (port problem)
---------------------------------------------------------------------------------------

/oftpUpdate {
  /openftplog Update Port $1 Total Connections $2 Status: $3
  /set %myport $1
  if $3 != Listening { /porthopper }
}

---------------------------------------------------------------------------------------
Log bans and unbans (also send to channel)
---------------------------------------------------------------------------------------

/oftpBannedIP {
  /openftplog BannedIP $1 $2 $3
  /msg #openftpmsg Ban $1 $2 $3
}

/oftpUnbannedIP {
  /openftplog UnbannedIP $1 $2 $3
  /msg #openftpmsg Unban $1 $3
}

---------------------------------------------------------------------------------------
Ok, the big one.  You of course must remove the lines like this below
---------------------------------------------------------------------------------------

/oftpLogon {
  /hostToNick $3 
  /set %oftpNick $result
;---------------------------------------------------------------------------------------
;Use #warezguild or whatever
;---------------------------------------------------------------------------------------
  /hostToNickChanCount $3 #warezguild
  /set %oftpNickChanCount $result

  /openftpdbg 5 nicks in guild %oftpNickChanCount ( %oftpNick )

  if %oftpNickChanCount <= 0 {
    /hostToNick $2
    /set %oftpNick $result
    /hostToNickChanCount $2 #warezguild
    /set %oftpNickChanCount $result
    /openftpdbg 5 nicks in guild %oftpNickChanCount ( %oftpNick )
  }

;---------------------------------------------------------------------------------------
;doc is my logon but you use yours.  also, make %doclogin something else too.
;---------------------------------------------------------------------------------------
  /openftplog 4Logon by %oftpNick : $2 to account $1.  $4 of $6 connections.
  if $1 == doc { 
    /set %doclogin $4 
    if %oftpNickChanCount == 0 {
      /dde openftp kickuser "" $2
      /dde openftp banuser "" $2 15
      /openftplog 12Kicked IP $2 for not being in the guild
    }
  }
;---------------------------------------------------------------------------------------
;fast is another logon i have. (change %fastlogin too)
;---------------------------------------------------------------------------------------
  if $1 == fast { 
    /set %fastlogin $4 
    if %oftpNickChanCount == 0 {
      /dde openftp kickuser "" $2
      /dde openftp banuser "" $2 15
      /openftplog 12Kicked IP $2 for not being in the guild
    }
  }
}

/oftpLogoff {
  /hostToNick $3 
  /set %oftpNick $result

  if %oftpNickChanCount <= 0 {
    /hostToNick $2
    /set %oftpNick $result
  }

  ;  /openftplog User $1 from IP $2 $3 $result logged off.
  /openftplog 4Logoff by %oftpNick : $2 from account $1.

;---------------------------------------------------------------------------------------
;Use the same stuff as in /oftpLogon
;---------------------------------------------------------------------------------------
  if $1 == doc   {  
    /set %doclogin $4
  }
  if $1 == fast { 
    /set %fastlogin $4
  }
}


=======================================================================================
 Finally, the whole point of %doclogin and %fastlogin is so you can use in your ad
 and make it show the number of logged in users.

  EXAMPLE:  Log on to my site as doc/phibez ( %doclogin of 5 users ).

  IMPORTANT:  Must have %doclogin with spaces around it or mirc gets mad.
=======================================================================================
