I of course, removed all the paths to certain files, etc. for obvious reasons.
Code: Select all
function irclog($usr, $buffer, $chan, $said, $nicks, $switch)
{ global $open, $filename, $hour;
$said = htmlentities($said);
if($switch == TRUE)
{
fclose($open);
} else {
$parts = explode(" ", $buffer);
if($hour != date("g")) // Every hour, create a new log file.
{
fclose($open);
unset($open);
$filename2 = explode(".html", $filename);
$filename2 = $filename2[0];
$filename2 .= " -TO- [" . date("g.i.a") . "] " . date("n-j-y") . ".html";
rename("PATH/$filename", "E:/irc/logs/$filename2"); // Rename the log file to indicate when logging was stopped in that file.
unset($filename2);
}
if(!isset($open)) // If no log file has been started, do the following.
{
$filename = "[" . date("g.i.a") . "] " . date("n-j-y") . ".html"; // Write a file name with a time and date.
$hour = date("g"); // Get the hour. We will use this to dictate when to change files.
$open = fopen("PATH/$filename", "w"); // Create a file stream
fwrite($open, "<ht ml><he ad><tit le>IRC Logs - " . date("g:i A - n/j/y") . "</ti tle></he ad><bo dy>"); // Write the header to the file.
}
if($parts[1] == "PRIVMSG") // If a regular message is sent to the channel, then...
{
$write = "[" . date("g:i a") ."]" . " <b><$usr></b> [$chan] " . $said . "<br/>\n";
fwrite($open, $write);
}
if($parts[1] == "JOIN") // If somebody joins, then...
{
$write = "[" . date("g:i a") ."]" . " <b><$usr></b> <font color=green>Has Joined.</font><br/>\n";
fwrite($open, $write);
}
if($parts[3] == ":". chr(1) . "ACTION") // If somebody /me's, then...
{
$said = str_replace(CHR(1), "", $said);
$said = str_replace("ACTION", $usr, $said);
$write = "[" . date("g:i a") ."]" . " <b><$usr></b> [$chan] <font color=purple>$said</font> <br/>\n";
fwrite($open, $write);
}
}
return; // Return.
}
Read. Learn. Code.