Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("colors.php");
- $path = "/home/ttech/logs/ChannelLogger";
- $excludes = array(
- "alright sparky",
- "spam"
- );
- $actual_lines = 1;
- $line_change = array(
- "sets",
- "has",
- "kicked"
- );
- $users = array();
- $channel = "#transcendence";
- function get_channel_name(){
- global $channel;
- echo $channel;
- }
- function make_date_list(){
- if(isset($_GET['channel'])){
- $channel = stripslashes(htmlentities($_GET['channel']));
- }
- //$line = "\t\t<div class=\"dates\"><p>";
- $line = "";
- $dates = array("January","Febuary","March","April","May","June","July","August","September","October","November","December");
- foreach($dates as $date){
- echo " / <a href=\"?month=$date\">$date</a> /";
- }
- //$line .= "</p></div>";
- }
- function get_last_updated(){
- // Why the heck is filemtime not workign here?!
- print date("F d H:i:s.");
- }
- function is_even($number){
- return(!($number & 1));
- }
- function make_users_list($users){
- echo "\t\t<ul>\n";
- foreach($users as $user => $color){
- if(!stristr($user,"*")){
- echo "\t\t\t<li style=\"color: $color\">$user</li>\n";
- }
- }
- echo "\t\t</ul>";
- }
- function process_line($line_num,$line,$null){
- global $excludes,$actual_lines,$colors_list,$users;
- $date = "";
- if(is_even($line_num)){
- $line_type = "line_even";
- } else {
- $line_type = "line_odd";
- }
- $line = htmlentities($line);
- // We need to create the line correctly, purge anything possibly not usefull to us.
- // We need a better line thing here but I can't remember what I was saying.
- $message_parts = explode(" ",$line);
- if(preg_match("/(.*T.*) (\*\*\* (.*?) .*(has (joined|quit)|sets|was kicked) (.*))/",htmlspecialchars_decode($line),$matches_result)){
- $date = $matches_result[1];
- $user = $matches_result[3];
- /*if(!$user == $message_parts[3]){
- $user = $message_parts[3];
- echo "True $user\n";
- }*/
- $user = str_replace(array("<",">",">","<"),"",$message_parts[3]);
- /*if(in_array($user,$users)){
- $line = str_replace("*** $user","*** <span class=\"nick\">$user</span>",$line);
- }*/
- $line = "<span class=\"action\">".$matches_result[2]."</span>\n";
- $actual_lines++;
- } elseif(stristr($line,"***") OR stristr($line,"* ")){
- $date = $message_parts[0];
- $user = $message_parts[3];
- $user = str_replace(array("<",">",">","<"),"",$message_parts[3]);
- $line = "<span class=\"action\">".$line."</span>\n";
- $actual_lines++;
- } else {
- foreach($excludes as $exclude){
- //if(!stristr($line,$exclude) OR !stristr($line,"***")){
- if(preg_match("/([0-9+\$\/_.-]*?T[0-9+\$\:\/_.-]*) .*(\<(.*?)\> .*)/",htmlspecialchars_decode($line),$matches_result)){
- $date = $matches_result[1];
- $nick = $matches_result[3];
- $user = $matches_result[3];
- $user = str_replace(array("<",">",">","<"),"",$message_parts[2]);
- //echo "A: ".$message_parts[2]."\tB: $user\n";
- if(!stristr($line,$exclude)){
- if(!fnmatch("*\*\*\* $nick <*!~*\@*\> ", $line) OR !fnmatch("*\*\*\* $nick <*!~*\@*> ", $line)){
- /*if(stristr($user,"!")){
- $user = explode("!",$user);
- $user = $user[0];
- }*/
- if(array_key_exists($user,$users)){
- $line = str_replace(array("<$user>","<$user>"),"<span class=\"nick\"><span style=\"color: ".$users[$user]."\">$user</span></span>",$line);
- } else {
- $users[$user] = get_random_color();
- }
- }
- $actual_lines++; // Increment all lines that are real...
- }
- } // end regex line match
- } // End Foreach
- } // End IF / Else
- // Make a nice date format whoa hworth hw ot wrthp st
- //var_dump($users);
- $line = str_replace($date,"",$line);
- // Massive hack goes here... Fix later
- //$date = str_replace(array(" ","T"),array("","\t"),$date);
- $date_parts = explode("T", $date);
- $date = "<span class=\"prefix\"><span class=\"date\">".$date_parts[0];
- if(isset($date[1])){
- @$date .= "<span class=\"time\">".str_replace(" ","",$date_parts[1])."</span>";
- }
- $date .= "</span></span>";
- // End hack
- $proc_line = str_replace(array("\n","\t","\r"," "," "),"",$line);
- echo "\t\t\t<div class=\"$line_type\"><span class=\"linenumbers\">$line_num</span>$date<span class=\"content\">".$proc_line."</span></div>\n";
- }
- if(@isset($_GET['channel']) OR @stristr($_GET['channel'],"##")){
- $channel = str_replace(array("#","##"),"",stripslashes(strval(urldecode($_GET['channel']))));
- switch($channel){
- case "transcendence":
- $channel = "#transcendence";
- break;
- default:
- $channel = $channel;
- break;
- }
- }
- if(isset($_GET['month'])){
- $month = stripslashes(strval(urldecode($_GET['month'])));
- } else {
- $month = date("F");
- }
- if(isset($_GET['network'])){
- $channel = stripslashes(strval(urldecode($_GET['channel'])));
- } else {
- $network = "freenode";
- }
- /* Debug Mode */
- if(isset($_GET['network'])){
- $channel = stripslashes(strval(urldecode($_GET['channel'])));
- } else {
- $network = "freenode";
- }
- include "header.php";
- $filename = "$path/$network/#$channel/$month/#$channel.log";
- if(file_exists($filename)){
- echo "\t\t<div id=\"messages\">\n";
- $lines = file($filename, FILE_SKIP_EMPTY_LINES);
- foreach ($lines as $line_num => $line) {
- process_line($line_num,$line,$users);
- }
- echo "\t\t</div>\n\t </div>\n\t<div id=\"userbar\">\n";
- make_users_list($users);
- echo "\t</div>";
- } else {
- echo "\t\t<div id=\"messages\"><p>Sorry no channel exists by that name perhaps you should remove the forward # from the name and try again?</p></div>";
- }
- include "footer.php";
- ?>
Add Comment
Please, Sign In to add comment