Advertisement
illpastethat

FTP and MC players madmatty

Sep 8th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 3.57 KB | None | 0 0
  1. on *:TEXT:!players:#mcwall: { enable #madserver | msg Madserver players }
  2. #madserver off
  3. on *:TEXT:*:?: {
  4.   if ($nick == Madserver) && (:&9Developers:&e != $1) {
  5.     if (*there are * players online* iswm $1-) {
  6.       set %mc.players $3
  7.     }
  8.     else {
  9.       set %mc.names $addtok(%mc.names,$remove($2-,$chr(32)),44)
  10.       var %x 2
  11.       while ($($+($,%x),2) != $null) {
  12.         set %mc.ftp %mc.ftp $($+($,%x),2) $+([,$right($left($1,-2),-3),]),$null)
  13.         inc %x 2
  14.       }
  15.     }
  16.     if (!$timer(mcplayers)) {
  17.       .timermcplayers 1 2 mcplayers
  18.     }
  19.   }
  20. }
  21. alias mcplayers {
  22.   msg #mcwall %mc.players $iif(%mc.players == 1,player,players) -- $replace(%mc.names,$chr(44),$chr(44) $+ $chr(32))
  23.   var %x 1
  24.   while ($calc(%x + 1) < $numtok(%mc.ftp,32)) {
  25.     write $iif(%x == 1,-c,$null) online.txt $gettok(%mc.ftp,%x $+(-,$calc(%x + 1)),32)
  26.     inc %x 2
  27.   }
  28.   ftp upload
  29.   .unset %mc*
  30.   .disable #madserver
  31. }
  32. #madserver end
  33.  
  34. alias ftp {
  35.   var %file $iif($$1 == upload,$mircdironline.txt,$mircdir), $&
  36.     %getfile $iif($1 == upload,/public_html/,/public_html/namebans.txt)
  37.   sockclose *ftp_test. $+ $1
  38.   sockopen ftp_test. $+ $1 mcwall.bugs3.com 21
  39.   sockmark ftp_test. $+ $1 $+(%getfile,ÿ,%file)
  40. }
  41. on *:sockopen:ftp_test.*:{
  42.   sockwrite -nt $sockname USER u106703019
  43.   sockwrite -nt $sockname PASS password
  44.   ; Specify a BINARY transfer
  45.   sockwrite -nt $sockname TYPE I
  46.   ; Set the start position to 0
  47.   sockwrite -nt $sockname REST 0
  48.   sockwrite -nt $sockname CWD /
  49.   ; Initiate a PASSIVE connection, meaning that we wait for the server to tell us which port/IP to connect to
  50.   sockwrite -nt $sockname PASV
  51. }
  52. on *:sockread:ftp_test.*:{
  53.   var %s
  54.   sockread %s
  55.   echo -a S1: %s
  56.   ; A simple bit of regex to determine that the server's reply is in the format: "227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)" - a1.a2.a3.a4 is the IP and 256*p1+p2 is the port.
  57.   if ($regex(%s,/227.*?\(([0-9,]+)\)/)) {
  58.     tokenize 44 $regml(1)  
  59.     ; Establish a NEW connection to the IP with the port suggested by the server (it's a passive connection)
  60.     sockopen 2 $+ $sockname $replace($1-4,$chr(32),.) $calc($5* 256+$6)
  61.   }
  62. }
  63. ; A little regex is used so that $regml(1) will contain either "upload" or "download"
  64. on $*:sockopen:/2ftp_test\.(.*)/:{
  65.   ; Now we have connected to the IP on the port suggested by the FTP server, tokenize the sock mark
  66.   tokenize 255 $sock($mid($sockname,2)).mark
  67.   ; Now we need to check if the user wanted to upload or download a file
  68.   if ($regml(1) == upload) {
  69.     ; Tell the original connection the name of the file we want to upload
  70.     sockwrite -nt $mid($sockname,2) DELE $1 $+ $nopath($2)
  71.     sockwrite -nt $mid($sockname,2) STOR $1 $+ $nopath($2)
  72.     ; Read the contents of the file into a binary variable (called &bvar)
  73.     bread $qt($2) 0 $file($2).size &bvar
  74.     ; Write the data to the new connection
  75.     sockwrite $sockname &bvar
  76.   }
  77.   else {
  78.     ; Tell the original connection the path and name of the file we want to retrieve
  79.     sockwrite -nt $mid($sockname,2) RETR $1
  80.     ; Set the sockmark to 1 so that we know the next lot of data will be the bytes of the file
  81.     sockmark $sockname 1
  82.   }
  83. }
  84. on *:sockread:2ftp_test.*:{
  85.   tokenize 255 $sock($mid($sockname,2)).mark
  86.   sockread &b
  87.   ; If the "226 Transfer complete" message is displayed, stop writing to the file.
  88.   if ($bfind(&b,1,226).text == 1) sockmark $sockname
  89.   ; If the sock mark is set to the value "1", it means the server is sending us the bytes of the file
  90.   if ($sock($sockname).mark) bwrite $qt($2 $+ $nopath($1)) -1 -1 &b
  91.   else echo -a S2: $bvar(&b,1-).text
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement