<?php
require_once($file_path."inc_common.php");
include($engine_path."users_get_list.php");
include($file_path."inc_user_class.php");
include($data_path."engine/".$long_life_data_engine."/users_get_object.php");
include($file_path."designes/".$design."/common_title.php");
include($file_path."designes/".$design."/common_browser_detect.php");
set_variable("logdate");
$mes_time = array();
$mes_type = array();
$mes_ip   = array();
$mes_from = array();
$mes_fromwotags = array();
$mes_room = array();
$mes_roomname = array();
$mes_body = array();
if ($logdate=="") {$logdate=date("Y-m-d", my_time());}
if ($room=="") {$room="0";}
echo "<form method=\"post\" action=\"logs.php?session=$session\">";
$handle = opendir($data_path."logs/");
echo "$w_at_date:<select name=\"logdate\" style=\"width:128px\">";
      while (false !== ($tmp_file = readdir($handle))) {
         if (substr($tmp_file,0,6)!="config" and is_file($data_path."logs/".$tmp_file)) {
            $logfile_name = substr($tmp_file,0,strpos($tmp_file,"."));
            echo "<option value=\"$logfile_name\"";
            if ($logfile_name==$logdate)  echo "selected";
            echo ">$logfile_name</option>\n";
         }
      }
      echo "</select>";
      closedir($handle);
echo "   $w_logsroom: ";
echo "<select name=\"room\" style=\"width:108px\">";
for ($r=0; $r<count($room_ids);$r++)
{
   echo "<option value=\"".$room_ids[$r]."\"";
   if ($rooms[$room_ids[$r]]["title"] == $rooms[$room]["title"]) echo " selected";
   echo ">".$rooms[$room_ids[$r]]["title"]."</option>\n";
}
echo "</select>";
echo "<input type=\"submit\" value=\"$w_letsgo\">";
echo "</form>";
$log_file = $data_path."logs/".$logdate.".log";
$logsfile = file($log_file);
for ($i=0;$i<count($logsfile);$i++)
   list ($mes_time[$i],$mes_type[$i],$mes_ip[$i],$mes_from[$i],$mes_room[$i],$mes_body[$i],$mes_fromwotags[$i]) =
      explode("\t",trim($logsfile[$i]));
unset($logsfile);
echo "<hr>";
echo "$w_logsdate <b>$logdate</b>,$w_logsroom: <b>".$rooms[$room]["title"]."</b>";
echo "<hr>";
if ($current_user->user_class<1) {
echo "<table width=\"100%\"><tr><td align=\"center\" width=\"5%\">$w_logstime</td><td align=\"center\" width=\"10%\">$w_logsnick</td><td width=\"*\" align=\"center\">$w_logsmes</td>";
echo "</tr>";
for ($j=0;$j<count($mes_from);$j++)
{      
    if ($mes_room[$j]=="room ".$room) {   
   echo "<tr><td align=\"center\">$mes_time[$j]</td><td align=\"center\">$mes_from[$j]</td><td>$mes_body[$j]</td>";
   echo "</tr>";
   }
}
echo "</table>";
}
if ($current_user->user_class>1) {
echo "<table width=\"100%\"><tr><td align=\"center\" width=\"5%\">$w_logstime</td><td align=\"center\" width=\"10%\">$w_logsnick</td><td width=\"*\" align=\"center\">$w_logsmes</td>";
echo "<td align=\"center\" width=\"10%\">$w_logsip</td>";
echo "</tr>";
for ($j=0;$j<count($mes_from);$j++)
{      
    if ($mes_room[$j]=="room ".$room) {   
   echo "<tr><td align=\"center\">$mes_time[$j]</td><td align=\"center\">$mes_from[$j]</td><td>$mes_body[$j]</td>";
   echo "<td>$mes_ip[$j]</td>";
   echo "</tr>";
   }
}
echo "</table>";
}
echo "<hr>";
?>
<center><font size="1">©2005 mc[mad.cat!]. ICQ UIN: 368291, mailto: mad.cat@bryasnktalk.ru</font></center>