All pastes #1205407 Raw Edit

phpbot by GODD

public php v1 · immutable
#1205407 ·published 2008-09-18 23:31 UTC
rendered paste body
<?php//PHP Bot for connecting two irc servers together, made by GODD//todo: update help entries// Prevent PHP from stopping the script after 30 secset_time_limit(0);header("Cache-Control: no-cache, must-revalidate");// Date in the pastheader("Expires: Mon, 26 Jul 1997 05:00:00 GMT");/*$server = $_GET['server'];$port = $_GET['port'];$chan = $_GET['chan'];$idle = $_GET['idle'];*/$args = $_SERVER['argv'];$server = "irc.foonetic.net";//$args[1];$port = "6667";//$args[2]; //$chan = $args[3];$idle = $args[3];$start = "#bot-test";$server1 = "irc.plain-text.info";$port1 = "6667"$start1 = '#bot-test';function help($socket,$name) {        //help stuffs      fputs($socket,"PRIVMSG ".$name." : GODDbot v1.0, it's ".date('l dS \of F Y h:i:s A')."\n");      fputs($socket,"PRIVMSG ".$name." : C0d3d By G0DD\n");      fputs($socket,"PRIVMSG ".$name." : I live to serve you. Accepted commands are:\n");      fputs($socket,"PRIVMSG ".$name." : \t!help\t\t\t\t\tdisplay this(no shit).\n");      fputs($socket,"PRIVMSG ".$name." : \t!msg user mssg\t\t\tsend a message to user of mssg\n");      fputs($socket,"PRIVMSG ".$name." : \t!join room\t\t\t\tjoin room room\n");      fputs($socket,"PRIVMSG ".$name." : \t!part\t\t\t\t\tleave the current room\n");      fputs($socket,"PRIVMSG ".$name." : \t!idlerpg user password\t\tlogin to idlerpg as user with pass\n");      fputs($socket,"PRIVMSG ".$name." : \t!rpgstats user\t\t\t\tcheck user's rpg stats\n");      fputs($socket,"PRIVMSG ".$name." : \t!identify password\t\t\tlogin with password\n");      fputs($socket,"PRIVMSG ".$name." : \t!nick nick\t\t\t\t\tchange bot name to nick\n");      fputs($socket,"PRIVMSG ".$name." : \t!self-terminate\t\t\t\tsuicide\n");}//start get xml datafunction getxmldata($rpguser){        $host = "http://www.enigmagroup.org";        $file = "/idlerpg/xml.php?player=".$rpguser;        $data = implode("",file($host.$file));        return $data;}//end get xml datafunction getstats($socket,$name,$rpguser){        $xml = getxmldata($rpguser);                $player = simplexml_load_string($xml);                 $username=$player->username;                 $level=$player->level;        // $class=$player->'class';                 $ttl=$player->ttl;                 $online=$player->online;                 $totalidled=$player->totalidled;                  fputs($socket,"PRIVMSG ".$name." :Stats for ".$username.": \n");                  fputs($socket,"PRIVMSG ".$name." :Level: ".$level." \n");                  fputs($socket,"PRIVMSG ".$name." :Time till next: ".$ttl." seconds \n");                if($online==1){fputs($socket,"PRIVMSG ".$name." :Status: Online \n");}                else{fputs($socket,"PRIVMSG ".$name." :Status: Offline\n");}                  fputs($socket,"PRIVMSG ".$name." :Total Time Idled: ".$totalidled." seconds \n");}function idlerpg($socket,$char,$pass){        fputs($socket,"JOIN #idlerpg\n");        fputs($socket,"PRIVMSG MitNick :LOGIN ".$char." ".$pass."\n");}function suicide($socket,$name,$room){        fputs($socket, "PRIVMSG ".$room." :Bye Now!\n");        fputs($socket,"PRIVMSG ".$name." :Fuck you too.\n");        fputs($socket, "QUIT ".$name.": I LOVE YOU TOO\n");        return 0;}function nick($socket,$nick,$pass){        $pass=str_replace(array(chr(10),chr(13)),'',$pass);        fputs($socket,"NICK ".$nick."\n");        if(isset($pass)){fputs($socket,"PRIVMSG NickServ :identify ".$pass."\n");}}function joinus($socket,$chan,$pass){        if(isset($pass)){fputs($socket,"JOIN ".$chan." ".$pass."\n");}        else{fputs($socket,"JOIN ".$chan."\n");}}function leaveus($socket,$room){        fputs($socket,"PRIVMSG ".$room." :Ill be in the other room\n");        fputs($socket,"PART ".$room."\n");}function priv($socket,$arg1,$ex){            $arg2 = " :";            $i=5;            while($ex[$i]!=""){                $arg2 .=            str_replace(array(chr(10),chr(13)),'',$ex[$i])." ";                $i++;            }            $arg2 .="\n";            fputs($socket, "PRIVMSG ".$arg1.$arg2);}function ident($sock,$arg1){            fputs($sock, "PRIVMSG NickServ :identify ".$arg1."\n");}if (!($server==""||$port=="")) {				//connection one				$socket = fsockopen($server, $port); 				fputs($socket,"USER GODDbot thenullbyte.org GODD :GODDbot\n");		        fputs($socket,"NICK GODDbot\n"); // Join channel				fputs($socket,"$start\n");				ident($socket,"loombaer");        				//connection two				$socket1 = fsockopen($server1,$port1);				fputs($socket1,"USER GODDbot thenullbyte.org GODD :GODDbot\n");				fputs($socket1,"NICK GODDbot\n");				fputs($socket1,"JOIN $start1\n");				ident($socket1,"loombaer");$alive=1;$alive1=1;echo fgets($socket,128);echo fgets($socket1,128);while($alive==1) {	if($alive1!=1)$alive=0;    // Continue the rest of the script here        while($alive1==1){		        if($data = fgets($socket, 128)){		        echo $data;		        flush();				$ex = explode(' ', $data);				}		        if($data1 = fgets($socket1,128)){		        echo $data1;		        flush();				$ex1 = explode(' ', $data1);				}				        if($ex[4]." ".$ex[5]." ".$ex[6]==":No such nick/channel"){            fputs($socket,"PRIVMSG ".$name." :I am sorry, there is no user by that name\n");        }        // Send PONG back to the server        if($ex1[0] == "PING"){           fputs($socket1, "PONG ".$ex1[1]."\n");        }        if($ex[0] == "PING"){            fputs($socket, "PONG ".$ex[1]."\n");        }        $name = preg_replace('/!.*/','',$ex[0]);        $name = str_replace(':','',$name);		        $name1 = preg_replace('/!.*/','',$ex1[0]);        $name1 = str_replace(':','',$name1);        $command = str_replace(array(chr(10),chr(13)),'',$ex[3]);        $command1 = str_replace(array(chr(10),chr(13)),'',$ex1[3]);        $arg2 = str_replace(array(chr(10),chr(13)),'',$ex1[4]);        $arg1 = str_replace(array(chr(10),chr(13)),'',$ex[4]);        if ($command == ":!self-terminate" || $command1 == ":!self-terminate"){                $alive=suicide($socket1, $name, $ex1[2]);                $alive=suicide($socket, $name, $ex[2]);                $alive1=0;        }        if (($name1 = 'c3p0' || $name1 = 'CrackBot') && $hash==1){fputs($socket,"PRIVMSG ".$chan1." :".$command1."\n");$yes=0;}        if ($command == ":!hash"){                $hash=$arg1;                fputs($socket1,"PRIVMSG #bot-test :!search ".$hash."\n");                fputs($socket1,"PRIVMSG #bot-test :.c3p0 addmd5 ".$hash."\n");                $hash=1;				$command = '';        }        if ($command == ":!help") {help($socket,$name);}        if ($command == ":!sayhi") {fputs($socket, "PRIVMSG ".$ex[2]." :HI THERE!\n");}        if ($command==":!msg"){priv($socket,$arg1,$ex);}        if ($command==":!idlerpg"){idlerpg($socket,$arg1,$ex[5]);}        if ($command==":!nick"){nick($socket,$arg1,$ex[5]);}        if ($command==":!join"){joinus($socket,$arg1,$ex[5]);}        if ($command==":!identify"){ident($socket,$arg1);}        if ($command==":!leave"){leaveus($socket,$ex[2]);}        flush();    }}        fclose($socket);}else{echo "Please specify a server and port...<\ br>";} ?>