Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2020-10-16 19:05:59 -04:00
commit 8a9d01290a
94 changed files with 589 additions and 699 deletions

View File

@ -285,6 +285,7 @@ CREATE TABLE `Filters` (
`UserId` int(10) unsigned,
`Query_json` text NOT NULL,
`AutoArchive` tinyint(3) unsigned NOT NULL default '0',
`AutoUnarchive` tinyint(3) unsigned NOT NULL default '0',
`AutoVideo` tinyint(3) unsigned NOT NULL default '0',
`AutoUpload` tinyint(3) unsigned NOT NULL default '0',
`AutoEmail` tinyint(3) unsigned NOT NULL default '0',

15
db/zm_update-1.35.10.sql Normal file
View File

@ -0,0 +1,15 @@
--
-- Add AutoUnarchive action to Filters
--
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Filters'
AND column_name = 'AutoUnarchive'
) > 0,
"SELECT 'Column AutoUunarchive already exists in Filters'",
"ALTER TABLE Filters ADD `AutoUnarchive` tinyint(3) unsigned NOT NULL default '0' AFTER `AutoArchive`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -28,7 +28,7 @@
%global _hardened_build 1
Name: zoneminder
Version: 1.35.9
Version: 1.35.10
Release: 1%{?dist}
Summary: A camera monitoring and analysis tool
Group: System Environment/Daemons

View File

@ -58,6 +58,7 @@ Id
Name
Query_json
AutoArchive
AutoUnarchive
AutoVideo
AutoUpload
AutoEmail
@ -201,26 +202,18 @@ sub Sql {
$self->{Sql} .= 'extract( hour_second from E.EndTime )';
} elsif ( $term->{attr} eq 'EndWeekday' ) {
$self->{Sql} .= "weekday( E.EndTime )";
#
} elsif ( $term->{attr} eq 'ExistsInFileSystem' ) {
push @{$self->{PostSQLConditions}}, $term;
$self->{Sql} .= 'TRUE /* ExistsInFileSystem */';
} elsif ( $term->{attr} eq 'DiskSpace' ) {
$self->{Sql} .= 'E.DiskSpace';
} elsif ( $term->{attr} eq 'DiskPercent' ) {
$self->{Sql} .= 'zmDiskPercent';
$self->{HasDiskPercent} = !undef;
$self->{HasPreCondition} = !undef;
} elsif ( $term->{attr} eq 'DiskBlocks' ) {
$self->{Sql} .= 'zmDiskBlocks';
$self->{HasDiskBlocks} = !undef;
$self->{HasPreCondition} = !undef;
} elsif ( $term->{attr} eq 'SystemLoad' ) {
$self->{Sql} .= 'zmSystemLoad';
$self->{HasSystemLoad} = !undef;
$self->{HasPreCondition} = !undef;
} else {
$self->{Sql} .= 'E.'.$term->{attr};
}
@ -348,6 +341,9 @@ sub Sql {
if ( $self->{AutoArchive} ) {
push @auto_terms, 'E.Archived = 0';
}
if ( $self->{AutoUnarchive} ) {
push @auto_terms, 'E.Archived = 1';
}
# Don't do this, it prevents re-generation and concatenation.
# If the file already exists, then the video won't be re-recreated
if ( $self->{AutoVideo} ) {
@ -401,7 +397,7 @@ sub Sql {
$sort_column = 'E.StartTime';
}
my $sort_order = $filter_expr->{sort_asc} ? 'ASC' : 'DESC';
$sql .= ' ORDER BY '.$sort_column." ".$sort_order;
$sql .= ' ORDER BY '.$sort_column.' '.$sort_order;
if ( $filter_expr->{limit} ) {
$sql .= ' LIMIT 0,'.$filter_expr->{limit};
}

View File

@ -98,6 +98,7 @@ use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)
;
logInit($filter_id?(id=>'zmfilter_'.$filter_id):());
sub HupHandler {
# This idea at this time is to just exit, freeing up the memory.
# zmfilter.pl will be respawned by zmdc.
@ -236,6 +237,7 @@ sub getFilters {
$sql .= ' `Background` = 1 AND';
}
$sql .= '( `AutoArchive` = 1
or `AutoUnarchive` = 1
or `AutoVideo` = 1
or `AutoUpload` = 1
or `AutoEmail` = 1
@ -282,6 +284,7 @@ sub checkFilter {
join(', ',
($filter->{AutoDelete}?'delete':()),
($filter->{AutoArchive}?'archive':()),
($filter->{AutoUnarchive}?'unarchive':()),
($filter->{AutoVideo}?'video':()),
($filter->{AutoUpload}?'upload':()),
($filter->{AutoEmail}?'email':()),
@ -299,7 +302,7 @@ sub checkFilter {
last if $zm_terminate;
my $Event = new ZoneMinder::Event($$event{Id}, $event);
Debug("Checking event $Event->{Id}");
Debug('Checking event '.$Event->{Id});
my $delete_ok = !undef;
$dbh->ping();
if ( $filter->{AutoArchive} ) {
@ -311,6 +314,15 @@ sub checkFilter {
my $res = $sth->execute($Event->{Id})
or Error("Unable to execute '$sql': ".$dbh->errstr());
}
if ( $filter->{AutoUnarchive} ) {
Info("Unarchiving event $Event->{Id}");
# Do it individually to avoid locking up the table for new events
my $sql = 'UPDATE `Events` SET `Archived` = 0 WHERE `Id` = ?';
my $sth = $dbh->prepare_cached($sql)
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
my $res = $sth->execute($Event->{Id})
or Error("Unable to execute '$sql': ".$dbh->errstr());
}
if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} ) {
if ( !$Event->{Videoed} ) {
$delete_ok = undef if !generateVideo($filter, $Event);

View File

@ -1 +1 @@
1.35.9
1.35.10

View File

@ -19,11 +19,11 @@ function probe( &$url_bits ) {
$cam_list_html = file_get_contents('http://'.$url_bits['host'].':5000/monitoring/');
if ( $cam_list_html ) {
ZM\Logger::Debug("Have content at port 5000/monitoring");
ZM\Debug("Have content at port 5000/monitoring");
$matches_count = preg_match_all(
'/<a href="http:\/\/([.[:digit:]]+):([[:digit:]]+)\/\?action=stream" target="_blank">([^<]+)<\/a>/',
$cam_list_html, $cam_list );
ZM\Logger::Debug(print_r($cam_list,true));
ZM\Debug(print_r($cam_list,true));
}
if ( $matches_count ) {
for( $index = 0; $index < $matches_count; $index ++ ) {
@ -33,7 +33,7 @@ function probe( &$url_bits ) {
if ( ! isset($new_stream['scheme'] ) )
$new_stream['scheme'] = 'http';
$available_streams[] = $new_stream;
ZM\Logger::Debug("Have new stream " . print_r($new_stream,true) );
ZM\Debug("Have new stream " . print_r($new_stream,true) );
}
} else {
ZM\Info('No matches');

View File

@ -252,7 +252,7 @@ switch ( $_REQUEST['task'] ) {
ZM\Fatal('Can\'t create exports dir at \''.ZM_DIR_EXPORTS.'\'');
}
$exportPath = ZM_DIR_EXPORTS.'/zm-log-'.$exportKey.$exportExt;
ZM\Logger::Debug("Exporting to $exportPath");
ZM\Debug("Exporting to $exportPath");
if ( !($exportFP = fopen($exportPath, 'w')) )
ZM\Fatal("Unable to open log export file $exportPath");
$logs = array();
@ -261,7 +261,7 @@ switch ( $_REQUEST['task'] ) {
$log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : '';
$logs[] = $log;
}
ZM\Logger::Debug(count($logs).' lines being exported by '.$sql.implode(',', $values));
ZM\Debug(count($logs).' lines being exported by '.$sql.implode(',', $values));
switch( $format ) {
case 'text' :

View File

@ -8,7 +8,7 @@ if ( empty($_REQUEST['modal']) ) {
$modal = validJsStr($_REQUEST['modal']);
$data = array();
ZM\Logger::Debug("Including modals/$modal.php");
ZM\Debug("Including modals/$modal.php");
# Shouldn't be necessary but at the moment we have last .conf file contents
ob_start();
@$result = include('modals/'.$modal.'.php');

View File

@ -60,7 +60,7 @@ if ( isset($_SESSION['montageReviewFilter']) and !$eids ) {
#unset($_SESSION['montageReviewFilter']);
#session_write_close();
#} else {
#Logger::Debug("NO montageReviewFilter");
#Debug("NO montageReviewFilter");
}
$exportFormat = '';

View File

@ -49,6 +49,7 @@ if ( ! $result ) return;
$current_session = $_SESSION;
zm_session_start();
$user_cache = array();
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
$_SESSION = array();
if ( ! session_decode($row['data']) ) {
@ -63,10 +64,15 @@ while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
# Not logged in
continue;
}
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
if ( ! $user ) {
ZM\Logger::Debug('User not found for ' . $_SESSION['username']);
continue;
if ( isset($user_cache[$_SESSION['username']]) ) {
$user = $user_cache[$_SESSION['username']];
} else {
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
if ( ! $user ) {
ZM\Debug('User not found for ' . $_SESSION['username']);
continue;
}
$user_cache[$_SESSION['username']] = $user;
}
echo '

View File

@ -0,0 +1,47 @@
<?php
$error='';
if ( !canEdit('System') ) {
$error = 'Insufficient permissions';
} else if ( !defined('ZM_PATH_SHUTDOWN') or ZM_PATH_SHUTDOWN == '' ) {
$error = 'ZM_PATH_SHUTDOWN is not defined. This is normally configured in /etc/zm/conf.d/01-system-paths.conf';
} else if ( !file_exists(ZM_PATH_SHUTDOWN) ) {
$error = 'Path does not exist for ZM_PATH_SHUTDOWN. Current value is '.ZM_PATH_SHUTDOWN;
}
if ( $error ) {
ZM\Error($error);
return;
}
?>
<div class="modal" id="shutdownModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><?php echo translate('Shutdown').' '.translate('Restart') ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p class="warning"><h2>Warning</h2>
This command will either shutdown or restart all ZoneMinder Servers<br/>
</p>
<p>
<input type="radio" name="when" value="now" id="whennow"/><label for="whennow">Now</label>
<input type="radio" name="when" value="1min" id="when1min" checked="checked"/><label for="when1min">1 Minute</label>
</p>
<p id="respText" class="invisible">
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-command="cancel" data-on-click-this="manageShutdownBtns" id="cancelBtn" disabled><?php echo translate('Cancel') ?></button>
<button type="button" class="btn btn-primary" data-command="restart" data-on-click-this="manageShutdownBtns"><?php echo translate('Restart') ?></button>
<button type="button" class="btn btn-primary" data-command="shutdown" data-on-click-this="manageShutdownBtns"><?php echo translate('Shutdown') ?></button>
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo translate('Close') ?></button>
</div>
</form>
</div>
</div>
</div>

58
web/ajax/shutdown.php Normal file
View File

@ -0,0 +1,58 @@
<?php
//
// ZoneMinder web action file
// Copyright (C) 2019 ZoneMinder LLC
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
$message = '';
if ( !canEdit('System') ) {
$message = 'Need System permissions to shutdown server';
} else if ( !isset($_REQUEST['command']) ) {
$message = 'A command is required. Cannot continue';
}
if ( $message ) {
ZM\Warning($message);
ajaxError($message);
return;
}
$data = array();
$when = isset($_REQUEST['when']) and $_REQUEST['when'] == 'now' ? 'now' : '+1';
$command = $_REQUEST['command'];
if ( $command == 'shutdown' ) {
exec('sudo -n '.ZM_PATH_SHUTDOWN." -P $when 2>&1", $data['output'], $data['rc']);
#exec('sudo -n /bin/systemctl poweroff -i 2>&1', $data['output'], $data['rc']);
ZM\Debug('Shutdown output ' .$data['rc'].' '.implode("\n",$data['output']));
#ZM\Debug("Shutdown output " . shell_exec('/bin/systemctl poweroff -i 2>&1'));
} else if ( $command == 'restart' ) {
$data['output'] = array();
exec('sudo -n '.ZM_PATH_SHUTDOWN." -r $when 2>&1", $data['output'], $data['rc']);
#exec('sudo -n /bin/systemctl reboot -i 2>&1', $data['output'], $data['rc']);
ZM\Debug("Shutdown output " . implode("\n",$data['output']));
} else if ( $command == 'cancel' ) {
$data['output'] = array();
exec('sudo '.ZM_PATH_SHUTDOWN.' -c 2>&1', $data['output'], $data['rc']);
} else {
ajaxError('Unknwn command:'.$command);
return;
}
ajaxResponse($data);
return;
?>

View File

@ -336,7 +336,7 @@ function collectData() {
}
}
}
#ZM\Logger::Debug(print_r($data, true));
#ZM\Debug(print_r($data, true));
return $data;
}

View File

@ -31,19 +31,19 @@ if ( sem_acquire($semaphore,1) !== false ) {
switch ( $_REQUEST['command'] ) {
case CMD_VARPLAY :
ZM\Logger::Debug('Varplaying to '.$_REQUEST['rate']);
ZM\Debug('Varplaying to '.$_REQUEST['rate']);
$msg = pack('lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768);
break;
case CMD_ZOOMIN :
ZM\Logger::Debug('Zooming to '.$_REQUEST['x'].','.$_REQUEST['y']);
ZM\Debug('Zooming to '.$_REQUEST['x'].','.$_REQUEST['y']);
$msg = pack('lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y']);
break;
case CMD_PAN :
ZM\Logger::Debug('Panning to '.$_REQUEST['x'].','.$_REQUEST['y']);
ZM\Debug('Panning to '.$_REQUEST['x'].','.$_REQUEST['y']);
$msg = pack('lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y']);
break;
case CMD_SCALE :
ZM\Logger::Debug('Scaling to '.$_REQUEST['scale']);
ZM\Debug('Scaling to '.$_REQUEST['scale']);
$msg = pack('lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale']);
break;
case CMD_SEEK :
@ -53,7 +53,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
1000000*( $_REQUEST['offset']-intval($_REQUEST['offset'])));
break;
default :
ZM\Logger::Debug('Sending command ' . $_REQUEST['command']);
ZM\Debug('Sending command ' . $_REQUEST['command']);
$msg = pack('lc', MSG_CMD, $_REQUEST['command']);
break;
}
@ -67,7 +67,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
// WHY? We will just send another one...
// ANSWER: Because otherwise we get a log of errors logged
//ZM\Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
//ZM\Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
usleep(1000);
}
@ -126,16 +126,16 @@ if ( sem_acquire($semaphore,1) !== false ) {
$auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS);
if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) {
$data['auth'] = $auth_hash;
ZM\Logger::Debug("including nw auth hash " . $data['auth']);
ZM\Debug("including nw auth hash " . $data['auth']);
} else {
ZM\Logger::Debug('Not including nw auth hash becase it hashn\'t changed '.$auth_hash);
ZM\Debug('Not including nw auth hash becase it hashn\'t changed '.$auth_hash);
}
}
ajaxResponse(array('status'=>$data));
break;
case MSG_DATA_EVENT :
if ( version_compare( phpversion(), '5.6.0', '<') ) {
ZM\Logger::Debug('Using old unpack methods to handle 64bit event id');
ZM\Debug('Using old unpack methods to handle 64bit event id');
$data = unpack('ltype/ieventlow/ieventhigh/dduration/dprogress/irate/izoom/Cpaused', $msg);
$data['event'] = $data['eventhigh'] << 32 | $data['eventlow'];
} else {
@ -156,7 +156,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
sem_release($semaphore);
} else {
ZM\Logger::Debug('Couldn\'t get semaphore');
ZM\Debug('Couldn\'t get semaphore');
ajaxResponse(array());
}

View File

@ -105,7 +105,7 @@ class AppController extends Controller {
if ( ! is_session_started() )
zm_session_start();
ZM\Logger::Debug(print_r($_SESSION, true));
ZM\Debug(print_r($_SESSION, true));
$user = userFromSession();
session_write_close();
}

View File

@ -50,10 +50,10 @@ class HostController extends AppController {
$cred_depr = [];
if ( $username && $password ) {
ZM\Logger::Debug('Username and password provided, generating access and refresh tokens');
ZM\Debug('Username and password provided, generating access and refresh tokens');
$cred = $this->_getCredentials(true, '', $username); // generate refresh
} else {
ZM\Logger::Debug('Only generating access token');
ZM\Debug('Only generating access token');
$cred = $this->_getCredentials(false, $token); // don't generate refresh
}
@ -72,7 +72,7 @@ class HostController extends AppController {
$login_array['credentials'] = $cred_depr[0];
$login_array['append_password'] = $cred_depr[1];
} else {
ZM\Logger::Debug('Legacy Auth is disabled, not generating auth= credentials');
ZM\Debug('Legacy Auth is disabled, not generating auth= credentials');
}
$login_array['version'] = $ver[0];
@ -203,7 +203,7 @@ class HostController extends AppController {
if ( $mid ) {
// Get disk usage for $mid
ZM\Logger::Debug("Executing du -s0 $zm_dir_events/$mid | awk '{print $1}'");
ZM\Debug("Executing du -s0 $zm_dir_events/$mid | awk '{print $1}'");
$usage = shell_exec("du -s0 $zm_dir_events/$mid | awk '{print $1}'");
} else {
$monitors = $this->Monitor->find('all', array(

View File

@ -178,7 +178,7 @@ class MonitorsController extends AppController {
)
) {
if ( !defined('ZM_SERVER_ID')) {
ZM\Logger::Debug("Not defined ZM_SERVER_ID");
ZM\Debug("Not defined ZM_SERVER_ID");
}
$this->daemonControl($this->Monitor->id, 'start');
}
@ -386,7 +386,7 @@ class MonitorsController extends AppController {
}
$shellcmd = escapeshellcmd("$zm_path_bin/zmdc.pl $command $daemon $args");
ZM\Logger::Debug("Command $shellcmd");
ZM\Debug("Command $shellcmd");
$status = exec($shellcmd);
$status_text .= $status."\n";
}

View File

@ -133,10 +133,10 @@ class Event extends AppModel {
if ( file_exists($this->Path().'/'.$event['DefaultVideo']) ) {
return 1;
} else {
ZM\Logger::Debug('File does not exist at ' . $this->Path().'/'.$event['DefaultVideo'] );
ZM\Debug('File does not exist at ' . $this->Path().'/'.$event['DefaultVideo'] );
}
} else {
ZM\Logger::Debug('No DefaultVideo in Event' . $this->Event);
ZM\Debug('No DefaultVideo in Event' . $this->Event);
return 0;
}
} // end function fileExists($event)

View File

@ -291,7 +291,7 @@ class Event extends ZM_Object {
# The idea here is that we don't really want to use the analysis jpeg as the thumbnail.
# The snapshot image will be generated during capturing
if ( file_exists($this->Path().'/snapshot.jpg') ) {
Logger::Debug("snapshot exists");
Debug("snapshot exists");
$frame = null;
} else {
# Load the frame with the highest score to use as a thumbnail
@ -396,14 +396,14 @@ class Event extends ZM_Object {
if ( $frame and !is_array($frame) ) {
# Must be an Id
Logger::Debug("Assuming that $frame is an Id");
Debug("Assuming that $frame is an Id");
$frame = array('FrameId'=>$frame, 'Type'=>'', 'Delta'=>0);
}
if ( ( !$frame ) and file_exists($eventPath.'/snapshot.jpg') ) {
# No frame specified, so look for a snapshot to use
$captImage = 'snapshot.jpg';
Logger::Debug('Frame not specified, using snapshot');
Debug('Frame not specified, using snapshot');
$frame = array('FrameId'=>'snapshot', 'Type'=>'', 'Delta'=>0);
} else {
$captImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId']);
@ -421,11 +421,11 @@ class Event extends ZM_Object {
#$command ='ffmpeg -v 0 -i '.$videoPath.' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage;
$command ='ffmpeg -ss '. $frame['Delta'] .' -i '.$videoPath.' -frames:v 1 '.$eventPath.'/'.$captImage;
Logger::Debug('Running '.$command);
Debug('Running '.$command);
$output = array();
$retval = 0;
exec($command, $output, $retval);
Logger::Debug("Retval: $retval, output: " . implode("\n", $output));
Debug("Retval: $retval, output: " . implode("\n", $output));
} else {
Error('Can\'t create frame images from video because there is no video file for event '.$Event->Id().' at ' .$Event->Path());
}
@ -529,7 +529,7 @@ class Event extends ZM_Object {
return;
}
}
Logger::Debug("sending command to $url");
Debug("sending command to $url");
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
@ -545,7 +545,7 @@ class Event extends ZM_Object {
Error("Error restarting zmc using $url");
}
$event_data = json_decode($result,true);
Logger::Debug(print_r($event_data['event']['Event'],1));
Debug(print_r($event_data['event']['Event'],1));
return $event_data['event']['Event']['fileExists'];
} catch ( Exception $e ) {
Error("Except $e thrown trying to get event data");
@ -577,7 +577,7 @@ class Event extends ZM_Object {
return;
}
}
Logger::Debug("sending command to $url");
Debug("sending command to $url");
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
@ -593,7 +593,7 @@ class Event extends ZM_Object {
Error("Error restarting zmc using $url");
}
$event_data = json_decode($result,true);
Logger::Debug(print_r($event_data['event']['Event'], 1));
Debug(print_r($event_data['event']['Event'], 1));
return $event_data['event']['Event']['fileSize'];
} catch ( Exception $e ) {
Error("Except $e thrown trying to get event data");

View File

@ -16,6 +16,7 @@ class Filter extends ZM_Object {
'EmailBody' => '',
'AutoDelete' => 0,
'AutoArchive' => 0,
'AutoUnarchive' => 0,
'AutoVideo' => 0,
'AutoUpload' => 0,
'AutoMessage' => 0,
@ -55,6 +56,9 @@ class Filter extends ZM_Object {
foreach ( $this->FilterTerms() as $term ) {
$this->_querystring .= $term->querystring($separator);
} # end foreach term
if ( $this->Id() ) {
$this->_querystring .= $separator.'filter[Id]='.$this->Id();
}
}
return $this->_querystring;
}
@ -226,7 +230,7 @@ class Filter extends ZM_Object {
if ( (!defined('ZM_SERVER_ID')) or (!$Server->Id()) or (ZM_SERVER_ID==$Server->Id()) ) {
# Local
Logger::Debug("Controlling filter locally $command for server ".$Server->Id());
Debug("Controlling filter locally $command for server ".$Server->Id());
daemonControl($command, 'zmfilter.pl', '--filter_id='.$this->{'Id'}.' --daemon');
} else {
# Remote case
@ -243,7 +247,7 @@ class Filter extends ZM_Object {
}
}
$url .= '&view=filter&object=filter&action=control&command='.$command.'&Id='.$this->Id().'&ServerId='.$Server->Id();
Logger::Debug("sending command to $url");
Debug("sending command to $url");
$data = array();
if ( defined('ZM_ENABLE_CSRF_MAGIC') ) {
require_once( 'includes/csrf/csrf-magic.php' );
@ -274,7 +278,7 @@ class Filter extends ZM_Object {
public function execute() {
$command = ZM_PATH_BIN.'/zmfilter.pl --filter_id='.escapeshellarg($this->Id());
$result = exec($command, $output, $status);
Logger::Debug("$command status:$status output:".implode("\n", $output));
Debug("$command status:$status output:".implode("\n", $output));
return $status;
}

View File

@ -329,14 +329,14 @@ class FilterTerm {
public function test($event=null) {
if ( !isset($event) ) {
# Is a Pre Condition
Logger::Debug("Testing " . $this->attr);
Debug("Testing " . $this->attr);
if ( $this->attr == 'DiskPercent' ) {
# The logic on this is really ugly. We are going to treat it as an OR
foreach ( $this->filter->get_StorageAreas() as $storage ) {
$string_to_eval = 'return $storage->disk_usage_percent() '.$this->op.' '.$this->val.';';
try {
$ret = eval($string_to_eval);
Logger::Debug("Evalled $string_to_eval = $ret");
Debug("Evalled $string_to_eval = $ret");
if ( $ret )
return true;
} catch ( Throwable $t ) {
@ -348,7 +348,7 @@ class FilterTerm {
$string_to_eval = 'return getLoad() '.$this->op.' '.$this->val.';';
try {
$ret = eval($string_to_eval);
Logger::Debug("Evaled $string_to_eval = $ret");
Debug("Evaled $string_to_eval = $ret");
if ( $ret )
return true;
} catch ( Throwable $t ) {
@ -374,7 +374,7 @@ class FilterTerm {
$string_to_eval = 'return $event->Storage()->disk_usage_percent() '.$this->op.' '.$this->val.';';
try {
$ret = eval($string_to_eval);
Logger::Debug("Evalled $string_to_eval = $ret");
Debug("Evalled $string_to_eval = $ret");
if ( $ret )
return true;
} catch ( Throwable $t ) {
@ -385,7 +385,7 @@ class FilterTerm {
$string_to_eval = 'return $event->Storage()->disk_usage_blocks() '.$this->op.' '.$this->val.';';
try {
$ret = eval($string_to_eval);
Logger::Debug("Evalled $string_to_eval = $ret");
Debug("Evalled $string_to_eval = $ret");
if ( $ret )
return true;
} catch ( Throwable $t ) {

View File

@ -181,7 +181,7 @@ class Monitor extends ZM_Object {
FROM `Monitor_Status` WHERE `MonitorId`=?';
$row = dbFetchOne($sql, NULL, array($this->{'Id'}));
if ( !$row ) {
Error('Unable to load Monitor record for Id='.$this->{'Id'});
Warning('Unable to load Monitor status record for Id='.$this->{'Id'}.' using '.$sql);
foreach ( $this->status_fields as $k => $v ) {
$this->{$k} = $v;
}
@ -329,7 +329,7 @@ class Monitor extends ZM_Object {
return;
}
}
Logger::Debug('sending command to '.$url);
Debug('sending command to '.$url);
$context = stream_context_create();
try {
@ -389,7 +389,7 @@ class Monitor extends ZM_Object {
return;
}
}
Logger::Debug("sending command to $url");
Debug("sending command to $url");
$context = stream_context_create();
try {
@ -538,7 +538,7 @@ class Monitor extends ZM_Object {
if ( $command == 'quit' or $command == 'start' or $command == 'stop' ) {
# These are special as we now run zmcontrol as a daemon through zmdc.
$status = daemonStatus('zmcontrol.pl', array('--id', $this->{'Id'}));
Logger::Debug("Current status $status");
Debug("Current status $status");
if ( $status or ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) ) {
daemonControl($command, 'zmcontrol.pl', '--id '.$this->{'Id'});
return;
@ -552,10 +552,10 @@ class Monitor extends ZM_Object {
if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
# Local
Logger::Debug('Trying to send options ' . print_r($options, true));
Debug('Trying to send options ' . print_r($options, true));
$optionString = jsonEncode($options);
Logger::Debug("Trying to send options $optionString");
Debug("Trying to send options $optionString");
// Either connects to running zmcontrol.pl or runs zmcontrol.pl to send the command.
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
if ( $socket < 0 ) {
@ -589,7 +589,7 @@ class Monitor extends ZM_Object {
$url .= '?user='.$_SESSION['username'];
}
}
Logger::Debug("sending command to $url");
Debug("sending command to $url");
$context = stream_context_create();
try {

View File

@ -94,7 +94,7 @@ class Storage extends ZM_Object {
}
$used = $this->disk_used_space();
$usage = round(($used / $total) * 100);
//Logger::Debug("Used $usage = round( ( $used / $total ) * 100 )");
//Debug("Used $usage = round( ( $used / $total ) * 100 )");
return $usage;
}

View File

@ -32,7 +32,7 @@ if ( !canEdit('Events') ) {
if ( $action == 'archive' ) {
$dbConn->beginTransaction();
$eids = getAffectedIds('eids');
ZM\Logger::Debug("E IDS" . print_r($eids, true));
ZM\Debug("E IDS" . print_r($eids, true));
foreach ( $eids as $markEid ) {
dbQuery('UPDATE Events SET Archived=? WHERE Id=?', array(1, $markEid));
}
@ -41,7 +41,7 @@ if ( $action == 'archive' ) {
} else if ( $action == 'unarchive' ) {
$dbConn->beginTransaction();
$eids = getAffectedIds('eids');
ZM\Logger::Debug("E IDS" . print_r($eids, true));
ZM\Debug("E IDS" . print_r($eids, true));
foreach ( $eids as $markEid ) {
dbQuery('UPDATE Events SET Archived=? WHERE Id=?', array(0, $markEid));
}

View File

@ -64,7 +64,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
$_REQUEST['filter']['Background'] = empty($_REQUEST['filter']['Background']) ? 0 : 1;
$_REQUEST['filter']['Concurrent'] = empty($_REQUEST['filter']['Concurrent']) ? 0 : 1;
$changes = $filter->changes($_REQUEST['filter']);
ZM\Logger::Debug('Changes: ' . print_r($changes,true));
ZM\Debug('Changes: ' . print_r($changes,true));
if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) {
if ( $filter->Background() )

View File

@ -52,7 +52,7 @@ if ( $action == 'function' ) {
$monitor->zmaControl('start');
}
} else {
ZM\Logger::Debug('No change to function, not doing anything.');
ZM\Debug('No change to function, not doing anything.');
}
} // end if action
$redirect = '?view=console';

View File

@ -23,7 +23,7 @@ if ( $action == 'logout' ) {
userLogout();
$view = 'login';
} elseif ( $action == 'config' ) {
$redirect = '?view=user&uid='.$user['Id'];
$redirect = '?view=user&prev=console&uid='.$user['Id'];
}
?>

View File

@ -75,10 +75,10 @@ if ( $action == 'save' ) {
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');
ZM\Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId']);
ZM\Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId']);
if ( ( !$_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
ZM\Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
ZM\Debug('Auto selecting server to ' . ZM_SERVER_ID);
}
}
@ -235,7 +235,7 @@ if ( $action == 'save' ) {
$restart = true;
} else {
ZM\Logger::Debug('No action due to no changes to Monitor');
ZM\Debug('No action due to no changes to Monitor');
} # end if count(changes)
if ( !$mid ) {

View File

@ -1,44 +0,0 @@
<?php
//
// ZoneMinder web action file
// Copyright (C) 2019 ZoneMinder LLC
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canEdit('System') ) {
ZM\Warning('Need System permissions to shutdown server');
return;
}
if ( $action ) {
$when = isset($_POST['when']) and $_POST['when'] == 'now' ? 'now' : '+1';
if ( $action == 'shutdown' ) {
$output = array();
$rc = 0;
exec('sudo -n '.ZM_PATH_SHUTDOWN." -P $when 2>&1", $output, $rc);
#exec('sudo -n /bin/systemctl poweroff -i 2>&1', $output, $rc);
ZM\Logger::Debug("Shutdown output $rc " . implode("\n",$output));
#ZM\Logger::Debug("Shutdown output " . shell_exec('/bin/systemctl poweroff -i 2>&1'));
} else if ( $action == 'restart' ) {
$output = array();
exec('sudo -n '.ZM_PATH_SHUTDOWN." -r $when 2>&1", $output);
#exec('sudo -n /bin/systemctl reboot -i 2>&1', $output);
ZM\Logger::Debug("Shutdown output " . implode("\n",$output));
} else if ( $action == 'cancel' ) {
$output = array();
exec('sudo '.ZM_PATH_SHUTDOWN.' -c 2>&1', $output);
}
} # end if action
?>

View File

@ -66,9 +66,7 @@ if ( $action == 'Save' ) {
} else {
dbQuery('INSERT INTO Users SET '.implode(', ', $changes));
}
$refreshParent = true;
} # end if changes
$redirect = '?view=options&tab=users';
} else if ( ZM_USER_SELF_EDIT and ( $_REQUEST['uid'] == $user['Id'] ) ) {
$uid = $user['Id'];
@ -99,9 +97,7 @@ if ( $action == 'Save' ) {
zm_session_start();
generateAuthHash(ZM_AUTH_HASH_IPS, true);
session_write_close();
$refreshParent = true;
}
$redirect = '?view=options&tab=users';
}
} // end if $action == user
?>

View File

@ -72,12 +72,12 @@ function validateUser($username='', $password='') {
// We assume we don't need to support mysql < 4.1
// Starting MY SQL 4.1, mysql concats a '*' in front of its password hash
// https://blog.pythian.com/hashing-algorithm-in-mysql-password-2/
ZM\Logger::Debug('Saved password is using MYSQL password function');
ZM\Debug('Saved password is using MYSQL password function');
$input_password_hash = '*'.strtoupper(sha1(sha1($password, true)));
$password_correct = ($user['Password'] == $input_password_hash);
break;
case 'bcrypt' :
ZM\Logger::Debug('bcrypt signature found, assumed bcrypt password');
ZM\Debug('bcrypt signature found, assumed bcrypt password');
$password_correct = password_verify($password, $user['Password']);
break;
case 'mysql+bcrypt' :
@ -85,10 +85,10 @@ function validateUser($username='', $password='') {
// this is done so that we don't spend cycles doing two bcrypt password_verify calls
// for every wrong password entered. This will only be invoked for passwords zmupdate.pl has
// overlay hashed
ZM\Logger::Debug("Detected bcrypt overlay hashing for $username");
ZM\Debug("Detected bcrypt overlay hashing for $username");
$bcrypt_hash = substr($user['Password'], 4);
$mysql_encoded_password = '*'.strtoupper(sha1(sha1($password, true)));
ZM\Logger::Debug("Comparing password $mysql_encoded_password to bcrypt hash: $bcrypt_hash");
ZM\Debug("Comparing password $mysql_encoded_password to bcrypt hash: $bcrypt_hash");
$password_correct = password_verify($mysql_encoded_password, $bcrypt_hash);
break;
default:
@ -130,7 +130,7 @@ function validateToken($token, $allowed_token_type='access') {
return array(false, 'Incorrect token type');
}
} else {
ZM\Logger::Debug('Not comparing token types as [any] was passed');
ZM\Debug('Not comparing token types as [any] was passed');
}
$username = $jwt_payload['user'];
@ -210,7 +210,7 @@ function generateAuthHash($useRemoteAddr, $force=false) {
} else {
$authKey = ZM_AUTH_HASH_SECRET.$user['Username'].$user['Password'].$local_time[2].$local_time[3].$local_time[4].$local_time[5];
}
#ZM\Logger::Debug("Generated using hour:".$local_time[2] . ' mday:' . $local_time[3] . ' month:'.$local_time[4] . ' year: ' . $local_time[5] );
#ZM\Debug("Generated using hour:".$local_time[2] . ' mday:' . $local_time[3] . ' month:'.$local_time[4] . ' year: ' . $local_time[5] );
$auth = md5($authKey);
$_SESSION['AuthHash'.$_SESSION['remoteAddr']] = $auth;
$_SESSION['AuthHashGeneratedAt'] = $time;
@ -248,14 +248,14 @@ function userFromSession() {
if ( isset($_SESSION['AuthHash'.$_SESSION['remoteAddr']]) )
$user = getAuthUser($_SESSION['AuthHash'.$_SESSION['remoteAddr']]);
else
ZM\Logger::Debug("No auth hash in session, there should have been");
ZM\Debug("No auth hash in session, there should have been");
} else {
# Need to refresh permissions and validate that the user still exists
$sql = 'SELECT * FROM Users WHERE Enabled=1 AND Username=?';
$user = dbFetchOne($sql, NULL, array($_SESSION['username']));
}
} else {
ZM\Logger::Debug('No username in session');
ZM\Debug('No username in session');
}
return $user;
}

View File

@ -193,21 +193,21 @@ function csrf_check($fatal = true) {
$tokens = '';
do {
if (!isset($_POST[$name])) {
#Logger::Debug("POST[$name] is not set");
#Debug("POST[$name] is not set");
break;
#} else {
#Logger::Debug("POST[$name] is set as " . $_POST[$name] );
#Debug("POST[$name] is set as " . $_POST[$name] );
}
// we don't regenerate a token and check it because some token creation
// schemes are volatile.
$tokens = $_POST[$name];
if (!csrf_check_tokens($tokens)) {
#Logger::Debug("Failed checking tokens");
#Debug("Failed checking tokens");
break;
#} else {
#Logger::Debug("Token passed");
#Debug("Token passed");
}
$ok = true;
} while (false);
@ -296,7 +296,7 @@ function csrf_callback($tokens) {
// Don't make it too easy for users to inflict a CSRF attack on themselves.
echo "<p><strong>Only try again if you weren't sent to this page by someone as this is potentially a sign of an attack.</strong></p>";
echo "<form method='post' action=''>$data<input type='submit' value='Try again' /></form>";
ZM\Logger::Debug("Failed csrf check");
ZM\Debug("Failed csrf check");
}
echo "<p>Debug: $tokens</p></body></html>
";
@ -318,27 +318,27 @@ function csrf_check_tokens($tokens) {
* Checks if a token is valid.
*/
function csrf_check_token($token) {
#Logger::Debug("Checking CSRF token $token");
#Debug("Checking CSRF token $token");
if (strpos($token, ':') === false) {
#Logger::Debug("Checking CSRF token $token bad because no :");
#Debug("Checking CSRF token $token bad because no :");
return false;
}
list($type, $value) = explode(':', $token, 2);
if (strpos($value, ',') === false) {
#Logger::Debug("Checking CSRF token $token bad because no ,");
#Debug("Checking CSRF token $token bad because no ,");
return false;
}
list($x, $time) = explode(',', $token, 2);
if ($GLOBALS['csrf']['expires']) {
if (time() > $time + $GLOBALS['csrf']['expires']) {
#Logger::Debug("Checking CSRF token $token bad because expired");
#Debug("Checking CSRF token $token bad because expired");
return false;
}
}
switch ($type) {
case 'sid':
{
#Logger::Debug("Checking sid: $value === " . csrf_hash(session_id(), $time) );
#Debug("Checking sid: $value === " . csrf_hash(session_id(), $time) );
return $value === csrf_hash(session_id(), $time);
}
case 'cookie':
@ -348,10 +348,10 @@ return false;
return $value === csrf_hash($_COOKIE[$n], $time);
case 'key':
if (!$GLOBALS['csrf']['key']) {
Logger::Debug("Checking key: no key set" );
Debug("Checking key: no key set" );
return false;
}
#Logger::Debug("Checking sid: $value === " . csrf_hash($GLOBALS['csrf']['key'], $time) );
#Debug("Checking sid: $value === " . csrf_hash($GLOBALS['csrf']['key'], $time) );
return $value === csrf_hash($GLOBALS['csrf']['key'], $time);
// We could disable these 'weaker' checks if 'key' was set, but
// that doesn't make me feel good then about the cookie-based

View File

@ -105,7 +105,7 @@ function dbLog($sql, $update=false) {
global $dbLogLevel;
$noExecute = $update && ($dbLogLevel >= DB_LOG_DEBUG);
if ( $dbLogLevel > DB_LOG_OFF )
ZM\Logger::Debug( "SQL-LOG: $sql".($noExecute?' (not executed)':'') );
ZM\Debug( "SQL-LOG: $sql".($noExecute?' (not executed)':'') );
return( $noExecute );
}
@ -146,7 +146,7 @@ function dbQuery($sql, $params=NULL) {
}
} else {
if ( defined('ZM_DB_DEBUG') ) {
ZM\Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):''));
ZM\Debug("SQL: $sql values:" . ($params?implode(',',$params):''));
}
$result = $dbConn->query($sql);
if ( ! $result ) {
@ -155,7 +155,7 @@ function dbQuery($sql, $params=NULL) {
}
}
if ( defined('ZM_DB_DEBUG') ) {
ZM\Logger::Debug('SQL: '.$sql.' '.($params?implode(',',$params):'').' rows: '.$result->rowCount());
ZM\Debug('SQL: '.$sql.' '.($params?implode(',',$params):'').' rows: '.$result->rowCount());
}
} catch(PDOException $e) {
ZM\Error("SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):''));

View File

@ -104,7 +104,7 @@ function CORSHeaders() {
# 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 ) {
ZM\Logger::Debug('Setting default Access-Control-Allow-Origin from ' . $_SERVER['HTTP_ORIGIN']);
ZM\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');
}
@ -117,7 +117,7 @@ function CORSHeaders() {
preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN'])
) {
$valid = true;
ZM\Logger::Debug('Setting Access-Control-Allow-Origin from '.$_SERVER['HTTP_ORIGIN']);
ZM\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;
@ -392,7 +392,7 @@ function getEventDefaultVideoPath($event) {
}
function deletePath( $path ) {
ZM\Logger::Debug('Deleting '.$path);
ZM\Debug('Deleting '.$path);
if ( is_dir($path) ) {
system(escapeshellcmd('rm -rf '.$path));
} else if ( file_exists($path) ) {
@ -424,6 +424,9 @@ function deleteEvent($event) {
} # CAN EDIT
}
/**
* $label must be already escaped. It can't be done here since it sometimes contains HTML tags.
*/
function makeLink($url, $label, $condition=1, $options='') {
$string = '';
if ( $condition ) {
@ -443,32 +446,6 @@ function makeHelpLink($ohndx) {
return $string;
}
/**
* $label must be already escaped. It can't be done here since it sometimes contains HTML tags.
*/
function makePopupLink($url, $winName, $winSize, $label, $condition=1, $options='') {
// Avoid double-encoding since some consumers incorrectly pass a pre-escaped URL.
$string = '<a';
if ( $condition ) {
$string .= ' class="popup-link" href="' . htmlspecialchars($url, ENT_COMPAT | ENT_HTML401, ini_get('default_charset'), false) . '"';
$string .= ' data-window-name="' . htmlspecialchars($winName) . '"';
if ( is_array( $winSize ) ) {
$string .= ' data-window-tag="' . htmlspecialchars($winSize[0]) . '"';
$string .= ' data-window-width="' . htmlspecialchars($winSize[1]) . '"';
$string .= ' data-window-height="' . htmlspecialchars($winSize[2]) . '"';
} else {
$string .= ' data-window-tag="' . htmlspecialchars($winSize) . '"';
}
$string .= ($options ? (' ' . $options ) : '') . '>';
} else {
$string .= '>';
}
$string .= $label;
$string .= '</a>';
return $string;
}
function makeButton($url, $buttonValue, $condition=1, $options='') {
$string = '<button type="button" data-on-click-this="'.$buttonValue.'"';
$string .= ' data-url="' .$url. '"';
@ -491,7 +468,7 @@ function htmlSelect($name, $contents, $values, $behaviours=false) {
}
}
return '<select name="'.$name.'" '.$behaviourText.'>'.htmlOptions($contents, $values).'</select>';
return '<select name="'.$name.'" '.$behaviourText.'>'.PHP_EOL.htmlOptions($contents, $values).'</select>';
}
function htmlOptions($options, $values) {
@ -522,8 +499,7 @@ function htmlOptions($options, $values) {
$options_html .= '<option value="'.htmlspecialchars($value, ENT_COMPAT | ENT_HTML401, ini_get('default_charset'), false).'"'.
($selected?' selected="selected"':'').
($disabled?' disabled="disabled"':'').
'>'.htmlspecialchars($text, ENT_COMPAT | ENT_HTML401, ini_get('default_charset'), false).'</option>
';
'>'.htmlspecialchars($text, ENT_COMPAT | ENT_HTML401, ini_get('default_charset'), false).'</option>'.PHP_EOL;
} # end foreach options
if ( $values and ((!is_array($values)) or count($values) ) and ! $has_selected ) {
ZM\Warning('Specified value '.print_r($values, true).' not in contents: '.print_r($options, true));
@ -814,7 +790,7 @@ function daemonControl($command, $daemon=false, $args=false) {
}
$string = escapeshellcmd($string);
#$string .= ' 2>/dev/null >&- <&- >/dev/null';
ZM\Logger::Debug('daemonControl '.$string);
ZM\Debug('daemonControl '.$string);
exec($string);
}
@ -955,7 +931,7 @@ function createVideo($event, $format, $rate, $scale, $overwrite=false) {
$command .= ' -o';
$command = escapeshellcmd($command);
$result = exec($command, $output, $status);
ZM\Logger::Debug("generating Video $command: result($result outptu:(".implode("\n", $output )." status($status");
ZM\Debug("generating Video $command: result($result outptu:(".implode("\n", $output )." status($status");
return $status ? '' : rtrim($result);
}
@ -1658,17 +1634,17 @@ function coordsToPoints($coords) {
function limitPoints(&$points, $min_x, $min_y, $max_x, $max_y) {
foreach ( $points as &$point ) {
if ( $point['x'] < $min_x ) {
ZM\Logger::Debug('Limiting point x'.$point['x'].' to min_x '.$min_x);
ZM\Debug('Limiting point x'.$point['x'].' to min_x '.$min_x);
$point['x'] = $min_x;
} else if ( $point['x'] > $max_x ) {
ZM\Logger::Debug('Limiting point x'.$point['x'].' to max_x '.$max_x);
ZM\Debug('Limiting point x'.$point['x'].' to max_x '.$max_x);
$point['x'] = $max_x;
}
if ( $point['y'] < $min_y ) {
ZM\Logger::Debug('Limiting point y'.$point['y'].' to min_y '.$min_y);
ZM\Debug('Limiting point y'.$point['y'].' to min_y '.$min_y);
$point['y'] = $min_y;
} else if ( $point['y'] > $max_y ) {
ZM\Logger::Debug('Limiting point y'.$point['y'].' to max_y '.$max_y);
ZM\Debug('Limiting point y'.$point['y'].' to max_y '.$max_y);
$point['y'] = $max_y;
}
} // end foreach point
@ -2093,7 +2069,7 @@ function getStreamHTML($monitor, $options = array()) {
if ( $scale < $options['scale'] )
$options['scale'] = $scale;
} else {
Warning('Invalid value for width: '.$options['width']);
ZM\Warning('Invalid value for width: '.$options['width']);
}
}
}
@ -2193,7 +2169,7 @@ function check_timezone() {
'TIME_FORMAT(TIMEDIFF(NOW(), UTC_TIMESTAMP),\'%H%i\')'
));
#Logger::Debug("System timezone offset determine to be: $sys_tzoffset,\x20
#Debug("System timezone offset determine to be: $sys_tzoffset,\x20
#PHP timezone offset determine to be: $php_tzoffset,\x20
#Mysql timezone offset determine to be: $mysql_tzoffset
#");

View File

@ -158,7 +158,7 @@ class Logger {
$this->initialised = true;
//Logger::Debug( "LogOpts: level=".self::$codes[$this->level]."/".self::$codes[$this->effectiveLevel].", screen=".self::$codes[$this->termLevel].", database=".self::$codes[$this->databaseLevel].", logfile=".self::$codes[$this->fileLevel]."->".$this->logFile.", weblog=".self::$codes[$this->weblogLevel].", syslog=".self::$codes[$this->syslogLevel] );
//Debug( "LogOpts: level=".self::$codes[$this->level]."/".self::$codes[$this->effectiveLevel].", screen=".self::$codes[$this->termLevel].", database=".self::$codes[$this->databaseLevel].", logfile=".self::$codes[$this->fileLevel]."->".$this->logFile.", weblog=".self::$codes[$this->weblogLevel].", syslog=".self::$codes[$this->syslogLevel] );
}
private function terminate() {
@ -199,9 +199,6 @@ class Logger {
return self::$instance;
}
public static function Debug( $string ) {
Logger::fetch()->logPrint( Logger::DEBUG, $string );
}
public function id( $id=NULL ) {
if ( isset($id) && $this->id != $id ) {
@ -459,6 +456,10 @@ function Dump( &$var, $label='VAR' ) {
Logger::fetch()->logPrint( Logger::DEBUG, ob_get_clean() );
}
function Debug( $string ) {
Logger::fetch()->logPrint( Logger::DEBUG, $string );
}
function Info( $string ) {
Logger::fetch()->logPrint( Logger::INFO, $string );
}

View File

@ -25,7 +25,7 @@ function zm_session_start() {
}
ini_set('session.name', 'ZMSESSID');
ZM\Logger::Debug('Setting cookie parameters to '.print_r($currentCookieParams, true));
ZM\Debug('Setting cookie parameters to '.print_r($currentCookieParams, true));
}
session_start();
$_SESSION['remoteAddr'] = $_SERVER['REMOTE_ADDR']; // To help prevent session hijacking
@ -37,7 +37,7 @@ function zm_session_start() {
session_start();
} else if ( !empty($_SESSION['generated_at']) ) {
if ( $_SESSION['generated_at']<($now-(ZM_COOKIE_LIFETIME/2)) ) {
ZM\Logger::Debug('Regenerating session because generated_at ' . $_SESSION['generated_at'] . ' < ' . $now . '-'.ZM_COOKIE_LIFETIME.'/2 = '.($now-ZM_COOKIE_LIFETIME/2));
ZM\Debug('Regenerating session because generated_at ' . $_SESSION['generated_at'] . ' < ' . $now . '-'.ZM_COOKIE_LIFETIME.'/2 = '.($now-ZM_COOKIE_LIFETIME/2));
zm_session_regenerate_id();
}
}

View File

@ -56,7 +56,7 @@ require_once('includes/Monitor.php');
if ( 0 and ZM\Logger::fetch()->debugOn() ) {
ob_start();
phpinfo(INFO_VARIABLES);
ZM\Logger::Debug(ob_get_contents());
ZM\Debug(ob_get_contents());
ob_end_clean();
}
@ -82,7 +82,7 @@ define('ZM_BASE_URL', '');
require_once('includes/functions.php');
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
ZM\Logger::Debug('OPTIONS Method, only doing CORS');
ZM\Debug('OPTIONS Method, only doing CORS');
# Add Cross domain access headers
CORSHeaders();
return;
@ -183,6 +183,9 @@ $user = null;
if ( isset($_REQUEST['view']) )
$view = detaintPath($_REQUEST['view']);
if ( isset($_REQUEST['redirect']) )
$redirect = '?view='.detaintPath($_REQUEST['redirect']);
# Add CSP Headers
$cspNonce = bin2hex(zm_random_bytes(16));
@ -218,7 +221,7 @@ if ( (!$view and !$request) or ($view == 'console') ) {
check_timezone();
}
ZM\Logger::Debug("View: $view Request: $request Action: $action User: " . ( isset($user) ? $user['Username'] : 'none' ));
ZM\Debug("View: $view Request: $request Action: $action User: " . ( isset($user) ? $user['Username'] : 'none' ));
if (
ZM_ENABLE_CSRF_MAGIC &&
( $action != 'login' ) &&
@ -229,14 +232,14 @@ if (
( $view != 'archive' ) // returns data
) {
require_once('includes/csrf/csrf-magic.php');
#ZM\Logger::Debug("Calling csrf_check with the following values: \$request = \"$request\", \$view = \"$view\", \$action = \"$action\"");
#ZM\Debug("Calling csrf_check with the following values: \$request = \"$request\", \$view = \"$view\", \$action = \"$action\"");
csrf_check();
}
# Need to include actions because it does auth
if ( $action and !$request ) {
if ( file_exists('includes/actions/'.$view.'.php') ) {
ZM\Logger::Debug("Including includes/actions/$view.php");
ZM\Debug("Including includes/actions/$view.php");
require_once('includes/actions/'.$view.'.php');
} else {
ZM\Warning("No includes/actions/$view.php for action $action");
@ -251,7 +254,7 @@ if ( ZM_OPT_USE_AUTH and (!isset($user)) and ($view != 'login') and ($view != 'n
header('HTTP/1.1 401 Unauthorized');
exit;
}
ZM\Logger::Debug('Redirecting to login');
ZM\Debug('Redirecting to login');
$view = 'none';
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=login';
if ( ! $request ) {
@ -268,7 +271,7 @@ if ( ZM_OPT_USE_AUTH and (!isset($user)) and ($view != 'login') and ($view != 'n
if ( $redirect ) {
ZM\Logger::Debug("Redirecting to $redirect");
ZM\Debug("Redirecting to $redirect");
header('Location: '.$redirect);
return;
}

View File

@ -72,14 +72,10 @@ function MonitorStream(monitorData) {
this.onclick = function(evt) {
var el = evt.currentTarget;
var tag = 'watch';
var id = el.getAttribute("data-monitor-id");
var width = el.getAttribute("data-width");
var height = el.getAttribute("data-height");
var url = '?view=watch&mid='+id;
var name = 'zmWatch'+id;
evt.preventDefault();
createPopup(url, name, tag, width, height);
window.location.assign(url);
};
this.setup_onclick = function() {

View File

@ -989,7 +989,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -951,7 +951,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -989,7 +989,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -947,7 +947,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -949,7 +949,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -973,7 +973,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -367,6 +367,7 @@ $SLANG = array(
'Ffmpeg' => 'Ffmpeg',
'File' => 'File',
'FilterArchiveEvents' => 'Archive all matches',
'FilterUnarchiveEvents' => 'Unarchive all matches',
'FilterUpdateDiskSpace' => 'Update used disk space',
'FilterDeleteEvents' => 'Delete all matches',
'FilterCopyEvents' => 'Copy all matches',
@ -1074,7 +1075,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -953,7 +953,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -946,7 +946,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -990,7 +990,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -953,7 +953,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -948,7 +948,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -948,7 +948,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -942,7 +942,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -887,7 +887,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -957,7 +957,7 @@ $OLANG = array(
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",
// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked"
// 'Help' => "This is some new help for this option which will be displayed in the window when the ? is clicked"
// ),
);

View File

@ -508,6 +508,7 @@ th.table-th-sort-rev span.table-th-sort-span {
margin: 0 auto 8px auto;
line-height: 130%;
text-align: center;
clear: both;
}
#content p {

View File

@ -27,7 +27,6 @@
}
#definitionPanel {
float: left;
margin: 2px;
text-align: center;
}

View File

@ -19,15 +19,23 @@
//
$rates = array(
'10000' => '100x',
'5000' => '50x',
'2500' => '25x',
'1000' => '10x',
'400' => '4x',
'200' => '2x',
'100' => translate('Real'),
'50' => '1/2x',
'25' => '1/4x',
-5000 => '-50x',
-2500 => '-25x',
-1000 => '-10x',
-500 => '-5x',
-200 => '-2x',
-100 => '-1x',
-50 => '-1/2x',
-25 => '-1/4x',
0 => translate('Stop'),
25 => '1/4x',
50 => '1/2x',
100 => '1x',
200 => '2x',
500 => '5x',
1000 => '10x',
2500 => '25x',
5000 => '50x'
);
$scales = array(

View File

@ -897,7 +897,7 @@ function exportEvents(
ZM\Error("Can't create exports dir at '$export_dir'");
return false;
}
ZM\Logger::Debug("Successfully created dir '$export_dir'");
ZM\Debug("Successfully created dir '$export_dir'");
chmod($export_dir, 0700);
if ( !chdir($export_dir) ) {
ZM\Error("Can't chdir to $export_dir");
@ -925,7 +925,7 @@ function exportEvents(
#continue;
$cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'/'.$file. ' 2>&1';
exec($cmd, $output, $return);
ZM\Logger::Debug($cmd.' return code: '.$return.' output: '.print_r($output,true));
ZM\Debug($cmd.' return code: '.$return.' output: '.print_r($output,true));
} # end foreach event_exportFile
} # end foreach event

View File

@ -737,7 +737,7 @@ function getAcctCircleHTML($skin, $user=null) {
if ( ZM_OPT_USE_AUTH and $user ) {
$result .= '<p id="getAcctCircleHTML" class="navbar-text mr-2">'.PHP_EOL;
$result .= makeLink('#', '<i class="material-icons">account_circle</i> '. $user['Username'],
(ZM_AUTH_TYPE == 'builtin'), 'data-toggle="modal" data-target="#modalLogout" data-backdrop="false"' ).PHP_EOL;
(ZM_AUTH_TYPE == 'builtin'), 'id="logoutButton" data-toggle="modal" data-target="#modalLogout" data-backdrop="false"' ).PHP_EOL;
$result .= '</p>'.PHP_EOL;
}
@ -756,9 +756,9 @@ function getStatusBtnHTML($status) {
//$result .= '</li>'.PHP_EOL;
if ( ZM_SYSTEM_SHUTDOWN ) {
$result .= '<p class="navbar-text">'.PHP_EOL;
$result .= makePopupLink('?view=shutdown', 'zmShutdown', 'shutdown', '<i class="material-icons md-18">power_settings_new</i>' ).PHP_EOL;
$result .= '</p>'.PHP_EOL;
$result .= '<div class="navbar-text pr-2 align-self-center">'.PHP_EOL;
$result .= '<button class="btn btn-outline" data-on-click="getShutdownModal" data-toggle="tooltip" data-placement="top" title="' .translate("Shutdown"). '" ><i class="material-icons md-18">power_settings_new</i></button>'.PHP_EOL;
$result .= '</div>'.PHP_EOL;
}
} else if ( canView('System') ) {

View File

@ -21,7 +21,6 @@
// This file should only contain static JavaScript and no php.
// Use skin.js.php for JavaScript that need pre-processing
//
var popupOptions = "resizable,scrollbars,status=no,toolbar=yes";
// Globally define the icons used in the bootstrap-table top-right toolbar
var icons = {
@ -59,88 +58,6 @@ function checkSize() {
}
}
// Deprecated
function newWindow( url, name, width, height ) {
window.open( url, name, popupOptions+",width="+width+",height="+height );
}
function getPopupSize( tag, width, height ) {
if ( typeof popupSizes == 'undefined' ) {
Error("Can't find any window sizes");
return {'width': 0, 'height': 0};
}
var popupSize = Object.clone(popupSizes[tag]);
if ( !popupSize ) {
Error("Can't find window size for tag '"+tag+"'");
return {'width': 0, 'height': 0};
}
if ( popupSize.width && popupSize.height ) {
if ( width || height ) {
Warning("Ignoring passed dimensions "+width+"x"+height+" when getting popup size for tag '"+tag+"'");
}
return popupSize;
}
if ( popupSize.addWidth ) {
popupSize.width = popupSize.addWidth;
if ( !width ) {
Error("Got addWidth but no passed width when getting popup size for tag '"+tag+"'");
} else {
popupSize.width += parseInt(width);
}
} else if ( width ) {
popupSize.width = width;
Error("Got passed width but no addWidth when getting popup size for tag '"+tag+"'");
}
if ( popupSize.minWidth && popupSize.width < popupSize.minWidth ) {
Warning("Adjusting to minimum width when getting popup size for tag '"+tag+"'");
popupSize.width = popupSize.minWidth;
}
if ( popupSize.addHeight ) {
popupSize.height = popupSize.addHeight;
if ( !height ) {
Error("Got addHeight but no passed height when getting popup size for tag '"+tag+"'");
} else {
popupSize.height += parseInt(height);
}
} else if ( height ) {
popupSize.height = height;
Error("Got passed height but no addHeight when getting popup size for tag '"+tag+"'");
}
if ( popupSize.minHeight && ( popupSize.height < popupSize.minHeight ) ) {
Warning("Adjusting to minimum height ("+popupSize.minHeight+") when getting popup size for tag '"+tag+"' because calculated height is " + popupSize.height);
popupSize.height = popupSize.minHeight;
}
return popupSize;
}
function zmWindow(sub_url) {
var zmWin = window.open( 'https://www.zoneminder.com'+(sub_url?sub_url:''), 'ZoneMinder' );
if ( ! zmWin ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
zmWin.focus();
}
}
function createPopup( url, name, tag, width, height ) {
var popupSize = getPopupSize( tag, width, height );
var popupDimensions = "";
if ( popupSize.width > 0 ) {
popupDimensions += ",width="+popupSize.width;
}
if ( popupSize.height > 0 ) {
popupDimensions += ",height="+popupSize.height;
}
var popup = window.open( url+"&popup=1", name, popupOptions+popupDimensions );
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
// Polyfill for NodeList.prototype.forEach on IE.
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
@ -155,26 +72,6 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
});
});
document.querySelectorAll(".popup-link").forEach(function(el) {
el.addEventListener("click", function onClick(evt) {
var el = this;
var url;
if ( el.hasAttribute("href") ) {
// <a>
url = el.getAttribute("href");
} else {
// buttons
url = el.getAttribute("data-url");
}
var name = el.getAttribute("data-window-name");
var tag = el.getAttribute("data-window-tag");
var width = el.getAttribute("data-window-width");
var height = el.getAttribute("data-window-height");
evt.preventDefault();
createPopup(url, name, tag, width, height);
});
});
document.querySelectorAll(".zmlink").forEach(function(el) {
el.addEventListener("click", function onClick(evt) {
var el = this;
@ -195,7 +92,17 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
el.addEventListener("click", submitTab);
});
// 'data-on-click-this' calls the global function in the attribute value with the element when a click happens.
dataOnClickThis();
dataOnClick();
dataOnClickTrue();
dataOnChangeThis();
dataOnChange();
dataOnInput();
dataOnInputThis();
});
// 'data-on-click-this' calls the global function in the attribute value with the element when a click happens.
function dataOnClickThis() {
document.querySelectorAll("a[data-on-click-this], button[data-on-click-this], input[data-on-click-this]").forEach(function attachOnClick(el) {
var fnName = el.getAttribute("data-on-click-this");
if ( !window[fnName] ) {
@ -204,8 +111,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
}
el.onclick = window[fnName].bind(el, el);
});
}
// 'data-on-click' calls the global function in the attribute value with no arguments when a click happens.
// 'data-on-click' calls the global function in the attribute value with no arguments when a click happens.
function dataOnClick() {
document.querySelectorAll("i[data-on-click], a[data-on-click], button[data-on-click], input[data-on-click]").forEach(function attachOnClick(el) {
var fnName = el.getAttribute("data-on-click");
if ( !window[fnName] ) {
@ -217,8 +126,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
window[fnName](ev);
};
});
}
// 'data-on-click-true' calls the global function in the attribute value with no arguments when a click happens.
// 'data-on-click-true' calls the global function in the attribute value with no arguments when a click happens.
function dataOnClickTrue() {
document.querySelectorAll("a[data-on-click-true], button[data-on-click-true], input[data-on-click-true]").forEach(function attachOnClick(el) {
var fnName = el.getAttribute("data-on-click-true");
if ( !window[fnName] ) {
@ -229,8 +140,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
window[fnName](true);
};
});
}
// 'data-on-change-this' calls the global function in the attribute value with the element when a change happens.
// 'data-on-change-this' calls the global function in the attribute value with the element when a change happens.
function dataOnChangeThis() {
document.querySelectorAll("select[data-on-change-this], input[data-on-change-this]").forEach(function attachOnChangeThis(el) {
var fnName = el.getAttribute("data-on-change-this");
if ( !window[fnName] ) {
@ -239,8 +152,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
}
el.onchange = window[fnName].bind(el, el);
});
}
// 'data-on-change' adds an event listener for the global function in the attribute value when a change happens.
// 'data-on-change' adds an event listener for the global function in the attribute value when a change happens.
function dataOnChange() {
document.querySelectorAll("select[data-on-change], input[data-on-change]").forEach(function attachOnChange(el) {
var fnName = el.getAttribute("data-on-change");
if ( !window[fnName] ) {
@ -249,8 +164,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
}
el.onchange = window[fnName];
});
}
// 'data-on-input' adds an event listener for the global function in the attribute value when an input happens.
// 'data-on-input' adds an event listener for the global function in the attribute value when an input happens.
function dataOnInput() {
document.querySelectorAll("input[data-on-input]").forEach(function(el) {
var fnName = el.getAttribute("data-on-input");
if ( !window[fnName] ) {
@ -259,8 +176,10 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
}
el.oninput = window[fnName];
});
}
// 'data-on-input-this' calls the global function in the attribute value with the element when an input happens.
// 'data-on-input-this' calls the global function in the attribute value with the element when an input happens.
function dataOnInputThis() {
document.querySelectorAll("input[data-on-input-this]").forEach(function(el) {
var fnName = el.getAttribute("data-on-input-this");
if ( !window[fnName] ) {
@ -269,48 +188,24 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
}
el.oninput = window[fnName].bind(el, el);
});
});
}
function createEventPopup( eventId, eventFilter, width, height ) {
function openEvent( eventId, eventFilter ) {
var url = '?view=event&eid='+eventId;
if ( eventFilter ) {
url += eventFilter;
}
var name = 'zmEvent';
var popupSize = getPopupSize( 'event', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
window.location.assign(url);
}
function createFramesPopup( eventId, width, height ) {
function openFrames( eventId ) {
var url = '?view=frames&eid='+eventId;
var name = 'zmFrames';
var popupSize = getPopupSize( 'frames', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
window.location.assign(url);
}
function createFramePopup( eventId, frameId, width, height ) {
function openFrame( eventId, frameId, width, height ) {
var url = '?view=frame&eid='+eventId+'&fid='+frameId;
var name = 'zmFrame';
var popupSize = getPopupSize( 'frame', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
window.location.assign(url);
}
function windowToFront() {
@ -345,7 +240,7 @@ if ( currentView != 'none' && currentView != 'login' ) {
$j(document).ready(function() {
// Load the Logout and State modals into the dom
getLogoutModal();
$j('#logoutButton').click(getLogoutModal());
if ( canEditSystem ) $j('#stateModalBtn').click(getStateModal);
// Trigger autorefresh of the widget bar stats on the navbar
@ -429,13 +324,20 @@ if ( currentView != 'none' && currentView != 'login' ) {
});
});
// After retieving modal html via Ajax, this will insert it into the DOM
function insertModalHtml(name, html) {
var modal = $j('#' + name);
if ( modal.length ) {
modal.replaceWith(html);
} else {
$j("body").append(html);
}
}
// Manage the modal html we received after user clicks help link
function optionhelpModal(data) {
if ( $j('#optionhelp').length ) {
$j('#optionhelp').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('optionhelp', data.html);
$j('#optionhelp').modal('show');
// Manage the CLOSE optionhelp modal button
@ -577,17 +479,6 @@ function confirmDelete( message ) {
return ( confirm( message?message:'Are you sure you wish to delete?' ) );
}
if ( refreshParent ) {
refreshParentWindow();
}
if ( focusWindow ) {
windowToFront();
}
if ( closePopup ) {
closeWindow();
}
window.addEventListener( 'DOMContentLoaded', checkSize );
function convertLabelFormat(LabelFormat, monitorName) {
@ -759,11 +650,7 @@ function reminderClickFunction() {
function enoperm() {
$j.getJSON(thisUrl + '?request=modal&modal=enoperm')
.done(function(data) {
if ( $j('#ENoPerm').length ) {
$j('#ENoPerm').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('ENoPerm', data.html);
$j('#ENoPerm').modal('show');
// Manage the CLOSE optionhelp modal button
@ -777,11 +664,7 @@ function enoperm() {
function getLogoutModal() {
$j.getJSON(thisUrl + '?request=modal&modal=logout')
.done(function(data) {
if ( $j('#modalLogout').length ) {
$j('#modalLogout').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('modalLogout', data.html);
})
.fail(logAjaxFail);
}
@ -789,11 +672,7 @@ function getLogoutModal() {
function getStateModal() {
$j.getJSON(thisUrl + '?request=modal&modal=state')
.done(function(data) {
if ( $j('#modalState').length ) {
$j('#modalState').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('modalState', data.html);
$j('#modalState').modal('show');
manageStateModalBtns();
})
@ -878,11 +757,7 @@ function getModal(id) {
return;
}
if ( $j('#'+id).length ) {
$j('#'+id).replaceWith(data.html);
} else {
$j('body').append(data.html);
}
insertModalHtml(id, data.html);
manageModalBtns(id);
modal = $j('#'+id+'Modal');
if ( ! modal.length ) {
@ -956,3 +831,36 @@ function exportEvent() {
.fail(logAjaxFail);
$j('#exportProgress').removeClass( 'invisible' );
}
// Loads the shutdown modal
function getShutdownModal() {
$j.getJSON(thisUrl + '?request=modal&modal=shutdown')
.done(function(data) {
insertModalHtml('shutdownModal', data.html);
dataOnClickThis();
$j('#shutdownModal').modal('show');
})
.fail(logAjaxFail);
}
function manageShutdownBtns(element) {
var cmd = element.getAttribute('data-command');
var when = $j('#when1min').is(':checked') ? '1min' : 'now';
var respText = $j('#respText');
$j.getJSON(thisUrl + '?request=shutdown&when=' + when + '&command=' + cmd)
.done(function(data) {
respText.removeClass('invisible');
if ( data.rc ) {
respText.html('<h2>Error</h2>' + data.output);
} else {
$j('#cancelBtn').prop('disabled', false);
if ( cmd == 'cancel' ) {
respText.html('<h2>Success</h2>Event has been cancelled');
} else {
respText.html('<h2>Success</h2>You may cancel this shutdown by clicking ' + cancelString);
}
}
})
.fail(logAjaxFail);
}

View File

@ -31,6 +31,7 @@ var currentView = '<?php echo $view ?>';
var exportProgressString = '<?php echo addslashes(translate('Exporting')) ?>';
var exportFailedString = '<?php echo translate('ExportFailed') ?>';
var exportSucceededString = '<?php echo translate('ExportSucceeded') ?>';
var cancelString = '<?php echo translate('Cancel') ?>';
<?php
/* We can't trust PHP_SELF on a path like /index.php/"%3E%3Cimg src=x onerror=prompt('1');%3E which
will still load index.php but will include the arbitrary payload after `.php/`. To mitigate this,

View File

@ -122,7 +122,7 @@ if ( isset($_COOKIE['zmCycleHeight']) and $_COOKIE['zmCycleHeight'] ) {
session_write_close();
ZM\Logger::Debug(print_r($options,true));
ZM\Debug(print_r($options,true));
noCacheHeaders();
xhtmlHeaders(__FILE__, translate('CycleWatch'));

View File

@ -211,7 +211,12 @@ if ( ($codec == 'MP4' || $codec == 'auto' ) && $Event->DefaultVideo() ) {
style="transform: matrix(1, 0, 0, 1, 0, 0);"
<?php echo $scale ? 'width="'.reScale($Event->Width(), $scale).'"' : '' ?>
<?php echo $scale ? 'height="'.reScale($Event->Height(), $scale).'"' : '' ?>
data-setup='{ "controls": true, "autoplay": true, "preload": "auto", "plugins": { "zoomrotate": { "zoom": "<?php echo $Zoom ?>"}}}'
data-setup='{ "controls": true, "autoplay": true, "preload": "auto", "playbackRates": [ <?php echo implode(',',
array_map(function($r){return $r/100;},
array_filter(
array_keys($rates),
function($r){return $r >= 0 ? true : false;},
))) ?>], "plugins": { "zoomrotate": { "zoom": "<?php echo $Zoom ?>"}}}'
>
<source src="<?php echo $Event->getStreamSrc(array('mode'=>'mpeg','format'=>'h264'),'&amp;'); ?>" type="video/mp4">
<track id="monitorCaption" kind="captions" label="English" srclang="en" src='data:plain/text;charset=utf-8,"WEBVTT\n\n 00:00:00.000 --> 00:00:01.000 ZoneMinder"' default/>
@ -274,7 +279,7 @@ if ( (ZM_WEB_STREAM_METHOD == 'mpeg') && ZM_MPEG_LIVE_FORMAT ) {
<span id="mode"><?php echo translate('Mode') ?>: <span id="modeValue">Replay</span></span>
<span id="rate"><?php echo translate('Rate') ?>:
<?php
$rates = array( -800=>'-8x', -400=>'-4x', -200=>'-2x', -100=>'-1x', 0=>translate('Stop'), 100 => '1x', 200=>'2x', 400=>'4x', 800=>'8x' );
#rates are defined in skins/classic/includes/config.php
echo htmlSelect('rate', $rates, intval($rate), array('id'=>'rateValue'));
?>
<!--<span id="rateValue"><?php echo $rate/100 ?></span>x</span>-->

View File

@ -42,7 +42,7 @@ if ( isset($_REQUEST['filter'])) {
parseSort();
$filterQuery = $filter->querystring();
ZM\Logger::Debug('Filter '.print_r($filter, true));
ZM\Debug('Filter '.print_r($filter, true));
if ( $filter->sql() ) {
$eventsSql .= ' AND ('.$filter->sql().')';
@ -58,14 +58,14 @@ $limit = isset($_REQUEST['limit']) ? validInt($_REQUEST['limit']) : $filter['lim
if ( $_POST ) {
// I think this is basically so that a refresh doesn't repost
ZM\Logger::Debug('Redirecting to ' . $_SERVER['REQUEST_URI']);
ZM\Debug('Redirecting to ' . $_SERVER['REQUEST_URI']);
header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
exit();
}
$failed = !$filter->test_pre_sql_conditions();
if ( $failed ) {
ZM\Logger::Debug('Pre conditions failed, not doing sql');
ZM\Debug('Pre conditions failed, not doing sql');
}
$results = $failed ? null : dbQuery($eventsSql);
@ -75,13 +75,13 @@ if ( ! $results ) {
global $error_message;
$error_message = dbError($eventsSql);
}
ZM\Logger::Debug("Pre conditions succeeded sql return $nEvents events");
ZM\Debug("Pre conditions succeeded sql return $nEvents events");
if ( !empty($limit) && ($nEvents > $limit) ) {
$nEvents = $limit;
}
$pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE);
#Logger::Debug("Page $page Limit $limit #vents: $nEvents pages: $pages ");
#Debug("Page $page Limit $limit #vents: $nEvents pages: $pages ");
if ( !empty($page) ) {
if ( $page < 0 )
$page = 1;
@ -121,6 +121,7 @@ getBodyTopHTML();
<button id="backBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Back') ?>" disabled><i class="fa fa-arrow-left"></i></button>
<button id="refreshBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Refresh') ?>" ><i class="fa fa-refresh"></i></button>
<button id="tlineBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('ShowTimeline') ?>" ><i class="fa fa-history"></i></button>
<button id="filterBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Filter') ?>"><i class="fa fa-filter"></i></button>
<button id="viewBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('View') ?>" disabled><i class="fa fa-binoculars"></i></button>
<button id="archiveBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Archive') ?>" disabled><i class="fa fa-archive"></i></button>
<button id="unarchiveBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Unarchive') ?>" disabled><i class="fa fa-file-archive-o"></i></button>
@ -211,7 +212,7 @@ if ( $results ) {
if ( $limit and (count($events) >= $limit) ) {
break;
}
ZM\Logger::Debug("Have " . count($events) . " events, limit $limit");
ZM\Debug("Have " . count($events) . " events, limit $limit");
}
foreach ( $events as $event ) {

View File

@ -34,6 +34,14 @@ parseSort();
$filterNames = array(''=>translate('ChooseFilter'));
$filter = NULL;
$fid = 0;
if ( isset($_REQUEST['Id']) ) {
$fid = validInt($_REQUEST['Id']);
} else if ( isset($_REQUEST['filter[Id]']) ) {
$fid = validInt($_REQUEST['filter[Id]']);
ZM\Warning("got fid by object id $fid");
}
foreach ( ZM\Filter::find(null,array('order'=>'lower(Name)')) as $Filter ) {
$filterNames[$Filter->Id()] = $Filter->Id() . ' ' . $Filter->Name();
if ( $Filter->Background() )
@ -41,7 +49,7 @@ foreach ( ZM\Filter::find(null,array('order'=>'lower(Name)')) as $Filter ) {
if ( $Filter->Concurrent() )
$filterNames[$Filter->Id()] .= '&';
if ( isset($_REQUEST['Id']) && ($_REQUEST['Id'] == $Filter->Id()) ) {
if ( $fid == $Filter->Id() ) {
$filter = $Filter;
}
}
@ -52,6 +60,8 @@ if ( !$filter ) {
# Update our filter object with whatever changes we have made before saving
$filter->set($_REQUEST['filter']);
}
} else {
ZM\Debug('filter: ' . print_r($filter,true));
}
$conjunctionTypes = ZM\getFilterQueryConjunctionTypes();
@ -215,13 +225,13 @@ if ( (null !== $filter->Concurrent()) and $filter->Concurrent() )
</p>
<?php if ( ZM_OPT_USE_AUTH ) { ?>
<p><label><?php echo translate('FilterUser') ?></label>
<?php
<?php
global $user;
echo htmlSelect('filter[UserId]',
ZM\User::Indexed_By_Id(),
//ZM\User::find(),
$filter->UserId() ? $filter->UserId() : $user['Id']
); ?>
echo htmlSelect('filter[UserId]',
ZM\User::Indexed_By_Id(),
$filter->UserId() ? $filter->UserId() : $user['Id']
);
?>
</p>
<?php } ?>
<p>
@ -233,7 +243,7 @@ for ( $i=0; $i < count($terms); $i++ ) {
if ( ! isset( $term['op'] ) )
$term['op'] = '=';
if ( ! isset( $term['attr'] ) )
$term['attr'] = '';
$term['attr'] = 'Id';
if ( ! isset( $term['val'] ) )
$term['val'] = '';
if ( ! isset( $term['cnj'] ) )
@ -345,7 +355,7 @@ for ( $i=0; $i < count($terms); $i++ ) {
</td>
</tr>
<?php
} # end foreach filter
} # end foreach term
?>
</tbody>
</table>
@ -392,6 +402,10 @@ echo htmlSelect( 'filter[Query][sort_asc]', $sort_dirns, $filter->sort_asc() );
<label><?php echo translate('FilterArchiveEvents') ?></label>
<input type="checkbox" name="filter[AutoArchive]" value="1"<?php if ( $filter->AutoArchive() ) { ?> checked="checked"<?php } ?> data-on-click-this="updateButtons"/>
</p>
<p>
<label><?php echo translate('FilterUnarchiveEvents') ?></label>
<input type="checkbox" name="filter[AutoUnarchive]" value="1"<?php if ( $filter->AutoUnarchive() ) { ?> checked="checked"<?php } ?> data-on-click-this="updateButtons"/>
</p>
<p><label><?php echo translate('FilterUpdateDiskSpace') ?></label>
<input type="checkbox" name="filter[UpdateDiskSpace]" value="1"<?php echo !$filter->UpdateDiskSpace() ? '' : ' checked="checked"' ?> data-on-click-this="updateButtons"/>
</p>

View File

@ -173,11 +173,7 @@ function initPage() {
if ( showDonatePopup ) {
$j.getJSON(thisUrl + '?request=modal&modal=donate')
.done(function(data) {
if ( $j('#donate').length ) {
$j('#donate').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('donate', data.html);
$j('#donate').modal('show');
// Manage the Apply button
$j('#donateApplyBtn').click(function(evt) {
@ -203,11 +199,7 @@ function initPage() {
// Load the Function modal on page load
$j.getJSON(thisUrl + '?request=modal&modal=function')
.done(function(data) {
if ( $j('#modalFunction').length ) {
$j('#modalFunction').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('modalFunction', data.html);
// Manage the Function modal
manageFunctionModal();
})

View File

@ -34,11 +34,7 @@ function getIdSelections() {
function getDelConfirmModal(key) {
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm&key=' + key)
.done(function(data) {
if ( $j('#deleteConfirm').length ) {
$j('#deleteConfirm').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
})
.fail(logAjaxFail);

View File

@ -18,7 +18,7 @@ monitorData[monitorData.length] = {
'width': <?php echo $monitor->ViewWidth() ?>,
'height':<?php echo $monitor->ViewHeight() ?>,
'url': '<?php echo $monitor->UrlToIndex() ?>',
'onclick': function(){createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->ViewWidth(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->ViewHeight(), $monitor->PopupScale() ); ?> );},
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );},
'type': '<?php echo $monitor->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>'
};

View File

@ -6,11 +6,7 @@ var deleteBtn = $j('#deleteBtn');
function getDeviceModal(did) {
$j.getJSON(thisUrl + '?request=modal&modal=device&did=' + did)
.done(function(data) {
if ( $j('#deviceModal').length ) {
$j('#deviceModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('deviceModal', data.html);
$j('#deviceModal').modal('show');
// Manage the Save button
$j('#deviceSaveBtn').click(function(evt) {
@ -37,11 +33,7 @@ function enableDeviceModal() {
function getDelConfirmModal(key) {
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm&key=' + key)
.done(function(data) {
if ( $j('#deleteConfirm').length ) {
$j('#deleteConfirm').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
})
.fail(logAjaxFail);

View File

@ -209,10 +209,14 @@ function changeRate() {
vid.currentTime(vid.currentTime() - (revSpeed/2)); //Half of reverse speed because our interval is 500ms.
}
}, 500); //500ms is a compromise between smooth reverse and realistic performance
} else {
streamReq.send(streamParms+"&command="+CMD_VARPLAY+"&rate="+rate);
} // end if vid
} else { // Forward rate
if ( vid ) {
vid.playbackRate(rate/100);
} else {
streamReq.send(streamParms+"&command="+CMD_VARPLAY+"&rate="+rate);
}
}
Cookie.write('zmEventRate', rate, {duration: 10*365, samesite: 'strict'});
@ -434,14 +438,14 @@ function streamFastRev( action ) {
function streamPrev(action) {
if ( action ) {
$j(".vjsMessage").remove();
location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery + '&popup='+popup);
location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery);
return;
if ( vid && PrevEventDefVideoPath.indexOf("view_video") > 0 ) {
CurEventDefVideoPath = PrevEventDefVideoPath;
eventQuery(prevEventId);
} else if (zmsBroke || (vid && PrevEventDefVideoPath.indexOf("view_video") < 0) || $j("#vjsMessage").length || PrevEventDefVideoPath.indexOf("view_video") > 0) {//zms broke, leaving videojs, last event, moving to videojs
location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery + '&popup='+popup);
location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery);
} else {
streamReq.send(streamParms+"&command="+CMD_PREV);
streamPlay();
@ -463,13 +467,13 @@ function streamNext(action) {
// We used to try to dynamically update all the bits in the page, which is really complex
// How about we just reload the page?
//
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery + '&popup='+popup);
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
return;
if ( vid && ( NextEventDefVideoPath.indexOf("view_video") > 0 ) ) { //on and staying with videojs
CurEventDefVideoPath = NextEventDefVideoPath;
eventQuery(nextEventId);
} else if ( zmsBroke || (vid && NextEventDefVideoPath.indexOf("view_video") < 0) || NextEventDefVideoPath.indexOf("view_video") > 0) {//reload zms, leaving vjs, moving to vjs
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery + '&popup='+popup);
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
} else {
streamReq.send(streamParms+"&command="+CMD_NEXT);
streamPlay();
@ -957,11 +961,7 @@ function renameEvent() {
function editEvent() {
$j.getJSON(thisUrl + '?request=modal&modal=eventdetail&eid='+eventData.Id)
.done(function(data) {
if ( $j('#eventDetailModal').length ) {
$j('#eventDetailModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('eventDetailModal', data.html);
$j('#eventDetailModal').modal('show');
// Manage the Save button
$j('#eventDetailSaveBtn').click(function(evt) {

View File

@ -16,6 +16,7 @@
var CMD_NONE = <?php echo CMD_NONE ?>;
var CMD_PAUSE = <?php echo CMD_PAUSE ?>;
var CMD_PLAY = <?php echo CMD_PLAY ?>;
var CMD_VARPLAY = <?php echo CMD_VARPLAY ?>;
var CMD_STOP = <?php echo CMD_STOP ?>;
var CMD_FASTFWD = <?php echo CMD_FASTFWD ?>;
var CMD_SLOWFWD = <?php echo CMD_SLOWFWD ?>;

View File

@ -39,11 +39,7 @@ function getArchivedSelections() {
function getDelConfirmModal() {
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm')
.done(function(data) {
if ( $j('#deleteConfirm').length ) {
$j('#deleteConfirm').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
})
.fail(logAjaxFail);
@ -77,11 +73,7 @@ function manageDelConfirmModalBtns() {
function getEventDetailModal(eid) {
$j.getJSON(thisUrl + '?request=modal&modal=eventdetail&eids[]=' + eid)
.done(function(data) {
if ( $j('#eventDetailModal').length ) {
$j('#eventDetailModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('eventDetailModal', data.html);
$j('#eventDetailModal').modal('show');
// Manage the Save button
$j('#eventDetailSaveBtn').click(function(evt) {
@ -157,6 +149,12 @@ function initPage() {
window.location.assign('?view=timeline'+filterQuery);
});
// Manage the FILTER Button
document.getElementById("filterBtn").addEventListener("click", function onFilterClick(evt) {
evt.preventDefault();
window.location.assign('?view=filter'+filterQuery);
});
// Manage the VIEW button
document.getElementById("viewBtn").addEventListener("click", function onViewClick(evt) {
var selections = getIdSelections();
@ -212,11 +210,7 @@ function initPage() {
evt.preventDefault();
$j.getJSON(thisUrl + '?request=modal&modal=eventdetail&eids[]='+selections.join('&eids[]='))
.done(function(data) {
if ( $j('#eventDetailModal').length ) {
$j('#eventDetailModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('eventDetailModal', data.html);
$j('#eventDetailModal').modal('show');
// Manage the Save button
$j('#eventDetailSaveBtn').click(function(evt) {
@ -242,11 +236,7 @@ function initPage() {
evt.preventDefault();
$j.getJSON(thisUrl + '?request=modal&modal=download&eids[]='+selections.join('&eids[]='))
.done(function(data) {
if ( $j('#downloadModal').length ) {
$j('#downloadModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('downloadModal', data.html);
$j('#downloadModal').modal('show');
// Manage the GENERATE DOWNLOAD button
$j('#exportButton').click(exportEvent);

View File

@ -83,11 +83,7 @@ function exportEvents( ) {
function getEventDetailModal(eid) {
$j.getJSON(thisUrl + '?request=modal&modal=eventdetail&eids[]=' + eid)
.done(function(data) {
if ( $j('#eventDetailModal').length ) {
$j('#eventDetailModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('eventDetailModal', data.html);
$j('#eventDetailModal').modal('show');
// Manage the Save button
$j('#eventDetailSaveBtn').click(function(evt) {

View File

@ -56,6 +56,7 @@ function validateForm(form) {
} else if ( form.elements['filter[Background]'].checked ) {
if ( ! (
form.elements['filter[AutoArchive]'].checked ||
form.elements['filter[AutoUnarchive]'].checked ||
form.elements['filter[UpdateDiskSpace]'].checked ||
form.elements['filter[AutoVideo]'].checked ||
form.elements['filter[AutoEmail]'].checked ||
@ -79,6 +80,8 @@ function updateButtons(element) {
var canExecute = false;
if ( form.elements['filter[AutoArchive]'] && form.elements['filter[AutoArchive]'].checked ) {
canExecute = true;
} else if ( form.elements['filter[AutoUnarchive]'] && form.elements['filter[AutoUnarchive]'].checked ) {
canExecute = true;
} else if ( form.elements['filter[AutoCopy]'] && form.elements['filter[AutoCopy]'].checked ) {
canExecute = true;
} else if ( form.elements['filter[AutoMove]'] && form.elements['filter[AutoMove]'].checked ) {
@ -171,7 +174,6 @@ function submitToMontageReview(element) {
function submitToExport(element) {
var form = element.form;
window.location.assign('?view=export&'+$j(form).serialize());
//createPopup('?view=export&filter_id='+form.elements['Id'].value, 'zmExport', 'export' );
}
function executeFilter( element ) {
@ -408,13 +410,7 @@ function getModal(id) {
return;
}
if ( $j('#'+id).length ) {
console.log("replacing");
$j('#'+id).replaceWith(data.html);
} else {
console.log("Adding to body"+data.html);
$j('body').append(data.html);
}
insertModalHtml(id, data.html);
manageModalBtns(id);
modal = $j('#'+id+'Modal');
if ( ! modal.length ) {

View File

@ -2,11 +2,7 @@
function newGroup() {
$j.getJSON(thisUrl + '?request=modal&modal=group')
.done(function(data) {
if ( $j('#groupModal').length ) {
$j('#groupModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('groupdModal', data.html);
$j('#groupModal').modal('show');
$j('.chosen').chosen("destroy");
$j('.chosen').chosen();
@ -32,11 +28,7 @@ function editGroup( element ) {
} else {
$j.getJSON(thisUrl + '?request=modal&modal=group&gid=' + gid)
.done(function(data) {
if ( $j('#groupModal').length ) {
$j('#groupModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('groupModal', data.html);
$j('#groupModal').modal('show');
$j('.chosen').chosen("destroy");
$j('.chosen').chosen();

View File

@ -37,7 +37,7 @@ monitorData[monitorData.length] = {
'width': <?php echo $monitor->ViewWidth() ?>,
'height':<?php echo $monitor->ViewHeight() ?>,
'url': '<?php echo $monitor->UrlToIndex( ZM_MIN_STREAMING_PORT ? ($monitor->Id() + ZM_MIN_STREAMING_PORT) : '') ?>',
'onclick': function(){createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->ViewWidth(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->ViewHeight(), $monitor->PopupScale() ); ?> );},
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );},
'type': '<?php echo $monitor->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>'
};

View File

@ -739,11 +739,7 @@ function click_panright() {
function click_download() {
$j.getJSON(thisUrl + '?request=modal&modal=download')
.done(function(data) {
if ( $j('#downloadModal').length ) {
$j('#downloadModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('downloadModal', data.html);
$j('#downloadModal').modal('show');
// Manage the GENERATE DOWNLOAD button
$j('#exportButton').click(exportEvent);

View File

@ -2,11 +2,7 @@
function getServerModal(sid) {
$j.getJSON(thisUrl + '?request=modal&modal=server&id=' + sid)
.done(function(data) {
if ( $j('#ServerModal').length ) {
$j('#ServerModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('ServerModal', data.html);
$j('#ServerModal').modal('show');
// Manage the Save button
$j('#serverSubmitBtn').click(function(evt) {
@ -33,11 +29,7 @@ function enableServerModal() {
function getStorageModal(sid) {
$j.getJSON(thisUrl + '?request=modal&modal=storage&id=' + sid)
.done(function(data) {
if ( $j('#storageModal').length ) {
$j('#storageModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('storageModal', data.html);
$j('#storageModal').modal('show');
// Manage the Save button
$j('#storageSubmitBtn').click(function(evt) {

View File

@ -1,3 +1,7 @@
var backBtn = $j('#backBtn');
var settingsBtn = $j('#settingsBtn');
var enableAlmBtn = $j('#enableAlmBtn');
var forceAlmBtn = $j('#forceAlmBtn');
function showEvents() {
$('ptzControls').addClass('hidden');
@ -202,22 +206,22 @@ function getStreamCmdResponse(respObj, respText) {
if ( canEditMonitors ) {
if ( streamStatus.enabled ) {
$('enableAlarmsLink').addClass('hidden');
$('disableAlarmsLink').removeClass('hidden');
enableAlmBtn.addClass('disabled');
enableAlmBtn.prop('title', disableAlarmsStr);
if ( streamStatus.forced ) {
$('forceAlarmLink').addClass('hidden');
$('cancelAlarmLink').removeClass('hidden');
forceAlmBtn.addClass('disabled');
forceAlmBtn.prop('title', cancelForcedAlarmStr);
} else {
$('forceAlarmLink').removeClass('hidden');
$('cancelAlarmLink').addClass('hidden');
forceAlmBtn.removeClass('disabled');
forceAlmBtn.prop('title', forceAlarmStr);
}
$('forceCancelAlarm').removeClass('hidden');
forceAlmBtn.prop('disabled', false);
} else {
$('enableAlarmsLink').removeClass('hidden');
$('disableAlarmsLink').addClass('hidden');
$('forceCancelAlarm').addClass('hidden');
enableAlmBtn.removeClass('disabled');
enableAlmBtn.prop('title', enableAlarmsStr);
forceAlmBtn.prop('disabled', true);
}
$('enableDisableAlarms').removeClass('hidden');
enableAlmBtn.prop('disabled', false);
} // end if canEditMonitors
if ( streamStatus.auth ) {
@ -468,6 +472,14 @@ function cmdEnableAlarms() {
alarmCmdReq.send(alarmCmdParms+"&command=enableAlarms");
}
function cmdAlarm() {
if ( enableAlmBtn.hasClass('disabled') ) {
cmdEnableAlarms();
} else {
cmdDisableAlarms();
}
}
function cmdForceAlarm() {
alarmCmdReq.send(alarmCmdParms+"&command=forceAlarm");
if ( window.event ) {
@ -483,6 +495,14 @@ function cmdCancelForcedAlarm() {
return false;
}
function cmdForce() {
if ( forceAlmBtn.hasClass('disabled') ) {
cmdCancelForcedAlarm();
} else {
cmdForceAlarm();
}
}
function getActResponse( respObj, respText ) {
if ( respObj.result == 'Ok' ) {
if ( respObj.refreshParent && window.opener ) {
@ -562,11 +582,9 @@ function getEventCmdResponse( respObj, respText ) {
var link = new Element('a', {
'href': '#',
'events': {
'click': createEventPopup.pass( [
'click': openEvent.pass( [
zm_event.Id,
'&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1',
zm_event.Width,
zm_event.Height
'&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1'
] )
}
});
@ -576,11 +594,9 @@ function getEventCmdResponse( respObj, respText ) {
link = new Element('a', {
'href': '#',
'events': {
'click': createEventPopup.pass( [
'click': openEvent.pass( [
zm_event.Id,
'&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1',
zm_event.Width,
zm_event.Height
'&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1'
] )
}
});
@ -590,11 +606,11 @@ function getEventCmdResponse( respObj, respText ) {
row.getElement('td.colTime').set('text', zm_event.StartTime);
row.getElement('td.colSecs').set('text', zm_event.Length);
link = new Element('a', {'href': '#', 'events': {'click': createFramesPopup.pass( [zm_event.Id, zm_event.Width, zm_event.Height] )}});
link = new Element('a', {'href': '#', 'events': {'click': openFrames.pass( [zm_event.Id] )}});
link.set('text', zm_event.Frames+'/'+zm_event.AlarmFrames);
link.inject(row.getElement('td.colFrames'));
link = new Element('a', {'href': '#', 'events': {'click': createFramePopup.pass( [zm_event.Id, '0', zm_event.Width, zm_event.Height] )}});
link = new Element('a', {'href': '#', 'events': {'click': openFrame.pass( [zm_event.Id, '0'] )}});
link.set('text', zm_event.AvgScore+'/'+zm_event.MaxScore);
link.inject(row.getElement('td.colScore'));
@ -830,11 +846,7 @@ function updatePresetLabels() {
function getCtrlPresetModal() {
$j.getJSON(thisUrl + '?request=modal&modal=controlpreset&mid=' + monitorId)
.done(function(data) {
if ( $j('#ctrlPresetModal').length ) {
$j('#ctrlPresetModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('ctrlPresetModal', data.html);
updatePresetLabels();
// Manage the Preset Select box
$j('#preset').change(updatePresetLabels);
@ -850,11 +862,7 @@ function getCtrlPresetModal() {
function getSettingsModal() {
$j.getJSON(thisUrl + '?request=modal&modal=settings&mid=' + monitorId)
.done(function(data) {
if ( $j('#settingsModal').length ) {
$j('#settingsModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
insertModalHtml('settingsModal', data.html);
// Manage the Save button
$j('#settingsSubmitModal').click(function(evt) {
evt.preventDefault();
@ -916,6 +924,29 @@ function initPage() {
} else if ( monitorRefresh > 0 ) {
setInterval(reloadWebSite, monitorRefresh*1000);
}
// Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
evt.preventDefault();
window.history.back();
});
// Don't enable the back button if there is no previous zm page to go back to
backBtn.prop('disabled', !document.referrer.length);
// Manage the REFRESH Button
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
evt.preventDefault();
window.location.reload(true);
});
// Manage the SETTINGS button
document.getElementById("settingsBtn").addEventListener("click", function onSettingsClick(evt) {
evt.preventDefault();
$j('#settingsModal').modal('show');
});
// Only enable the settings button for local cameras
settingsBtn.prop('disabled', !(monitorType == 'Local' && canViewControl));
}
// Kick everything off

View File

@ -24,6 +24,11 @@ stateStrings[STATE_TAPE] = "<?php echo translate('Record') ?>";
var deleteString = "<?php echo translate('Delete') ?>";
var enableAlarmsStr = "<?php echo translate('EnableAlarms') ?>";
var disableAlarmsStr = "<?php echo translate('DisableAlarms') ?>";
var forceAlarmStr = "<?php echo translate('ForceAlarm') ?>";
var cancelForcedAlarmStr = "<?php echo translate('CancelForcedAlarm') ?>";
var CMD_NONE = <?php echo CMD_NONE ?>;
var CMD_PAUSE = <?php echo CMD_PAUSE ?>;
var CMD_PLAY = <?php echo CMD_PLAY ?>;

View File

@ -439,10 +439,8 @@ function drawZonePoints() {
});
var style = imageFrame.currentStyle || window.getComputedStyle(imageFrame);
scale = (imageFrame.clientWidth - ( style.paddingLeft.toInt() + style.paddingRight.toInt() )) / maxX;
console.log("Scale = width: " + imageFrame.clientWidth);
for ( var i = 0; i < zone['Points'].length; i++ ) {
console.log("scale: " + scale + " x " + zone['Points'][i].x + " = " + Math.round(zone['Points'][i].x * scale));
var div = new Element('div', {
'id': 'point'+i,
'data-point-index': i,
@ -470,12 +468,9 @@ function drawZonePoints() {
} );
for ( var i = 0; i < zone['Points'].length; i++ ) {
var row;
row = new Element('tr', {'id': 'row'+i});
var row = new Element('tr', {'id': 'row'+i});
row.addEvent('mouseover', highlightOn.pass(i));
row.addEvent('mouseout', highlightOff.pass(i));
//row.onmouseover = highlightOn.pass(i)
//row.onmouseout = window['highlightOff'].bind(div, div);
var cell = new Element('td');
cell.set('text', i+1);
cell.inject(row);
@ -669,6 +664,8 @@ function initPage() {
el.addEventListener("load", imageLoadEvent, {passive: true});
});
window.addEventListener("resize", drawZonePoints, {passive: true});
// if the image link is broken for some reason we won't draw the points, so do it manually
drawZonePoints();
// Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {

View File

@ -835,6 +835,7 @@ include('_monitor_source_nvsocket.php');
'1600x1200'=>'1600x1200 2MP',
'1920x1080'=>'1920x1080 1080p',
'2048x1536'=>'2048x1536 3MP',
'2560x1440'=>'2560x1440 1440p QHD WQHD',
'2592x1944'=>'2592x1944 5MP',
'3840x2160'=>'3840x2160 4K UHD',
), $monitor->Width().'x'.$monitor->Height()

View File

@ -79,7 +79,7 @@ if ( $layout_id and is_numeric($layout_id) and isset($layoutsById[$layout_id]) )
$Layout = $layoutsById[$layout_id];
$Positions = json_decode($Layout->Positions(), true);
} else {
ZM\Logger::Debug('Layout not found');
ZM\Debug('Layout not found');
}
if ( $Layout and ( $Layout->Name() != 'Freeform' ) ) {
// Use layout instead of other options

View File

@ -42,7 +42,7 @@ function execONVIF($cmd) {
$shell_command"
);
} else {
ZM\Logger::Debug('Results from probe: '.implode('<br/>', $output));
ZM\Debug('Results from probe: '.implode('<br/>', $output));
}
return $output;
@ -80,7 +80,7 @@ function probeCameras($localIp) {
$camera['monitor']['Notes'] .= $tokens[1].'='.$tokens[2]."\n";
// $camera['location'] = $tokens[2];
} else {
ZM\Logger::Debug('Unknown token '.$tokens[1].' = '.$tokens[2]);
ZM\Debug('Unknown token '.$tokens[1].' = '.$tokens[2]);
}
}
} // end foreach token
@ -119,7 +119,7 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
);
$profiles[] = $profile;
} else {
ZM\Logger::Debug("Line did not match preg: $line");
ZM\Debug("Line did not match preg: $line");
}
} // end foreach line
} // end if results from execONVIF
@ -187,7 +187,7 @@ if ( !isset($_REQUEST['step']) || ($_REQUEST['step'] == '1') ) {
if ( $matches[1] != 'lo' ) {
$interfaces[$matches[1]] = $matches[1];
} else {
ZM\Logger::Debug("No match for $line");
ZM\Debug("No match for $line");
}
}
}
@ -247,7 +247,7 @@ if ( !isset($_REQUEST['step']) || ($_REQUEST['step'] == '1') ) {
#empty($_REQUEST['password']) )
$probe = json_decode(base64_decode($_REQUEST['probe']));
ZM\Logger::Debug(print_r($probe, true));
ZM\Debug(print_r($probe, true));
foreach ( $probe as $name=>$value ) {
if ( isset($value) ) {
$monitor[$name] = $value;

View File

@ -156,7 +156,7 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
$userMonitors[] = $monitors[$monitorId]['Name'];
}
}
ZM\Logger::Debug("monitors: ".$user_row['Username'] . ' ' . $user_row['MonitorIds']. ' :' . print_r($userMonitors, true));
ZM\Debug("monitors: ".$user_row['Username'] . ' ' . $user_row['MonitorIds']. ' :' . print_r($userMonitors, true));
?>
<tr>
<td class="colUsername"><?php echo makeLink('?view=user&amp;uid='.$user_row['Id'], validHtmlStr($user_row['Username']).($user['Username']==$user_row['Username']?'*':''), $canEdit) ?></td>

View File

@ -62,7 +62,7 @@ if ( count($selected_monitor_ids) ) {
}
parseFilter($filter);
$filterQuery = $filter['query'];
ZM\Logger::Debug($filterQuery);
ZM\Debug($filterQuery);
$eventsSql = 'SELECT *,
UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs,
@ -94,7 +94,7 @@ while ( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
if ( count($EventsByMonitor[$event['MonitorId']]['Events']) ) {
$last_event = end($EventsByMonitor[$event['MonitorId']]['Events']);
#Logger::Debug(print_r($last_event,true));
#Debug(print_r($last_event,true));
$gap = $last_event->EndTimeSecs() - $event['StartTimeSecs'];
if ( $gap < $EventsByMonitor[$event['MonitorId']]['MinGap'] )

View File

@ -1,79 +0,0 @@
<?php
//
// ZoneMinder web shutdown view file
// Copyright (C) 2019 ZoneMinder LLC
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canEdit('System') ) {
$view = 'error';
return;
}
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Shutdown').' '.translate('Restart'));
?>
<body>
<div id="page">
<div id="header">
<h2><?php echo translate('Shutdown').' '.translate('Restart') ?></h2>
</div>
<div id="content">
<?php
if ( !defined('ZM_PATH_SHUTDOWN') or ZM_PATH_SHUTDOWN == '' ) {
echo '<div class="error">ZM_PATH_SHUTDOWN is not defined. This is normally configured in /etc/zm/conf.d/01-system-paths.conf</div>';
} else if ( !file_exists(ZM_PATH_SHUTDOWN) ) {
echo '<div class="error">Path does not exist for ZM_PATH_SHUTDOWN. Current value is '.ZM_PATH_SHUTDOWN.'</div>';
} else {
?>
<form name="contentForm" id="contentForm" method="post" action="?">
<input type="hidden" name="view" value="shutdown"/>
<?php
if ( isset($output) ) {
echo '<p>'.implode('<br/>', $output).'</p>';
}
if ( isset($_POST['when']) and ($_POST['when'] != 'NOW') and ($action != 'cancel') ) {
echo '<p>You may cancel this shutdown by clicking '.translate('Cancel').'</p>';
}
?>
<p class="warning"><h2>Warning</h2>
This command will either shutdown or restart all ZoneMinder Servers<br/>
</p>
<p>
<input type="radio" name="when" value="now" id="whennow"/><label for="whennow">Now</label>
<input type="radio" name="when" value="1min" id="when1min" checked="checked"/><label for="when1min">1 Minute</label>
</p>
<div id="contentButtons">
<?php
if ( isset($_POST['when']) and ($_POST['when'] != 'NOW') and ($action != 'cancel') ) {
?>
<button type="submit" name="action" value="cancel"><?php echo translate('Cancel') ?></button>
<?php
}
?>
<button type="submit" name="action" value="restart"><?php echo translate('Restart') ?></button>
<button type="submit" name="action" value="shutdown"><?php echo translate('Shutdown') ?></button>
<button type="button" data-on-click="closeWindow"><?php echo translate('Close') ?></button>
</div>
</form>
<?php
} # end if PATH_SHUTDOWN looks value
?>
</div>
</div>
<?php xhtmlFooter() ?>

View File

@ -500,7 +500,7 @@ for ( $i = 0; $i < $chart['graph']['width']; $i++ ) {
} # end foreach MonitorId
} # end foreach x
//ZM\Logger::Debug(print_r( $monEventSlots,true ));
//ZM\Debug(print_r( $monEventSlots,true ));
//print_r( $monFrameSlots );
//print_r( $chart );

View File

@ -69,6 +69,7 @@ xhtmlHeaders(__FILE__, translate('User').' - '.$newUser->Username());
</div>
<div id="content" class="row justify-content-center">
<form id="contentForm" name="contentForm" method="post" action="?view=user">
<input type="hidden" name="redirect" value="<?php echo isset($_REQUEST['prev']) ? $_REQUEST['prev'] : 'options&tab=users' ?>"/>
<input type="hidden" name="uid" value="<?php echo validHtmlStr($_REQUEST['uid']) ?>"/>
<table id="contentTable" class="table">
<tbody>

View File

@ -59,23 +59,23 @@ noCacheHeaders();
xhtmlHeaders(__FILE__, $monitor->Name().' - '.translate('Feed'));
?>
<body>
<div id="page">
<?php if ( !$popup ) echo getNavBarHTML() ?>
<div id="header">
<div id="monitorName"><?php echo validHtmlStr($monitor->Name()) ?></div>
<div id="menuControls">
<?php
if ( canView('Control') && $monitor->Type() == 'Local' ) {
?>
<div id="settingsControl">
<button type="button" data-toggle="modal" data-target="#settingsModal"><?php echo translate('Settings') ?></button>
</div>
<?php
}
?>
<div id="scaleControl"><?php echo translate('Scale').': '.htmlSelect('scale', $scales, $scale, array('id'=>'scale')); ?></div>
</div>
<div id="closeControl"><a href="#" data-on-click="<?php echo $popup ? 'closeWindow' : 'backWindow' ?>"><?php echo $popup ? translate('Close') : translate('Back') ?></a></div>
<?php echo getNavBarHTML() ?>
<div class="d-flex flex-row justify-content-between px-3 py-1">
<div>
<button type="button" id="backBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Back') ?>" disabled><i class="fa fa-arrow-left"></i></button>
<button type="button" id="refreshBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Refresh') ?>" ><i class="fa fa-refresh"></i></button>
<button type="button" id="settingsBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Settings') ?>" disabled><i class="fa fa-sliders"></i></button>
<button type="button" id="enableAlmBtn" class="btn btn-normal" data-on-click="cmdAlarm" data-toggle="tooltip" data-placement="top" title="<?php echo translate('DisableAlarms') ?>" disabled><i class="fa fa-bell"></i></button>
<button type="button" id="forceAlmBtn" class="btn btn-danger" data-on-click="cmdForce" data-toggle="tooltip" data-placement="top" title="<?php echo translate('ForceAlarm') ?>" disabled><i class="fa fa-exclamation-circle"></i></button>
</div>
<div>
<h2><?php echo validHtmlStr($monitor->Name()) ?></h2>
</div>
<div>
<?php echo translate('Scale').': '.htmlSelect('scale', $scales, $scale, array('id'=>'scale')); ?>
</div>
</div>
<?php
if ( $monitor->Status() != 'Connected' and $monitor->Type() != 'WebSite' ) {
@ -94,20 +94,6 @@ if ( $streamMode == 'jpeg' ) {
<?php if ( $monitor->Type() != 'WebSite' ) { ?>
<div id="monitorStatus">
<?php if ( canEdit('Monitors') ) { ?>
<div id="enableDisableAlarms">
<button type="button" id="enableAlarmsLink" data-on-click="cmdEnableAlarms" class="hidden">
<?php echo translate('EnableAlarms') ?></button>
<button type="button" id="disableAlarmsLink" data-on-click="cmdDisableAlarms" class="hidden">
<?php echo translate('DisableAlarms') ?></button>
</div>
<div id="forceCancelAlarm">
<button type="button" id="forceAlarmLink" data-on-click="cmdForceAlarm"><?php echo translate('ForceAlarm') ?></button>
<button type="button" id="cancelAlarmLink" data-on-click="cmdCancelForcedAlarm" class="hidden"><?php echo translate('CancelForcedAlarm') ?></button>
</div>
<?php
}
?>
<div id="monitorState"><?php echo translate('State') ?>:&nbsp;<span id="stateValue"></span>&nbsp;-&nbsp;<span id="fpsValue"></span>&nbsp;fps</div>
</div>
<div id="dvrControls">

View File

@ -55,7 +55,7 @@ if ( !$mimetype ) {
$connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
$filename = "zmExport_$connkey.$file_ext";
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
ZM\Logger::Debug("downloading archive from $filename_path");
ZM\Debug("downloading archive from $filename_path");
if ( is_readable($filename_path) ) {
while (ob_get_level()) {
ob_end_clean();

View File

@ -87,11 +87,11 @@ if ( empty($_REQUEST['path']) ) {
if (file_exists($path_anim_gif)) {
// we found the animation gif file
$media_type = 'image/gif';
ZM\Logger::Debug("Animation file found at $path");
ZM\Debug("Animation file found at $path");
$path = $path_anim_gif;
} else if (file_exists($path_image)) {
// animation not found, but image found
ZM\Logger::Debug("Image file found at $path");
ZM\Debug("Image file found at $path");
$path = $path_image;
} else {
// neither animation nor image found
@ -206,14 +206,14 @@ if ( empty($_REQUEST['path']) ) {
$percentage = ($Frame->FrameId() - $previousBulkFrame['FrameId']) / ($nextBulkFrame['FrameId'] - $previousBulkFrame['FrameId']);
$Frame->Delta($previousBulkFrame['Delta'] + floor( 100* ( $nextBulkFrame['Delta'] - $previousBulkFrame['Delta'] ) * $percentage )/100);
ZM\Logger::Debug("Got virtual frame from Bulk Frames previous delta: " . $previousBulkFrame['Delta'] . " + nextdelta:" . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage );
ZM\Debug("Got virtual frame from Bulk Frames previous delta: " . $previousBulkFrame['Delta'] . " + nextdelta:" . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage );
} else {
ZM\Fatal('No Frame found for event('.$_REQUEST['eid'].') and frame id('.$_REQUEST['fid'].')');
}
}
// Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
ZM\Logger::Debug("Path: $path");
ZM\Debug("Path: $path");
}
} else {
@ -235,7 +235,7 @@ if ( empty($_REQUEST['path']) ) {
} # end if have eid
if ( !file_exists($path) ) {
ZM\Logger::Debug("$path does not exist");
ZM\Debug("$path does not exist");
# Generate the frame JPG
if ( ($show == 'capture') and $Event->DefaultVideo() ) {
if ( !file_exists($Event->Path().'/'.$Event->DefaultVideo()) ) {
@ -245,11 +245,11 @@ if ( empty($_REQUEST['path']) ) {
$command = ZM_PATH_FFMPEG.' -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -frames:v 1 '.$path;
#$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
#$command ='ffmpeg -v 0 -i '.$Storage->Path().'/'.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
ZM\Logger::Debug("Running $command");
ZM\Debug("Running $command");
$output = array();
$retval = 0;
exec( $command, $output, $retval );
ZM\Logger::Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
ZM\Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
if ( ! file_exists( $path ) ) {
header('HTTP/1.0 404 Not Found');
ZM\Fatal('Can\'t create frame images from video for this event '.$Event->DefaultVideo() );
@ -334,7 +334,7 @@ if ( $errorText ) {
ZM\Error('No bytes read from '. $path);
}
} else {
ZM\Logger::Debug("Doing a scaled image: scale($scale) width($width) height($height)");
ZM\Debug("Doing a scaled image: scale($scale) width($width) height($height)");
$i = 0;
if ( ! ( $width && $height ) ) {
$i = imagecreatefromjpeg($path);
@ -347,7 +347,7 @@ if ( $errorText ) {
$width = ($height * $oldWidth) / $oldHeight;
} elseif ( $width != 0 && $height == 0 ) {
$height = ($width * $oldHeight) / $oldWidth;
ZM\Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight) / $oldWidth");
ZM\Debug("Figuring out height using width: $height = ($width * $oldHeight) / $oldWidth");
}
if ( $width == $oldWidth && $height == $oldHeight ) {
ZM\Warning('No change to width despite scaling.');
@ -361,7 +361,7 @@ ZM\Logger::Debug("Figuring out height using width: $height = ($width * $oldHeigh
header('Content-Disposition: inline; filename="' . $filename . '"');
}
if ( !( file_exists($scaled_path) and readfile($scaled_path) ) ) {
ZM\Logger::Debug("Cached scaled image does not exist at $scaled_path or is no good.. Creating it");
ZM\Debug("Cached scaled image does not exist at $scaled_path or is no good.. Creating it");
ob_start();
if ( !$i )
$i = imagecreatefromjpeg($path);
@ -373,12 +373,12 @@ ZM\Logger::Debug("Figuring out height using width: $height = ($width * $oldHeigh
file_put_contents($scaled_path, $scaled_jpeg_data);
echo $scaled_jpeg_data;
} else {
ZM\Logger::Debug("Sending $scaled_path");
ZM\Debug("Sending $scaled_path");
$bytes = readfile($scaled_path);
if ( !$bytes ) {
ZM\Error('No bytes read from '. $scaled_path);
} else {
ZM\Logger::Debug("$bytes sent");
ZM\Debug("$bytes sent");
}
}
}

View File

@ -66,14 +66,14 @@ $end = $size-1;
$length = $size;
if ( isset($_SERVER['HTTP_RANGE']) ) {
ZM\Logger::Debug('Using Range '.$_SERVER['HTTP_RANGE']);
ZM\Debug('Using Range '.$_SERVER['HTTP_RANGE']);
if ( preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) {
$begin = intval($matches[1]);
if ( !empty($matches[2]) ) {
$end = intval($matches[2]);
}
$length = $end - $begin + 1;
ZM\Logger::Debug("Using Range $begin $end size: $size, length: $length");
ZM\Debug("Using Range $begin $end size: $size, length: $length");
}
} # end if HTTP_RANGE