wackwall Admin
Zodiac : Chinese zodiac : Posts : 159 Points : 5291 Reputation : 2 Join date : 10/12/2010 Age : 42 Location : Sarawak
| Subject: PHP IRC Bot Tue Mar 22, 2011 11:58 am | |
| Jun Run it Online... only things i got done was the stats and the md5 function, and a !die function ofcourse - Code:
-
<?php //------------------------------------------------------------ //Binary Underground b0t by otak :) //------------------------------------------------------------ //======================================== //------------------------------------------------------------ //Command list //------------------------------------------------------------ //!stats - shows the site stats //!md5enc <text> - encrypts <text> //!md5dec <hash> - decrypts hash // //more to come here! //say something everytime a new post is made, like New Thread/Post: Blah by blah. //say something everytime we get a new member, like Newly registerd: name here. //maybe query the passdb for a exact match? //any more ideas? lol //------------------------------------------------------------ //basic setup of teh bot //------------------------------------------------------------ $me = "Binary-UG"; $nspass = ""; $server = "irc.dal.net"; $chan = "#otak"; //------------------------------------------------------------ //database setup of teh bot //------------------------------------------------------------ $dbuser = "binary_admin"; $dbpass = ""; $dbname = "binary_vb"; //------------------------------------------------------------
$con = mysql_connect("localhost",$dbuser,$dbpass); mysql_select_db($dbname, $con); if (!$con) { die('Could not connect: ' . mysql_error()); }
set_time_limit(0);
$socket = fsockopen($server, 6667);
fputs($socket,"USER ".$me." binary-ug.com BUG :BUG-b0t\n"); fputs($socket,"NICK ".$me."\n"); if ( $nspass<>"" ) { fputs($socket,"PRIVMSG NickServ :IDENTIFY ".$nspass."\n"); } fputs($socket,"JOIN ".$chan."\n");
while(1) {
while($data = fgets($socket, 128)) {
echo nl2br($data); flush();
$ex = explode(' ', $data); //ping if($ex[0] == "PING"){ fputs($socket, "PONG ".$ex[1]."\n"); }
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]); $extras = str_replace(array(chr(10), chr(13)), '', $ex[4]);
//stats if ($command == ":!stats") { $statthreads=mysql_num_rows(mysql_query("SELECT * FROM thread")); $statposts=mysql_num_rows(mysql_query("SELECT * FROM post")); $statusers=mysql_num_rows(mysql_query("SELECT * FROM user")); fputs($socket, "PRIVMSG ".$ex[2]." :Threads: ".$statthreads.", Posts: ".$statposts.", Users: ".$statusers."\n"); } //md5dec if (ereg("^:!md5dec", $command)) { $hash = $extras; if ($hash != '' && strlen($hash) == 32){ $xml = simplexml_load_file('http://gdataonline.com/qkhash.php?mode=xml&hash='.$hash); if ($xml){ foreach($xml->children() as $child){ if ($child->getName() == 'result') fputs($socket, "PRIVMSG ".$ex[2]." :".$hash." : ".$child."\n"); elseif ($child == 'Hash not found') fputs($socket, "PRIVMSG ".$ex[2]." :".$hash." was not found in the database.\n"); } }else fputs($socket, "PRIVMSG ".$ex[2]." :".$hash." was not found in the database.\n"); }else fputs($socket, "PRIVMSG ".$ex[2]." :Invalid hash.\n"); } //md5enc if (ereg("^:!md5enc", $command)) { $hash = md5($extras); fputs($socket, "PRIVMSG ".$ex[2]." :".$hash." : ".$extras."\n"); } //die if ($command == ":!die") { die('bhai bhai'); } } } mysql_close($con); ?> Enjoy!! | |
|
siperda
Posts : 1 Points : 4501 Reputation : 0 Join date : 02/12/2011 Location : sky
| Subject: Re: PHP IRC Bot Fri Dec 02, 2011 11:31 am | |
| do you have rfi scanner and auto spread it? | |
|