Bug 291 - Revamped date/time handling to use strftime instead of date and

to use locale aware formats. Also extracted out common formats.


git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1896 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2006-03-27 22:01:33 +00:00
parent 6230ea5f49
commit b833a07e31
18 changed files with 128 additions and 106 deletions

View File

@ -1686,7 +1686,7 @@ if ( !empty($action) )
}
elseif ( $action == "reset" )
{
$_SESSION['event_reset_time'] = strftime( "%Y-%m-%d %H:%M:%S" );
$_SESSION['event_reset_time'] = strftime( STRF_FMT_DATETIME_DB );
setcookie( "event_reset_time", $_SESSION['event_reset_time'], time()+3600*24*30*12*10 );
if ( $cookies ) session_write_close();
}

View File

@ -18,6 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//
// This section contains options substituted by the zmconfig.pl utility, do not edit these directly
//
define( "ZM_CONFIG", "@ZM_CONFIG@" ); // Path to config file
@ -35,10 +36,12 @@ while ( !feof($cfg) )
}
fclose( $cfg );
//
// This section is options normally derived from other options or configuration
//
define( "ZMU_PATH", ZM_PATH_BIN."/zmu" ); // Local path to the ZoneMinder Utility
//
// Alarm states
//
define( "STATE_IDLE", 0 );
@ -47,6 +50,7 @@ define( "STATE_ALARM", 2 );
define( "STATE_ALERT", 3 );
define( "STATE_TAPE", 4 );
//
// These are miscellaneous options you won't normally need to change
//
define( "MAX_EVENTS", 10 ); // The maximum number of events to show in the monitor event listing
@ -57,6 +61,21 @@ define( 'DEVICE_WIDTH', 150 ); // Default device width for phones and hand
define( 'DEVICE_HEIGHT', 150 ); // Default device height for phones and handhelds
define( 'DEVICE_LINES', 10 ); // Default device lines for phones and handhelds
//
// Date and time formats, eventually some of these may end up in the language files
//
define( "DATE_FMT_CONSOLE_LONG", "D jS M, g:ia" ); // This is the main console date/time, date() or strftime() format
define( "DATE_FMT_CONSOLE_SHORT", "%H:%M" ); // This is the xHTML console date/time, date() or strftime() format
define( "STRF_FMT_DATETIME_DB", "%Y-%m-%d %H:%M:%S" ); // Strftime format for database queries, don't change
define( "STRF_FMT_DATETIME", "%c" ); // Strftime locale aware format for dates with times
define( "STRF_FMT_DATE", "%x" ); // Strftime locale aware format for dates without times
define( "STRF_FMT_TIME", "%X" ); // Strftime locale aware format for times without dates
define( "STRF_FMT_DATETIME_SHORT", "%y/%m/%d %H:%M:%S" ); // Strftime shorter format for dates with time, not locale aware
define( "STRF_FMT_DATETIME_SHORTER", "%m/%d %H:%M:%S" ); // Strftime shorter format for dates with time, not locale aware, used where space is tight
require_once( 'zm_db.php' );
loadConfig();

View File

@ -68,7 +68,7 @@ function exportEventDetail( $event )
<tr><td><?= $zmSlangMonitor ?></td><td><?= $event['MonitorName'] ?> (<?= $event['MonitorId'] ?>)</td></tr>
<tr><td><?= $zmSlangCause ?></td><td><?= $event['Cause'] ?></td></tr>
<tr><td><?= $zmSlangNotes ?></td><td><?= $event['Notes'] ?></td></tr>
<tr><td><?= $zmSlangTime ?></td><td><?= strftime( "%m/%d %H:%M:%S", strtotime($event['StartTime']) ) ?></td></tr>
<tr><td><?= $zmSlangTime ?></td><td><?= strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime']) ) ?></td></tr>
<tr><td><?= $zmSlangDuration ?></td><td><?= $event['Length'] ?></td></tr>
<tr><td><?= $zmSlangFrames ?></td><td><?= $event['Frames'] ?></td></tr>
<tr><td><?= $zmSlangAttrAlarmFrames ?></td><td><?= $event['AlarmFrames'] ?></td></tr>
@ -148,7 +148,7 @@ function exportEventFrames( $event )
<tr bgcolor="<?= $bgcolor ?>">
<td align="center"><?= $frame['FrameId'] ?></td>
<td align="center"><?= $alarm_frame?$zmSlangYes:$zmSlangNo ?></td>
<td align="center"><?= date( "H:i:s", $frame['UnixTimeStamp'] ) ?></td>
<td align="center"><?= strftime( STRF_FMT_TIME, $frame['UnixTimeStamp'] ) ?></td>
<td align="center"><?= number_format( $frame['Delta'], 2 ) ?></td>
<td align="center"><?= $frame['Score'] ?></td>
<?php

View File

@ -96,6 +96,15 @@ function userLogout()
session_destroy();
}
function noCacheHeaders()
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
}
function authHash( $use_remote_addr )
{
if ( version_compare( phpversion(), "4.1.0", "<") )
@ -1239,16 +1248,16 @@ function parseFilter( $save_to_session=false, $term_sep='&' )
$value = "'$value'";
break;
case 'DateTime':
$value = "'".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."'";
$value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'";
break;
case 'Date':
$value = "to_days( '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
case 'Time':
$value = "extract( hour_second from '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
case 'Weekday':
$value = "weekday( '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "weekday( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
}
$value_list[] = $value;

View File

@ -34,13 +34,9 @@ mysql_free_result( $result );
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: ".ZM_WEB_REFRESH_MAIN."; URL=$PHP_SELF" );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$db_now = strftime( STRF_FMT_DATETIME_DB );
$sql = "select * from Monitors order by Sequence asc";
$result = mysql_query( $sql );
if ( !$result )
@ -225,7 +221,7 @@ newWindow( '<?= $PHP_SELF ?>?view=donate', 'zmDonate', <?= $jws['donate']['w'] ?
<input type="hidden" name="view" value="<?= $view ?>">
<input type="hidden" name="action" value="delete">
<tr>
<td class="smallhead" align="left"><?= date( "D jS M, g:ia" ) ?></td>
<td class="smallhead" align="left"><?= preg_match( '/%/', DATE_FMT_CONSOLE_LONG )?strftime( DATE_FMT_CONSOLE_LONG ):date( DATE_FMT_CONSOLE_LONG ) ?></td>
<td class="bighead" align="center"><strong><a href="http://www.zoneminder.com" target="ZoneMinder">ZoneMinder</a> <?= $zmSlangConsole ?> - <?php if ( canEdit( 'System' ) ) { ?><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=state', 'zmState', <?= $jws['state']['w'] ?>, <?= $jws['state']['h'] ?> );"><?= $status ?></a> - <?php } ?><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=version', 'zmVersion', ".$jws['version']['w'].", ".$jws['version']['h']." );", "v".ZM_VERSION, canEdit( 'System' ) ) ?></strong></td>
<td class="smallhead" align="right"><?= $zmSlangLoad ?>: <?= getLoad() ?> / <?= $zmSlangDisk ?>: <?= getDiskPercent() ?>%</td>
</tr>

View File

@ -74,12 +74,7 @@ if ( ZM_WEB_REFRESH_METHOD == "http" )
{
header("Refresh: ".ZM_WEB_REFRESH_CYCLE."; URL=$PHP_SELF?view=cycle&group=$group&mid=$next_mid&mode=$mode" );
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -418,7 +418,7 @@ function viewEvents( form, name )
<td align="center" class="text"><a href="javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&eid=<?= $event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&page=1', 'zmEvent', <?= reScale( $event['Width'], $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE )+$jws['event']['w'] ?>, <?= reScale( $event['Height'], $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE )+$jws['event']['h'] ?> );"><?= $event['Name'] ?><?php if ( $event['Archived'] ) echo "*" ?></a></td>
<td align="center" class="text"><?= $event['MonitorName'] ?></td>
<td align="center" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=eventdetail&eid=".$event['Id']."', 'zmEventDetail', ".$jws['eventdetail']['w'].", ".$jws['eventdetail']['h']." );", $event['Cause'], canEdit( 'Events' ) ) ?></td>
<td align="center" class="text"><?= strftime( "%m/%d %H:%M:%S", strtotime($event['StartTime']) ) ?></td>
<td align="center" class="text"><?= strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime']) ) ?></td>
<td align="center" class="text"><?= $event['Length'] ?></td>
<td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=frames&eid=<?= $event['Id'] ?>', 'zmFrames', <?= $jws['frames']['w'] ?>, <?= $jws['frames']['h'] ?> );"><?= $event['Frames'] ?></a></td>
<td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=frames&eid=<?= $event['Id'] ?>', 'zmFrames', <?= $jws['frames']['w'] ?>, <?= $jws['frames']['h'] ?> );"><?= $event['AlarmFrames'] ?></a></td>

View File

@ -82,7 +82,7 @@ if ( count($frames) )
<tr bgcolor="<?= $bgcolor ?>">
<td class="text" align="center"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=frame&eid=<?= $eid ?>&fid=<?= $frame['FrameId'] ?>', 'zmImage', <?= $event['Width']+$jws['image']['w'] ?>, <?= $event['Height']+$jws['image']['h'] ?> );"><?= $frame['FrameId'] ?></a></td>
<td class="text" align="center"><?= $alarm_frame?$zmSlangYes:$zmSlangNo ?></td>
<td class="text" align="center"><?= date( "H:i:s", $frame['UnixTimeStamp'] ) ?></td>
<td class="text" align="center"><?= strftime( STRF_FMT_TIME, $frame['UnixTimeStamp'] ) ?></td>
<td class="text" align="center"><?= number_format( $frame['Delta'], 2 ) ?></td>
<?php
if ( ZM_RECORD_EVENT_STATS && $alarm_frame )

View File

@ -58,11 +58,7 @@ if ( $mode != "stream" )
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: ".ZM_WEB_REFRESH_IMAGE."; URL=$PHP_SELF?view=montagefeed&mid=$mid&mode=still&scale=$scale" );
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) );

View File

@ -54,13 +54,10 @@ $old_alarm = ( $status <= STATE_PREALARM && $last_status > STATE_PREALARM );
$refresh = (($status>=STATE_PREALARM)&&($status<=STATE_ALERT))?1:ZM_WEB_REFRESH_STATUS;
$url = "$PHP_SELF?view=montagestatus&mid=$mid&last_status=$status";
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: $refresh; URL=$url" );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -24,6 +24,43 @@ if ( !canView( 'Events' ) )
return;
}
//
// Date/time formats used in charts
//
// These are the time axis range text. The first of each pair is the start date/time
// and the second is the last so often contains additional information
//
// When the chart range is years
define( "STRF_TL_AXIS_RANGE_YEAR1", "%b %Y" );
define( "STRF_TL_AXIS_RANGE_YEAR2", STRF_TL_AXIS_RANGE_YEAR1 );
// When the chart range is months
define( "STRF_TL_AXIS_RANGE_MONTH1", "%b" );
define( "STRF_TL_AXIS_RANGE_MONTH2", STRF_TL_AXIS_RANGE_MONTH1." %Y" );
// When the chart range is days
define( "STRF_TL_AXIS_RANGE_DAY1", "%d" );
define( "STRF_TL_AXIS_RANGE_DAY2", STRF_TL_AXIS_RANGE_DAY1." %b %Y" );
// When the chart range is less than a day
define( "STRF_TL_AXIS_RANGE_TIME1", "%H:%M" );
define( "STRF_TL_AXIS_RANGE_TIME2", STRF_TL_AXIS_RANGE_TIME1.", %d %b %Y" );
//
// These are the time axis tick labels
//
define( "STRF_TL_AXIS_LABEL_YEAR", "%Y" );
define( "STRF_TL_AXIS_LABEL_MONTH", "%M" );
define( "STRF_TL_AXIS_LABEL_WEEK", "%d/%m" );
define( "STRF_TL_AXIS_LABEL_DAY", "%d" );
define( "STRF_TL_AXIS_LABEL_HOUR", "%H:00" );
define( "STRF_TL_AXIS_LABEL_10MINUTE", "%H:%M" );
define( "STRF_TL_AXIS_LABEL_MINUTE", "%H:%M" );
define( "STRF_TL_AXIS_LABEL_10SECOND", "%S" );
define( "STRF_TL_AXIS_LABEL_SECOND", "%S" );
// Turn error reporting on full temporarily.
error_reporting( E_ALL );
$mouseover = true;
@ -133,24 +170,24 @@ if ( isset($range) )
{
$max_time_t--;
}
$min_time = date( "Y-m-d H:i:s", $min_time_t );
$max_time = date( "Y-m-d H:i:s", $max_time_t );
$min_time = strftime( STRF_FMT_DATETIME_DB, $min_time_t );
$max_time = strftime( STRF_FMT_DATETIME_DB, $max_time_t );
}
elseif ( isset($min_time) )
{
$min_time_t = strtotime($min_time);
$max_time_t = $min_time_t + $range;
$mid_time_t = $min_time_t + $half_range;
$mid_time = date( "Y-m-d H:i:s", $mid_time_t );
$max_time = date( "Y-m-d H:i:s", $max_time_t );
$mid_time = strftime( STRF_FMT_DATETIME_DB, $mid_time_t );
$max_time = strftime( STRF_FMT_DATETIME_DB, $max_time_t );
}
elseif ( isset($max_time) )
{
$max_time_t = strtotime($max_time);
$min_time_t = $max_time_t - $range;
$mid_time_t = $min_time_t + $half_range;
$min_time = date( "Y-m-d H:i:s", $min_time_t );
$mid_time = date( "Y-m-d H:i:s", $mid_time_t );
$min_time = strftime( STRF_FMT_DATETIME_DB, $min_time_t );
$mid_time = strftime( STRF_FMT_DATETIME_DB, $mid_time_t );
}
}
elseif ( isset($min_time) && isset($max_time) )
@ -160,7 +197,7 @@ elseif ( isset($min_time) && isset($max_time) )
$range = ($max_time_t - $min_time_t) + 1;
$half_range = (int)($range/2);
$mid_time_t = $min_time_t + $half_range;
$mid_time = date( "Y-m-d H:i:s", $mid_time_t );
$mid_time = strftime( STRF_FMT_DATETIME_DB, $mid_time_t );
}
if ( isset($min_time) && isset($max_time) )
@ -219,7 +256,7 @@ else
$range = ($max_time_t - $min_time_t) + 1;
$half_range = (int)($range/2);
$mid_time_t = $min_time_t + $half_range;
$mid_time = date( "Y-m-d H:i:s", $mid_time_t );
$mid_time = strftime( STRF_FMT_DATETIME_DB, $mid_time_t );
}
//echo "MnT: $temp_min_time, MxT: $temp_max_time, ExP: $temp_expandable<br>";
@ -234,15 +271,15 @@ if ( $filter_query )
//echo '<br>';
$scales = array(
array( "name"=>"year", "factor"=>60*60*24*365, "align"=>1, "zoomout"=>2, "label"=>"Y" ),
array( "name"=>"month", "factor"=>60*60*24*30, "align"=>1, "zoomout"=>12, "label"=>"M" ),
array( "name"=>"week", "factor"=>60*60*24*7, "align"=>1, "zoomout"=>4.25, "label"=>"j/n", "label_check"=>"W" ),
array( "name"=>"day", "factor"=>60*60*24, "align"=>1, "zoomout"=>7, "label"=>"j" ),
array( "name"=>"hour", "factor"=>60*60, "align"=>1, "zoomout"=>24, "label"=>"H:00", "label_check"=>"H" ),
array( "name"=>"minute10", "factor"=>60, "align"=>10, "zoomout"=>6, "label"=>"H:i", "label_check"=>"i" ),
array( "name"=>"minute", "factor"=>60, "align"=>1, "zoomout"=>10, "label"=>"H:i", "label_check"=>"i" ),
array( "name"=>"second10", "factor"=>1, "align"=>10, "zoomout"=>6, "label"=>"s" ),
array( "name"=>"second", "factor"=>1, "align"=>1, "zoomout"=>10, "label"=>"s" ),
array( "name"=>"year", "factor"=>60*60*24*365, "align"=>1, "zoomout"=>2, "label"=>STRF_TL_AXIS_LABEL_YEAR ),
array( "name"=>"month", "factor"=>60*60*24*30, "align"=>1, "zoomout"=>12, "label"=>STRF_TL_AXIS_LABEL_MONTH ),
array( "name"=>"week", "factor"=>60*60*24*7, "align"=>1, "zoomout"=>4.25, "label"=>STRF_TL_AXIS_LABEL_WEEK, "label_check"=>"%W" ),
array( "name"=>"day", "factor"=>60*60*24, "align"=>1, "zoomout"=>7, "label"=>STRF_TL_AXIS_LABEL_DAY ),
array( "name"=>"hour", "factor"=>60*60, "align"=>1, "zoomout"=>24, "label"=>STRF_TL_AXIS_LABEL_HOUR, "label_check"=>"%H" ),
array( "name"=>"minute10", "factor"=>60, "align"=>10, "zoomout"=>6, "label"=>STRF_TL_AXIS_LABEL_10MINUTE, "label_check"=>"%M" ),
array( "name"=>"minute", "factor"=>60, "align"=>1, "zoomout"=>10, "label"=>STRF_TL_AXIS_LABEL_MINUTE, "label_check"=>"%M" ),
array( "name"=>"second10", "factor"=>1, "align"=>10, "zoomout"=>6, "label"=>STRF_TL_AXIS_LABEL_10SECOND ),
array( "name"=>"second", "factor"=>1, "align"=>1, "zoomout"=>10, "label"=>STRF_TL_AXIS_LABEL_SECOND ),
);
$maj_x_scale = getDateScale( $scales, $range, $chart['grid']['x']['major']['min'], $chart['grid']['x']['major']['max'] );
@ -250,15 +287,15 @@ $maj_x_scale = getDateScale( $scales, $range, $chart['grid']['x']['major']['min'
// Adjust the range etc for scale
$min_time_t -= $min_time_t%($maj_x_scale['factor']*$maj_x_scale['align']);
$min_time = date( "Y-m-d H:i:s", $min_time_t );
$min_time = strftime( STRF_FMT_DATETIME_DB, $min_time_t );
$max_time_t += (($maj_x_scale['factor']*$maj_x_scale['align'])-$max_time_t%($maj_x_scale['factor']*$maj_x_scale['align']))-1;
if ( $max_time_t > time() )
$max_time_t = time();
$max_time = date( "Y-m-d H:i:s", $max_time_t );
$max_time = strftime( STRF_FMT_DATETIME_DB, $max_time_t );
$range = ($max_time_t - $min_time_t) + 1;
$half_range = (int)($range/2);
$mid_time_t = $min_time_t + $half_range;
$mid_time = date( "Y-m-d H:i:s", $mid_time_t );
$mid_time = strftime( STRF_FMT_DATETIME_DB, $mid_time_t );
//echo "R:$range<br>";
//echo "MnT:$min_time<br>";
@ -295,7 +332,6 @@ $mon_frame_slots = array();
if ( !($event_result = mysql_query( $events_sql )) )
die( mysql_error() );
$monitor_ids = array();
//echo "YYY:".date( "r" )."<br>"; flush();
while( $event = mysql_fetch_assoc( $event_result ) )
{
if ( !isset($monitor_ids[$event['MonitorId']]) )
@ -412,7 +448,6 @@ ksort($monitor_ids,SORT_NUMERIC);
ksort($mon_event_slots,SORT_NUMERIC);
ksort($mon_frame_slots,SORT_NUMERIC);
//echo "AAA:".date( "r" )."<br>"; flush();
// Add on missing frames
$xcount = 0;
foreach( array_keys($mon_frame_slots) as $monitor_id )
@ -435,8 +470,6 @@ foreach( array_keys($mon_frame_slots) as $monitor_id )
}
}
}
//echo "Fetched $xcount frames<br>";
//echo "BBB:".date( "r" )."<br>"; flush();
$chart['data']['y']['range'] = ($chart['data']['y']['hi'] - $chart['data']['y']['lo']) + 1;
$chart['data']['y']['density'] = $chart['data']['y']['range']/$chart['graph']['height'];
@ -455,7 +488,6 @@ foreach ( array_keys($monitor_ids) as $monitor_id )
$max_height = $monitors[$monitor_id]['Height'];
}
//echo "ZZZ:".date( "r" )."<br>"; flush();
// Optimise boxes
foreach( array_keys($mon_event_slots) as $monitor_id )
{
@ -514,7 +546,6 @@ foreach( array_keys($mon_event_slots) as $monitor_id )
}
// Stack events
//echo "XXX:".date( "r" )."<br>"; flush();
$frame_slots = array();
$frame_monitor_ids = array_keys($mon_frame_slots);
for ( $i = 0; $i < $chart['graph']['width']; $i++ )
@ -550,7 +581,6 @@ for ( $i = 0; $i < $chart['graph']['width']; $i++ )
}
}
}
//echo "YYY:".date( "r" )."<br>"; flush();
//print_r( $mon_event_slots );
//print_r( $mon_frame_slots );
@ -562,22 +592,22 @@ preg_match( '/^(\d+)-(\d+)-(\d+) (\d+):(\d+)/', $max_time, $end_matches );
if ( $start_matches[1] != $end_matches[1] )
{
// Different years
$title = date( "M Y", $chart['data']['x']['lo'] )." - ".date( "M Y", $chart['data']['x']['hi'] );
$title = strftime( STRF_TL_AXIS_RANGE_YEAR1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_YEAR2, $chart['data']['x']['hi'] );
}
elseif ( $start_matches[2] != $end_matches[2] )
{
// Different months
$title = date( "M", $chart['data']['x']['lo'] )." - ".date( "M Y", $chart['data']['x']['hi'] );
$title = strftime( STRF_TL_AXIS_RANGE_MONTH1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_MONTH2, $chart['data']['x']['hi'] );
}
elseif ( $start_matches[3] != $end_matches[3] )
{
// Different dates
$title = date( "j", $chart['data']['x']['lo'] )." - ".date( "j M Y", $chart['data']['x']['hi'] );
$title = strftime( STRF_TL_AXIS_RANGE_DAY1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_DAY2, $chart['data']['x']['hi'] );
}
else
{
// Different times
$title = date( "H:i", $chart['data']['x']['lo'] )." - ".date( "H:i, j M Y", $chart['data']['x']['hi'] );
$title = strftime( STRF_TL_AXIS_RANGE_TIME1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_TIME2, $chart['data']['x']['hi'] );
}
function getDateScale( $scales, $range, $min_lines, $max_lines )
@ -635,11 +665,11 @@ function drawXGrid( $chart, $scale, $label_class, $tick_class, $grid_class, $zoo
$time_offset = (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density']));
if ( $scale['align'] > 1 )
{
$label = (int)(date( $label_check, $time_offset )/$scale['align']);
$label = (int)(strftime( $label_check, $time_offset )/$scale['align']);
}
else
{
$label = date( $label_check, $time_offset );
$label = strftime( $label_check, $time_offset );
}
if ( !isset($last_label) || ($last_label != $label) )
{
@ -653,7 +683,7 @@ function drawXGrid( $chart, $scale, $label_class, $tick_class, $grid_class, $zoo
if ( $label_class )
{
?>
<div class="<?= $label_class ?>" style="left: <?= $x-25 ?>px;"><?= date( $scale['label'], $time_offset ); ?></div>
<div class="<?= $label_class ?>" style="left: <?= $x-25 ?>px;"><?= strftime( $scale['label'], $time_offset ); ?></div>
<?php
}
if ( $tick_class )
@ -672,8 +702,8 @@ function drawXGrid( $chart, $scale, $label_class, $tick_class, $grid_class, $zoo
{
//$zoom_mid_time = (int)($chart['data']['x']['lo'] + (($last_tick+(($i - $last_tick)/2)) * $chart['data']['x']['density']));
$zoom_min_time = date( "Y-m-d H:i:s", (int)($chart['data']['x']['lo'] + ($last_tick * $chart['data']['x']['density'])) );
$zoom_max_time = date( "Y-m-d H:i:s", (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
$zoom_min_time = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($last_tick * $chart['data']['x']['density'])) );
$zoom_max_time = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?= $zoom_class ?>" style="left: <?= $last_tick-1 ?>px; width: <?= $i-$last_tick ?>px;" title="<?= $zmSlangZoomIn ?>" onClick="window.location='<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&min_time=<?= $zoom_min_time ?>&max_time=<?= $zoom_max_time ?>'"></div>
<?php
@ -685,8 +715,8 @@ function drawXGrid( $chart, $scale, $label_class, $tick_class, $grid_class, $zoo
}
if ( $zoom_class )
{
$zoom_min_time = date( "Y-m-d H:i:s", (int)($chart['data']['x']['lo'] + ($last_tick * $chart['data']['x']['density'])) );
$zoom_max_time = date( "Y-m-d H:i:s", (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
$zoom_min_time = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($last_tick * $chart['data']['x']['density'])) );
$zoom_max_time = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?= $zoom_class ?>" style="left: <?= $last_tick-1 ?>px; width: <?= $i-$last_tick ?>px;" onClick="window.location='<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&min_time=<?= $zoom_min_time ?>&max_time=<?= $zoom_max_time ?>'"></div>
<?php
@ -748,7 +778,7 @@ function getSlotLoadImageBehaviour( $slot )
$annotation .= "<em>";
$annotation .= $monitor['Name'].
"<br>".$slot['event']['Name'].($slot_frame?("(".$slot_frame.")"):"").
"<br>".strftime( "%y/%m/%d %H:%M:%S", strtotime($slot['event']['StartTime']) ).
"<br>".strftime( STRF_FMT_DATETIME_SHORT, strtotime($slot['event']['StartTime']) ).
" - ".$slot['event']['Length']."s".
"<br>".htmlentities($slot['event']['Cause']).
(!empty($slot['event']['Notes'])?("<br>".htmlentities($slot['event']['Notes'])):"").
@ -1517,16 +1547,16 @@ function parseFilterToTree()
$value = "'$value'";
break;
case 'DateTime':
$value = "'".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."'";
$value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'";
break;
case 'Date':
$value = "to_days( '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
case 'Time':
$value = "extract( hour_second from '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
case 'Weekday':
$value = "weekday( '".strftime( "%Y-%m-%d %H:%M:%S", strtotime( $value ) )."' )";
$value = "weekday( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break;
}
$value_list[] = $value;

View File

@ -36,11 +36,7 @@ if ( !$max_events )
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: ".ZM_WEB_REFRESH_EVENTS."; URL=$PHP_SELF?view=watchevents&mid=$mid&max_events=".MAX_EVENTS );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result )
@ -151,7 +147,7 @@ while( $event = mysql_fetch_assoc( $result ) )
<tr bgcolor="#FFFFFF">
<td align="center" class="text"><a href="javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&eid=<?= $event['Id'] ?>&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?><?= $sort_query ?>&page=1', 'zmEvent' );"><?= $event['Id'] ?></a></td>
<td align="center" class="text"><a href="javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&eid=<?= $event['Id'] ?>&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?><?= $sort_query ?>&page=1', 'zmEvent' );"><?= $event['Name'] ?></a></td>
<td align="center" class="text"><?= strftime( "%m/%d %H:%M:%S", strtotime($event['StartTime']) ) ?></td>
<td align="center" class="text"><?= strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime']) ) ?></td>
<td align="center" class="text"><?= $event['Length'] ?></td>
<td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=frames&eid=<?= $event['Id'] ?>', 'zmFrames', <?= $jws['frames']['w'] ?>, <?= $jws['frames']['h'] ?> );"><?= $event['Frames'] ?>/<?= $event['AlarmFrames'] ?></a></td>
<td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=frame&eid=<?= $event['Id'] ?>&fid=0', 'zmImage', <?= $monitor['Width']+$jws['image']['w'] ?>, <?= $monitor['Height']+$jws['image']['h'] ?> );"><?= $event['AvgScore'] ?>/<?= $event['MaxScore'] ?></a></td>

View File

@ -48,11 +48,7 @@ if ( $mode != "stream" )
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: ".ZM_WEB_REFRESH_IMAGE."; URL=$PHP_SELF?view=watchfeed&mid=$mid&mode=still&scale=$scale" );
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
$image_src = getStreamSrc( array( "mode=single", "monitor=".$mid, "scale=".$scale ) );

View File

@ -68,11 +68,7 @@ $refresh = (isset($force)||$forced||isset($disable)||$disabled||(($status>=STATE
$url = "$PHP_SELF?view=watchstatus&mid=$mid&last_status=$status".(($force||$forced)?"&forced=1":"").(($disable||$disabled)?"&disabled=1":"");
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: $refresh; URL=$url" );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -54,11 +54,7 @@ require_once( 'zm_lang.php' );
require_once( 'zm_funcs.php' );
require_once( 'zm_actions.php' );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
header("Content-type: text/vnd.wap.wml");
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );

View File

@ -21,7 +21,7 @@
$running = daemonCheck();
$status = $running?$zmSlangRunning:$zmSlangStopped;
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$db_now = strftime( STRF_FMT_DATETIME_DB );
$sql = "select M.*, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if((to_days(E.StartTime)=to_days('$db_now')) && E.Archived = 0,1,NULL)) as TodayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id";
$result = mysql_query( $sql );
if ( !$result )
@ -57,7 +57,7 @@ mysql_free_result( $result );
<card id="zmConsole" title="<?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangConsole ?>" ontimer="<?= $PHP_SELF ?>?view=<?= $view ?>">
<timer value="<?= REFRESH_MAIN*10 ?>"/>
<p align="center">
<?= date( "H:i" ) ?> - <?= makeLink( "$PHP_SELF?view=state", $status, canEdit( 'System' ) ) ?> - <?= getLoad() ?> / <?= getDiskPercent() ?>%
<?= strftime( DATE_FMT_CONSOLE_SHORT ) ?> - <?= makeLink( "$PHP_SELF?view=state", $status, canEdit( 'System' ) ) ?> - <?= getLoad() ?> / <?= getDiskPercent() ?>%
<table columns="4" align="LLRR">
<?php
if ( false )

View File

@ -53,11 +53,7 @@ else
require_once( 'zm_lang.php' );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );

View File

@ -28,7 +28,7 @@ if ( !$result )
$group = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$db_now = strftime( STRF_FMT_DATETIME_DB );
$sql = "select M.*, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if((to_days(E.StartTime)=to_days('$db_now')) && E.Archived = 0,1,NULL)) as TodayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id";
$result = mysql_query( $sql );
if ( !$result )
@ -73,7 +73,7 @@ mysql_free_result( $result );
<body>
<table style="width: 100%">
<tr>
<td align="left"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>"><?= date( "H:i" ) ?></a></td><td align="center"><?= makeLink( "$PHP_SELF?view=state", $status, canEdit( 'System' ) ) ?></td><td align="right"><?= getLoad() ?>/<?= getDiskPercent() ?>%</td>
<td align="left"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>"><?= <?= preg_match( '/%/', DATE_FMT_CONSOLE_SHORT )?strftime( DATE_FMT_CONSOLE_SHORT ):date( DATE_FMT_CONSOLE_SHORT ) ?></a></td><td align="center"><?= makeLink( "$PHP_SELF?view=state", $status, canEdit( 'System' ) ) ?></td><td align="right"><?= getLoad() ?>/<?= getDiskPercent() ?>%</td>
</tr>
</table>
<table>