/** * show_log * * Actually show the log for this specific day * * @param PDO $db A PDO object referring to the database * * @return void * @author Eli White <*****@*****.**> **/ function show_log(PDO $db) { $channel = $_GET['w']; $day = $_GET['d']; $parts = explode('-', $day); $formatted_date = "{$parts[0]}-{$parts[1]}-{$parts[2]}"; // Begin the HTML page: template_header('Date: ' . utf8specialchars($formatted_date) . ' - Channel: ' . utf8specialchars($channel)); // Query the database to get all log lines for this date: $prepared = $db->prepare("select time(tstamp) as t, type, nick, message\n from logs\n where lower(chan) = :chan and date(tstamp) = :day\n order by tstamp asc"); $prepared->execute(array(':chan' => $channel, ':day' => $day)); // Loop through each line, foreach ($prepared as $row) { // Prepare some basic details for output: $color = nick_color($row['nick']); $time = utf8specialchars($row['t']); $msg = utf8specialchars($row['message']); $nick = utf8specialchars($row['nick']); $type = false; // Now change the format of the line based upon the type: switch ($row['type']) { case 4: // PRIVMSG (A Regular Message) echo "[{$time}] <span style=\"color:#{$color};\">" . "<{$nick}></span> {$msg}<br />\n"; break; case 5: // ACTION (emote) echo "[{$time}] <span style=\"color:#{$color};\">" . "*{$nick} {$msg}</span><br />\n"; break; case 1: // JOIN echo "[{$time}] -> {$nick} joined the room.<br />\n"; break; case 2: // PART (leaves channel) echo "[{$time}] -> {$nick} left the room: {$msg}<br />\n"; break; case 3: // QUIT (quits the server) echo "[{$time}] -> {$nick} left the server: {$msg}<br />\n"; break; case 6: // NICK (changes their nickname) echo "[{$time}] -> {$nick} is now known as: {$msg}<br />\n"; break; case 7: // KICK (booted) echo "[{$time}] -> {$nick} boots {$msg} from the room.<br />\n"; break; case 8: // MODE (changed their mode) $type = 'MODE'; case 9: // TOPIC (changed the topic) $type = $type ? $type : 'TOPIC'; echo "[{$time}] -> {$nick}: :{$type}: {$msg}<br />\n"; } } // Finish up the page: template_footer(); }
/** * show_log * * Actually show the log for this specific day * * @param PDO $db A PDO object referring to the database * @param string $table The name of the logging table * @return void * @author Eli White <*****@*****.**> **/ function show_log(PDO $db, $table) { $channel = $_GET['c']; $host = $_GET['h']; $day = $_GET['d']; $parts = explode('-', $day); $formatted_date = "{$parts[0]}-{$parts[1]}-{$parts[2]}"; // Begin the HTML page: template_header('Date: ' . utf8specialchars($formatted_date) . ' - Channel: ' . utf8specialchars($channel) . ' (' . utf8specialchars($host) . ')'); // Query the database to get all log lines for this date: $prepared = $db->prepare("SELECT time(`created_on`) AS t, type, nick, message\n FROM {$table}\n WHERE `host` = ? AND `channel` = ? AND date(`created_on`) = ?\n ORDER by `created_on` asc"); $prepared->execute(array($host, $channel, $day)); // Loop through each line, foreach ($prepared as $result) { // Prepare some basic details for output: $color = nick_color($result->nick); $time = utf8specialchars($result->t); $msg = utf8specialchars($result->message); $nick = utf8specialchars($result->nick); $type = false; // Now change the format of the line based upon the type: switch ($result->type) { case 'privmsg': // PRIVMSG (A Regular Message) echo "[{$time}] <span style=\"color:#{$color};\">" . "<{$nick}></span> {$msg}<br />\n"; break; case 'action': // ACTION (emote) echo "[{$time}] <span style=\"color:#{$color};\">" . "*{$nick} {$msg}</span><br />\n"; break; case 'join': // JOIN echo "[{$time}] -> {$nick} joined the room.<br />\n"; break; case 'part': // PART (leaves channel) echo "[{$time}] -> {$nick} left the room: {$msg}<br />\n"; break; /* Not currently logged case 3: // QUIT (quits the server) echo "[$time] -> {$nick} left the server: {$msg}<br />\n"; break; case 6: // NICK (changes their nickname) echo "[$time] -> {$nick} is now known as: {$msg}<br />\n"; break; case 7: // KICK (booted) echo "[$time] -> {$nick} boots {$msg} from the room.<br />\n"; break; case 8: // MODE (changed their mode) $type = 'MODE'; case 9: // TOPIC (changed the topic) $type = $type ? $type : 'TOPIC'; echo "[$time] -> {$nick}: :{$type}: {$msg}<br />\n"; */ } } // Finish up the page: template_footer(); }