diff --git a/web/ajax/add_monitors.php b/web/ajax/add_monitors.php
index 69ce0332f..de24cdfac 100644
--- a/web/ajax/add_monitors.php
+++ b/web/ajax/add_monitors.php
@@ -1,6 +1,6 @@
set(array(
'StorageId' => 1,
'ServerId' => 'auto',
@@ -19,11 +19,11 @@ function probe( &$url_bits ) {
$cam_list_html = file_get_contents('http://'.$url_bits['host'].':5000/monitoring/');
if ( $cam_list_html ) {
- Logger::Debug("Have content at port 5000/monitoring");
+ ZM\Logger::Debug("Have content at port 5000/monitoring");
$matches_count = preg_match_all(
'/([^<]+)<\/a>/',
$cam_list_html, $cam_list );
- Logger::Debug(print_r($cam_list,true));
+ ZM\Logger::Debug(print_r($cam_list,true));
}
if ( $matches_count ) {
for( $index = 0; $index < $matches_count; $index ++ ) {
@@ -33,10 +33,10 @@ function probe( &$url_bits ) {
if ( ! isset($new_stream['scheme'] ) )
$new_stream['scheme'] = 'http';
$available_streams[] = $new_stream;
-Logger::Debug("Have new stream " . print_r($new_stream,true) );
+ZM\Logger::Debug("Have new stream " . print_r($new_stream,true) );
}
} else {
- Info('No matches');
+ ZM\Info('No matches');
}
if ( 0 ) {
// No port given, do a port scan
@@ -57,7 +57,7 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
$new_stream['port'] = $port;
} else {
socket_close($socket);
- Info("No connection to ".$url_bits['host'] . " on port $port");
+ ZM\Info("No connection to ".$url_bits['host'] . " on port $port");
continue;
}
if ( $new_stream ) {
@@ -65,7 +65,7 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
$new_stream['scheme'] = 'http';
$url = unparse_url($new_stream, array('path'=>'/', 'query'=>'action=snapshot'));
list($width, $height, $type, $attr) = getimagesize( $url );
- Info("Got $width x $height from $url");
+ ZM\Info("Got $width x $height from $url");
$new_stream['Width'] = $width;
$new_stream['Height'] = $height;
@@ -93,9 +93,9 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
foreach ( $available_streams as &$stream ) {
# check for existence in db.
$stream['url'] = unparse_url( $stream, array('path'=>'/','query'=>'action=stream') );
- $monitors = Monitor::find( array('Path'=>$stream['url']) );
+ $monitors = ZM\Monitor::find( array('Path'=>$stream['url']) );
if ( count($monitors) ) {
- Info("Found monitors matching " . $stream['url'] );
+ ZM\Info("Found monitors matching " . $stream['url'] );
$stream['Monitor'] = $monitors[0];
if ( isset( $stream['Width'] ) and ( $stream['Monitor']->Width() != $stream['Width'] ) ) {
$stream['Warning'] .= 'Monitor width ('.$stream['Monitor']->Width().') and stream width ('.$stream['Width'].") do not match!\n";
@@ -135,9 +135,9 @@ if ( canEdit( 'Monitors' ) ) {
if ( 0 ) {
// Shortcut test
- $monitors = Monitor::find( array('Path'=>$_REQUEST['url']) );
+ $monitors = ZM\Monitor::find( array('Path'=>$_REQUEST['url']) );
if ( count( $monitors ) ) {
- Info("Monitor found for " . $_REQUEST['url']);
+ ZM\Info("Monitor found for " . $_REQUEST['url']);
$url_bits['url'] = $_REQUEST['url'];
$url_bits['Monitor'] = $monitors[0];
$available_stream[] = $url_bits;
@@ -174,7 +174,7 @@ if ( 0 ) {
$name = $data[0];
$url = $data[1];
$group = $data[2];
- Info("Have the following line data $name $url $group");
+ ZM\Info("Have the following line data $name $url $group");
$url_bits = null;
if ( preg_match('/(\d+)\.(\d+)\.(\d+)\.(\d+)/', $url) ) {
@@ -183,7 +183,7 @@ if ( 0 ) {
$url_bits = parse_url( $url );
}
if ( ! $url_bits ) {
- Info("Bad url, skipping line $name $url $group");
+ ZM\Info("Bad url, skipping line $name $url $group");
continue;
}
@@ -207,11 +207,11 @@ if ( 0 ) {
} // end case import
default:
{
- Warning("unknown action " . $_REQUEST['action'] );
+ ZM\Warning("unknown action " . $_REQUEST['action'] );
} // end ddcase default
}
} else {
- Warning("Cannot edit monitors" );
+ ZM\Warning("Cannot edit monitors" );
}
ajaxError( 'Unrecognised action or insufficient permissions' );
diff --git a/web/ajax/alarm.php b/web/ajax/alarm.php
index 002f9f784..099bbf671 100644
--- a/web/ajax/alarm.php
+++ b/web/ajax/alarm.php
@@ -1,6 +1,6 @@
beginTransaction();
- $dbConn->exec( 'LOCK TABLES Monitors WRITE' );
+ $dbConn->exec('LOCK TABLES Monitors WRITE');
for ( $i = 0; $i < count($monitor_ids); $i += 1 ) {
$monitor_id = $monitor_ids[$i];
$monitor_id = preg_replace( '/^monitor_id-/', '', $monitor_id );
if ( ( ! $monitor_id ) or ! ( is_integer( $monitor_id ) or ctype_digit( $monitor_id ) ) ) {
- Warning( "Got $monitor_id from " . $monitor_ids[$i] );
+ Warning("Got $monitor_id from " . $monitor_ids[$i]);
continue;
}
- dbQuery( 'UPDATE Monitors SET Sequence=? WHERE Id=?', array( $i, $monitor_id ) );
+ dbQuery('UPDATE Monitors SET Sequence=? WHERE Id=?', array($i, $monitor_id));
} // end for each monitor_id
$dbConn->commit();
$dbConn->exec('UNLOCK TABLES');
@@ -25,13 +24,12 @@ if ( canEdit( 'Monitors' ) ) {
} // end case sort
default:
{
- Warning("unknown action " . $_REQUEST['action'] );
+ ZM\Warning('unknown action ' . $_REQUEST['action']);
} // end ddcase default
}
} else {
- Warning("Cannot edit monitors" );
+ ZM\Warning('Cannot edit monitors');
}
-ajaxError( 'Unrecognised action or insufficient permissions' );
-
+ajaxError('Unrecognised action or insufficient permissions');
?>
diff --git a/web/ajax/control.php b/web/ajax/control.php
index abdc8c8ef..ae7acac9e 100644
--- a/web/ajax/control.php
+++ b/web/ajax/control.php
@@ -8,7 +8,7 @@ if ( empty($_REQUEST['id']) )
if ( canView( 'Control', $_REQUEST['id'] ) )
{
- $monitor = new Monitor( $_REQUEST['id'] );
+ $monitor = new ZM\Monitor( $_REQUEST['id'] );
$ctrlCommand = buildControlCommand( $monitor );
diff --git a/web/ajax/event.php b/web/ajax/event.php
index 4eed2e832..0756627b8 100644
--- a/web/ajax/event.php
+++ b/web/ajax/event.php
@@ -119,7 +119,7 @@ if ( canEdit( 'Events' ) ) {
}
case 'delete' :
{
- $Event = new Event( $_REQUEST['id'] );
+ $Event = new ZM\Event( $_REQUEST['id'] );
if ( ! $Event->Id() ) {
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.' ) );
} else {
diff --git a/web/ajax/log.php b/web/ajax/log.php
index 2a5aa039e..e8caff6bd 100644
--- a/web/ajax/log.php
+++ b/web/ajax/log.php
@@ -9,7 +9,7 @@ switch ( $_REQUEST['task'] ) {
{
// Silently ignore bogus requests
if ( !empty($_POST['level']) && !empty($_POST['message']) ) {
- logInit(array('id'=>'web_js'));
+ ZM\logInit(array('id'=>'web_js'));
$string = $_POST['message'];
@@ -21,9 +21,9 @@ switch ( $_REQUEST['task'] ) {
$levels = array_flip(Logger::$codes);
if ( !isset($levels[$_POST['level']]) )
- Panic("Unexpected logger level '".$_POST['level']."'");
+ ZM\Panic("Unexpected logger level '".$_POST['level']."'");
$level = $levels[$_POST['level']];
- Logger::fetch()->logPrint($level, $string, $file, $line);
+ ZM\Logger::fetch()->logPrint($level, $string, $file, $line);
}
ajaxResponse();
break;
@@ -33,7 +33,7 @@ switch ( $_REQUEST['task'] ) {
if ( !canView('System') )
ajaxError('Insufficient permissions to view log entries');
- $servers = Server::find();
+ $servers = ZM\Server::find();
$servers_by_Id = array();
# There is probably a better way to do this.
foreach ( $servers as $server ) {
@@ -46,7 +46,7 @@ switch ( $_REQUEST['task'] ) {
$limit = 100;
if ( isset($_REQUEST['limit']) ) {
if ( ( !is_integer($_REQUEST['limit']) and !ctype_digit($_REQUEST['limit']) ) ) {
- Error('Invalid value for limit ' . $_REQUEST['limit']);
+ ZM\Error('Invalid value for limit ' . $_REQUEST['limit']);
} else {
$limit = $_REQUEST['limit'];
}
@@ -54,7 +54,7 @@ switch ( $_REQUEST['task'] ) {
$sortField = 'TimeKey';
if ( isset($_REQUEST['sortField']) ) {
if ( !in_array($_REQUEST['sortField'], $filterFields) and ( $_REQUEST['sortField'] != 'TimeKey' ) ) {
- Error("Invalid sort field " . $_REQUEST['sortField']);
+ ZM\Error("Invalid sort field " . $_REQUEST['sortField']);
} else {
$sortField = $_REQUEST['sortField'];
}
@@ -76,7 +76,7 @@ switch ( $_REQUEST['task'] ) {
foreach ( $filter as $field=>$value ) {
if ( ! in_array($field, $filterFields) ) {
- Error("$field is not in valid filter fields");
+ ZM\Error("$field is not in valid filter fields");
continue;
}
if ( $field == 'Level' ){
@@ -105,8 +105,8 @@ switch ( $_REQUEST['task'] ) {
$value = $log[$field];
if ( $field == 'Level' ) {
- if ( $value <= Logger::INFO )
- $options[$field][$value] = Logger::$codes[$value];
+ if ( $value <= ZM\Logger::INFO )
+ $options[$field][$value] = ZM\Logger::$codes[$value];
else
$options[$field][$value] = 'DB'.$value;
} else if ( $field == 'ServerId' ) {
@@ -146,14 +146,14 @@ switch ( $_REQUEST['task'] ) {
$sortField = 'TimeKey';
if ( isset($_POST['sortField']) ) {
if ( ! in_array( $_POST['sortField'], $filterFields ) and ( $_POST['sortField'] != 'TimeKey' ) ) {
- Error("Invalid sort field " . $_POST['sortField'] );
+ ZM\Error("Invalid sort field " . $_POST['sortField'] );
} else {
$sortField = $_POST['sortField'];
}
}
$sortOrder = (isset($_POST['sortOrder']) and $_POST['sortOrder']) == 'asc' ? 'asc':'desc';
- $servers = Server::find();
+ $servers = ZM\Server::find();
$servers_by_Id = array();
# There is probably a better way to do this.
foreach ( $servers as $server ) {
@@ -164,11 +164,11 @@ switch ( $_REQUEST['task'] ) {
$where = array();
$values = array();
if ( $minTime ) {
- Logger::Debug("MinTime: $minTime");
+ ZM\Logger::Debug("MinTime: $minTime");
if ( preg_match('/(.+)(\.\d+)/', $minTime, $matches) ) {
# This handles sub second precision
$minTime = strtotime($matches[1]).$matches[2];
- Logger::Debug("MinTime: $minTime");
+ ZM\Logger::Debug("MinTime: $minTime");
} else {
$minTime = strtotime($minTime);
}
@@ -214,27 +214,27 @@ switch ( $_REQUEST['task'] ) {
$exportExt = 'xml';
break;
default :
- Fatal("Unrecognised log export format '$format'");
+ ZM\Fatal("Unrecognised log export format '$format'");
}
$exportKey = substr(md5(rand()),0,8);
$exportFile = "zm-log.$exportExt";
if ( ! file_exists(ZM_DIR_EXPORTS) ) {
- Logger::Debug('Creating ' . ZM_DIR_EXPORTS);
+ ZM\Logger::Debug('Creating ' . ZM_DIR_EXPORTS);
if ( ! mkdir(ZM_DIR_EXPORTS) ) {
- Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'");
+ ZM\Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'");
}
}
$exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt";
- Logger::Debug("Exporting to $exportPath");
+ ZM\Logger::Debug("Exporting to $exportPath");
if ( !($exportFP = fopen($exportPath, 'w')) )
- Fatal("Unable to open log export file $exportPath");
+ ZM\Fatal("Unable to open log export file $exportPath");
$logs = array();
foreach ( dbFetchAll($sql, NULL, $values) as $log ) {
$log['DateTime'] = preg_replace('/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey']);
$log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : '';
$logs[] = $log;
}
- Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values));
+ ZM\Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values));
switch( $format ) {
case 'text' :
@@ -318,10 +318,10 @@ switch ( $_REQUEST['task'] ) {
' );
foreach ( $logs as $log ) {
$classLevel = $log['Level'];
- if ( $classLevel < Logger::FATAL )
- $classLevel = Logger::FATAL;
- elseif ( $classLevel > Logger::DEBUG )
- $classLevel = Logger::DEBUG;
+ if ( $classLevel < ZM\Logger::FATAL )
+ $classLevel = ZM\Logger::FATAL;
+ elseif ( $classLevel > ZM\Logger::DEBUG )
+ $classLevel = ZM\Logger::DEBUG;
$logClass = 'log-'.strtolower(Logger::$codes[$classLevel]);
fprintf( $exportFP, " \n", $logClass, $log['DateTime'], $log['Component'], $log['Server'], $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
}
@@ -384,10 +384,10 @@ switch ( $_REQUEST['task'] ) {
ajaxError('Insufficient permissions to download logs');
if ( empty($_REQUEST['key']) )
- Fatal('No log export key given');
+ ZM\Fatal('No log export key given');
$exportKey = $_REQUEST['key'];
if ( empty($_REQUEST['format']) )
- Fatal('No log export format given');
+ ZM\Fatal('No log export format given');
$format = $_REQUEST['format'];
switch( $format ) {
@@ -404,7 +404,7 @@ switch ( $_REQUEST['task'] ) {
$exportExt = 'xml';
break;
default :
- Fatal("Unrecognised log export format '$format'");
+ ZM\Fatal("Unrecognised log export format '$format'");
}
$exportFile = "zm-log.$exportExt";
diff --git a/web/ajax/status.php b/web/ajax/status.php
index 7692b2e67..f95f16c8c 100644
--- a/web/ajax/status.php
+++ b/web/ajax/status.php
@@ -284,7 +284,7 @@ function collectData() {
if ( in_array($matches[1], $fieldSql) ) {
$sql .= $matches[1];
} else {
- Error('Sort field ' . $matches[1] . ' not in SQL Fields');
+ ZM\Error('Sort field ' . $matches[1] . ' not in SQL Fields');
}
if ( count($matches) > 2 ) {
$sql .= ' '.strtoupper($matches[2]);
@@ -292,7 +292,7 @@ function collectData() {
$sql .= ' '.strtoupper($matches[3]);
}
} else {
- Error("Sort field didn't match regexp $sort_field");
+ ZM\Error("Sort field didn't match regexp $sort_field");
}
} # end foreach sort field
} # end if has sort
@@ -323,7 +323,7 @@ function collectData() {
}
}
}
- #Logger::Debug(print_r($data, true));
+ #ZM\Logger::Debug(print_r($data, true));
return $data;
}
diff --git a/web/ajax/stream.php b/web/ajax/stream.php
index 44aaec8e6..b60cf32f5 100644
--- a/web/ajax/stream.php
+++ b/web/ajax/stream.php
@@ -20,7 +20,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
if ( file_exists( $localSocketFile ) ) {
- Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
+ ZM\Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
// They could be. We can maybe have concurrent requests from a browser.
}
if ( ! socket_bind( $socket, $localSocketFile ) ) {
@@ -29,23 +29,23 @@ if ( sem_acquire($semaphore,1) !== false ) {
switch ( $_REQUEST['command'] ) {
case CMD_VARPLAY :
- Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
+ ZM\Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
break;
case CMD_ZOOMIN :
- Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
+ ZM\Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
break;
case CMD_PAN :
- Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
+ ZM\Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
break;
case CMD_SCALE :
- Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
+ ZM\Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
break;
case CMD_SEEK :
- Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
+ ZM\Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
break;
default :
@@ -81,18 +81,18 @@ if ( sem_acquire($semaphore,1) !== false ) {
$numSockets = socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
if ( $numSockets === false ) {
- Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
+ ZM\Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
ajaxError( 'socket_select failed: '.socket_strerror(socket_last_error()) );
} else if ( $numSockets < 0 ) {
- Error( "Socket closed $remSockFile" );
+ ZM\Error( "Socket closed $remSockFile" );
ajaxError( "Socket closed $remSockFile" );
} else if ( $numSockets == 0 ) {
- Error( "Timed out waiting for msg $remSockFile" );
+ ZM\Error( "Timed out waiting for msg $remSockFile" );
socket_Set_nonblock($socket);
#ajaxError( "Timed out waiting for msg $remSockFile" );
} else if ( $numSockets > 0 ) {
if ( count($rSockets) != 1 ) {
- Error( 'Bogus return from select, '.count($rSockets).' sockets available' );
+ ZM\Error( 'Bogus return from select, '.count($rSockets).' sockets available' );
ajaxError( 'Bogus return from select, '.count($rSockets).' sockets available' );
}
}
@@ -122,9 +122,9 @@ if ( sem_acquire($semaphore,1) !== false ) {
case MSG_DATA_WATCH :
{
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
- Logger::Debug("FPS: " . $data['fps'] );
+ ZM\Logger::Debug("FPS: " . $data['fps'] );
$data['fps'] = round( $data['fps'], 2 );
- Logger::Debug("FPS: " . $data['fps'] );
+ ZM\Logger::Debug("FPS: " . $data['fps'] );
$data['rate'] /= RATE_BASE;
$data['delay'] = round( $data['delay'], 2 );
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
@@ -161,7 +161,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
sem_release($semaphore);
} else {
- Logger::Debug("Couldn't get semaphore");
+ ZM\Logger::Debug("Couldn't get semaphore");
ajaxResponse( array() );
}
diff --git a/web/includes/Event.php b/web/includes/Event.php
index a4f389aca..51995ac19 100644
--- a/web/includes/Event.php
+++ b/web/includes/Event.php
@@ -1,4 +1,5 @@
fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'MontageLayout');
- foreach ( $results as $row => $obj ) {
- $filters[] = $obj;
+ $results = $result->fetchALL();
+ foreach ( $results as $row ) {
+ $filters[] = new MontageLayout($row);
}
}
return $filters;
diff --git a/web/includes/Server.php b/web/includes/Server.php
index ea633c4be..96d07e9c1 100644
--- a/web/includes/Server.php
+++ b/web/includes/Server.php
@@ -1,8 +1,10 @@
null,
diff --git a/web/includes/Storage.php b/web/includes/Storage.php
index a7372b15a..67264f298 100644
--- a/web/includes/Storage.php
+++ b/web/includes/Storage.php
@@ -1,5 +1,7 @@
delete();
} // end if monitor found in db
} // end if canedit this monitor
diff --git a/web/includes/actions/control.php b/web/includes/actions/control.php
index d3a75a751..36f6b14fb 100644
--- a/web/includes/actions/control.php
+++ b/web/includes/actions/control.php
@@ -20,11 +20,11 @@
// Monitor control actions, require a monitor id and control view permissions for that monitor
if ( empty($_REQUEST['mid']) ) {
- Warning("Settings requires a monitor id");
+ ZM\Warning('Settings requires a monitor id');
return;
}
if ( ! canView('Control', $_REQUEST['mid']) ) {
- Warning("Settings requires the Control permission");
+ ZM\Warning('Settings requires the Control permission');
return;
}
@@ -32,7 +32,7 @@ require_once('control_functions.php');
require_once('Monitor.php');
$mid = validInt($_REQUEST['mid']);
if ( $action == 'control' ) {
- $monitor = new Monitor($mid);
+ $monitor = new ZM\Monitor($mid);
$ctrlCommand = buildControlCommand($monitor);
sendControlCommand($monitor->Id(), $ctrlCommand);
diff --git a/web/includes/actions/controlcap.php b/web/includes/actions/controlcap.php
index 71b59e1b6..eec3ffd8b 100644
--- a/web/includes/actions/controlcap.php
+++ b/web/includes/actions/controlcap.php
@@ -20,13 +20,13 @@
if ( !canEdit('Control') ) {
- Warning("Need Control permissions to edit control capabilities");
+ ZM\Warning('Need Control permissions to edit control capabilities');
return;
} // end if !canEdit Controls
if ( $action == 'controlcap' ) {
require_once('includes/Control.php');
- $Control = new Control( !empty($_REQUEST['cid']) ? $_REQUEST['cid'] : null );
+ $Control = new ZM\Control( !empty($_REQUEST['cid']) ? $_REQUEST['cid'] : null );
//$changes = getFormChanges( $control, $_REQUEST['newControl'], $types, $columns );
$Control->save($_REQUEST['newControl']);
diff --git a/web/includes/actions/controlcaps.php b/web/includes/actions/controlcaps.php
index f67a37dad..3e5310d19 100644
--- a/web/includes/actions/controlcaps.php
+++ b/web/includes/actions/controlcaps.php
@@ -20,16 +20,15 @@
if ( !canEdit('Control') ) {
- Warning("Need Control permissions to edit control capabilities");
+ ZM\Warning('Need Control permissions to edit control capabilities');
return;
} // end if !canEdit Controls
-}
if ( $action == 'delete' ) {
if ( isset($_REQUEST['markCids']) ) {
foreach( $_REQUEST['markCids'] as $markCid ) {
- dbQuery('DELETE FROM Controls WHERE Id = ?', array($markCid));
dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($markCid));
+ dbQuery('DELETE FROM Controls WHERE Id = ?', array($markCid));
$refreshParent = true;
}
}
diff --git a/web/includes/actions/device.php b/web/includes/actions/device.php
index a9d1f9e5a..c1a882d89 100644
--- a/web/includes/actions/device.php
+++ b/web/includes/actions/device.php
@@ -20,7 +20,7 @@
// Device view actions
if ( !canEdit('Devices') ) {
- Warning("No devices permission in editing device");
+ ZM\Warning('No devices permission in editing device');
return;
} // end if !canEdit(Devices)
@@ -39,7 +39,7 @@ if ( $action == 'device' ) {
$view = 'none';
}
} else {
- Error("Unknown action in device");
+ ZM\Error('Unknown action in device');
} // end if action
?>
diff --git a/web/includes/actions/devices.php b/web/includes/actions/devices.php
index 4cb5d43a3..01c562370 100644
--- a/web/includes/actions/devices.php
+++ b/web/includes/actions/devices.php
@@ -20,7 +20,7 @@
// Device view actions
if ( !canEdit('Devices') ) {
- Warning("No devices permission in editing device");
+ ZM\Warning('No devices permission in editing device');
return;
} // end if !canEdit(Devices)
diff --git a/web/includes/actions/donate.php b/web/includes/actions/donate.php
index 74361c4e5..156491ede 100644
--- a/web/includes/actions/donate.php
+++ b/web/includes/actions/donate.php
@@ -19,7 +19,7 @@
//
if ( !canEdit('System') ) {
- Warning("Need System permissions to update donation");
+ ZM\Warning('Need System permissions to update donation');
return;
}
diff --git a/web/includes/actions/event.php b/web/includes/actions/event.php
index 89a2694c8..a3c6d56c3 100644
--- a/web/includes/actions/event.php
+++ b/web/includes/actions/event.php
@@ -20,7 +20,7 @@
// If there is an action on an event, then we must have an id.
if ( !empty($_REQUEST['eid']) ) {
- Warning("No eid in action on event view");
+ ZM\Warning('No eid in action on event view');
return;
}
diff --git a/web/includes/actions/eventdetail.php b/web/includes/actions/eventdetail.php
index 561c2cb78..20bd084ee 100644
--- a/web/includes/actions/eventdetail.php
+++ b/web/includes/actions/eventdetail.php
@@ -19,13 +19,13 @@
//
if ( !isset($_REQUEST['markEids']) ) {
- Warning('Events actions require eids');
+ ZM\Warning('Events actions require eids');
return;
}
// Event scope actions, view permissions only required
if ( !canEdit('Events') ) {
- Warning("Events actions require Edit permissions");
+ ZM\Warning('Events actions require Edit permissions');
return;
} // end if ! canEdit(Events)
diff --git a/web/includes/actions/events.php b/web/includes/actions/events.php
index 10642f329..d7e4c18d8 100644
--- a/web/includes/actions/events.php
+++ b/web/includes/actions/events.php
@@ -19,13 +19,13 @@
//
if ( !isset($_REQUEST['markEids']) ) {
- Warning('Events actions require eids');
+ ZM\Warning('Events actions require eids');
return;
}
// Event scope actions, view permissions only required
if ( !canEdit('Events') ) {
- Warning("Events actions require Edit permissions");
+ ZM\Warning('Events actions require Edit permissions');
return;
} // end if ! canEdit(Events)
diff --git a/web/includes/actions/filter.php b/web/includes/actions/filter.php
index c15f36c65..a89938697 100644
--- a/web/includes/actions/filter.php
+++ b/web/includes/actions/filter.php
@@ -20,7 +20,7 @@
// Event scope actions, view permissions only required
if ( !canView('Events') ) {
- Warning('You do not have permission to view Events.');
+ ZM\Warning('You do not have permission to view Events.');
return;
}
@@ -32,7 +32,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
} else if ( canEdit('Events') ) {
require_once('includes/Filter.php');
- $filter = new Filter($_REQUEST['Id']);
+ $filter = new ZM\Filter($_REQUEST['Id']);
if ( $action == 'delete' ) {
if ( !empty($_REQUEST['Id']) ) {
@@ -42,7 +42,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
$filter->delete();
} else {
- Error("No filter id passed when deleting");
+ ZM\Error("No filter id passed when deleting");
}
} else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) {
@@ -98,7 +98,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
) {
$filter->control($_REQUEST['command'], $_REQUEST['ServerId']);
} else {
- Error('Invalid command for filter ('.$_REQUEST['command'].')');
+ ZM\Error('Invalid command for filter ('.$_REQUEST['command'].')');
}
} // end if save or execute
} // end if canEdit(Events)
diff --git a/web/includes/actions/function.php b/web/includes/actions/function.php
index 5fca0d8a1..f60b98fda 100644
--- a/web/includes/actions/function.php
+++ b/web/includes/actions/function.php
@@ -21,12 +21,12 @@
// Monitor edit actions, require a monitor id and edit permissions for that monitor
if ( empty($_REQUEST['mid']) ) {
- Error("Must specify mid");
+ ZM\Error('Must specify mid');
return;
}
$mid = validInt($_REQUEST['mid']);
if ( !canEdit('Monitors', $mid) ) {
- Error("You do not have permission to edit monitor $mid");
+ ZM\Error("You do not have permission to edit monitor $mid");
return;
}
@@ -52,7 +52,7 @@ if ( $action == 'function' ) {
}
$refreshParent = true;
} else {
- Logger::Debug("No change to function, not doing anything.");
+ ZM\Logger::Debug('No change to function, not doing anything.');
}
} // end if action
$view = 'none';
diff --git a/web/includes/actions/group.php b/web/includes/actions/group.php
index 36a3f8faa..ec4f28969 100644
--- a/web/includes/actions/group.php
+++ b/web/includes/actions/group.php
@@ -22,7 +22,7 @@
# Should probably verify that each monitor id is a valid monitor, that we have access to.
# However at the moment, you have to have System permissions to do this
if ( ! canEdit('Groups') ) {
- Warning("Need group edit permissions to edit groups");
+ ZM\Warning('Need group edit permissions to edit groups');
return;
}
diff --git a/web/includes/actions/groups.php b/web/includes/actions/groups.php
index 22d138240..8e4522187 100644
--- a/web/includes/actions/groups.php
+++ b/web/includes/actions/groups.php
@@ -33,13 +33,13 @@ if ( ($action == 'setgroup') && canView('Groups')) {
# Should probably verify that each monitor id is a valid monitor, that we have access to.
# However at the moment, you have to have System permissions to do this
if ( ! canEdit('Groups') ) {
- Warning("Need group edit permissions to edit groups");
+ ZM\Warning('Need group edit permissions to edit groups');
return;
}
if ( $action == 'delete' ) {
if ( !empty($_REQUEST['gid']) ) {
- foreach ( Group::find(array('Id'=>$_REQUEST['gid'])) as $Group ) {
+ foreach ( ZM\Group::find(array('Id'=>$_REQUEST['gid'])) as $Group ) {
$Group->delete();
}
}
diff --git a/web/includes/actions/monitor.php b/web/includes/actions/monitor.php
index 2e73e4184..815100e4e 100644
--- a/web/includes/actions/monitor.php
+++ b/web/includes/actions/monitor.php
@@ -25,10 +25,10 @@ if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
foreach ( $_REQUEST['mids'] as $mid ) {
$mid = ValidInt($mid);
if ( ! canEdit('Monitors', $mid) ) {
- Warning("Cannot edit monitor $mid");
+ ZM\Warning("Cannot edit monitor $mid");
continue;
}
- $Monitor = new Monitor($mid);
+ $Monitor = new ZM\Monitor($mid);
if ( $Monitor->Type() != 'WebSite' ) {
$Monitor->zmaControl('stop');
$Monitor->zmcControl('stop');
@@ -47,7 +47,7 @@ if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
if ( ! canEdit('Monitors') ) {
- Warning("Monitor actions require Monitors Permissions");
+ ZM\Warning("Monitor actions require Monitors Permissions");
return;
}
@@ -68,7 +68,7 @@ if ( $action == 'monitor' ) {
$x10Monitor = array();
}
}
- $Monitor = new Monitor($monitor);
+ $Monitor = new ZM\Monitor($monitor);
// Define a field type for anything that's not simple text equivalent
$types = array(
@@ -86,10 +86,10 @@ if ( $action == 'monitor' ) {
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne(
'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
- Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId'] );
+ ZM\Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId'] );
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
- Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
+ ZM\Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
}
}
@@ -107,12 +107,12 @@ if ( $action == 'monitor' ) {
dbQuery('UPDATE Monitors SET '.implode(', ', $changes).' WHERE Id=?', array($mid));
// Groups will be added below
if ( isset($changes['Name']) or isset($changes['StorageId']) ) {
- $OldStorage = new Storage($monitor['StorageId']);
+ $OldStorage = new ZM\Storage($monitor['StorageId']);
$saferOldName = basename($monitor['Name']);
if ( file_exists($OldStorage->Path().'/'.$saferOldName) )
unlink($OldStorage->Path().'/'.$saferOldName);
- $NewStorage = new Storage($_REQUEST['newMonitor']['StorageId']);
+ $NewStorage = new ZM\Storage($_REQUEST['newMonitor']['StorageId']);
if ( ! file_exists($NewStorage->Path().'/'.$mid) )
mkdir($NewStorage->Path().'/'.$mid, 0755);
$saferNewName = basename($_REQUEST['newMonitor']['Name']);
@@ -164,24 +164,24 @@ if ( $action == 'monitor' ) {
$zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height'];
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
//$view = 'none';
- $Storage = new Storage($_REQUEST['newMonitor']['StorageId']);
+ $Storage = new ZM\Storage($_REQUEST['newMonitor']['StorageId']);
mkdir($Storage->Path().'/'.$mid, 0755);
$saferName = basename($_REQUEST['newMonitor']['Name']);
symlink($mid, $Storage->Path().'/'.$saferName);
} else {
- Error('Error saving new Monitor.');
+ ZM\Error('Error saving new Monitor.');
$error_message = dbError($sql);
return;
}
} else {
- Error('Users with Monitors restrictions cannot create new monitors.');
+ ZM\Error('Users with Monitors restrictions cannot create new monitors.');
return;
}
$restart = true;
} else {
- Logger::Debug('No action due to no changes to Monitor');
+ ZM\Logger::Debug('No action due to no changes to Monitor');
} # end if count(changes)
if (
@@ -220,7 +220,7 @@ if ( $action == 'monitor' ) {
if ( $restart ) {
- $new_monitor = new Monitor($mid);
+ $new_monitor = new ZM\Monitor($mid);
//fixDevices();
if ( $new_monitor->Type() != 'WebSite' ) {
@@ -238,6 +238,6 @@ if ( $action == 'monitor' ) {
} // end if restart
$view = 'none';
} else {
- Warning("Unknown action $action in Monitor");
+ ZM\Warning("Unknown action $action in Monitor");
} // end if action == Delete
?>
diff --git a/web/includes/actions/montage.php b/web/includes/actions/montage.php
index 3040fd83a..7ab105d0c 100644
--- a/web/includes/actions/montage.php
+++ b/web/includes/actions/montage.php
@@ -22,7 +22,7 @@ if ( isset($_REQUEST['object']) ) {
if ( $_REQUEST['object'] == 'MontageLayout' ) {
// System edit actions
if ( ! canEdit('System') ) {
- Warning("Need System permissions to edit layouts");
+ ZM\Warning('Need System permissions to edit layouts');
return;
}
require_once('includes/MontageLayout.php');
diff --git a/web/includes/actions/options.php b/web/includes/actions/options.php
index d7853ec9e..0c80bacf0 100644
--- a/web/includes/actions/options.php
+++ b/web/includes/actions/options.php
@@ -20,7 +20,7 @@
// System edit actions
if ( !canEdit('System') ) {
- Warning("Must have System permissions to perform options actions");
+ ZM\Warning('Must have System permissions to perform options actions');
return;
}
diff --git a/web/includes/actions/privacy.php b/web/includes/actions/privacy.php
index 99bbd7150..5712d5b40 100644
--- a/web/includes/actions/privacy.php
+++ b/web/includes/actions/privacy.php
@@ -19,7 +19,7 @@
//
if ( !canEdit('System') ) {
- Warning("Need System permissions to update privacy");
+ ZM\Warning('Need System permissions to update privacy');
return;
}
diff --git a/web/includes/actions/server.php b/web/includes/actions/server.php
index d991fd228..1ffe4933d 100644
--- a/web/includes/actions/server.php
+++ b/web/includes/actions/server.php
@@ -20,7 +20,7 @@
// System edit actions
if ( ! canEdit('System') ) {
- Warning("Need System permissions to add servers");
+ ZM\Warning('Need System permissions to add servers');
return;
}
@@ -48,6 +48,6 @@ if ( $action == 'Save' ) {
}
$view = 'none';
} else {
- Error("Unknown action $action in saving Server");
+ ZM\Error("Unknown action $action in saving Server");
}
?>
diff --git a/web/includes/actions/settings.php b/web/includes/actions/settings.php
index 872dae95e..25c4f76d4 100644
--- a/web/includes/actions/settings.php
+++ b/web/includes/actions/settings.php
@@ -21,11 +21,11 @@
// Monitor control actions, require a monitor id and control view permissions for that monitor
if ( empty($_REQUEST['mid']) ) {
- Warning("Settings requires a monitor id");
+ ZM\Warning('Settings requires a monitor id');
return;
}
if ( ! canView('Control', $_REQUEST['mid']) ) {
- Warning("Settings requires the Control permission");
+ ZM\Warning('Settings requires the Control permission');
return;
}
diff --git a/web/includes/actions/state.php b/web/includes/actions/state.php
index 9cb5eb8c9..9799cdec3 100644
--- a/web/includes/actions/state.php
+++ b/web/includes/actions/state.php
@@ -20,7 +20,7 @@
// System edit actions
if ( !canEdit('System') ) {
- Warning('Need System Permission to edit states');
+ ZM\Warning('Need System Permission to edit states');
return;
}
if ( $action == 'state' ) {
diff --git a/web/includes/actions/storage.php b/web/includes/actions/storage.php
index 94b76bae7..f60c8227d 100644
--- a/web/includes/actions/storage.php
+++ b/web/includes/actions/storage.php
@@ -20,7 +20,7 @@
// System edit actions
if ( ! canEdit('System') ) {
- Warning("Need System permission to edit Storage");
+ ZM\Warning('Need System permission to edit Storage');
return;
}
@@ -43,7 +43,7 @@ if ( $action == 'Save' ) {
}
$view = 'none';
} else {
- Error("Unknown action $action in saving Storage");
+ ZM\Error("Unknown action $action in saving Storage");
}
?>
diff --git a/web/includes/actions/version.php b/web/includes/actions/version.php
index 0e89b2457..fde85427f 100644
--- a/web/includes/actions/version.php
+++ b/web/includes/actions/version.php
@@ -20,7 +20,7 @@
// System edit actions
if ( !canEdit('System') ) {
- Warning("Need System permissions to update version");
+ ZM\Warning('Need System permissions to update version');
return;
}
if ( $action == 'version' && isset($_REQUEST['option']) ) {
diff --git a/web/includes/actions/zones.php b/web/includes/actions/zones.php
index f7ee15c9d..babb4fa7b 100644
--- a/web/includes/actions/zones.php
+++ b/web/includes/actions/zones.php
@@ -20,7 +20,7 @@
if ( !empty($_REQUEST['mid']) && canEdit('Monitors', $_REQUEST['mid']) ) {
$mid = validInt($_REQUEST['mid']);
- $monitor = new Monitor($mid);
+ $monitor = new ZM\Monitor($mid);
if ( $action == 'delete' ) {
if ( isset($_REQUEST['markZids']) ) {
diff --git a/web/includes/auth.php b/web/includes/auth.php
index c74c13b80..9f12a2b8f 100644
--- a/web/includes/auth.php
+++ b/web/includes/auth.php
@@ -87,7 +87,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
}
$_SESSION['remoteAddr'] = $_SERVER['REMOTE_ADDR']; // To help prevent session hijacking
if ( $dbUser = dbFetchOne($sql, NULL, $sql_values) ) {
- Info("Login successful for user \"$username\"");
+ ZM\Info("Login successful for user \"$username\"");
$_SESSION['user'] = $user = $dbUser;
unset($_SESSION['loginFailed']);
if ( ZM_AUTH_TYPE == 'builtin' ) {
@@ -95,7 +95,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
}
session_regenerate_id();
} else {
- Warning("Login denied for user \"$username\"");
+ ZM\Warning("Login denied for user \"$username\"");
$_SESSION['loginFailed'] = true;
unset($user);
}
@@ -106,7 +106,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
function userLogout() {
global $user;
- Info('User "'.$user['Username'].'" logged out');
+ ZM\Info('User "'.$user['Username'].'" logged out');
session_start();
unset($_SESSION['user']);
unset($user);
@@ -119,7 +119,7 @@ function getAuthUser($auth) {
if ( ZM_AUTH_HASH_IPS ) {
$remoteAddr = $_SERVER['REMOTE_ADDR'];
if ( !$remoteAddr ) {
- Error("Can't determine remote address for authentication, using empty string");
+ ZM\Error("Can't determine remote address for authentication, using empty string");
$remoteAddr = '';
}
}
@@ -145,7 +145,7 @@ function getAuthUser($auth) {
} // end foreach hour
} // end foreach user
} // end if using auth hash
- Error("Unable to authenticate user from auth hash '$auth'");
+ ZM\Error("Unable to authenticate user from auth hash '$auth'");
return false;
} // end getAuthUser($auth)
@@ -213,7 +213,7 @@ function is_session_started() {
return session_id() === '' ? FALSE : TRUE;
}
} else {
- Warning("php_sapi_name === 'cli'");
+ ZM\Warning("php_sapi_name === 'cli'");
}
return FALSE;
}
diff --git a/web/includes/config.php.in b/web/includes/config.php.in
index bf4b24e0b..01382ad37 100644
--- a/web/includes/config.php.in
+++ b/web/includes/config.php.in
@@ -138,7 +138,7 @@ define( 'MYSQL_FMT_DATETIME_SHORT', '%y/%m/%d %H:%i:%S' ); // MySQL date_format
require_once( 'database.php' );
require_once( 'logger.php' );
loadConfig();
-Logger::fetch()->initialise();
+ZM\Logger::fetch()->initialise();
$GLOBALS['defaultUser'] = array(
'Username' => 'admin',
diff --git a/web/includes/database.php b/web/includes/database.php
index 95fabee11..b567f6c6d 100644
--- a/web/includes/database.php
+++ b/web/includes/database.php
@@ -93,7 +93,7 @@ function dbLog( $sql, $update=false ) {
global $dbLogLevel;
$noExecute = $update && ($dbLogLevel >= DB_LOG_DEBUG);
if ( $dbLogLevel > DB_LOG_OFF )
- Logger::Debug( "SQL-LOG: $sql".($noExecute?" (not executed)":"") );
+ ZM\Logger::Debug( "SQL-LOG: $sql".($noExecute?" (not executed)":"") );
return( $noExecute );
}
@@ -104,7 +104,7 @@ function dbError( $sql ) {
return '';
$message = "SQL-ERR '".implode("\n",$dbConn->errorInfo())."', statement was '".$sql."'";
- Error($message);
+ ZM\Error($message);
return $message;
}
@@ -130,32 +130,32 @@ function dbQuery( $sql, $params=NULL ) {
try {
if ( isset($params) ) {
if ( ! $result = $dbConn->prepare( $sql ) ) {
- Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
+ ZM\Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
return NULL;
}
if ( ! $result->execute( $params ) ) {
- Error("SQL: Error executing $sql: " . implode(',', $result->errorInfo() ) );
+ ZM\Error("SQL: Error executing $sql: " . implode(',', $result->errorInfo() ) );
return NULL;
}
} else {
if ( defined('ZM_DB_DEBUG') ) {
- Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') );
+ ZM\Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') );
}
$result = $dbConn->query($sql);
if ( ! $result ) {
- Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
+ ZM\Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
return NULL;
}
}
if ( defined('ZM_DB_DEBUG') ) {
if ( $params )
- Logger::Debug("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() );
+ ZM\Logger::Debug("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() );
else
- Logger::Debug("SQL: $sql: rows:" . $result->rowCount() );
+ ZM\Logger::Debug("SQL: $sql: rows:" . $result->rowCount() );
}
} catch(PDOException $e) {
- Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):'') );
+ ZM\Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):'') );
return NULL;
}
return $result;
@@ -164,7 +164,7 @@ function dbQuery( $sql, $params=NULL ) {
function dbFetchOne( $sql, $col=false, $params=NULL ) {
$result = dbQuery( $sql, $params );
if ( ! $result ) {
- Error( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" . ( $params ? 'params: ' . join(',',$params) : '' ) );
+ ZM\Error( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" . ( $params ? 'params: ' . join(',',$params) : '' ) );
return false;
}
if ( ! $result->rowCount() ) {
@@ -175,7 +175,7 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) {
if ( $result && $dbRow = $result->fetch(PDO::FETCH_ASSOC) ) {
if ( $col ) {
if ( ! array_key_exists($col, $dbRow) ) {
- Warning("$col does not exist in the returned row " . print_r($dbRow, true));
+ ZM\Warning("$col does not exist in the returned row " . print_r($dbRow, true));
}
return $dbRow[$col];
}
@@ -187,7 +187,7 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) {
function dbFetchAll( $sql, $col=false, $params=NULL ) {
$result = dbQuery( $sql, $params );
if ( ! $result ) {
- Error( "SQL-ERR dbFetchAll no result, statement was '".$sql."'" . ( $params ? 'params: ' .join(',', $params) : '' ) );
+ ZM\Error( "SQL-ERR dbFetchAll no result, statement was '".$sql."'" . ( $params ? 'params: ' .join(',', $params) : '' ) );
return false;
}
@@ -294,7 +294,7 @@ function getTableDescription( $table, $asString=1 ) {
//$desc['minLength'] = -128;
break;
default :
- Error( "Unexpected text qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
+ ZM\Error( "Unexpected text qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
break;
}
} elseif ( preg_match( "/^(enum|set)\((.*)\)$/", $row['Type'], $matches ) ) {
@@ -326,7 +326,7 @@ function getTableDescription( $table, $asString=1 ) {
//$desc['maxValue'] = 127;
break;
default :
- Error( "Unexpected integer qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
+ ZM\Error( "Unexpected integer qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
break;
}
if ( !empty($matches[1]) )
@@ -361,7 +361,7 @@ function getTableDescription( $table, $asString=1 ) {
break;
}
} else {
- Error( "Can't parse database type '".$row['Type']."' found for field '".$row['Field']."' in table '".$table."'" );
+ ZM\Error( "Can't parse database type '".$row['Type']."' found for field '".$row['Field']."' in table '".$table."'" );
}
if ( $asString )
diff --git a/web/includes/functions.php b/web/includes/functions.php
index 0a224358a..29247e377 100644
--- a/web/includes/functions.php
+++ b/web/includes/functions.php
@@ -90,12 +90,12 @@ function CORSHeaders() {
# The following is left for future reference/use.
$valid = false;
- $Servers = Server::find();
+ $Servers = ZM\Server::find();
if ( sizeof($Servers) < 1 ) {
# Only need CORSHeaders in the event that there are multiple servers in use.
# ICON: Might not be true. multi-port?
if ( ZM_MIN_STREAMING_PORT ) {
- Logger::Debug("Setting default Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
+ ZM\Logger::Debug('Setting default Access-Control-Allow-Origin from ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Headers: x-requested-with,x-request');
}
@@ -108,14 +108,14 @@ function CORSHeaders() {
preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN'])
) {
$valid = true;
- Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
+ ZM\Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Headers: x-requested-with,x-request');
break;
}
}
if ( !$valid ) {
- Warning($_SERVER['HTTP_ORIGIN'] . ' is not found in servers list.');
+ ZM\Warning($_SERVER['HTTP_ORIGIN'] . ' is not found in servers list.');
}
}
}
@@ -409,7 +409,7 @@ function getZmuCommand( $args ) {
}
function getEventDefaultVideoPath( $event ) {
- $Event = new Event( $event );
+ $Event = new ZM\Event( $event );
return $Event->getStreamSrc( array( 'mode'=>'mpeg', 'format'=>'h264' ) );
}
@@ -424,15 +424,15 @@ function deletePath( $path ) {
function deleteEvent( $event ) {
if ( empty($event) ) {
- Error( 'Empty event passed to deleteEvent.');
+ ZM\Error('Empty event passed to deleteEvent.');
return;
}
if ( gettype($event) != 'array' ) {
# $event could be an eid, so turn it into an event hash
- $event = new Event( $event );
+ $event = new ZM\Event( $event );
} else {
-Logger::Debug("Event type: " . gettype($event));
+ZM\Logger::Debug("Event type: " . gettype($event));
}
global $user;
@@ -527,7 +527,7 @@ function htmlOptions($contents, $values) {
if ( isset($option['disabled']) ) {
$disabled = $option['disabled'];
- Error("Setting to disabled");
+ ZM\Error("Setting to disabled");
}
} else if ( is_object($option) ) {
$text = $option->Name();
@@ -556,7 +556,7 @@ function buildSelect( $name, $contents, $behaviours=false ) {
elseif ( isset($_REQUEST[$arr]) )
$value = $_REQUEST[$arr];
if ( !preg_match_all( '/\[\s*[\'"]?(\w+)["\']?\s*\]/', $matches[2], $matches ) ) {
- Fatal( "Can't parse selector '$name'" );
+ ZM\Fatal( "Can't parse selector '$name'" );
}
for ( $i = 0; $i < count($matches[1]); $i++ ) {
$idx = $matches[1][$i];
@@ -833,17 +833,17 @@ function daemonControl( $command, $daemon=false, $args=false ) {
}
$string = escapeshellcmd( $string );
#$string .= ' 2>/dev/null >&- <&- >/dev/null';
-Logger::Debug("daemonControl $string");
+ZM\Logger::Debug("daemonControl $string");
exec( $string );
}
function zmcControl($monitor, $mode=false) {
- $Monitor = new Monitor( $monitor );
+ $Monitor = new ZM\Monitor( $monitor );
return $Monitor->zmcControl($mode);
}
function zmaControl($monitor, $mode=false) {
- $Monitor = new Monitor($monitor);
+ $Monitor = new ZM\Monitor($monitor);
return $Monitor->zmaControl($mode);
}
@@ -916,7 +916,7 @@ function zmaCheck( $monitor ) {
}
function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
- $Event = new Event( $event );
+ $Event = new ZM\Event( $event );
return $Event->getImageSrc( $frame, $scale, $captureOnly, $overwrite );
}
@@ -940,7 +940,7 @@ function createListThumbnail( $event, $overwrite=false ) {
$scale = (SCALE_BASE*ZM_WEB_LIST_THUMB_HEIGHT)/$event['Height'];
$thumbWidth = reScale( $event['Width'], $scale );
} else {
- Fatal( "No thumbnail width or height specified, please check in Options->Web" );
+ ZM\Fatal( "No thumbnail width or height specified, please check in Options->Web" );
}
$imageData = getImageSrc( $event, $frame, $scale, false, $overwrite );
@@ -1196,11 +1196,11 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
if ( ! $StorageArea ) {
for ( $j = 0; $j < count($terms); $j++ ) {
if ( isset($terms[$j]['attr']) and $terms[$j]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
- $StorageArea = new Storage($terms[$j]['val']);
+ $StorageArea = new ZM\Storage($terms[$j]['val']);
break;
}
} // end foreach remaining term
- if ( ! $StorageArea ) $StorageArea = new Storage();
+ if ( ! $StorageArea ) $StorageArea = new ZM\Storage();
} // end no StorageArea found yet
$filter['sql'] .= getDiskPercent( $StorageArea->Path() );
@@ -1210,7 +1210,7 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
if ( ! $StorageArea ) {
for ( $j = $i; $j < count($terms); $j++ ) {
if ( isset($terms[$i]['attr']) and $terms[$i]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
- $StorageArea = new Storage($terms[$i]['val']);
+ $StorageArea = new ZM\Storage($terms[$i]['val']);
}
} // end foreach remaining term
} // end no StorageArea found yet
@@ -1242,7 +1242,7 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
}
break;
case 'StorageId':
- $StorageArea = new Storage( $value );
+ $StorageArea = new ZM\Storage( $value );
if ( $value != 'NULL' )
$value = dbEscape($value);
break;
@@ -1462,7 +1462,7 @@ function getDiskPercent($path = ZM_DIR_EVENTS) {
}
function getDiskBlocks() {
- if ( ! $StorageArea ) $StorageArea = new Storage();
+ if ( ! $StorageArea ) $StorageArea = new ZM\Storage();
$df = shell_exec( 'df '.escapeshellarg($StorageArea->Path() ));
$space = -1;
if ( preg_match( '/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches ) )
@@ -1847,17 +1847,17 @@ function coordsToPoints( $coords ) {
function limitPoints( &$points, $min_x, $min_y, $max_x, $max_y ) {
foreach ( $points as &$point ) {
if ( $point['x'] < $min_x ) {
- Logger::Debug('Limiting point x'.$point['x'].' to min_x ' . $min_x );
+ ZM\Logger::Debug('Limiting point x'.$point['x'].' to min_x ' . $min_x );
$point['x'] = $min_x;
} else if ( $point['x'] > $max_x ) {
- Logger::Debug('Limiting point x'.$point['x'].' to max_x ' . $max_x );
+ ZM\Logger::Debug('Limiting point x'.$point['x'].' to max_x ' . $max_x );
$point['x'] = $max_x;
}
if ( $point['y'] < $min_y ) {
- Logger::Debug('Limiting point y'.$point['y'].' to min_y ' . $min_y );
+ ZM\Logger::Debug('Limiting point y'.$point['y'].' to min_y ' . $min_y );
$point['y'] = $min_y;
} else if ( $point['y'] > $max_y ) {
- Logger::Debug('Limiting point y'.$point['y'].' to max_y ' . $max_y );
+ ZM\Logger::Debug('Limiting point y'.$point['y'].' to max_y ' . $max_y );
$point['y'] = $max_y;
}
} // end foreach point
@@ -1912,13 +1912,13 @@ function initX10Status() {
if ( !isset($x10_status) ) {
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( $socket < 0 ) {
- Fatal( 'socket_create() failed: '.socket_strerror($socket) );
+ ZM\Fatal( 'socket_create() failed: '.socket_strerror($socket) );
}
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
if ( @socket_connect( $socket, $sock_file ) ) {
$command = 'status';
if ( !socket_write( $socket, $command ) ) {
- Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
+ ZM\Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
}
socket_shutdown( $socket, 1 );
$x10Output = '';
@@ -1954,13 +1954,13 @@ function getDeviceStatusX10( $key ) {
function setDeviceStatusX10( $key, $status ) {
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( $socket < 0 ) {
- Fatal( 'socket_create() failed: '.socket_strerror($socket) );
+ ZM\Fatal( 'socket_create() failed: '.socket_strerror($socket) );
}
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
if ( @socket_connect( $socket, $sock_file ) ) {
$command = "$status;$key";
if ( !socket_write( $socket, $command ) ) {
- Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
+ ZM\Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
}
socket_shutdown( $socket, 1 );
$x10Response = socket_read( $socket, 256 );
@@ -1983,18 +1983,18 @@ function logState() {
$state = 'ok';
$levelCounts = array(
- Logger::FATAL => array( ZM_LOG_ALERT_FAT_COUNT, ZM_LOG_ALARM_FAT_COUNT ),
- Logger::ERROR => array( ZM_LOG_ALERT_ERR_COUNT, ZM_LOG_ALARM_ERR_COUNT ),
- Logger::WARNING => array( ZM_LOG_ALERT_WAR_COUNT, ZM_LOG_ALARM_WAR_COUNT ),
+ ZM\Logger::FATAL => array( ZM_LOG_ALERT_FAT_COUNT, ZM_LOG_ALARM_FAT_COUNT ),
+ ZM\Logger::ERROR => array( ZM_LOG_ALERT_ERR_COUNT, ZM_LOG_ALARM_ERR_COUNT ),
+ ZM\Logger::WARNING => array( ZM_LOG_ALERT_WAR_COUNT, ZM_LOG_ALARM_WAR_COUNT ),
);
# This is an expensive request, as it has to hit every row of the Logs Table
- $sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
+ $sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.ZM\Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
$counts = dbFetchAll($sql);
if ( $counts ) {
foreach ( $counts as $count ) {
- if ( $count['Level'] <= Logger::PANIC )
- $count['Level'] = Logger::FATAL;
+ if ( $count['Level'] <= ZM\Logger::PANIC )
+ $count['Level'] = ZM\Logger::FATAL;
if ( !($levelCount = $levelCounts[$count['Level']]) ) {
Error('Unexpected Log level '.$count['Level']);
next;
@@ -2026,15 +2026,15 @@ function checkJsonError($value) {
$value = var_export($value,true);
switch( json_last_error() ) {
case JSON_ERROR_DEPTH :
- Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" );
+ ZM\Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" );
case JSON_ERROR_CTRL_CHAR :
- Fatal( "Unable to decode JSON string '$value', unexpected control character found" );
+ ZM\Fatal( "Unable to decode JSON string '$value', unexpected control character found" );
case JSON_ERROR_STATE_MISMATCH :
- Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" );
+ ZM\Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" );
case JSON_ERROR_SYNTAX :
- Fatal( "Unable to decode JSON string '$value', syntax error" );
+ ZM\Fatal( "Unable to decode JSON string '$value', syntax error" );
default :
- Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() );
+ ZM\Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() );
case JSON_ERROR_NONE:
break;
}
@@ -2122,7 +2122,7 @@ define( 'HTTP_STATUS_BAD_REQUEST', 400 );
define( 'HTTP_STATUS_FORBIDDEN', 403 );
function ajaxError( $message, $code=HTTP_STATUS_OK ) {
- Error( $message );
+ ZM\Error( $message );
if ( function_exists( 'ajaxCleanup' ) )
ajaxCleanup();
if ( $code == HTTP_STATUS_OK ) {
@@ -2168,7 +2168,7 @@ function cache_bust( $file ) {
if ( file_exists(ZM_DIR_CACHE.'/'.$cacheFile) or symlink(ZM_PATH_WEB.'/'.$file, ZM_DIR_CACHE.'/'.$cacheFile) ) {
return 'cache/'.$cacheFile;
} else {
- Warning("Failed linking $file to $cacheFile");
+ ZM\Warning("Failed linking $file to $cacheFile");
}
return $file;
}
@@ -2292,7 +2292,7 @@ function getStreamHTML( $monitor, $options = array() ) {
$monitor->Name());
} else {
if ( $options['mode'] == 'stream' ) {
- Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
+ ZM\Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
}
$options['mode'] = 'single';
$streamSrc = $monitor->getStreamSrc( $options );
@@ -2308,7 +2308,7 @@ function getStreamMode( ) {
$streamMode = 'jpeg';
} else {
$streamMode = 'single';
- Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
+ ZM\Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
}
return $streamMode;
} // end function getStreamMode
@@ -2349,13 +2349,13 @@ function check_timezone() {
#");
if ( $sys_tzoffset != $php_tzoffset )
- Fatal("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
+ ZM\Fatal("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
if ( $sys_tzoffset != $mysql_tzoffset )
- Error("ZoneMinder is not installed properly: mysql's timezone does not match the system timezone! Event lists will display incorrect times.");
+ ZM\Error("ZoneMinder is not installed properly: mysql's timezone does not match the system timezone! Event lists will display incorrect times.");
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone')))
- Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
+ ZM\Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
}
diff --git a/web/includes/logger.php b/web/includes/logger.php
index 28d0ce902..1e37f708e 100644
--- a/web/includes/logger.php
+++ b/web/includes/logger.php
@@ -1,5 +1,6 @@
%s %s %s %d %s %s %s %s
- +