Added mysql_free_result calls.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1820 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2006-01-15 13:09:30 +00:00
parent 321f8cbf5c
commit 1f14862239
50 changed files with 113 additions and 11 deletions

View File

@ -226,6 +226,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$ctrl_command = $monitor['Command']; $ctrl_command = $monitor['Command'];
if ( !preg_match( '/^\//', $ctrl_command ) ) if ( !preg_match( '/^\//', $ctrl_command ) )
@ -934,6 +935,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$control = mysql_fetch_assoc( $result ); $control = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {
@ -996,6 +998,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$old_function = $monitor['Function']; $old_function = $monitor['Function'];
$old_enabled = $monitor['Enabled']; $old_enabled = $monitor['Enabled'];
@ -1020,6 +1023,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( $zid > 0 ) if ( $zid > 0 )
{ {
@ -1027,6 +1031,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$zone = mysql_fetch_assoc( $result ); $zone = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {
@ -1082,6 +1087,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( ZM_OPT_X10 ) if ( ZM_OPT_X10 )
{ {
@ -1092,6 +1098,7 @@ if ( isset($action) )
{ {
$x10_monitor = array(); $x10_monitor = array();
} }
mysql_free_result( $result );
} }
} }
else else
@ -1139,6 +1146,7 @@ if ( isset($action) )
{ {
$zones[] = $zone; $zones[] = $zone;
} }
mysql_free_result( $result );
foreach ( $zones as $zone ) foreach ( $zones as $zone )
{ {
$new_zone = $zone; $new_zone = $zone;
@ -1175,6 +1183,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$changes[] = "Sequence = ".($row['MaxSequence']+1); $changes[] = "Sequence = ".($row['MaxSequence']+1);
$sql = "insert into Monitors set ".implode( ", ", $changes ); $sql = "insert into Monitors set ".implode( ", ", $changes );
@ -1235,6 +1244,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
fixDevices(); fixDevices();
if ( $cookies ) session_write_close(); if ( $cookies ) session_write_close();
if ( daemonCheck() ) if ( daemonCheck() )
@ -1252,10 +1262,12 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$result = mysql_query( "select * from Monitors where Id = '$smid'" ); $result = mysql_query( "select * from Monitors where Id = '$smid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$smonitor = mysql_fetch_assoc( $result ); $smonitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$sql = "update Monitors set Sequence = '".$smonitor['Sequence']."' where Id = '".$monitor['Id']."'"; $sql = "update Monitors set Sequence = '".$smonitor['Sequence']."' where Id = '".$monitor['Id']."'";
$result = mysql_query( $sql ); $result = mysql_query( $sql );
@ -1303,6 +1315,7 @@ if ( isset($action) )
{ {
continue; continue;
} }
mysql_free_result( $result );
$sql = "select Id from Events where MonitorId = '$mark_mid'"; $sql = "select Id from Events where MonitorId = '$mark_mid'";
$result = mysql_query( $sql ); $result = mysql_query( $sql );
@ -1314,6 +1327,7 @@ if ( isset($action) )
{ {
$mark_eids[] = $row['Id']; $mark_eids[] = $row['Id'];
} }
mysql_free_result( $result );
foreach( $mark_eids as $mark_eid ) foreach( $mark_eids as $mark_eid )
{ {
deleteEvent( $mark_eid ); deleteEvent( $mark_eid );
@ -1511,6 +1525,7 @@ if ( isset($action) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$db_user = mysql_fetch_assoc( $result ); $db_user = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {
@ -1566,6 +1581,7 @@ if ( isset($action) )
{ {
$definitions[] = $monitor['Id'].":".$monitor['Function'].":".$monitor['Enabled']; $definitions[] = $monitor['Id'].":".$monitor['Function'].":".$monitor['Enabled'];
} }
mysql_free_result( $result );
$definition = join( ',', $definitions ); $definition = join( ',', $definitions );
if ( $new_state ) if ( $new_state )
$run_state = $new_state; $run_state = $new_state;

View File

@ -39,17 +39,13 @@ function getEnumValues( $table, $column )
{ {
$enum_values = array(); $enum_values = array();
$result = mysql_query( "DESCRIBE $table $column" ); $result = mysql_query( "DESCRIBE $table $column" );
if ( $result ) if ( !$result )
{ die( mysql_error() );
$row = mysql_fetch_assoc($result); $row = mysql_fetch_assoc($result);
mysql_free_result( $result );
preg_match_all( "/'([^']+)'/", $row['Type'], $enum_matches ); preg_match_all( "/'([^']+)'/", $row['Type'], $enum_matches );
$enum_values = $enum_matches[1]; $enum_values = $enum_matches[1];
} return( $enum_values );
else
{
echo mysql_error();
}
return $enum_values;
} }
function getSetValues( $table, $column ) function getSetValues( $table, $column )
@ -70,6 +66,7 @@ function getUniqueValues( $table, $column, $as_string=1 )
else else
$values = $row[0]; $values = $row[0];
} }
mysql_free_result( $result );
} }
else else
{ {
@ -91,6 +88,7 @@ function getTableColumns( $table, $as_string=1 )
else else
$columns[] = $row[Type]; $columns[] = $row[Type];
} }
mysql_free_result( $result );
} }
else else
{ {

View File

@ -106,6 +106,7 @@ function exportEventFrames( $event )
{ {
$frames[] = $row; $frames[] = $row;
} }
mysql_free_result( $result );
ob_start(); ob_start();
exportHeader( $zmSlangFrames." ".$event['Id'] ); exportHeader( $zmSlangFrames." ".$event['Id'] );
@ -190,6 +191,7 @@ function exportFileList( $eid )
if ( !($result = mysql_query( $sql )) ) if ( !($result = mysql_query( $sql )) )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$event_path = sprintf( "%s/%s/%d", ZM_DIR_EVENTS, $event['MonitorName'], $event['Id'] ); $event_path = sprintf( "%s/%s/%d", ZM_DIR_EVENTS, $event['MonitorName'], $event['Id'] );
$files = array(); $files = array();

View File

@ -67,6 +67,7 @@ function userLogin( $username, $password="" )
{ {
unset( $user ); unset( $user );
} }
mysql_free_result( $result );
if ( $cookies ) session_write_close(); if ( $cookies ) session_write_close();
} }
@ -900,6 +901,7 @@ function createListThumbnail( $event, $overwrite=false )
if ( !($result = mysql_query( $sql )) ) if ( !($result = mysql_query( $sql )) )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$frame_id = $frame['FrameId']; $frame_id = $frame['FrameId'];
if ( ZM_WEB_LIST_THUMB_WIDTH ) if ( ZM_WEB_LIST_THUMB_WIDTH )
@ -1321,6 +1323,7 @@ function fixSequences()
} }
$sequence++; $sequence++;
} }
mysql_free_result( $result );
} }
function firstSet() function firstSet()

View File

@ -28,6 +28,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

View File

@ -44,6 +44,7 @@ if ( !empty($cid) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$control = mysql_fetch_assoc( $result ); $control = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {

View File

@ -33,6 +33,7 @@ while( $row = mysql_fetch_assoc( $result ) )
{ {
$controls[] = $row; $controls[] = $row;
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -31,6 +31,7 @@ if ( $group )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
} }
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence"; $sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence";
@ -46,6 +47,7 @@ while( $row = mysql_fetch_assoc( $result ) )
} }
$mids[$row['Id']] = $row['Name']; $mids[$row['Id']] = $row['Name'];
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -31,6 +31,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$cmds = getControlCommands( $monitor ); $cmds = getControlCommands( $monitor );

View File

@ -28,6 +28,7 @@ $result = mysql_query( "select * from Monitors as M inner join Controls as C on
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$presets = array(); $presets = array();
for ( $i = 1; $i <= $monitor['NumPresets']; $i++ ) for ( $i = 1; $i <= $monitor['NumPresets']; $i++ )

View File

@ -38,6 +38,7 @@ if ( $group )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
} }
@ -59,6 +60,7 @@ while( $row = mysql_fetch_assoc( $result ) )
$row['ScaledHeight'] = reScale( $monitor['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $row['ScaledHeight'] = reScale( $monitor['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$monitors[] = $row; $monitors[] = $row;
} }
mysql_free_result( $result );
$monitor = $monitors[$mon_idx]; $monitor = $monitors[$mon_idx];
$next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id']; $next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id'];

View File

@ -30,6 +30,7 @@ if ( $eid )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$new_event = mysql_fetch_assoc( $result ); $new_event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
elseif ( $eids ) elseif ( $eids )
{ {
@ -58,6 +59,7 @@ elseif ( $eids )
$new_event['Notes'] = ""; $new_event['Notes'] = "";
} }
} }
mysql_free_result( $result );
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -113,6 +113,7 @@ else
if ( !($result = mysql_query( $count_sql )) ) if ( !($result = mysql_query( $count_sql )) )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$n_events = $row['EventCount']; $n_events = $row['EventCount'];
if ( !empty($limit) && $n_events > $limit ) if ( !empty($limit) && $n_events > $limit )
{ {
@ -138,6 +139,7 @@ else
else else
$unarchived = true; $unarchived = true;
} }
mysql_free_result( $result );
?> ?>
function toggleCheck(element,name) function toggleCheck(element,name)
{ {

View File

@ -36,6 +36,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
$filter_data = $row; $filter_data = $row;
} }
} }
mysql_free_result( $result );
$auto_str = ""; $auto_str = "";
if ( isset($filter_data) ) if ( isset($filter_data) )

View File

@ -88,6 +88,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
$filter_data = $row; $filter_data = $row;
} }
} }
mysql_free_result( $result );
?> ?>
<?php if ( count($filter_names) ) { ?> <?php if ( count($filter_names) ) { ?>
<td align="left" colspan="3" class="text"><?= $zmSlangSaveAs ?>:&nbsp;<?= buildSelect( $select_name, $filter_names, "submitToFilter( document.filter_form );" ); ?>&nbsp;<?= $zmSlangOrEnterNewName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="<?= $filter_name ?>" class="form"></td> <td align="left" colspan="3" class="text"><?= $zmSlangSaveAs ?>:&nbsp;<?= buildSelect( $select_name, $filter_names, "submitToFilter( document.filter_form );" ); ?>&nbsp;<?= $zmSlangOrEnterNewName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="<?= $filter_name ?>" class="form"></td>

View File

@ -28,6 +28,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( $fid ) if ( $fid )
{ {
@ -35,6 +36,7 @@ if ( $fid )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {
@ -42,6 +44,7 @@ else
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$fid = $frame['FrameId']; $fid = $frame['FrameId'];
} }

View File

@ -28,6 +28,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '$eid' order by FrameId"; $sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '$eid' order by FrameId";
$result = mysql_query( $sql ); $result = mysql_query( $sql );
@ -37,6 +38,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
{ {
$frames[] = $row; $frames[] = $row;
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -38,6 +38,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
} }
$groups[] = $row; $groups[] = $row;
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>

View File

@ -48,12 +48,14 @@ if ( !empty($mid) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( ZM_OPT_X10 ) if ( ZM_OPT_X10 )
{ {
$result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" ); $result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$x10_monitor = mysql_fetch_assoc( $result ); $x10_monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
} }
else else
@ -112,6 +114,7 @@ if ( !empty($preset) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$preset = mysql_fetch_assoc( $result ); $preset = mysql_fetch_assoc( $result );
mysql_free_result( $result );
foreach ( $preset as $name=>$value ) foreach ( $preset as $name=>$value )
{ {
if ( isset($value) ) if ( isset($value) )
@ -220,6 +223,7 @@ function loadLocations( Form )
returnLocationSelect.options.length = option_count; returnLocationSelect.options.length = option_count;
<?php <?php
} }
mysql_free_result( $result );
?> ?>
} }
else else

View File

@ -32,6 +32,7 @@ while ( $preset = mysql_fetch_assoc( $result ) )
{ {
$presets[$preset['Id']] = $preset['Name']; $presets[$preset['Id']] = $preset['Name'];
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -31,6 +31,7 @@ if ( $group )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
} }
@ -47,6 +48,7 @@ while( $row = mysql_fetch_assoc( $result ) )
} }
$monitors[] = $row; $monitors[] = $row;
} }
mysql_free_result( $result );
$rows = intval(((count($monitors)-1)/ZM_WEB_MONTAGE_MAX_COLS)+1); $rows = intval(((count($monitors)-1)/ZM_WEB_MONTAGE_MAX_COLS)+1);
$cols = intval(ceil(count($monitors)/$rows)); $cols = intval(ceil(count($monitors)/$rows));

View File

@ -44,6 +44,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$montage_width = ZM_WEB_MONTAGE_WIDTH?ZM_WEB_MONTAGE_WIDTH:reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $montage_width = ZM_WEB_MONTAGE_WIDTH?ZM_WEB_MONTAGE_WIDTH:reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$montage_height = ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $montage_height = ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );

View File

@ -37,6 +37,7 @@ if ( $mid )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
elseif ( ZM_OPT_CONTROL ) elseif ( ZM_OPT_CONTROL )
{ {
@ -47,6 +48,7 @@ elseif ( ZM_OPT_CONTROL )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
} }
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence"; $sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence";
@ -65,6 +67,7 @@ elseif ( ZM_OPT_CONTROL )
$control_mid = $row['Id']; $control_mid = $row['Id'];
} }
} }
mysql_free_result( $result );
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -198,6 +198,7 @@ if ( $tab == "users" )
</tr> </tr>
<?php <?php
} }
mysql_free_result( $result );
?> ?>
<tr><td colspan="12" class="ruled">&nbsp;</td></tr> <tr><td colspan="12" class="ruled">&nbsp;</td></tr>
<tr><td colspan="12" align="right"><input type="button" value="<?= $zmSlangAddNewUser ?>" class="form" onClick="javascript: newWindow( '<?= $PHP_SELF ?>?view=user&uid=-1', 'zmUser', <?= $jws['user']['w'] ?>, <?= $jws['user']['h'] ?> );"<?php if ( !canEdit( 'System' ) ) { ?> disabled<?php } ?>>&nbsp;<input type="submit" name="delete_btn" value="<?= $zmSlangDelete ?>" class="form" disabled>&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow();"></td></tr> <tr><td colspan="12" align="right"><input type="button" value="<?= $zmSlangAddNewUser ?>" class="form" onClick="javascript: newWindow( '<?= $PHP_SELF ?>?view=user&uid=-1', 'zmUser', <?= $jws['user']['w'] ?>, <?= $jws['user']['h'] ?> );"<?php if ( !canEdit( 'System' ) ) { ?> disabled<?php } ?>>&nbsp;<input type="submit" name="delete_btn" value="<?= $zmSlangDelete ?>" class="form" disabled>&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow();"></td></tr>

View File

@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$zmu_command = getZmuCommand( " -m $mid -B -C -H -O" ); $zmu_command = getZmuCommand( " -m $mid -B -C -H -O" );
$zmu_output = exec( escapeshellcmd( $zmu_command ) ); $zmu_output = exec( escapeshellcmd( $zmu_command ) );

View File

@ -33,6 +33,7 @@ while( $state = mysql_fetch_assoc( $result ) )
{ {
$states[] = $state; $states[] = $state;
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -30,6 +30,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
{ {
$stats[] = $row; $stats[] = $row;
} }
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

View File

@ -106,6 +106,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
//} //}
$monitors[$row['Id']] = $row; $monitors[$row['Id']] = $row;
} }
mysql_free_result( $result );
$range_sql = "select min(E.StartTime) as MinTime, max(E.EndTime) as MaxTime from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(E.StartTime) and not isnull(E.EndTime)"; $range_sql = "select min(E.StartTime) as MinTime, max(E.EndTime) as MaxTime from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(E.StartTime) and not isnull(E.EndTime)";
$events_sql = "select E.Id,E.Name,E.StartTime,E.EndTime,E.Length,E.Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(StartTime)"; $events_sql = "select E.Id,E.Name,E.StartTime,E.EndTime,E.Length,E.Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(StartTime)";
@ -198,6 +199,7 @@ else
if ( !($result = mysql_query( $range_sql )) ) if ( !($result = mysql_query( $range_sql )) )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset($min_time) ) if ( !isset($min_time) )
$min_time = $row['MinTime']; $min_time = $row['MinTime'];
@ -400,9 +402,11 @@ while( $event = mysql_fetch_assoc( $event_result ) )
$chart['data']['y']['hi'] = $frame['Score']; $chart['data']['y']['hi'] = $frame['Score'];
} }
} }
mysql_free_result( $frame_result );
} }
} }
} }
mysql_free_result( $event_result );
ksort($monitor_ids,SORT_NUMERIC); ksort($monitor_ids,SORT_NUMERIC);
ksort($mon_event_slots,SORT_NUMERIC); ksort($mon_event_slots,SORT_NUMERIC);
@ -426,6 +430,7 @@ foreach( array_keys($mon_frame_slots) as $monitor_id )
if ( !($frame_result = mysql_query( $frames_sql )) ) if ( !($frame_result = mysql_query( $frames_sql )) )
die( mysql_error() ); die( mysql_error() );
$curr_frame_slots[$i]['frame'] = mysql_fetch_assoc( $frame_result ); $curr_frame_slots[$i]['frame'] = mysql_fetch_assoc( $frame_result );
mysql_free_result( $frame_result );
} }
} }
} }

View File

@ -32,6 +32,7 @@ if ( !($db_user = mysql_fetch_assoc( $result )) )
$db_user['Username'] = $zmSlangNewUser; $db_user['Username'] = $zmSlangNewUser;
$db_user['Enabled'] = 1; $db_user['Enabled'] = 1;
} }
mysql_free_result( $result );
$new_user = $db_user; $new_user = $db_user;

View File

@ -37,6 +37,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset( $rate ) ) if ( !isset( $rate ) )
$rate = reScale( RATE_SCALE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); $rate = reScale( RATE_SCALE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE );

View File

@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset($scale) ) if ( !isset($scale) )
$scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );

View File

@ -46,6 +46,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@ -158,6 +159,7 @@ while( $event = mysql_fetch_assoc( $result ) )
</tr> </tr>
<?php <?php
} }
mysql_free_result( $result );
?> ?>
</table></td></tr> </table></td></tr>
</table></td> </table></td>

View File

@ -37,6 +37,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset( $scale ) ) if ( !isset( $scale ) )
$scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );

View File

@ -36,6 +36,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset( $scale ) ) if ( !isset( $scale ) )
$scale = $monitor['DefaultScale'] * ZM_WEB_DEFAULT_SCALE; $scale = $monitor['DefaultScale'] * ZM_WEB_DEFAULT_SCALE;

View File

@ -49,11 +49,13 @@ while ( $preset = mysql_fetch_assoc( $result ) )
$preset_names[$preset['Id']] = $preset['Name']; $preset_names[$preset['Id']] = $preset['Name'];
$presets[] = $preset; $presets[] = $preset;
} }
mysql_free_result( $result );
$result = mysql_query( "select * from Monitors where Id = '$mid'" ); $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$min_x = 0; $min_x = 0;
$max_x = $monitor['Width']-1; $max_x = $monitor['Width']-1;
@ -68,6 +70,7 @@ if ( !isset($new_zone) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$zone = mysql_fetch_assoc( $result ); $zone = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {

View File

@ -31,6 +31,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$result = mysql_query( "select * from Zones where MonitorId = '$mid' order by Area desc" ); $result = mysql_query( "select * from Zones where MonitorId = '$mid' order by Area desc" );
if ( !$result ) if ( !$result )
@ -44,6 +45,7 @@ while( $row = mysql_fetch_assoc( $result ) )
$zones[] = $row; $zones[] = $row;
} }
} }
mysql_free_result( $result );
$image = $monitor['Name']."-Zones.jpg"; $image = $monitor['Name']."-Zones.jpg";

View File

@ -51,6 +51,7 @@ while( $row = mysql_fetch_assoc( $result ) )
if ( $max_height < $row['Height'] ) $max_height = $row['Height']; if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
} }
} }
mysql_free_result( $result );
?> ?>
<wml> <wml>
<card id="zmConsole" title="<?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangConsole ?>" ontimer="<?= $PHP_SELF ?>?view=<?= $view ?>"> <card id="zmConsole" title="<?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangConsole ?>" ontimer="<?= $PHP_SELF ?>?view=<?= $view ?>">

View File

@ -22,6 +22,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$browser = array(); $browser = array();
$browser['Width'] = 100; $browser['Width'] = 100;
$browser['Height'] = 80; $browser['Height'] = 80;

View File

@ -26,6 +26,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
echo mysql_error(); echo mysql_error();
$group = mysql_fetch_assoc( $result ); $group = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$db_now = strftime( "%Y-%m-%d %H:%M:%S" ); $db_now = strftime( "%Y-%m-%d %H:%M:%S" );
$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"; $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";
@ -53,6 +54,7 @@ while( $row = mysql_fetch_assoc( $result ) )
if ( !$result2 ) if ( !$result2 )
echo mysql_error(); echo mysql_error();
$row2 = mysql_fetch_assoc( $result2 ); $row2 = mysql_fetch_assoc( $result2 );
mysql_free_result( $result2 );
$monitors[] = array_merge( $row, $row2 ); $monitors[] = array_merge( $row, $row2 );
if ( $row['Function'] != 'None' ) if ( $row['Function'] != 'None' )
{ {
@ -61,6 +63,7 @@ while( $row = mysql_fetch_assoc( $result ) )
if ( $max_height < $row['Height'] ) $max_height = $row['Height']; if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
} }
} }
mysql_free_result( $result );
?> ?>
<html> <html>
<head> <head>

View File

@ -43,6 +43,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( $fid ) if ( $fid )
{ {
@ -50,6 +51,7 @@ if ( $fid )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
elseif ( isset( $fid ) ) elseif ( isset( $fid ) )
{ {
@ -57,6 +59,7 @@ elseif ( isset( $fid ) )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$fid = $frame['FrameId']; $fid = $frame['FrameId'];
} }
@ -75,6 +78,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
break; break;
} }
} }
mysql_free_result( $result );
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column ".($sort_order=='asc'?'>=':'<=')." '".$event[$sort_field]."'$filter_sql$mid_sql order by $sort_column $sort_order"; $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column ".($sort_order=='asc'?'>=':'<=')." '".$event[$sort_field]."'$filter_sql$mid_sql order by $sort_column $sort_order";
$result = mysql_query( $sql ); $result = mysql_query( $sql );
@ -88,6 +92,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
break; break;
} }
} }
mysql_free_result( $result );
$frames_per_page = 15; $frames_per_page = 15;
$frames_per_line = 3; $frames_per_line = 3;
@ -228,6 +233,7 @@ while( $row = mysql_fetch_assoc( $result ) )
$alarm_frames[$row['FrameId']] = $row; $alarm_frames[$row['FrameId']] = $row;
} }
} }
mysql_free_result( $result );
?> ?>
<table> <table>
<?php <?php

View File

@ -27,11 +27,13 @@ $result = mysql_query( "select E.*,M.Name as MonitorName,M.Width,M.Height from E
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$result = mysql_query( "select * from Frames where EventID = '$eid' and Score = '".$event['MaxScore']."'" ); $result = mysql_query( "select * from Frames where EventID = '$eid' and Score = '".$event['MaxScore']."'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$fid = $frame['FrameId']; $fid = $frame['FrameId'];
$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; $device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH;

View File

@ -31,6 +31,7 @@ while( $row = mysql_fetch_assoc( $result ) )
{ {
$monitors[$row[Id]] = $row; $monitors[$row[Id]] = $row;
} }
mysql_free_result( $result );
if ( $filter_name ) if ( $filter_name )
{ {
@ -38,6 +39,7 @@ if ( $filter_name )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$filter_data = mysql_fetch_assoc( $result ); $filter_data = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !empty($filter_data) ) if ( !empty($filter_data) )
{ {
@ -111,6 +113,7 @@ elseif ( !empty( $limit ) )
if ( !($result = mysql_query( $count_sql )) ) if ( !($result = mysql_query( $count_sql )) )
die( mysql_error() ); die( mysql_error() );
$row = mysql_fetch_assoc( $result ); $row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$n_events = $row['EventCount']; $n_events = $row['EventCount'];
if ( !empty($limit) && $n_events > $limit ) if ( !empty($limit) && $n_events > $limit )
{ {
@ -250,6 +253,7 @@ if ( !empty($limit) && $n_events > $limit )
</tr> </tr>
<?php <?php
} }
mysql_free_result( $result );
?> ?>
</table> </table>
</body> </body>

View File

@ -31,6 +31,7 @@ while ( $row = mysql_fetch_assoc( $result ) )
{ {
$filter_names[$row['Name']] = $row['Name']; $filter_names[$row['Name']] = $row['Name'];
} }
mysql_free_result( $result );
?> ?>
<html> <html>

View File

@ -28,6 +28,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( $fid ) if ( $fid )
{ {
@ -35,6 +36,7 @@ if ( $fid )
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
} }
else else
{ {
@ -42,6 +44,7 @@ else
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$frame = mysql_fetch_assoc( $result ); $frame = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$fid = $frame['FrameId']; $fid = $frame['FrameId'];
} }

View File

@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
?> ?>
<html> <html>

View File

@ -23,6 +23,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
echo mysql_error(); echo mysql_error();
$group = mysql_fetch_assoc( $result ); $group = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$result = mysql_query( "select * from Monitors where Function != 'None' order by Sequence" ); $result = mysql_query( "select * from Monitors where Function != 'None' order by Sequence" );
$monitors = array(); $monitors = array();
@ -43,6 +44,7 @@ while( $row = mysql_fetch_assoc( $result ) )
if ( $max_height < $row['Height'] ) $max_height = $row['Height']; if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
$monitors[] = $row; $monitors[] = $row;
} }
mysql_free_result( $result );
?> ?>
<html> <html>

View File

@ -32,6 +32,7 @@ while( $state = mysql_fetch_assoc( $result ) )
{ {
$states[] = $state; $states[] = $state;
} }
mysql_free_result( $result );
?> ?>
<html> <html>

View File

@ -37,6 +37,7 @@ $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$event = mysql_fetch_assoc( $result ); $event = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; $device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH;
$device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; $device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT;

View File

@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
$monitor = mysql_fetch_assoc( $result ); $monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( !isset($scale) ) if ( !isset($scale) )
$scale = ZM_WEB_DEFAULT_SCALE; $scale = ZM_WEB_DEFAULT_SCALE;
@ -79,6 +80,8 @@ while( $row = mysql_fetch_assoc( $result ) )
if ( $max_height < $row['Height'] ) $max_height = $row['Height']; if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
$monitors[] = $row; $monitors[] = $row;
} }
mysql_free_result( $result );
//$monitor = $monitors[$mon_idx]; //$monitor = $monitors[$mon_idx];
$next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id']; $next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id'];
$prev_mid = $mon_idx==0?$mon_index[(count($monitors)-1)]['Id']:$monitors[$mon_idx-1]['Id']; $prev_mid = $mon_idx==0?$mon_index[(count($monitors)-1)]['Id']:$monitors[$mon_idx-1]['Id'];