From 1f148622395c41ef873411c3166344673872a71c Mon Sep 17 00:00:00 2001 From: stan Date: Sun, 15 Jan 2006 13:09:30 +0000 Subject: [PATCH] Added mysql_free_result calls. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1820 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_actions.php | 16 ++++++++++++++++ web/zm_db.php | 20 +++++++++----------- web/zm_export_funcs.php | 2 ++ web/zm_funcs.php | 3 +++ web/zm_html_view_control.php | 1 + web/zm_html_view_controlcap.php | 1 + web/zm_html_view_controlcaps.php | 1 + web/zm_html_view_controlmenu.php | 2 ++ web/zm_html_view_controlpanel.php | 1 + web/zm_html_view_controlpreset.php | 1 + web/zm_html_view_cycle.php | 2 ++ web/zm_html_view_eventdetail.php | 2 ++ web/zm_html_view_events.php | 2 ++ web/zm_html_view_filter.php | 1 + web/zm_html_view_filtersave.php | 1 + web/zm_html_view_frame.php | 3 +++ web/zm_html_view_frames.php | 2 ++ web/zm_html_view_function.php | 1 + web/zm_html_view_groups.php | 1 + web/zm_html_view_monitor.php | 4 ++++ web/zm_html_view_monitorpreset.php | 1 + web/zm_html_view_montage.php | 2 ++ web/zm_html_view_montagefeed.php | 1 + web/zm_html_view_montagemenu.php | 3 +++ web/zm_html_view_options.php | 1 + web/zm_html_view_settings.php | 1 + web/zm_html_view_state.php | 1 + web/zm_html_view_stats.php | 1 + web/zm_html_view_timeline.php | 5 +++++ web/zm_html_view_user.php | 1 + web/zm_html_view_video.php | 1 + web/zm_html_view_watch.php | 1 + web/zm_html_view_watchevents.php | 2 ++ web/zm_html_view_watchfeed.php | 1 + web/zm_html_view_watchmenu.php | 1 + web/zm_html_view_zone.php | 3 +++ web/zm_html_view_zones.php | 2 ++ web/zm_wml_view_console.php | 1 + web/zm_wml_view_feed.php | 1 + web/zm_xhtml_view_console.php | 3 +++ web/zm_xhtml_view_event.php | 6 ++++++ web/zm_xhtml_view_eventdetails.php | 2 ++ web/zm_xhtml_view_events.php | 4 ++++ web/zm_xhtml_view_filter.php | 1 + web/zm_xhtml_view_frame.php | 3 +++ web/zm_xhtml_view_function.php | 1 + web/zm_xhtml_view_montage.php | 2 ++ web/zm_xhtml_view_state.php | 1 + web/zm_xhtml_view_video.php | 1 + web/zm_xhtml_view_watch.php | 3 +++ 50 files changed, 113 insertions(+), 11 deletions(-) diff --git a/web/zm_actions.php b/web/zm_actions.php index 62353da38..976d02910 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -226,6 +226,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $ctrl_command = $monitor['Command']; if ( !preg_match( '/^\//', $ctrl_command ) ) @@ -934,6 +935,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $control = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { @@ -996,6 +998,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $old_function = $monitor['Function']; $old_enabled = $monitor['Enabled']; @@ -1020,6 +1023,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); if ( $zid > 0 ) { @@ -1027,6 +1031,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $zone = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { @@ -1082,6 +1087,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); if ( ZM_OPT_X10 ) { @@ -1092,6 +1098,7 @@ if ( isset($action) ) { $x10_monitor = array(); } + mysql_free_result( $result ); } } else @@ -1139,6 +1146,7 @@ if ( isset($action) ) { $zones[] = $zone; } + mysql_free_result( $result ); foreach ( $zones as $zone ) { $new_zone = $zone; @@ -1175,6 +1183,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $changes[] = "Sequence = ".($row['MaxSequence']+1); $sql = "insert into Monitors set ".implode( ", ", $changes ); @@ -1235,6 +1244,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); fixDevices(); if ( $cookies ) session_write_close(); if ( daemonCheck() ) @@ -1252,10 +1262,12 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $result = mysql_query( "select * from Monitors where Id = '$smid'" ); if ( !$result ) die( mysql_error() ); $smonitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $sql = "update Monitors set Sequence = '".$smonitor['Sequence']."' where Id = '".$monitor['Id']."'"; $result = mysql_query( $sql ); @@ -1303,6 +1315,7 @@ if ( isset($action) ) { continue; } + mysql_free_result( $result ); $sql = "select Id from Events where MonitorId = '$mark_mid'"; $result = mysql_query( $sql ); @@ -1314,6 +1327,7 @@ if ( isset($action) ) { $mark_eids[] = $row['Id']; } + mysql_free_result( $result ); foreach( $mark_eids as $mark_eid ) { deleteEvent( $mark_eid ); @@ -1511,6 +1525,7 @@ if ( isset($action) ) if ( !$result ) die( mysql_error() ); $db_user = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { @@ -1566,6 +1581,7 @@ if ( isset($action) ) { $definitions[] = $monitor['Id'].":".$monitor['Function'].":".$monitor['Enabled']; } + mysql_free_result( $result ); $definition = join( ',', $definitions ); if ( $new_state ) $run_state = $new_state; diff --git a/web/zm_db.php b/web/zm_db.php index d86347f73..decab0d03 100644 --- a/web/zm_db.php +++ b/web/zm_db.php @@ -39,17 +39,13 @@ function getEnumValues( $table, $column ) { $enum_values = array(); $result = mysql_query( "DESCRIBE $table $column" ); - if ( $result ) - { - $row = mysql_fetch_assoc($result); - preg_match_all( "/'([^']+)'/", $row['Type'], $enum_matches ); - $enum_values = $enum_matches[1]; - } - else - { - echo mysql_error(); - } - return $enum_values; + if ( !$result ) + die( mysql_error() ); + $row = mysql_fetch_assoc($result); + mysql_free_result( $result ); + preg_match_all( "/'([^']+)'/", $row['Type'], $enum_matches ); + $enum_values = $enum_matches[1]; + return( $enum_values ); } function getSetValues( $table, $column ) @@ -70,6 +66,7 @@ function getUniqueValues( $table, $column, $as_string=1 ) else $values = $row[0]; } + mysql_free_result( $result ); } else { @@ -91,6 +88,7 @@ function getTableColumns( $table, $as_string=1 ) else $columns[] = $row[Type]; } + mysql_free_result( $result ); } else { diff --git a/web/zm_export_funcs.php b/web/zm_export_funcs.php index bcada2b59..f6ea40c7e 100644 --- a/web/zm_export_funcs.php +++ b/web/zm_export_funcs.php @@ -106,6 +106,7 @@ function exportEventFrames( $event ) { $frames[] = $row; } + mysql_free_result( $result ); ob_start(); exportHeader( $zmSlangFrames." ".$event['Id'] ); @@ -190,6 +191,7 @@ function exportFileList( $eid ) if ( !($result = mysql_query( $sql )) ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $event_path = sprintf( "%s/%s/%d", ZM_DIR_EVENTS, $event['MonitorName'], $event['Id'] ); $files = array(); diff --git a/web/zm_funcs.php b/web/zm_funcs.php index 740ce9f5f..fc12647c8 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -67,6 +67,7 @@ function userLogin( $username, $password="" ) { unset( $user ); } + mysql_free_result( $result ); if ( $cookies ) session_write_close(); } @@ -900,6 +901,7 @@ function createListThumbnail( $event, $overwrite=false ) if ( !($result = mysql_query( $sql )) ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $frame_id = $frame['FrameId']; if ( ZM_WEB_LIST_THUMB_WIDTH ) @@ -1321,6 +1323,7 @@ function fixSequences() } $sequence++; } + mysql_free_result( $result ); } function firstSet() diff --git a/web/zm_html_view_control.php b/web/zm_html_view_control.php index bfd0b6b05..386bd60bd 100644 --- a/web/zm_html_view_control.php +++ b/web/zm_html_view_control.php @@ -28,6 +28,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_controlcap.php b/web/zm_html_view_controlcap.php index 070102edd..e2630796f 100644 --- a/web/zm_html_view_controlcap.php +++ b/web/zm_html_view_controlcap.php @@ -44,6 +44,7 @@ if ( !empty($cid) ) if ( !$result ) die( mysql_error() ); $control = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { diff --git a/web/zm_html_view_controlcaps.php b/web/zm_html_view_controlcaps.php index 8e4c2793b..4c3d46477 100644 --- a/web/zm_html_view_controlcaps.php +++ b/web/zm_html_view_controlcaps.php @@ -33,6 +33,7 @@ while( $row = mysql_fetch_assoc( $result ) ) { $controls[] = $row; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_controlmenu.php b/web/zm_html_view_controlmenu.php index 43dddcda5..a5ce0d1c6 100644 --- a/web/zm_html_view_controlmenu.php +++ b/web/zm_html_view_controlmenu.php @@ -31,6 +31,7 @@ if ( $group ) if ( !$result ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; } $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']; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_controlpanel.php b/web/zm_html_view_controlpanel.php index 013659f1b..619d2b694 100644 --- a/web/zm_html_view_controlpanel.php +++ b/web/zm_html_view_controlpanel.php @@ -31,6 +31,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $cmds = getControlCommands( $monitor ); diff --git a/web/zm_html_view_controlpreset.php b/web/zm_html_view_controlpreset.php index 37109890d..7ba3d95db 100644 --- a/web/zm_html_view_controlpreset.php +++ b/web/zm_html_view_controlpreset.php @@ -28,6 +28,7 @@ $result = mysql_query( "select * from Monitors as M inner join Controls as C on if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $presets = array(); for ( $i = 1; $i <= $monitor['NumPresets']; $i++ ) diff --git a/web/zm_html_view_cycle.php b/web/zm_html_view_cycle.php index 069a55858..ed9b8bfcc 100644 --- a/web/zm_html_view_cycle.php +++ b/web/zm_html_view_cycle.php @@ -38,6 +38,7 @@ if ( $group ) if ( !$result ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $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 ); $monitors[] = $row; } +mysql_free_result( $result ); $monitor = $monitors[$mon_idx]; $next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id']; diff --git a/web/zm_html_view_eventdetail.php b/web/zm_html_view_eventdetail.php index 30eea1e1a..c2b612f6b 100644 --- a/web/zm_html_view_eventdetail.php +++ b/web/zm_html_view_eventdetail.php @@ -30,6 +30,7 @@ if ( $eid ) if ( !$result ) die( mysql_error() ); $new_event = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } elseif ( $eids ) { @@ -58,6 +59,7 @@ elseif ( $eids ) $new_event['Notes'] = ""; } } + mysql_free_result( $result ); } ?> diff --git a/web/zm_html_view_events.php b/web/zm_html_view_events.php index 501a74fce..5b80f2105 100644 --- a/web/zm_html_view_events.php +++ b/web/zm_html_view_events.php @@ -113,6 +113,7 @@ else if ( !($result = mysql_query( $count_sql )) ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $n_events = $row['EventCount']; if ( !empty($limit) && $n_events > $limit ) { @@ -138,6 +139,7 @@ else else $unarchived = true; } + mysql_free_result( $result ); ?> function toggleCheck(element,name) { diff --git a/web/zm_html_view_filter.php b/web/zm_html_view_filter.php index 53ffe3418..f165f1363 100644 --- a/web/zm_html_view_filter.php +++ b/web/zm_html_view_filter.php @@ -36,6 +36,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) $filter_data = $row; } } +mysql_free_result( $result ); $auto_str = ""; if ( isset($filter_data) ) diff --git a/web/zm_html_view_filtersave.php b/web/zm_html_view_filtersave.php index 5ed62d69f..cab4fd458 100644 --- a/web/zm_html_view_filtersave.php +++ b/web/zm_html_view_filtersave.php @@ -88,6 +88,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) $filter_data = $row; } } +mysql_free_result( $result ); ?>   diff --git a/web/zm_html_view_frame.php b/web/zm_html_view_frame.php index 1356d6863..08446651c 100644 --- a/web/zm_html_view_frame.php +++ b/web/zm_html_view_frame.php @@ -28,6 +28,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( $fid ) { @@ -35,6 +36,7 @@ if ( $fid ) if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { @@ -42,6 +44,7 @@ else if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $fid = $frame['FrameId']; } diff --git a/web/zm_html_view_frames.php b/web/zm_html_view_frames.php index 7a3661fec..b68a9ceed 100644 --- a/web/zm_html_view_frames.php +++ b/web/zm_html_view_frames.php @@ -28,6 +28,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '$eid' order by FrameId"; $result = mysql_query( $sql ); @@ -37,6 +38,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) { $frames[] = $row; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_function.php b/web/zm_html_view_function.php index c82182b36..c956ee3f1 100644 --- a/web/zm_html_view_function.php +++ b/web/zm_html_view_function.php @@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_groups.php b/web/zm_html_view_groups.php index 1cf8eee94..df0b32273 100644 --- a/web/zm_html_view_groups.php +++ b/web/zm_html_view_groups.php @@ -38,6 +38,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) } $groups[] = $row; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_monitor.php b/web/zm_html_view_monitor.php index a954f9ebc..7de3fb056 100644 --- a/web/zm_html_view_monitor.php +++ b/web/zm_html_view_monitor.php @@ -48,12 +48,14 @@ if ( !empty($mid) ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); if ( ZM_OPT_X10 ) { $result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" ); if ( !$result ) die( mysql_error() ); $x10_monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } } else @@ -112,6 +114,7 @@ if ( !empty($preset) ) if ( !$result ) die( mysql_error() ); $preset = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); foreach ( $preset as $name=>$value ) { if ( isset($value) ) @@ -220,6 +223,7 @@ function loadLocations( Form ) returnLocationSelect.options.length = option_count; } else diff --git a/web/zm_html_view_monitorpreset.php b/web/zm_html_view_monitorpreset.php index c14be9d56..86dc1df31 100644 --- a/web/zm_html_view_monitorpreset.php +++ b/web/zm_html_view_monitorpreset.php @@ -32,6 +32,7 @@ while ( $preset = mysql_fetch_assoc( $result ) ) { $presets[$preset['Id']] = $preset['Name']; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_montage.php b/web/zm_html_view_montage.php index 3acf52527..6084711f1 100644 --- a/web/zm_html_view_montage.php +++ b/web/zm_html_view_montage.php @@ -31,6 +31,7 @@ if ( $group ) if ( !$result ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; } @@ -47,6 +48,7 @@ while( $row = mysql_fetch_assoc( $result ) ) } $monitors[] = $row; } +mysql_free_result( $result ); $rows = intval(((count($monitors)-1)/ZM_WEB_MONTAGE_MAX_COLS)+1); $cols = intval(ceil(count($monitors)/$rows)); diff --git a/web/zm_html_view_montagefeed.php b/web/zm_html_view_montagefeed.php index 0d4f500bc..5c4f9063d 100644 --- a/web/zm_html_view_montagefeed.php +++ b/web/zm_html_view_montagefeed.php @@ -44,6 +44,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $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_height = ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); diff --git a/web/zm_html_view_montagemenu.php b/web/zm_html_view_montagemenu.php index 9f74676c6..4a493f635 100644 --- a/web/zm_html_view_montagemenu.php +++ b/web/zm_html_view_montagemenu.php @@ -37,6 +37,7 @@ if ( $mid ) if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } elseif ( ZM_OPT_CONTROL ) { @@ -47,6 +48,7 @@ elseif ( ZM_OPT_CONTROL ) if ( !$result ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )"; } $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']; } } + mysql_free_result( $result ); } ?> diff --git a/web/zm_html_view_options.php b/web/zm_html_view_options.php index 5d7095861..0f9c58cc5 100644 --- a/web/zm_html_view_options.php +++ b/web/zm_html_view_options.php @@ -198,6 +198,7 @@ if ( $tab == "users" )   disabled  diff --git a/web/zm_html_view_settings.php b/web/zm_html_view_settings.php index f643aef27..8190bc435 100644 --- a/web/zm_html_view_settings.php +++ b/web/zm_html_view_settings.php @@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $zmu_command = getZmuCommand( " -m $mid -B -C -H -O" ); $zmu_output = exec( escapeshellcmd( $zmu_command ) ); diff --git a/web/zm_html_view_state.php b/web/zm_html_view_state.php index b5cd0226e..2b7b5d4bc 100644 --- a/web/zm_html_view_state.php +++ b/web/zm_html_view_state.php @@ -33,6 +33,7 @@ while( $state = mysql_fetch_assoc( $result ) ) { $states[] = $state; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_stats.php b/web/zm_html_view_stats.php index 1dbcecb51..99bf56910 100644 --- a/web/zm_html_view_stats.php +++ b/web/zm_html_view_stats.php @@ -30,6 +30,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) { $stats[] = $row; } +mysql_free_result( $result ); ?> diff --git a/web/zm_html_view_timeline.php b/web/zm_html_view_timeline.php index 161643cd2..9a819a733 100644 --- a/web/zm_html_view_timeline.php +++ b/web/zm_html_view_timeline.php @@ -106,6 +106,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) //} $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)"; $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 )) ) die( mysql_error() ); $row = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); if ( !isset($min_time) ) $min_time = $row['MinTime']; @@ -400,9 +402,11 @@ while( $event = mysql_fetch_assoc( $event_result ) ) $chart['data']['y']['hi'] = $frame['Score']; } } + mysql_free_result( $frame_result ); } } } +mysql_free_result( $event_result ); ksort($monitor_ids,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 )) ) die( mysql_error() ); $curr_frame_slots[$i]['frame'] = mysql_fetch_assoc( $frame_result ); + mysql_free_result( $frame_result ); } } } diff --git a/web/zm_html_view_user.php b/web/zm_html_view_user.php index 6f2845a6c..ff395f4f6 100644 --- a/web/zm_html_view_user.php +++ b/web/zm_html_view_user.php @@ -32,6 +32,7 @@ if ( !($db_user = mysql_fetch_assoc( $result )) ) $db_user['Username'] = $zmSlangNewUser; $db_user['Enabled'] = 1; } +mysql_free_result( $result ); $new_user = $db_user; diff --git a/web/zm_html_view_video.php b/web/zm_html_view_video.php index 1182a1419..3d1c8758f 100644 --- a/web/zm_html_view_video.php +++ b/web/zm_html_view_video.php @@ -37,6 +37,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( !isset( $rate ) ) $rate = reScale( RATE_SCALE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); diff --git a/web/zm_html_view_watch.php b/web/zm_html_view_watch.php index c4dc09976..6d99db0ed 100644 --- a/web/zm_html_view_watch.php +++ b/web/zm_html_view_watch.php @@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( !isset($scale) ) $scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); diff --git a/web/zm_html_view_watchevents.php b/web/zm_html_view_watchevents.php index 19ab5ba4c..c8ddd1db1 100644 --- a/web/zm_html_view_watchevents.php +++ b/web/zm_html_view_watchevents.php @@ -46,6 +46,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); ?> @@ -158,6 +159,7 @@ while( $event = mysql_fetch_assoc( $result ) ) diff --git a/web/zm_html_view_watchfeed.php b/web/zm_html_view_watchfeed.php index 5145fc86c..03cc3c9ef 100644 --- a/web/zm_html_view_watchfeed.php +++ b/web/zm_html_view_watchfeed.php @@ -37,6 +37,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( !isset( $scale ) ) $scale = reScale( SCALE_SCALE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); diff --git a/web/zm_html_view_watchmenu.php b/web/zm_html_view_watchmenu.php index 3e491be2b..d3a03990f 100644 --- a/web/zm_html_view_watchmenu.php +++ b/web/zm_html_view_watchmenu.php @@ -36,6 +36,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( !isset( $scale ) ) $scale = $monitor['DefaultScale'] * ZM_WEB_DEFAULT_SCALE; diff --git a/web/zm_html_view_zone.php b/web/zm_html_view_zone.php index 952111193..86e97983b 100644 --- a/web/zm_html_view_zone.php +++ b/web/zm_html_view_zone.php @@ -49,11 +49,13 @@ while ( $preset = mysql_fetch_assoc( $result ) ) $preset_names[$preset['Id']] = $preset['Name']; $presets[] = $preset; } +mysql_free_result( $result ); $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $min_x = 0; $max_x = $monitor['Width']-1; @@ -68,6 +70,7 @@ if ( !isset($new_zone) ) if ( !$result ) die( mysql_error() ); $zone = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { diff --git a/web/zm_html_view_zones.php b/web/zm_html_view_zones.php index b58fd1372..7337b8c8b 100644 --- a/web/zm_html_view_zones.php +++ b/web/zm_html_view_zones.php @@ -31,6 +31,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $result = mysql_query( "select * from Zones where MonitorId = '$mid' order by Area desc" ); if ( !$result ) @@ -44,6 +45,7 @@ while( $row = mysql_fetch_assoc( $result ) ) $zones[] = $row; } } +mysql_free_result( $result ); $image = $monitor['Name']."-Zones.jpg"; diff --git a/web/zm_wml_view_console.php b/web/zm_wml_view_console.php index 00ab7603f..8930375c4 100644 --- a/web/zm_wml_view_console.php +++ b/web/zm_wml_view_console.php @@ -51,6 +51,7 @@ while( $row = mysql_fetch_assoc( $result ) ) if ( $max_height < $row['Height'] ) $max_height = $row['Height']; } } +mysql_free_result( $result ); ?> diff --git a/web/zm_wml_view_feed.php b/web/zm_wml_view_feed.php index 8337f6ade..02f6de1e5 100644 --- a/web/zm_wml_view_feed.php +++ b/web/zm_wml_view_feed.php @@ -22,6 +22,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $browser = array(); $browser['Width'] = 100; $browser['Height'] = 80; diff --git a/web/zm_xhtml_view_console.php b/web/zm_xhtml_view_console.php index 26ad63191..f8cde4a5e 100644 --- a/web/zm_xhtml_view_console.php +++ b/web/zm_xhtml_view_console.php @@ -26,6 +26,7 @@ $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); $group = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $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"; @@ -53,6 +54,7 @@ while( $row = mysql_fetch_assoc( $result ) ) if ( !$result2 ) echo mysql_error(); $row2 = mysql_fetch_assoc( $result2 ); + mysql_free_result( $result2 ); $monitors[] = array_merge( $row, $row2 ); if ( $row['Function'] != 'None' ) { @@ -61,6 +63,7 @@ while( $row = mysql_fetch_assoc( $result ) ) if ( $max_height < $row['Height'] ) $max_height = $row['Height']; } } +mysql_free_result( $result ); ?> diff --git a/web/zm_xhtml_view_event.php b/web/zm_xhtml_view_event.php index efd96d903..fffd95775 100644 --- a/web/zm_xhtml_view_event.php +++ b/web/zm_xhtml_view_event.php @@ -43,6 +43,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( $fid ) { @@ -50,6 +51,7 @@ if ( $fid ) if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } elseif ( isset( $fid ) ) { @@ -57,6 +59,7 @@ elseif ( isset( $fid ) ) if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $fid = $frame['FrameId']; } @@ -75,6 +78,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) 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"; $result = mysql_query( $sql ); @@ -88,6 +92,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) break; } } +mysql_free_result( $result ); $frames_per_page = 15; $frames_per_line = 3; @@ -228,6 +233,7 @@ while( $row = mysql_fetch_assoc( $result ) ) $alarm_frames[$row['FrameId']] = $row; } } +mysql_free_result( $result ); ?> $limit ) { @@ -250,6 +253,7 @@ if ( !empty($limit) && $n_events > $limit )
diff --git a/web/zm_xhtml_view_filter.php b/web/zm_xhtml_view_filter.php index 60fd2f105..dde75d634 100644 --- a/web/zm_xhtml_view_filter.php +++ b/web/zm_xhtml_view_filter.php @@ -31,6 +31,7 @@ while ( $row = mysql_fetch_assoc( $result ) ) { $filter_names[$row['Name']] = $row['Name']; } +mysql_free_result( $result ); ?> diff --git a/web/zm_xhtml_view_frame.php b/web/zm_xhtml_view_frame.php index 5f75ee7df..30430b790 100644 --- a/web/zm_xhtml_view_frame.php +++ b/web/zm_xhtml_view_frame.php @@ -28,6 +28,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( $fid ) { @@ -35,6 +36,7 @@ if ( $fid ) if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); } else { @@ -42,6 +44,7 @@ else if ( !$result ) die( mysql_error() ); $frame = mysql_fetch_assoc( $result ); + mysql_free_result( $result ); $fid = $frame['FrameId']; } diff --git a/web/zm_xhtml_view_function.php b/web/zm_xhtml_view_function.php index d825729f8..6a8c7820b 100644 --- a/web/zm_xhtml_view_function.php +++ b/web/zm_xhtml_view_function.php @@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); ?> diff --git a/web/zm_xhtml_view_montage.php b/web/zm_xhtml_view_montage.php index a257fd06a..ef589867f 100644 --- a/web/zm_xhtml_view_montage.php +++ b/web/zm_xhtml_view_montage.php @@ -23,6 +23,7 @@ $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); $group = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $result = mysql_query( "select * from Monitors where Function != 'None' order by Sequence" ); $monitors = array(); @@ -43,6 +44,7 @@ while( $row = mysql_fetch_assoc( $result ) ) if ( $max_height < $row['Height'] ) $max_height = $row['Height']; $monitors[] = $row; } +mysql_free_result( $result ); ?> diff --git a/web/zm_xhtml_view_state.php b/web/zm_xhtml_view_state.php index 746c88afc..f2333d29c 100644 --- a/web/zm_xhtml_view_state.php +++ b/web/zm_xhtml_view_state.php @@ -32,6 +32,7 @@ while( $state = mysql_fetch_assoc( $result ) ) { $states[] = $state; } +mysql_free_result( $result ); ?> diff --git a/web/zm_xhtml_view_video.php b/web/zm_xhtml_view_video.php index 4482f5335..2c0165894 100644 --- a/web/zm_xhtml_view_video.php +++ b/web/zm_xhtml_view_video.php @@ -37,6 +37,7 @@ $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); $event = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); $device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; $device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; diff --git a/web/zm_xhtml_view_watch.php b/web/zm_xhtml_view_watch.php index 882766327..6309698c2 100644 --- a/web/zm_xhtml_view_watch.php +++ b/web/zm_xhtml_view_watch.php @@ -27,6 +27,7 @@ $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); +mysql_free_result( $result ); if ( !isset($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']; $monitors[] = $row; } +mysql_free_result( $result ); + //$monitor = $monitors[$mon_idx]; $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'];