SamB Posted April 9, 2007 Share Posted April 9, 2007 I have made a PHP script which allows users to register on a MTASA Race server with a password, not just via IP (infact it doesnt require peoples IPs at all ) Instead of storing usernames and passwords on the mIRC side, you store them server side. They are saved as level 1 RCON admins. So, they can use /rcon_login [password] to login . Make sure you set all your RCON commands required levels to be above 1! Dont want random people using RCON... Here is the script: http://xendot.com/mta/mta.rar There is a readme in it ^^. If you want to see an example of it, go to http://xendot.com/mta/ . I have added a theme to that though, the default theme is just white so its easy to change. I will release an example mtama script to go with it soon... Link to comment
stylo Posted April 9, 2007 Share Posted April 9, 2007 he thx but i havent an webserver that allows php or somthing i dont have an webserver at all Link to comment
lil Toady Posted April 9, 2007 Share Posted April 9, 2007 nice, make it also able for ppl to register straight from the server Link to comment
Tommis Posted April 10, 2007 Share Posted April 10, 2007 Hey, Good job boylett, keep up the good work! Cya, Tommis Link to comment
SamB Posted April 10, 2007 Author Share Posted April 10, 2007 nice, make it also able for ppl to register straight from the server Yes Im looking for a way to use ftp from mirc. But ofcourse they cant send admins pms =/. If there was a player controlled by mirc then it wud be fine, but I think its against the rules and I havent a clue about sockets . Link to comment
lil Toady Posted April 10, 2007 Share Posted April 10, 2007 well, you could do that easier. make a command !register. It PMs the user a random generated password. and also sends the data to that php form that will do everything. (not to the ftp) And after that user will be able to change his pass on that php page. Link to comment
SamB Posted April 10, 2007 Author Share Posted April 10, 2007 Whats the random function in mirc? Link to comment
lil Toady Posted April 10, 2007 Share Posted April 10, 2007 rand(,), so rand(1,10) will generate a random number between 1 and 10. You'll have to write some algorithm to generate a password with characters and numbers urself Link to comment
SamB Posted April 10, 2007 Author Share Posted April 10, 2007 ok, thanks . But how do I connect to ftp via mirc? Link to comment
Tommis Posted April 10, 2007 Share Posted April 10, 2007 (edited) Hey, Take a look around if there is a dll for that, if so, that would be the easiest method. Other than that, if that fails, then i guess your stuck with sockets. Lucky enough, mirc makes it quite easy to use sockets comparing to other launguages. Ask **lil_today bout that, hes quite skilled in that area. ;p Cya, Tommis Edited April 11, 2007 by Guest Link to comment
SamB Posted April 10, 2007 Author Share Posted April 10, 2007 By today I guess you meant toady. ok if i cannot find one on the internet somewhere I will ask toady. Link to comment
Tommis Posted April 11, 2007 Share Posted April 11, 2007 Hey, Take a look at this http://www.mircscripts.org/showdoc.php?type=tutorial&id=1531 Might be some help. Or This.. ;-------------- - ---- - - - ; FTP by praetorian ; [email protected] ; http://detox.xs3.com ;---------------- - - - ; this snippet allows you to upload and download files to and from an ftp server. ; contains signals so you may easily create your own front end or integrate it into an existing script. ; ; use this code however you like, i commented and organized it to help you in case you want to write your own. ; ; syntax: /ftp <"local file"> <"remote file"> ; note: filenames must be complete paths and contained in quotes, i.e. "c:\myfile.ext" ; ; CHANGES on 10/04/2004: ; - added signal ftp.start ; sent when a transfer is initiated. use this to open custom @wins or dialogs. ; - added signal ftp.connect ; sent when a control connection to the server is opened. ; - added signal ftp.close ; sent when raw 221 (goodbye) is recieved from the server. ; - added signal ftp.error ; sent when an error occurs when connecting or communicating with the ftp server, in regards to the control connection. ; this signal was missing from the original code (oops!) ; ;-------------------------- ------------------------------------ - - - ;-------------------- - - ; FTP control connection ;------------ - ----- - - alias ftp { var %sn $+(ftp.,$gettok($2,1,58),.,$ticks),%lf = $gettok($1-,2,34),%rf = $gettok($1-,4,34) ; open socket to ftp server and mark it with login and file info sockopen %sn $gettok($2,1,58) $iif($gettok($2,2,58),$ifmatch,21) sockmark %sn $1 $3 $4 %lf $+ * $+ %rf ; set timer to check for connection timeout $+(.timerftpt,%sn) 1 30 ftp_timeout %sn $gettok($2,1,58) .signal ftp.start $gettok($2,1,58) } alias ftp_timeout { ; if no response from server, close socket and send timeout signal sockclose $1 .signal ftp.timeout $2 } on 1:sockopen:ftp.*:{ ; if connect error, send error signal if ($sockerr) { .signal -n ftp.error $deltok($gettok($sockname,2-,46),-1,46) $sock($sockname).wsmsg | return } ; if no error, send connect signal else { .signal -n ftp.connect $deltok($gettok($sockname,2-,46),-1,46) } ; turn timeout timer off $+(.timerftpt,$sockname) off } on 1:sockread:ftp.*:{ ; send signal if error if ($sockerr) { .signal -n ftp.error $deltok($gettok($sockname,2-,46),-1,46) $sock($sockname).wsmsg | return } :read ; read socket data sockread %fd ; make sure socket data isnt null, parse it if (%fd) { tokenize 32 $sock($sockname).mark ; response 220 (welcome text), send user if (220* iswm %fd) { sockwrite -n $sockname user $2 } ; response 331 (password required), send password if (331* iswm %fd) { sockwrite -n $sockname pass $3 } ; response 230 (logged in), send CWD command to enter the right directory ; (used a loop in case of multiple directories) if (230* iswm %fd) { var %p = $nofile($gettok($4-,2,42)),%p = $iif($right(%p,1) = \,$left(%p,-1-),%p),%i = 1 if ($count(%p,\)) { while ($gettok(%p,%i,92)) { sockwrite -n $sockname CWD $ifmatch sockmark $sockname $+($iif($1 = download,d,u),%i) $2- inc %i } } else { sockwrite -n $sockname CWD %p } } ; response 250 (CWD command successful), send TYPE I (binary) if (250* iswm %fd) { sockwrite -n $sockname TYPE I } ; response 200 (type set), send PASV to enter passive mode if (200* iswm %fd) { sockwrite -n $sockname PASV } ; response 227 (entering passive mode), open data connection and begin transfer if (227* iswm %fd) { ; if transfer type is download, send RETR and open socket to server if ($1 = download) || ($1 = d1) { sockwrite -n $sockname RETR $nopath($gettok($4-,2,42)) ftp_datadownload $gettok($gettok(%fd,2,40),1,41) $4- } ; if transfer is upload, send STOR, open socket to server and begin uploading elseif ($1 = upload) || ($1 = u1) { sockwrite -n $sockname STOR $nopath($gettok($4-,1,42)) ftp_dataupload $gettok($gettok(%fd,2,40),1,41) $gettok($4-,1,42) } ; used in case multiple CWD commands were issued; makes sure connection is made ; on most current remote port elseif ($right($1,1) isnum) { sockmark $sockname $+($left($1,1),$calc($right($1,1) - 1)) $2- } } if (150* iswm %fd) { ; find socket that is downloading this file and mark it with the size var %i = 1,%filn = $gettok($gettok(%fd,8-,32),1,40),%fils = $gettok($gettok(%fd,2,40),1,32) while ($sock(ftpdatadownload.*,%i)) { var %im = $ifmatch if ($nopath($gettok($gettok($sock(%im).mark,2,32),2,42)) = %filn) { sockmark %im %fils $gettok($sock(%im).mark,2-,32) | break } inc %i } } ; response 226 (transfer complete), send QUIT if (226* iswm %fd) { sockwrite -n $sockname QUIT } ; signal ftp text response .signal ftp.text $deltok($gettok($sockname,2-,46),-1,46) %fd ; response 221 (goodbye), transfer complete, send close signal if (221* iswm %fd) { .signal ftp.close $deltok($gettok($sockname,2-,46),-1,46) } } if ($sockbr) { goto read } } ;----------- - --- - - ; FTP upload ;-------- -------- - - alias ftp_dataupload { var %fn = $2- tokenize 44 $1 var %fi = $replace($1-4,$chr(32),$chr(46)) var %fp = $longip($+(0.0.,$replace($5-7,$chr(32),$chr(46)))) var %sn = $+(ftpdataupload.,%fi,.,$ticks) ; open socket and mark it with needed info sockopen %sn %fi %fp sockmark %sn 0 %fn ; set a timer to check for connection timeout $+(.timerftpt,%sn) 1 30 ftp_timeout %sn %fi } on 1:sockopen:ftpdataupload.*:{ ; send error signal if error if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } ; send connect signal if no error else { .signal ftp.dataconnection.connect $sock($sockname).ip $sock($sockname).port } ; cancel timeout $+(.timerftpt,$sockname) off tokenize 32 $sock($sockname).mark ; read file and send first packet bread $+(",$2-,") $1 4096 &bvar sockwrite $sockname &bvar ; mark socket with current position of file sockmark $sockname 4096 $2- } on 1:sockwrite:ftpdataupload.*:{ ; send error signal if error if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } tokenize 32 $sock($sockname).mark ; read file bread $+(",$2-,") $1 4096 &bvar var %s = $sock($sockname).ip $sock($sockname).port $file($+(",$2-,")).size $sock($sockname).sent $sock($sockname).to ; if data was read, send it if ($bvar(&bvar,0)) { sockwrite $sockname &bvar sockmark $sockname $calc($1 + 4096) $2- .signal ftp.dataconnection.send %s } ; if no data was read, file is finished sending, so close socket else { .signal ftp.dataconnection.send.close $deltok(%s,3,32) | sockclose $sockname } } on 1:sockclose:ftpdataupload.*:{ ; if error send signal, else send close signal if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } else { .signal ftp.dataconnection.send.close $sock($sockname).ip $sock($sockname).port $sock($sockname).sent $sock($sockname).to } } ;------------ -- - - ; FTP download ;------- - - alias ftp_datadownload { var %fn = $2- tokenize 44 $1 var %fi = $replace($1-4,$chr(32),$chr(46)) var %fp = $longip($+(0.0.,$replace($5-7,$chr(32),$chr(46)))) var %sn = $+(ftpdatadownload.,%fi,.,$ticks) ; open socket and mark it with needed data sockopen %sn %fi %fp sockmark %sn 0 %fn ; start timeout timer $+(.timerftpt,%sn) 1 30 ftp_timeout %sn %fi } on 1:sockopen:ftpdatadownload.*:{ ; send error signal if error if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } ; send connect signal if no error else { .signal ftp.dataconnection.connect $sock($sockname).ip $sock($sockname).port } ; cancel timeout $+(.timerftpt,$sockname) off } on 1:sockread:ftpdatadownload.*:{ ; if error, send signal if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } ; read socket :read sockread &fd ; write to file bwrite $gettok($gettok($sock($sockname).mark,2-,32),1,42) -1 -1 &fd ; if data is still waiting to be read if ($sockbr) { goto read } ; send signal .signal ftp.dataconnection.receive $sock($sockname).ip $sock($sockname).port $gettok($sock($sockname).mark,1,32) $sock($sockname).rcvd $sock($sockname).to } on 1:sockclose:ftpdatadownload.*:{ ; if error send signal, else send close signal if ($sockerr) { .signal ftp.dataconnection.error $sock($sockname).wsmsg | return } else { .signal ftp.dataconnection.receive.close $sock($sockname).ip $sock($sockname).port $sock($sockname).rcvd $sock($sockname).to } } ;-------------- - - ; signals ;----------- - ; sent when a control connection starts on 1:signal:ftp.start:{ ; $1 = connection address\ip echo -s FTP: Opening connection to $1 } ; sent when a control connection successfully connects on 1:signal:ftp.connect:{ ; $1 = connection address\ip echo -s FTP: Connection to $1 successful. } ; sent when a control connection closes with raw 221 (goodbye) on 1:signal:ftp.close:{ ; $1 = connection address\ip echo -s FTP: Connection to $1 closed. } ; sent when a control connection recieves an error on 1:signal:ftp.error:{ ; $1 = connection address\ip ; $2 = error message echo -s FTP: Error connecting or communicating with $1 ( $+ $2 $+ ) } ; sent when a connection times out on 1:signal:ftp.timeout:{ ; $1 = connection address\ip echo -s FTP: Connection to $1 timed out. } ; sent when the ftp server sends text on 1:signal:ftp.text:{ ; $1 = connection address ; $2- = text echo -s FTP: $1 $+ : $2- } ; sent when an error occurs in a data connection on 1:signal:ftp.dataconnection.error:{ ; $1 = IP address ; $2 = port ; $3 = error message echo -s FTP: Error opening data connection ( $+ $3- $+ ). } ; sent when a data connection connects on 1:signal:ftp.dataconnection.connect:{ ; $1 = IP address ; $2 = port echo -s FTP: Data connection to $1 $+ : $+ $2 opened. } ; sent when an uploading data connection sends a packet on 1:signal:ftp.dataconnection.send:{ ; $1 = IP address ; $2 = port ; $3 = size of file ; $4 = total bytes sent ; $5 = seconds socket has been open (for calculating speed) var %p = $round($calc(($4 / $3) * 100),0) echo -s FTP: Uploaded $bytes($4).suf of $bytes($3).suf ( $+ %p $+ $chr(37) $+ ) to $1 ( $+ $bytes($calc($4 / $5)).suf $+ /s) } ; sent when a downloading data connection receives a packet on 1:signal:ftp.dataconnection.receive:{ ; $1 = IP address ; $2 = port ; $3 = file size ; $4 = total bytes received ; $5 = seconds socket has been open (for calculating speed) echo -s FTP: Received $bytes($4).suf of $bytes($3).suf ( $+ $calc(($4 / $3) * 100) $+ $chr(37) $+ ) from $1 ( $+ $bytes($calc($4 / $5)).suf $+ /s) } ; sent when an uploading data connection is closed\completed on 1:signal:ftp.dataconnection.send.close:{ ; $1 = IP address ; $2 = port ; $3 = total bytes sent ; $4 = seconds socket has been open (for calculating speed) echo -s FTP: Data connection to $1 $+ : $+ $2 closed (sent $bytes($3).suf in $duration($4) ( $+ $bytes($calc($3 / $4)).suf $+ /s)) } ; sent when a downloading data connection is closed\completed on 1:signal:ftp.dataconnection.receive.close:{ ; $1 = IP address ; $2 = port ; $3 = total bytes received ; $4 = seconds socket has been open (for calculating speed) echo -s FTP: Data connection to $1 $+ : $+ $2 closed (recieved $bytes($3).suf in $duration($4) ( $+ $bytes($calc($3 / $4)).suf $+ /s)) } Cya, Tommis[/code] Link to comment
lil Toady Posted April 11, 2007 Share Posted April 11, 2007 it'd be easier to fill a php form via sockets, just look at my trace Link to comment
SamB Posted April 11, 2007 Author Share Posted April 11, 2007 Can you make a function that fills a PHP form via sockets, and then gets what it outputs? Because I could create some special PHP files with no theme, so mirc could also see if there where any errors @Tommis yes i downloaded that ftp script already. Link to comment
lil Toady Posted April 11, 2007 Share Posted April 11, 2007 Here, i haven't tested though. You have to do a PHP file with method GET $_GET['name'] and $_GET['pass'] and it will save stuff. The file should only output 1 line, Like 'Successfully registered' or something on *:SIGNAL:mta.command:{ if ($3 == !register) mta.register $1 $2 PASSWORD } alias mta.register { set %mta.reg.host = www.example.com set %mta.reg.path = /mta/register.php set %mta.reg.data. [ $+ [ $mta.ip($1,$2) ] ] $1-3 if (!$sock($+(mta.register.,$mta.ip($1,$2)))) sockopen $+(mta.register.,$mta.ip($1,$2)) %mta.reg.host 80 } on *:SOCKOPEN:mta.register.*:{ tokenize 32 %mta.reg.data. [ $+ [ $right($sockname,-13) ] ] if ($sockerr > 0) { sockclose $sockname mta.text $1 Register: An error has occured. (socket error) } else { sockwrite -n $sockname GET $+(%mta.reg.path,?name=,$mta.nick($1,$2),&pass=,$3) HTTP/1.1 sockwrite -n $sockname User-Agent: MSIE 6.0 sockwrite -n $sockname Host: %mta.reg.host sockwrite $sockname $crlf } } on *:SOCKCLOSE:mta.register.*:{ unset %mta.reg.data. [ $+ [ $right($sockname,-13) ] ] } on *:SOCKREAD:mta.register.*:{ sockread %reg if (%reg) { tokenize 32 %mta.reg.data. [ $+ [ $right($sockname,-13) ] ] mta.pm $1 $2 %reg } } P.S: dont forget to change the lines set %mta.reg.host = www.example.com set %mta.reg.path = /mta/register.php Link to comment
SamB Posted April 11, 2007 Author Share Posted April 11, 2007 Why would I need to use $_GET when you put the variables in the path? register.php?name=..&pass=... Cant you just access the variables with $name and $pass ? Link to comment
lil Toady Posted April 11, 2007 Share Posted April 11, 2007 Why would I need to use $_GET when you put the variables in the path?register.php?name=..&pass=... Cant you just access the variables with $name and $pass ? um, well you're the PHP scripter, it's up to you to do it how you want. I just know that $_GET will work Link to comment
SamB Posted April 11, 2007 Author Share Posted April 11, 2007 ok. btw how do i know what the output from the php is? EDIT: nvm i was jus reading thru the code i see what you done thx Link to comment
Recommended Posts