File: 1.00.1a/server/bin/logwatch.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: require("include.php");
 23: $NATS->Start();
 24: $min_delay=2;
 25: $first=true;
 26: $lastlog=0;
 27: while (1==1)
 28: 	{
 29: 	$start=time();
 30: 	$q="SELECT * FROM fnlog WHERE logid>".$lastlog." ORDER BY logid";
 31: 	if ($first)
 32: 		{
 33: 		$q.=" DESC LIMIT 0,20";
 34: 		$first=false;
 35: 		}
 36: 	else $q.=" ASC";
 37: 	$r=$NATS->DB->Query($q);
 38: 	while ($row=$NATS->DB->Fetch_Array($r))
 39: 		{
 40: 		echo nicedt($row['postedx'])."\t".$row['loglevel']."\t".$row['modid'].":".$row['catid']."\t".$row['logevent']."\n";
 41: 		$lastlog=$row['logid'];
 42: 		}
 43: 	
 44: 	while ( (time()-$start)<$min_delay ) sleep(1);
 45: 	}
 46: ?>