"",
"gtk-gnutella" => "",
"icewm" => ""
);
//if (!isset ($_GET[channel])) { $_GET[channel] = "symlink"; }
$channels["$_GET[channel]"] = "selected";
# date vars
$today = getEggDate(getdate());
if (!isset ($_GET[date])) { $_GET[date] = $today; }
# view vars
$MODECOLOR = "gray"; // alternatively use a color like "#c6c6c6"
$ACTIONCOLOR = "red"; // same applies here.
$colors = array ( "#0000FF", "#00FF00", "#FF0000", "#FF00FF", "#888800",
"#000088", "#008800", "#880000", "#008800", "#880088", "#FF88FF",
"#FF8888", "#8888FF","#FF0088", "#FF8800", "#0088FF", "#8800FF");
# shitty colors: "#FFFF00", "#00FFFF", "#FFFF88", "#88FFFF", "#88FF88",
# "#00FF88", "#88FF00". No. of good colors: 17, that's enough.
# file system vars
$BASE = ".";
$LOGS = "/home/melone/botlogs";
$HEADER = "$BASE/header.inc";
$FOOTER = "$BASE/footer.inc";
$LOG = "$LOGS/$_GET[channel].log.$_GET[date]";
# variable variables
$nicks = array ("maol", "MelOne");
$line; // the chat text
$linedate; // the date of the chat line
$previous = getPrev($_GET[date]);
$next = getNext($_GET[date]);
#######################################################################
# #
# P R O C E D U R E D I V I S I O N ( M A I N ) #
# #
#######################################################################
# include header
include ("$HEADER");
if (isset ($_GET[channel])) { // normal operation
if (file_exists ($LOG)) {
// the table 'previous' and 'next' a.k.a. yesterday and tomorrow
echo "
\n";
echo "\n";
$file = fopen ("$LOG", r);
while ($chatline = fgets ($file, 4096)) {
sepDate($chatline);
// $line = nl2br (htmlentities ($line)); // replace newlines and entities
$line = htmlentities ($line); // replace newlines and entities
$line = doIt($line); // do the main stuff
$line = parseURL($line); //
echo "$linedate $line";
}
echo "
\n";
// the table 'previous' and 'next' a.k.a. yesterday and tomorrow
echo "\n";
} else { // file not opened
echo "bad luck, there's no log file for $_GET[channel] on $_GET[date]";
}
} else { // no input
echo "no channel selected yet, please do so now!";
}
# include footer
include ("$FOOTER");
#######################################################################
# #
# S U B F U N C T I O N S O F E G G 2 H T M L . P H P #
# #
#######################################################################
function parseURL($line) {
# parse $line for URLs and return url formatted
// $line = eregi_replace ("(http://[[:alnum:]\.\-]+[:alpha:]{2,3}/[[:alnum:]/;~\?\&_\-=]*)", "\\1", $line);
$line = ereg_replace("((ftp://)|(http://))(([[:alnum:]]|[[:punct:]])*)", "\\0",$line);
// $line = eregi_replace ("(http://[[:alnum:]\.\-]*\.[:alpha:]{2,3}/?)", "\\1", $line);
return $line;
}
function sepDate($chatline) {
# separate the date from the rest of the line
global $line, $linedate;
$twobits = explode (" ", $chatline, 2);
$line = $twobits[1]; $linedate = $twobits[0];
}
function colorNicks($line, $nick) {
# add colors to the nicks
global $nicks, $colors;
for ($i = 0; $i < sizeof ($nicks); $i++) {
if ($nicks[$i] == $nick) {
$color = $colors[$i % 17];
// $line = str_replace ("<$nicks[$i]>", "<$nicks[$i]>", "$line");
return str_replace ("<$nick>", "<$nick>", "$line");
}
}
// return $line;
}
function doIt($line) {
# the main routine
global $nicks, $ACTIONCOLOR, $MODECOLOR;
# check out if it's a normal line (beginning with )
if (ereg ("^<([][a-zA-Z0-9`{}_^|-]*)>", $line, $newnick)) {
# yup, a normal line, add nick if it's new
if (!in_array ($newnick[1], $nicks)) {
array_push ($nicks, $newnick[1]);
}
# and colorize it
return colorNicks ($line, $newnick[1]);
} else {
# an administrativia or action line
if (isActionLine ($line)) {
# an action line
return "$line";
}
# detect nick changes, then return a $MODECOLOR colored line
nickChange ($line);
return "$line";
}
}
function getEggDate($date) {
# return a string for a date in eggdrop's represantion
# i.e. DDMonYYYY
$day = $date[mday];
if ($day < 10) { $day = "0$day"; }
$month = substr ("$date[month]", 0, 3);
$year = $date[year];
return "$day$month$year";
}
function getPrev($date) {
# calculate the day before
return getEggDate(getdate(strtotime("$date") - 86400));
}
function getNext($date) {
# calculate the next day
return getEggDate(getdate(strtotime("$date") + 86400));
}
function isActionLine($line) {
# detect /me lines...
if (strstr ($line, "Action: ")) {
return true;
} // else...
return false;
}
function nickChange($line) {
# change our nicks hash if someone changes his/her nick
global $nicks;
if (strstr ($line, "Nick change: ")) {
# nick change detected
$boobs = explode (" ", $line); // $boobs[2] is the old nick, $boobs[4] the new
for ($i = 0; $i < sizeof ($nicks); $i++) {
if ($nicks[$i] == $boobs[2]) {
// $nicks[$i] = chop (str_replace ("
", "", $boobs[4]));;
$nicks[$i] = chop ($boobs[4]);
break;
}
}
}
}
php?>