Corrected event counts and reset times to use local rather than MySQL time.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@112 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2002-10-30 12:40:27 +00:00
parent 9ec7d50d85
commit d57869fcde
3 changed files with 5 additions and 8 deletions

View File

@ -279,12 +279,7 @@ if ( $action )
}
elseif ( $action == "reset" )
{
// Get MySQL's version of now
$result = mysql_query( "select now()" );
if ( !$result )
die( mysql_error() );
$row = mysql_fetch_row( $result );
$HTTP_SESSION_VARS[event_reset_time] = $row[0];
$HTTP_SESSION_VARS[event_reset_time] = strftime( "%Y-%m-%d %H:%M:%S" );
setcookie( "event_reset_time", $HTTP_SESSION_VARS[event_reset_time], time()+3600*24*30*12*10 );
}
}

View File

@ -51,7 +51,8 @@ switch( $view )
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
$sql = "select M.*, count(E.Id) as EventCount, count(if(E.Archived,1,NULL)) as ArchEventCount, count(if(E.StartTime>NOW() - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>NOW() - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount, count(if(E.StartTime>NOW() - INTERVAL 7 DAY && E.Archived = 0,1,NULL)) as WeekEventCount, count(if(E.StartTime>NOW() - INTERVAL 1 MONTH && E.Archived = 0,1,NULL)) as MonthEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by E.MonitorId order by Id";
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$sql = "select M.*, count(E.Id) as EventCount, count(if(E.Archived,1,NULL)) as ArchEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 7 DAY && E.Archived = 0,1,NULL)) as WeekEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 MONTH && E.Archived = 0,1,NULL)) as MonthEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by E.MonitorId order by Id";
$result = mysql_query( $sql );
if ( !$result )
echo mysql_error();

View File

@ -53,7 +53,8 @@ if ( $view == "console" )
if ( !$HTTP_SESSION_VARS[event_reset_time] )
$HTTP_SESSION_VARS[event_reset_time] = "2000-01-01 00:00:00";
$sql = "select M.*, count(E.Id) as EventCount, count(if(E.StartTime>'$HTTP_SESSION_VARS[event_reset_time]' && E.Archived = 0,1,NULL)) as ResetEventCount, count(if(E.StartTime>NOW() - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>NOW() - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by E.MonitorId order by Id";
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$sql = "select M.*, count(E.Id) as EventCount, count(if(E.StartTime>'$HTTP_SESSION_VARS[event_reset_time]' && E.Archived = 0,1,NULL)) as ResetEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by E.MonitorId order by Id";
$result = mysql_query( $sql );
if ( !$result )
echo mysql_error();