". $command. "\n\r"); } function log_to_file ($data, $important = false) { if ($important) { global $CONFIG; if ($fp = fopen($CONFIG['file_name'], "ab")) { if ( (fwrite($fp, $data) === FALSE) ) { echo "Could not write to file " . $CONFIG['file_name'] . ".\r\n"; } } else { echo "File " . $CONFIG['file_name'] . "could not be opened.\r\n"; } } } function log_to_mysql($channel, $username, $test) { global $CONFIG; $query = "INSERT INTO ". $CONFIG['table'] ." (time, channel, username, text) VALUES ('". time() ."', '". $channel ."', '". $username ."', '". $test ."')"; mysql_query($query); } function process_commands() { global $con, $CONFIG; $said = $con['buffer']['text']; $lsaid = strtolower($said); $thisdate = date( "F j, Y, g:i a", time() ); $break = "\r\n"; if ( !( strpos($lsaid, 'google') === false ) || !( strpos($lsaid, 'search') === false ) ) { logline('[Google ' . $thisdate . '] ' . $break . $said); // say("Gotcha."); } if ( !( strpos($lsaid, 'boyboy') === false ) ) { // logline('[Self ' . $thisdate . '] ' . $break . $said); // say("I'm dreaming..."); } } function logline($s) { log_to_file($s . "\r\n\r\n", true); } function say($s) { cmd_send( prep_text($s) ); } function parse_buffer() { global $con, $CONFIG; $buffer = $con['buffer']['all']; $buffer = explode(" ", $buffer, 4); $buffer['username'] = substr($buffer[0], 1, strpos($buffer['0'], "!")-1); $posExcl = strpos($buffer[0], "!"); $posAt = strpos($buffer[0], "@"); $buffer['identd'] = substr($buffer[0], $posExcl+1, $posAt-$posExcl-1); $buffer['hostname'] = substr($buffer[0], strpos($buffer[0], "@")+1); $buffer['user_host'] = substr($buffer[0],1); switch (strtoupper($buffer[1])) { case "JOIN": $buffer['text'] = "*JOINS: ". $buffer['username']." ( ".$buffer['user_host']." )"; $buffer['command'] = "JOIN"; $buffer['channel'] = $CONFIG['channel']; break; case "QUIT": $buffer['text'] = "*QUITS: ". $buffer['username']." ( ".$buffer['user_host']." )"; $buffer['command'] = "QUIT"; $buffer['channel'] = $CONFIG['channel']; break; case "NOTICE": $buffer['text'] = "*NOTICE: ". $buffer['username']; $buffer['command'] = "NOTICE"; $buffer['channel'] = substr($buffer[2], 1); break; case "PART": $buffer['text'] = "*PARTS: ". $buffer['username']." ( ".$buffer['user_host']." )"; $buffer['command'] = "PART"; $buffer['channel'] = $CONFIG['channel']; break; case "MODE": $buffer['text'] = $buffer['username']." sets mode: ".$buffer[3]; $buffer['command'] = "MODE"; $buffer['channel'] = $buffer[2]; break; case "NICK": $buffer['text'] = "*NICK: ".$buffer['username']." => ".substr($buffer[2], 1)." ( ".$buffer['user_host']." )"; $buffer['command'] = "NICK"; $buffer['channel'] = $CONFIG['channel']; break; default: $buffer['command'] = $buffer[1]; $buffer['channel'] = $buffer[2]; $buffer['text'] = substr($buffer[3], 1); break; } $con['buffer'] = $buffer; } function prep_text($message) { global $con; return ('PRIVMSG ' . $con['buffer']['channel'] . ' :' . $message); } ?>