From d57869fcdebb8a0ac2ae7760c1e36814ba7349aa Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 30 Oct 2002 12:40:27 +0000 Subject: [PATCH] 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 --- web/zmactions.php | 7 +------ web/zmhtml.php | 3 ++- web/zmwml.php | 3 ++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/web/zmactions.php b/web/zmactions.php index 386bbefeb..3ac85d8ed 100644 --- a/web/zmactions.php +++ b/web/zmactions.php @@ -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 ); } } diff --git a/web/zmhtml.php b/web/zmhtml.php index 7072206a6..1987bf835 100644 --- a/web/zmhtml.php +++ b/web/zmhtml.php @@ -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(); diff --git a/web/zmwml.php b/web/zmwml.php index 5cd41489a..06a00a86c 100644 --- a/web/zmwml.php +++ b/web/zmwml.php @@ -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();