Guest User

Untitled

a guest
Jul 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. <?php
  2. include("colors.php");
  3. $path = "/home/ttech/logs/ChannelLogger";
  4. $excludes = array(
  5. "alright sparky",
  6. "spam"
  7. );
  8. $actual_lines = 1;
  9. $line_change = array(
  10. "sets",
  11. "has",
  12. "kicked"
  13. );
  14. $users = array();
  15. $channel = "#transcendence";
  16.  
  17. function get_channel_name(){
  18. global $channel;
  19. echo $channel;
  20. }
  21. function make_date_list(){
  22. if(isset($_GET['channel'])){
  23. $channel = stripslashes(htmlentities($_GET['channel']));
  24. }
  25. //$line = "\t\t<div class=\"dates\"><p>";
  26. $line = "";
  27. $dates = array("January","Febuary","March","April","May","June","July","August","September","October","November","December");
  28. foreach($dates as $date){
  29. echo " / <a href=\"?month=$date\">$date</a> /";
  30. }
  31. //$line .= "</p></div>";
  32. }
  33. function get_last_updated(){
  34. // Why the heck is filemtime not workign here?!
  35. print date("F d H:i:s.");
  36. }
  37. function is_even($number){
  38. return(!($number & 1));
  39. }
  40. function make_users_list($users){
  41. echo "\t\t<ul>\n";
  42. foreach($users as $user => $color){
  43. if(!stristr($user,"*")){
  44. echo "\t\t\t<li style=\"color: $color\">$user</li>\n";
  45. }
  46. }
  47. echo "\t\t</ul>";
  48. }
  49. function process_line($line_num,$line,$null){
  50. global $excludes,$actual_lines,$colors_list,$users;
  51. $date = "";
  52. if(is_even($line_num)){
  53. $line_type = "line_even";
  54. } else {
  55. $line_type = "line_odd";
  56. }
  57. $line = htmlentities($line);
  58. // We need to create the line correctly, purge anything possibly not usefull to us.
  59. // We need a better line thing here but I can't remember what I was saying.
  60. $message_parts = explode(" ",$line);
  61. if(preg_match("/(.*T.*) (\*\*\* (.*?) .*(has (joined|quit)|sets|was kicked) (.*))/",htmlspecialchars_decode($line),$matches_result)){
  62. $date = $matches_result[1];
  63. $user = $matches_result[3];
  64. /*if(!$user == $message_parts[3]){
  65. $user = $message_parts[3];
  66. echo "True $user\n";
  67. }*/
  68. $user = str_replace(array("<",">",">","<"),"",$message_parts[3]);
  69. /*if(in_array($user,$users)){
  70. $line = str_replace("*** $user","*** <span class=\"nick\">$user</span>",$line);
  71. }*/
  72. $line = "<span class=\"action\">".$matches_result[2]."</span>\n";
  73. $actual_lines++;
  74. } elseif(stristr($line,"***") OR stristr($line,"* ")){
  75. $date = $message_parts[0];
  76. $user = $message_parts[3];
  77. $user = str_replace(array("<",">",">","<"),"",$message_parts[3]);
  78. $line = "<span class=\"action\">".$line."</span>\n";
  79. $actual_lines++;
  80. } else {
  81. foreach($excludes as $exclude){
  82. //if(!stristr($line,$exclude) OR !stristr($line,"***")){
  83. if(preg_match("/([0-9+\$\/_.-]*?T[0-9+\$\:\/_.-]*) .*(\<(.*?)\> .*)/",htmlspecialchars_decode($line),$matches_result)){
  84. $date = $matches_result[1];
  85. $nick = $matches_result[3];
  86. $user = $matches_result[3];
  87. $user = str_replace(array("<",">",">","<"),"",$message_parts[2]);
  88. //echo "A: ".$message_parts[2]."\tB: $user\n";
  89. if(!stristr($line,$exclude)){
  90. if(!fnmatch("*\*\*\* $nick <*!~*\@*\> ", $line) OR !fnmatch("*\*\*\* $nick <*!~*\@*> ", $line)){
  91. /*if(stristr($user,"!")){
  92. $user = explode("!",$user);
  93. $user = $user[0];
  94. }*/
  95. if(array_key_exists($user,$users)){
  96. $line = str_replace(array("<$user>","<$user>"),"<span class=\"nick\"><span style=\"color: ".$users[$user]."\">$user</span></span>",$line);
  97. } else {
  98. $users[$user] = get_random_color();
  99. }
  100. }
  101. $actual_lines++; // Increment all lines that are real...
  102. }
  103. } // end regex line match
  104. } // End Foreach
  105. } // End IF / Else
  106. // Make a nice date format whoa hworth hw ot wrthp st
  107. //var_dump($users);
  108. $line = str_replace($date,"",$line);
  109. // Massive hack goes here... Fix later
  110. //$date = str_replace(array(" ","T"),array("","\t"),$date);
  111. $date_parts = explode("T", $date);
  112. $date = "<span class=\"prefix\"><span class=\"date\">".$date_parts[0];
  113. if(isset($date[1])){
  114. @$date .= "<span class=\"time\">".str_replace(" ","",$date_parts[1])."</span>";
  115. }
  116. $date .= "</span></span>";
  117. // End hack
  118. $proc_line = str_replace(array("\n","\t","\r"," "," "),"",$line);
  119. echo "\t\t\t<div class=\"$line_type\"><span class=\"linenumbers\">$line_num</span>$date<span class=\"content\">".$proc_line."</span></div>\n";
  120. }
  121. if(@isset($_GET['channel']) OR @stristr($_GET['channel'],"##")){
  122. $channel = str_replace(array("#","##"),"",stripslashes(strval(urldecode($_GET['channel']))));
  123. switch($channel){
  124. case "transcendence":
  125. $channel = "#transcendence";
  126. break;
  127. default:
  128. $channel = $channel;
  129. break;
  130. }
  131. }
  132. if(isset($_GET['month'])){
  133. $month = stripslashes(strval(urldecode($_GET['month'])));
  134. } else {
  135. $month = date("F");
  136. }
  137. if(isset($_GET['network'])){
  138. $channel = stripslashes(strval(urldecode($_GET['channel'])));
  139. } else {
  140. $network = "freenode";
  141. }
  142.  
  143. /* Debug Mode */
  144.  
  145. if(isset($_GET['network'])){
  146. $channel = stripslashes(strval(urldecode($_GET['channel'])));
  147. } else {
  148. $network = "freenode";
  149. }
  150.  
  151.  
  152. include "header.php";
  153. $filename = "$path/$network/#$channel/$month/#$channel.log";
  154.  
  155. if(file_exists($filename)){
  156. echo "\t\t<div id=\"messages\">\n";
  157. $lines = file($filename, FILE_SKIP_EMPTY_LINES);
  158. foreach ($lines as $line_num => $line) {
  159. process_line($line_num,$line,$users);
  160. }
  161. echo "\t\t</div>\n\t </div>\n\t<div id=\"userbar\">\n";
  162. make_users_list($users);
  163. echo "\t</div>";
  164. } else {
  165. 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>";
  166. }
  167. include "footer.php";
  168. ?>
Add Comment
Please, Sign In to add comment