File: 1.08.0a/server/web/log.php (View as HTML)

  1: <?php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeNATS
  4: 
  5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
  6: 
  7: FreeNATS is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeNATS is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeNATS.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freenats
 21: -------------------------------------------------------------- */
 22: 
 23: ob_start();
 24: require("include.php");
 25: $NATS->Start();
 26: if (!$NATS_Session->Check($NATS->DB))
 27: 	{
 28: 	header("Location: ./?login_msg=Invalid+Or+Expired+Session");
 29: 	exit();
 30: 	}
 31: if ($NATS_Session->userlevel<9) UL_Error("View Log");
 32: 
 33: 
 34: ob_end_flush();
 35: Screen_Header("System Event Log",1);
 36: ?>
 37: 
 38: <br>
 39: <b class="subtitle">System Event Log</b><br><br>
 40: 
 41: <?php
 42: 
 43: if (isset($_REQUEST['f_mod'])) $f_mod=$_REQUEST['f_mod'];
 44: else $f_mod="";
 45: if (isset($_REQUEST['f_cat'])) $f_cat=$_REQUEST['f_cat'];
 46: else $f_cat="";
 47: if (isset($_REQUEST['f_lvl'])) $f_lvl=$_REQUEST['f_lvl'];
 48: else $f_lvl="";
 49: if (isset($_REQUEST['f_entry'])) $f_entry=$_REQUEST['f_entry'];
 50: else $f_entry="";
 51: if (isset($_REQUEST['d_show'])) $d_show=$_REQUEST['d_show'];
 52: else $d_show="30";
 53: if (isset($_REQUEST['d_from'])) $d_from=$_REQUEST['d_from'];
 54: else $d_from="0";
 55: 
 56: 
 57: $wc=array();
 58: if ($f_mod!="") $wc[]="modid=\"".ss($f_mod)."\"";
 59: if ($f_cat!="") $wc[]="catid=\"".ss($f_cat)."\"";
 60: if ($f_lvl!="") $wc[]="loglevel<=".ss($f_lvl);
 61: if ($f_entry!="") $wc[]="logevent LIKE \"%".ss($f_entry)."%\"";
 62: 
 63: if (count($wc)==0) $wc[]="1";
 64: 
 65: $q="SELECT * FROM fnlog WHERE";
 66: $first=true;
 67: foreach($wc as $c)
 68: 	{
 69: 	if ($first) $first=false;
 70: 	else $q.=" AND";
 71: 	$q.=" ".$c;
 72: 	}
 73: 
 74: $q.=" ORDER BY logid DESC";
 75: $q.=" LIMIT ".ss($d_from).",".ss($d_show);
 76: 
 77: echo "<table class=\"nicetable\">";
 78: echo "<form action=log.php method=post>";
 79: // posted mod cat lvl entry
 80: echo "<tr>";
 81: echo "<td><b>Filter:</b></td>";
 82: echo "<td><input type=text value=\"".$f_mod."\" name=f_mod size=10></td>";
 83: echo "<td><input type=text value=\"".$f_cat."\" name=f_cat size=10></td>";
 84: echo "<td><input type=text value=\"".$f_lvl."\" name=f_lvl size=2></td>";
 85: echo "<td><input type=text value=\"".$f_entry."\" name=f_entry size=40></td>";
 86: echo "</tr>";
 87: 
 88: echo "<tr><td><b>Show:</b></td>";
 89: echo "<td colspan=3 align=left>";
 90: echo "<input type=text value=\"".$d_show."\" size=4 name=d_show> entries from ";
 91: echo "<input type=text value=\"".$d_from."\" size=6 name=d_from>";
 92: echo "</td><td>";
 93: echo "<input type=submit value=\"Filter Log Entries and Display\"> <a href=log.php>Reset</a>";
 94: echo "</td></tr>";
 95: 
 96: echo "<tr><td colspan=3>";
 97: $dto=$d_from-$d_show;
 98: if ($dto<0) $dto=0;
 99: echo "<a href=log.php?d_from=".$dto."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
100: echo "&lt;&lt; Previous";
101: echo "</a></td>";
102: echo "<td colspan=2 align=right>";
103: $dto=$d_from+$d_show;
104: if ($dto<0) $dto=0;
105: echo "<a href=log.php?d_from=".$dto."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
106: echo "Next &gt;&gt;";
107: echo "</a></td></tr>";
108: 
109: //echo "<tr><td colspan=5>".$q."</td></tr>";
110: // <a href=log.php?d_from=".$d_from."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".$fentry.">
111: $r=$NATS->DB->Query($q);
112: while ($row=$NATS->DB->Fetch_Array($r))
113: 	{
114: 	echo "<tr><td>".nicedt($row['postedx'])."</td>";
115: 	echo "<td>";
116: 	echo "<a href=log.php?d_from=".$d_from."&d_show=".$d_show."&f_mod=".$row['modid']."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
117: 	echo $row['modid']."</a></td>";
118: 	echo "<td>";
119: 	echo "<a href=log.php?d_from=".$d_from."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$row['catid']."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
120: 	echo $row['catid']."</a></td>";
121: 	echo "<td>";
122: 	echo "<a href=log.php?d_from=".$d_from."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$row['loglevel']."&f_entry=".urlencode($f_entry).">";
123: 	echo $row['loglevel']."</a></td>";
124: 	echo "<td>".$row['logevent']."</td>";
125: 	echo "</tr>";
126: 	}
127: $NATS->DB->Free($r);
128: 
129: echo "<tr><td colspan=3>";
130: $dto=$d_from-$d_show;
131: if ($dto<0) $dto=0;
132: echo "<a href=log.php?d_from=".$dto."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
133: echo "&lt;&lt; Previous";
134: echo "</a></td>";
135: echo "<td colspan=2 align=right>";
136: $dto=$d_from+$d_show;
137: if ($dto<0) $dto=0;
138: echo "<a href=log.php?d_from=".$dto."&d_show=".$d_show."&f_mod=".$f_mod."&f_cat=".$f_cat."&f_lvl=".$f_lvl."&f_entry=".urlencode($f_entry).">";
139: echo "Next &gt;&gt;";
140: echo "</a></td></tr>";
141: 
142: 
143: echo "</table>";
144: 
145: //echo $q;
146: 
147: ?>
148: 
149: 
150: <?php
151: Screen_Footer();
152: ?>
153: