Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //If we're running from the command prompt, CLI will be 1. If running through a web server, CLI will be 0.
- define("CLI", !isset($_SERVER['HTTP_USER_AGENT']));
- define(using_secondary_nick,NULL);
- date_default_timezone_set("BST");
- error_reporting(E_ALL);
- $connect = @mysql_connect("localhost","root","rolex123");
- if (!$connect){
- echo("<p>Unable to connect to database server.</p>");
- die('Could not connect: ' . mysql_error());
- exit;
- }
- if (! @mysql_select_db("IRCBot")){
- echo("<p>Unable to connect to the database '");
- echo("IRCBot");
- echo("'</p>");
- exit;
- }
- $searchfor = array( "/\\00310(.+?)\\003(10|)/",
- "/\\00311(.+?)\\003(11|)/",
- "/\\00312(.+?)\\003(12|)/",
- "/\\00313(.+?)\\003(13|)/",
- "/\\00314(.+?)\\003(14|)/",
- "/\\00315(.+?)\\003(15|)/",
- "/\\001(.+?)\\001/",
- "/\\002(.+?)\\002/",
- "/\\0030(.+?)\\003(0|)/",
- "/\\0031(.+?)\\003(1|)/",
- "/\\0032(.+?)\\003(2|)/",
- "/\\0033(.+?)\\003(3|)/",
- "/\\0034(.+?)\\003(4|)/",
- "/\\0035(.+?)\\003(5|)/",
- "/\\0036(.+?)\\003(6|)/",
- "/\\0037(.+?)\\003(7|)/",
- "/\\0038(.+?)\\003(8|)/",
- "/\\0039(.+?)\\003(9|)/");
- $replacewith = array( "<span style='color: Teal;'>\\1</span>",
- "<span style='color: blue;'>\\1</span>",
- "<span style='color: #00fcf7;'>\\1</span>",
- "<span style='color: Pink;'>\\1</span>",
- "<span style='color: Grey;'>\\1</span>",
- "<span style='color: LightGrey;'>\\1</span>",
- "<u>\\1</u>",
- "<b>\\1</b>",
- "<span style='color: White;'>\\1</span>",
- "<span style='color: Black;'>\\1</span>",
- "<span style='color: Blue;'>\\1</span>",
- "<span style='color: Green;'>\\1</span>",
- "<span style='color: Red;'>\\1</span>",
- "<span style='color: Brown;'>\\1</span>",
- "<span style='color: Purple;'>\\1</span>",
- "<span style='color: Orange;'>\\1</span>",
- "<span style='color: Yellow;'>\\1</span>",
- "<span style='color: #00fc00;'>\\1</span>");
- set_time_limit(0);
- error_reporting(E_ALL);
- include("config.php");
- include("irc.to.html.php");
- foreach($server_chan as $chan => $pass){
- $channels_info[$chan]["users"] = array();
- $channels_info[$chan]["name"] = $chan;
- }
- $plugins = array();
- include("plugins/autoload.php");
- $server = array();
- $server['SOCKET'] = fsockopen($server_host, $server_port, $errno, $errstr, 5);
- if($server['SOCKET']){
- if($global_vars['type'] == "client"){
- SendCommand("PASS NOPASS\r");
- SendCommand("NICK ".$global_vars['bot_nickname']."\r");
- SendCommand("USER ".$global_vars['bot_nickname']." USING PHP IRC\r");
- }
- else{
- SendCommand("PASS services\r");
- SendCommand("SERVER BBot.alexmonk.co.uk 1 :The one and only\r");
- }
- $global_vars['is_fully_connected'] = FALSE;
- $channel_importantpeople = array();
- while(!feof($server['SOCKET'])){
- //$msg_was_encrypted = FALSE;
- $server['READ_BUFFER'] = htmlentities(fgets($server['SOCKET'], 1024));
- if($server['READ_BUFFER'] != ""){
- if(CLI == 0){
- //echo date("[d/m/Y H:i:s]")."[RECIEVE] ".preg_replace($searchfor,$replacewith,$server['READ_BUFFER'])."<br>\r\n";
- $output = preg_replace($searchfor,$replacewith,$server['READ_BUFFER']);
- //echo date("[d/m/Y H:i:s]")."[RECIEVE] ".topic_format_html($a,strlen($a),TRUE)."<br>\r\n";
- echo date("[d/m/Y H:i:s]")."[RECIEVE] ".$output."<br>\r\n";
- }
- else{
- echo strip_tags(date("[d/m/Y H:i:s]")."[RECIEVE] ".preg_replace($searchfor,$replacewith,$server['READ_BUFFER'])."<br>\r\n");
- }
- //echo date("[d/m/Y H:i:s]")."[RECIEVE] ".$server['READ_BUFFER']."<br>\n\r"; //display the recived data from the server
- }
- foreach($plugins as $plugin => $plugin_main_function_prefix){
- eval("".$plugin_main_function_prefix."Main(\$server,\$global_vars);");
- }
- if(substr($server['READ_BUFFER'], 0, 6) == "PING :"){
- SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r");
- }
- elseif(preg_match("/^:(.+?)!(.+?)@(.+?) PRIVMSG (E-Bot|(&|#)(.+?)) :!loadplugin (.+?)$/",$server['READ_BUFFER'],$matches)){
- if(in_array($matches[1],$global_vars['bot_masters'])){
- $matches[7] = trim($matches[7]);
- include("plugins/".$matches[7]);
- echo date("[d/m/Y H:i:s]")."[INTERNAL MESSAGE] Attempting to load plugin '".$matches[7]."'.<br>\r\n";
- }
- }
- elseif(preg_match("/^:(.+?)!(.+?)@(.+?) PRIVMSG (E-Bot|(&|#)(.+?)) :!unloadplugin (.+?)/",$server['READ_BUFFER'],$matches)){
- if(in_array($matches[1],$global_vars['bot_masters'])){
- $matches[7] = trim($matches[7]);
- unset($plugins[$matches[7]]);
- }
- }
- elseif(preg_match("/:(.+?)!(.+?)@(.+?) PRIVMSG (E-Bot|(&|#)(.+?)) :!restart(.+?)$/",$server['READ_BUFFER'],$matches)){
- if(in_array($matches[1],$global_vars['bot_masters'])){
- if(CLI == 0){
- $matches[7] = trim($matches[7]);
- if($matches[7] != ""){
- foreach($server_chan as $chan => $pass){
- SendCommand("PART ".$chan." :Restarting...\r");
- }
- fclose($server['SOCKET']);
- echo "Connection closed. Reloading page in ".$matches[7]." seconds.<br>\r\n";
- echo "<meta http-equiv=\"refresh\" content=\"".$matches[7]."\">";
- exit;
- }
- else{
- foreach($server_chan as $chan => $pass){
- SendCommand("PART ".$chan." :Restarting...\r");
- }
- fclose($server['SOCKET']);
- echo "Connection closed. Reloading page.<br>\r\n";
- echo "<meta http-equiv=\"refresh\" content=\"0\">";
- exit;
- }
- }
- else{
- SendCommand("PRIVMSG ".$matches[4]." :Cannot restart bot - running from command line. Please restart the bot manually.");
- }
- }
- }
- elseif(preg_match("/^:(.+?) (422|376) E-Bot :(MOTD File is missing|End of \/MOTD command|End of message of the day.)/",$server['READ_BUFFER'])){
- if($global_vars['secondary_nick_active'] == TRUE){
- SendCommand("PRIVMSG NickServ :GHOST E-Bot rolex123\r");
- }
- foreach($server_chan as $chan => $pass){
- if($pass != ""){
- SendCommand("JOIN ".$chan." ".$pass."\n\r");
- }
- else{
- SendCommand("JOIN ".$chan."\n\r");
- }
- }
- $global_vars['is_fully_connected'] = TRUE;
- }
- elseif(preg_match("/^:NickServ!services@azelphur.com (PRIVMSG|NOTICE) E-Bot :please choose a different nick./",$server['READ_BUFFER'])){
- SendCommand("MODE E-Bot +B\r");
- SendCommand($authcommand."\r");
- SendCommand("PRIVMSG NickServ :update\r");
- }
- elseif(preg_match("/^(.+?)!(.+?)@(.+?) INVITE E-Bot :(#|&)(.+?)$/",$server['READ_BUFFER'],$matches)){
- $matches[5] = trim($matches[5]);
- if(in_array($matches[5],$join_chans_on_invite)){
- SendCommand("JOIN :".$matches[4].$matches[5]."\r");
- }
- }
- elseif(preg_match("/^:irc.azelphur.com 433 \* E-Bot :Nickname is already in use./",$server['READ_BUFFER'])){
- SendCommand("NICK E-Bot_\r");
- $global_vars['secondary_nick_active'] = TRUE;
- }
- elseif(preg_match("/^:(.+?)!(.+?)@(.+?) (NOTICE|PRIVMSG) E-Bot :(E-Bot |!)rehash $/",$server['READ_BUFFER'])){
- include("config.php");
- }
- flush();
- }
- }
- function SendCommand($cmd){
- global $server;
- global $searchfor;
- global $replacewith;
- fwrite($server['SOCKET'], $cmd, strlen($cmd));
- if(CLI == 0){
- echo date("[d/m/Y H:i:s]")."[SEND] ".preg_replace($searchfor,$replacewith,$cmd)." <br>";
- }
- else{
- echo strip_tags(date("[d/m/Y H:i:s]")."[SEND] ".preg_replace($searchfor,$replacewith,$cmd)." <br>");
- }
- }
- // String EnCrypt + DeCrypt function
- // Author: halojoy, July 2006
- function convert($str, $ky = ''){
- //If the key is nothing, return the string without doing anything to it.
- if($ky == ''){
- return $str;
- }
- $ky = str_replace(chr(32), '', $ky); //Replace all spaces in the key with nothing
- //Check the key is long enough
- if(strlen($ky) < 8){
- return "Key was too short. Minimum 8 characters.";
- }
- //If the key lengh is smaller than 32, $kl will be set to the lengh
- //If not, then it is set to 32.
- if(strlen($ky) < 32){
- $kl = strlen($ky);
- }
- else{
- $kl = 32;
- }
- $k = array();
- for($i = 0; $i < $kl; $i++){
- $k[$i] = ord($ky{$i})&0x1F;
- }
- $j = 0;
- for($i = 0; $i < strlen($str); $i++){
- $e = ord($str{$i});
- if($e&0xE0){
- $str{$i} = chr($e^$k[$j]);
- }
- else{
- $str{$i} = chr($e);
- }
- $j++;
- if($j == $kl){
- $j = 0;
- }
- else{
- $j = $j;
- }
- }
- return $str;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement