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

pull/2571/head
Isaac Connor 2019-03-05 14:35:15 -05:00
commit fa124eb29a
26 changed files with 430 additions and 185 deletions

View File

@ -298,7 +298,7 @@ int cURLCamera::Capture( Image &image ) {
if(!frameComplete)
return -1;
return 0;
return 1;
}
int cURLCamera::PostCapture() {

View File

@ -84,7 +84,7 @@ int FileCamera::PreCapture() {
}
int FileCamera::Capture( Image &image ) {
return( image.ReadJpeg( path, colours, subpixelorder )?0:-1 );
return( image.ReadJpeg( path, colours, subpixelorder )?1:-1 );
}
int FileCamera::PostCapture() {

View File

@ -345,7 +345,8 @@ bool VideoStore::open() {
AVDictionary *opts = NULL;
// av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
// Shiboleth reports that this may break seeking in mp4 before it downloads
//av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
// av_dict_set(&opts, "movflags",
// "frag_keyframe+empty_moov+default_base_moof", 0);
if ((ret = avformat_write_header(oc, &opts)) < 0) {

View File

@ -152,30 +152,16 @@ int main( int argc, const char *argv[] ) {
connkey = atoi(value);
} else if ( !strcmp( name, "buffer" ) ) {
playback_buffer = atoi(value);
} else if ( config.opt_use_auth ) {
if ( strcmp( config.auth_relay, "none" ) == 0 ) {
if ( !strcmp( name, "user" ) ) {
username = value;
}
} else {
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
{
if ( !strcmp( name, "auth" ) ) {
strncpy( auth, value, sizeof(auth)-1 );
}
}
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
{
if ( !strcmp( name, "user" ) ) {
username = UriDecode( value );
}
if ( !strcmp( name, "pass" ) ) {
password = UriDecode( value );
Debug( 1, "Have %s for password", password.c_str() );
}
}
}
}
} else if ( !strcmp( name, "auth" ) ) {
strncpy( auth, value, sizeof(auth)-1 );
} else if ( !strcmp( name, "user" ) ) {
username = UriDecode( value );
} else if ( !strcmp( name, "pass" ) ) {
password = UriDecode(value);
Debug(1, "Have %s for password", password.c_str());
} else {
Debug(1, "Unknown parameter passed to zms %s=%s", name, value);
} // end if possible parameter names
} // end foreach parm
} // end if query
@ -323,5 +309,5 @@ int main( int argc, const char *argv[] ) {
logTerm();
zmDbClose();
return( 0 );
return(0);
}

View File

@ -19,7 +19,7 @@ switch ( $_REQUEST['task'] ) {
else
$line = NULL;
$levels = array_flip(Logger::$codes);
$levels = array_flip(ZM\Logger::$codes);
if ( !isset($levels[$_POST['level']]) )
ZM\Panic("Unexpected logger level '".$_POST['level']."'");
$level = $levels[$_POST['level']];
@ -322,7 +322,7 @@ switch ( $_REQUEST['task'] ) {
$classLevel = ZM\Logger::FATAL;
elseif ( $classLevel > ZM\Logger::DEBUG )
$classLevel = ZM\Logger::DEBUG;
$logClass = 'log-'.strtolower(Logger::$codes[$classLevel]);
$logClass = 'log-'.strtolower(ZM\Logger::$codes[$classLevel]);
fprintf( $exportFP, " <tr class=\"%s\"><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $logClass, $log['DateTime'], $log['Component'], $log['Server'], $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
}
fwrite( $exportFP,

View File

@ -63,11 +63,11 @@ private $defaults = array(
'SectionLength' => 600,
'FrameSkip' => 0,
'AnalysisFPSLimit' => null,
'AnalysisUpdateDelete' => 0,
'AnalysisUpdateDelay' => 0,
'MaxFPS' => null,
'AlarmMaxFPS' => null,
'FPSReportIneterval' => 100,
'RefBlencPerc' => 6,
'FPSReportInterval' => 100,
'RefBlendPerc' => 6,
'AlarmRefBlendPerc' => 6,
'Controllable' => 0,
'ControlId' => null,
@ -78,7 +78,6 @@ private $defaults = array(
'TrackDelay' => null,
'ReturnLocation' => -1,
'ReturnDelay' => null,
'DefaultView' => 'Events',
'DefaultRate' => 100,
'DefaultScale' => 100,
'SignalCheckPoints' => 0,
@ -634,7 +633,8 @@ private $control_fields = array(
} // end function Source
public function UrlToIndex() {
return $this->Server()->UrlToIndex(ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : null);
return $this->Server()->UrlToIndex();
//ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : null);
}
} // end class Monitor

View File

@ -28,13 +28,14 @@ if ( ! canView('Control', $_REQUEST['mid']) ) {
return;
}
require_once('control_functions.php');
require_once('Monitor.php');
require_once('includes/control_functions.php');
require_once('includes/Monitor.php');
$mid = validInt($_REQUEST['mid']);
if ( $action == 'control' ) {
$monitor = new ZM\Monitor($mid);
$ctrlCommand = buildControlCommand($monitor);
sendControlCommand($monitor->Id(), $ctrlCommand);
$view = 'none';
}
?>

View File

@ -27,28 +27,32 @@ if ( $action == 'donate' && isset($_REQUEST['option']) ) {
$option = $_REQUEST['option'];
switch( $option ) {
case 'go' :
// Ignore this, the caller will open the page itself
break;
// Ignore this, the caller will open the page itself
break;
case 'hour' :
case 'day' :
case 'week' :
case 'month' :
$nextReminder = time();
if ( $option == 'hour' ) {
$nextReminder += 60*60;
} elseif ( $option == 'day' ) {
$nextReminder += 24*60*60;
} elseif ( $option == 'week' ) {
$nextReminder += 7*24*60*60;
} elseif ( $option == 'month' ) {
$nextReminder += 30*24*60*60;
}
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
break;
$nextReminder = time();
if ( $option == 'hour' ) {
$nextReminder += 60*60;
} elseif ( $option == 'day' ) {
$nextReminder += 24*60*60;
} elseif ( $option == 'week' ) {
$nextReminder += 7*24*60*60;
} elseif ( $option == 'month' ) {
$nextReminder += 30*24*60*60;
}
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
break;
case 'never' :
case 'already' :
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_DYN_SHOW_DONATE_REMINDER'");
break;
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_DYN_SHOW_DONATE_REMINDER'");
break;
default :
Warning("Unknown value for option in donate: $option");
break;
} // end switch option
$view = 'none';
}
?>

View File

@ -18,33 +18,6 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// I think this is saving a Monitor from ajax...
if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
if ( $action == 'save' ) {
foreach ( $_REQUEST['mids'] as $mid ) {
$mid = ValidInt($mid);
if ( ! canEdit('Monitors', $mid) ) {
ZM\Warning("Cannot edit monitor $mid");
continue;
}
$Monitor = new ZM\Monitor($mid);
if ( $Monitor->Type() != 'WebSite' ) {
$Monitor->zmaControl('stop');
$Monitor->zmcControl('stop');
}
$Monitor->save($_REQUEST['newMonitor']);
if ( $Monitor->Function() != 'None' && $Monitor->Type() != 'WebSite' ) {
$Monitor->zmcControl('start');
if ( $Monitor->Enabled() ) {
$Monitor->zmaControl('start');
}
}
} // end foreach mid
$refreshParent = true;
} // end if action == save
} // end if object is Monitor
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
if ( ! canEdit('Monitors') ) {
ZM\Warning("Monitor actions require Monitors Permissions");

View File

@ -0,0 +1,52 @@
<?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.
//
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
if ( ! canEdit('Monitors') ) {
ZM\Warning("Monitor actions require Monitors Permissions");
return;
}
if ( $action == 'save' ) {
foreach ( $_REQUEST['mids'] as $mid ) {
$mid = ValidInt($mid);
if ( ! canEdit('Monitors', $mid) ) {
ZM\Warning("Cannot edit monitor $mid");
continue;
}
$Monitor = new ZM\Monitor($mid);
if ( $Monitor->Type() != 'WebSite' ) {
$Monitor->zmaControl('stop');
$Monitor->zmcControl('stop');
}
$Monitor->save($_REQUEST['newMonitor']);
if ( $Monitor->Function() != 'None' && $Monitor->Type() != 'WebSite' ) {
$Monitor->zmcControl('start');
if ( $Monitor->Enabled() ) {
$Monitor->zmaControl('start');
}
}
} // end foreach mid
$refreshParent = true;
$view = 'none';
} else {
ZM\Warning("Unknown action $action in Monitor");
} // end if action == Delete
?>

View File

@ -288,7 +288,7 @@ function getImageStreamHTML( $id, $src, $width, $height, $title='' ) {
if ( canStreamIframe() ) {
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>';
} else {
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" style="'.($width? ' width:'.$width.';' : '' ).($height ? ' height:'. $height.';' : '' ).'"/>';
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" style="'.($width? 'width:'.$width.';' : '' ).($height ? ' height:'. $height.';' : '' ).'"/>';
}
}
@ -2239,15 +2239,15 @@ function getStreamHTML( $monitor, $options = array() ) {
if ( isset($options['scale']) and $options['scale'] and ( $options['scale'] != 100 ) ) {
//Warning("Scale to " . $options['scale'] );
$options['width'] = reScale( $monitor->Width(), $options['scale'] ) . 'px';
$options['height'] = reScale( $monitor->Height(), $options['scale'] ) . 'px';
$options['width'] = reScale($monitor->Width(), $options['scale']).'px';
$options['height'] = reScale($monitor->Height(), $options['scale']).'px';
} else {
# scale is empty or 100
# There may be a fixed width applied though, in which case we need to leave the height empty
if ( ! ( isset($options['width']) and $options['width'] ) ) {
$options['width'] = $monitor->Width() . 'px';
$options['width'] = $monitor->Width().'px';
if ( ! ( isset($options['height']) and $options['height'] ) ) {
$options['height'] = $monitor->Height() . 'px';
$options['height'] = $monitor->Height().'px';
}
} else if ( ! isset($options['height']) ) {
$options['height'] = '';

View File

@ -38,7 +38,7 @@ if ( version_compare(phpversion(), '4.1.0', '<') ) {
if ( false ) {
ob_start();
phpinfo(INFO_VARIABLES);
$fp = fopen('/tmp/env.html', 'w');
$fp = fopen('/tmp/env.html', 'w+');
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_clean();
@ -70,8 +70,15 @@ define('ZM_BASE_PROTOCOL', $protocol);
// Use relative URL's instead
define('ZM_BASE_URL', '');
// Verify the system, php, and mysql timezones all match
require_once('includes/functions.php');
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
Logger::Debug("OPTIONS Method, only doing CORS");
# Add Cross domain access headers
CORSHeaders();
return;
}
// Verify the system, php, and mysql timezones all match
check_timezone();
if ( isset($_GET['skin']) ) {
@ -187,7 +194,7 @@ isset($view) || $view = NULL;
isset($request) || $request = NULL;
isset($action) || $action = NULL;
Logger::Debug("View: $view Request: $request Action: $action");
Logger::Debug("View: $view Request: $request Action: $action User: " . ( isset($user) ? $user['Username'] : 'none' ));
if (
ZM_ENABLE_CSRF_MAGIC &&
( $action != 'login' ) &&
@ -214,6 +221,12 @@ if ( $action ) {
# If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in.
if ( ZM_OPT_USE_AUTH and !isset($user) and ($view != 'login') ) {
/* AJAX check */
if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {
header('HTTP/1.1 401 Unauthorized');
exit;
}
Logger::Debug('Redirecting to login');
$view = 'none';
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=login';

View File

@ -537,6 +537,7 @@ $SLANG = array(
'NewState' => 'New State',
'NewUser' => 'New User',
'Next' => 'Next',
'NextMonitor' => 'Next Monitor',
'NoDetectedCameras' => 'No Detected Cameras',
'NoDetectedProfiles' => 'No Detected Profiles',
'NoFramesRecorded' => 'There are no frames recorded for this event',
@ -589,12 +590,14 @@ $SLANG = array(
'PathToApi' => 'Path To Api',
'Paths' => 'Paths',
'Pause' => 'Pause',
'PauseCycle' => 'Pause Cycle',
'PhoneBW' => 'Phone&nbsp;B/W',
'Phone' => 'Phone',
'PixelDiff' => 'Pixel Diff',
'Pixels' => 'pixels',
'PlayAll' => 'Play All',
'Play' => 'Play',
'PlayCycle' => 'Play Cycle',
'Plugins' => 'Plugins',
'PleaseWait' => 'Please Wait',
'Point' => 'Point',
@ -604,6 +607,7 @@ $SLANG = array(
'Preset' => 'Preset',
'Presets' => 'Presets',
'Prev' => 'Prev',
'PreviousMonitor' => 'Previous Monitor',
'Privacy' => 'Privacy',
'PrivacyAbout' => 'About',
'PrivacyAboutText' => 'Since 2002, ZoneMinder has been the premier free and open-source Video Management System (VMS) solution for Linux platforms. ZoneMinder is supported by the community and is managed by those who choose to volunteer their spare time to the project. The best way to improve ZoneMinder is to get involved.',

View File

@ -252,7 +252,7 @@ function controlPresets( $monitor, $cmds ) {
global $SLANG;
// MAX_PRESETS IS PER LINE
define( "MAX_PRESETS", "12" );
define( 'MAX_PRESETS', '12' );
$sql = 'SELECT * FROM ControlPresets WHERE MonitorId = ?';
$labels = array();
@ -282,12 +282,12 @@ function controlPresets( $monitor, $cmds ) {
<?php
if ( $monitor->HasHomePreset() ) {
?>
<button type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/>
<button type="button" class="ptzTextBtn" value="Home" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"><?php echo translate('Home') ?></button>
<?php
}
if ( canEdit('Monitors') && $monitor->CanSetPresets() ) {
?>
<button type="button" class="ptzTextBtn popup-link" value="<?php echo translate('Set') ?>" data-url="?view=controlpreset&amp;mid=<?php echo $monitor->Id() ?>" data-window-name="zmPreset" data-window-tag="preset"/>
<button type="button" class="ptzTextBtn popup-link" value="Set" data-url="?view=controlpreset&amp;mid=<?php echo $monitor->Id() ?>" data-window-name="zmPreset" data-window-tag="preset"><?php echo translate('Set') ?></button>
<?php
}
?>

View File

@ -259,8 +259,18 @@ function getNavBarHTML($reload = null) {
<?php
if ( ZM\logToDatabase() > ZM\Logger::NOLOG ) {
if ( ! ZM_RUN_AUDIT ) {
# zmaudit can clean the logs, but if we aren't running it, then we should clecan them regularly
dbQuery('DELETE FROM Logs WHERE TimeKey < unix_timestamp( NOW() - interval '.ZM_LOG_DATABASE_LIMIT.') LIMIT 100');
# zmaudit can clean the logs, but if we aren't running it, then we should clean them regularly
if ( preg_match('/^\d+$/', ZM_LOG_DATABASE_LIMIT) ) {
# Number of lines, instead of an interval
$rows = dbFetchOne('SELECT Count(*) AS Rows FROM Logs', 'Rows' );
if ( $rows > ZM_LOG_DATABASE_LIMIT ) {
dbQuery('DELETE low_priority FROM Logs ORDER BY TimeKey ASC LIMIT ?', array($rows - ZM_LOG_DATABASE_LIMIT));
}
} else if ( preg_match('/^\d\s*(hour|minute|day|week|month|year)$/', ZM_LOG_DATABASE_LIMIT, $matches) ) {
dbQuery('DELETE FROM Logs WHERE TimeKey < unix_timestamp( NOW() - interval '.ZM_LOG_DATABASE_LIMIT.') LIMIT 100');
} else {
ZM\Error('Potentially invalid value for ZM_LOG_DATABASE_LIMIT: ' . ZM_LOG_DATABASE_LIMIT);
}
}
echo makePopupLink( '?view=log', 'zmLog', 'log', '<span class="'.logState().'">'.translate('Log').'</span>' );
}

View File

@ -33,7 +33,7 @@ var popupSizes = {
'cycle': {'addWidth': 32, 'minWidth': 384, 'addHeight': 62},
'device': {'width': 260, 'height': 150},
'devices': {'width': 400, 'height': 240},
'donate': {'width': 500, 'height': 280},
'donate': {'width': 500, 'height': 480},
'download': {'width': 350, 'height': 215},
'event': {'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540},
'eventdetail': {'width': 600, 'height': 420},

View File

@ -49,7 +49,7 @@ xhtmlHeaders(__FILE__, translate('SetPreset') );
</div>
<div id="content">
<form name="contentForm" id="contentForm" method="post" action="?">
<input type="hidden" name="view" value="none"/>
<input type="hidden" name="view" value="control"/>
<input type="hidden" name="mid" value="<?php echo $monitor['Id'] ?>"/>
<input type="hidden" name="action" value="control"/>
<input type="hidden" name="control" value="presetSet"/>
@ -57,11 +57,11 @@ xhtmlHeaders(__FILE__, translate('SetPreset') );
<p><?php echo buildSelect('preset', $presets, 'updateLabel()' ) ?></p>
<p>
<label for="newLabel"><?php echo translate('NewLabel') ?></label>
<input type="text" name="newLabel" id="newLabel" value="" size="16"/>
<input type="text" name="newLabel" id="newLabel" value=""/>
</p>
<div id="contentButtons">
<input type="submit" value="<?php echo translate('Save') ?>"/>
<input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
<button type="submit" value="Save"><?php echo translate('Save') ?></button>
<button type="button" data-on-click="closeWindow"><?php echo translate('Cancel') ?></button>
</div>
</form>
</div>

View File

@ -23,46 +23,101 @@ if ( !canView('Stream') ) {
return;
}
if ( empty($_REQUEST['mode']) ) {
if ( canStream() )
$mode = 'stream';
else
$mode = 'still';
} else {
$mode = validHtmlStr($_REQUEST['mode']);
}
ob_start();
include('_monitor_filters.php');
$filterbar = ob_get_contents();
ob_end_clean();
$options = array();
if ( empty($_REQUEST['mode']) ) {
if ( canStream() )
$options['mode'] = 'stream';
else
$options['mode'] = 'still';
} else {
$options['mode'] = validHtmlStr($_REQUEST['mode']);
}
$widths = array(
'' => translate('auto'),
'100%' => '100%',
'160px' => '160px',
'320px' => '320px',
'352px' => '352px',
'640px' => '640px',
'1280px' => '1280px',
'1920px' => '1920px'
);
$heights = array(
'auto' => translate('auto'),
'240px' => '240px',
'480px' => '480px',
'720px' => '720px',
'1080px' => '1080px',
);
session_start();
if ( isset($_REQUEST['scale']) ) {
$options['scale'] = validInt($_REQUEST['scale']);
ZM\Logger::Debug('Setting scale from request to '.$options['scale']);
} else if ( isset($_COOKIE['zmCycleScale']) ) {
$options['scale'] = $_COOKIE['zmCycleScale'];
ZM\Logger::Debug('Setting scale from cookie to '.$options['scale']);
}
if ( !(isset($options['scale']) and $options['scale']) )
$options['scale'] = 100;
if ( isset($_COOKIE['zmCycleWidth']) and $_COOKIE['zmCycleWidth'] ) {
$_SESSION['zmCycleWidth'] = $options['width'] = $_COOKIE['zmCycleWidth'];
#} elseif ( isset($_SESSION['zmCycleWidth']) and $_SESSION['zmCycleWidth'] ) {
#$options['width'] = $_SESSION['zmCycleWidth'];
} else
$options['width'] = '';
if ( isset($_COOKIE['zmCycleHeight']) and $_COOKIE['zmCycleHeight'] )
$_SESSION['zmCycleHeight'] = $options['height'] = $_COOKIE['zmCycleHeight'];
#else if ( isset($_SESSION['zmCycleHeight']) and $_SESSION['zmCycleHeight'] )
#$options['height'] = $_SESSION['zmCycleHeight'];
else
$options['height'] = '';
session_write_close();
$monIdx = 0;
$monitors = array();
$monitor = NULL;
foreach( $displayMonitors as &$row ) {
if ( $row['Function'] == 'None' )
continue;
if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] )
if ( isset($_REQUEST['mid']) && ($row['Id'] == $_REQUEST['mid']) )
$monIdx = count($monitors);
$row['ScaledWidth'] = reScale($row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['ScaledHeight'] = reScale($row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['PopupScale'] = reScale(SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
if ( !isset($widths[$row['Width'].'px']) ) {
$widths[$row['Width'].'px'] = $row['Width'].'px';
}
if ( ! isset($heights[$row['Height'].'px']) ) {
$heights[$row['Height'].'px'] = $row['Height'].'px';
}
$row['connKey'] = generateConnKey();
$monitors[] = new ZM\Monitor($row);
unset($row);
} # end foreach Monitor
if ( $monitors ) {
$monitor = $monitors[$monIdx];
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]->Id():$monitors[$monIdx+1]->Id();
$montageWidth = $monitor->ScaledWidth();
$montageHeight = $monitor->ScaledHeight();
$widthScale = ($montageWidth*SCALE_BASE)/$monitor->Width();
$heightScale = ($montageHeight*SCALE_BASE)/$monitor->Height();
$scale = (int)(($widthScale<$heightScale)?$widthScale:$heightScale);
}
ZM\Logger::Debug(print_r($options,true));
noCacheHeaders();
xhtmlHeaders(__FILE__, translate('CycleWatch'));
?>
@ -71,7 +126,7 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
<?php echo $navbar = getNavBarHTML(); ?>
<div id="header">
<div id="headerButtons">
<?php if ( $mode == 'stream' ) { ?>
<?php if ( $options['mode'] == 'stream' ) { ?>
<a href="?view=<?php echo $view ?>&amp;mode=still&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stills') ?></a>
<?php } else { ?>
<a href="?view=<?php echo $view ?>&amp;mode=stream&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stream') ?></a>
@ -83,17 +138,39 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
<?php echo $filterbar ?>
</form>
</div>
<div id="sizeControl">
<span id="widthControl">
<label><?php echo translate('Width') ?>:</label>
<?php echo htmlSelect('width', $widths, $options['width'], array('data-on-change-this'=>'changeSize') ); ?>
</span>
<span id="heightControl">
<label><?php echo translate('Height') ?>:</label>
<?php echo htmlSelect('height', $heights, $options['height'], array('data-on-change-this'=>'changeSize') ); ?>
</span>
<span id="scaleControl">
<label><?php echo translate('Scale') ?>:</label>
<?php echo htmlSelect('scale', $scales, $options['scale'], array('data-on-change-this'=>'changeScale') ); ?>
</span>
</div>
</div>
<div id="content">
<div id="imageFeed">
<?php
if ( $monitor ) {
echo getStreamHTML($monitor, array('scale'=>$scale, 'mode'=>$mode, 'width'=>'100%'));
echo getStreamHTML($monitor, $options);
} else {
echo "There are no monitors to view.";
echo 'There are no monitors to view.';
}
?>
</div>
<div class="buttons">
<button type="button" value="&lt;" id="prevBtn" title="<?php echo translate('PreviousMonitor') ?>" class="active" data-on-click-true="cyclePrev">&lt;&lt;</button>
<button type="button" value="||" id="pauseBtn" title="<?php echo translate('PauseCycle') ?>" class="active" data-on-click-true="cyclePause">||</button>
<button type="button" value="|&gt;" id="playBtn" title="<?php echo translate('PlayCycle') ?>" class="inactive" disabled="disabled" data-on-click-true="streamCmdPlay">|&gt;</button>
<button type="button" value="&gt;" id="nextBtn" title="<?php echo translate('NextMonitor') ?>" class="active" data-on-click-true="cycleNext">&gt;&gt;</button>
</div>
</div>
</div>
<?php xhtmlFooter() ?>

View File

@ -18,25 +18,24 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canEdit( 'System' ) )
{
$view = "error";
return;
if ( !canEdit('System') ) {
$view = 'error';
return;
}
$options = array(
"go" => translate('DonateYes'),
"hour" => translate('DonateRemindHour'),
"day" => translate('DonateRemindDay'),
"week" => translate('DonateRemindWeek'),
"month" => translate('DonateRemindMonth'),
"never" => translate('DonateRemindNever'),
"already" => translate('DonateAlready'),
"go" => translate('DonateYes'),
"hour" => translate('DonateRemindHour'),
"day" => translate('DonateRemindDay'),
"week" => translate('DonateRemindWeek'),
"month" => translate('DonateRemindMonth'),
"never" => translate('DonateRemindNever'),
"already" => translate('DonateAlready'),
);
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Donate') );
xhtmlHeaders(__FILE__, translate('Donate'));
?>
<body>
<div id="page">
@ -46,17 +45,17 @@ xhtmlHeaders(__FILE__, translate('Donate') );
</div>
<div id="content">
<form name="contentForm" id="contentForm" method="post" action="?">
<input type="hidden" name="view" value="none"/>
<input type="hidden" name="view" value="donate"/>
<input type="hidden" name="action" value="donate"/>
<p>
<?php echo translate('DonateEnticement') ?>
</p>
<p>
<?php echo buildSelect( "option", $options ); ?>
<?php echo buildSelect('option', $options); ?>
</p>
<div id="contentButtons">
<input type="submit" value="<?php echo translate('Apply') ?>" data-on-click-this="submitForm">
<input type="button" value="<?php echo translate('Close') ?>" data-on-click="closeWindow">
<button type="submit"><?php echo translate('Apply') ?></button>
<button type="button" data-on-click="closeWindow"><?php echo translate('Close') ?></button>
</div>
</form>
</div>

View File

@ -1,9 +1,123 @@
var periodical_id;
function nextCycleView() {
window.location.replace('?view=cycle&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout);
}
function initCycle() {
nextCycleView.periodical(cycleRefreshTimeout);
function cyclePause() {
$clear(periodical_id);
$('pauseBtn').disabled = true;
$('playBtn').disabled = false;
}
function cycleStart() {
periodical_id = nextCycleView.periodical(cycleRefreshTimeout);
$('pauseBtn').disabled = false;
$('playBtn').disabled = true;
}
function cycleNext() {
monIdx ++;
if ( monIdx >= monitorData.length ) {
monIdx = 0;
}
if ( !monitorData[monIdx] ) {
console.log("No monitorData for " + monIdx);
}
window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout);
}
function cyclePrev() {
if ( monIdx )
monIdx -= 1;
else
monIdx = monitorData.length-1;
window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout);
}
function initCycle() {
periodical_id = nextCycleView.periodical(cycleRefreshTimeout);
}
function changeSize() {
var width = $('width').get('value');
var height = $('height').get('value');
// Scale the frame
monitor_frame = $j('#imageFeed');
if ( !monitor_frame ) {
console.log("Error finding frame");
return;
}
if ( width ) {
monitor_frame.css('width', width);
}
if ( height ) {
monitor_frame.css('height', height);
}
/* Stream could be an applet so can't use moo tools */
var streamImg = $('liveStream'+monitorData[monIdx].id);
if ( streamImg ) {
if ( streamImg.nodeName == 'IMG' ) {
var src = streamImg.src;
streamImg.src = '';
console.log(parseInt(width));
src = src.replace(/width=[\.\d]+/i, 'width='+parseInt(width));
src = src.replace(/height=[\.\d]+/i, 'height='+parseInt(height));
src = src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
streamImg.src = src;
}
streamImg.style.width = width ? width : null;
streamImg.style.height = height ? height : null;
} else {
console.log("Did not find liveStream"+monitorData[monIdx].id);
}
$('scale').set('value', '');
Cookie.write('zmCycleScale', '', {duration: 10*365});
Cookie.write('zmCycleWidth', width, {duration: 10*365});
Cookie.write('zmCycleHeight', height, {duration: 10*365});
} // end function changeSize()
function changeScale() {
var scale = $('scale').get('value');
$('width').set('value', 'auto');
$('height').set('value', 'auto');
Cookie.write('zmCycleScale', scale, { duration: 10*365 });
Cookie.write('zmCycleWidth', 'auto', { duration: 10*365 });
Cookie.write('zmCycleHeight', 'auto', { duration: 10*365 });
var newWidth = ( monitorData[monIdx].width * scale ) / SCALE_BASE;
var newHeight = ( monitorData[monIdx].height * scale ) / SCALE_BASE;
// Scale the frame
monitor_frame = $j('#imageFeed');
if ( !monitor_frame ) {
console.log("Error finding frame");
return;
}
if ( newWidth ) {
monitor_frame.css('width', newWidth+'px');
}
if ( newHeight ) {
monitor_frame.css('height', newHeight+'px');
}
/*Stream could be an applet so can't use moo tools*/
var streamImg = $j('#liveStream'+monitorData[monIdx].id)[0];
if ( streamImg ) {
if ( streamImg.nodeName == 'IMG' ) {
var src = streamImg.src;
streamImg.src = '';
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
src = src.replace(/scale=[\.\d]+/i, 'scale='+scale);
src = src.replace(/width=[\.\d]+/i, 'width='+newWidth);
src = src.replace(/height=[\.\d]+/i, 'height='+newHeight);
streamImg.src = src;
}
streamImg.style.width = newWidth + 'px';
streamImg.style.height = newHeight + 'px';
} else {
console.log("Did not find liveStream"+monitorData[monIdx].id);
}
} // end function changeScale()
window.addEventListener('DOMContentLoaded', initCycle);

View File

@ -1,4 +1,24 @@
var monIdx = '<?php echo $monIdx; ?>';
var nextMid = "<?php echo isset($nextMid)?$nextMid:'' ?>";
var mode = "<?php echo $mode ?>";
var mode = "<?php echo $options['mode'] ?>";
var cycleRefreshTimeout = <?php echo 1000*ZM_WEB_REFRESH_CYCLE ?>;
var monitorData = new Array();
<?php
foreach ( $monitors as $monitor ) {
?>
monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>,
'connKey': <?php echo $monitor->connKey() ?>,
'width': <?php echo $monitor->Width() ?>,
'height':<?php echo $monitor->Height() ?>,
'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->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );},
'type': '<?php echo $monitor->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>'
};
<?php
} // end foreach monitor
?>
var SCALE_BASE = <?php echo SCALE_BASE ?>;

View File

@ -1,13 +1,3 @@
function submitForm( element ) {
var form = element.form;
if ( form.option.selectedIndex == 0 ) {
form.view.value = currentView;
} else {
form.view.value = 'none';
}
form.submit();
}
if ( action == "donate" && option == "go" ) {
zmWindow();
}

View File

@ -140,6 +140,7 @@ function Monitor( monitorData ) {
console.log( 'No stream to reload?' );
}
} // end if Ok or not
var streamCmdTimeout = statusRefreshTimeout;
// The idea here is if we are alarmed, do updates faster. However, there is a timeout in the php side which isn't getting modified, so this may cause a problem. Also the server may only be able to update so fast.
//if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ) {
@ -262,10 +263,10 @@ function changeSize() {
continue;
}
if ( width ) {
monitor_frame.css('width', width+'px');
monitor_frame.css('width', width);
}
if ( height ) {
monitor_frame.css('height', height+'px');
monitor_frame.css('height', height);
}
/*Stream could be an applet so can't use moo tools*/
var streamImg = $( 'liveStream'+monitor.id );
@ -278,14 +279,14 @@ function changeSize() {
src = src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
streamImg.src = src;
}
streamImg.style.width = width? width + "px" : null;
streamImg.style.height = height ? height + "px" : null;
streamImg.style.width = width ? width : null;
streamImg.style.height = height ? height : null;
//streamImg.style.height = '';
}
var zonesSVG = $('zones'+monitor.id);
if ( zonesSVG ) {
zonesSVG.style.width = width ? width + "px" : '100%';
zonesSVG.style.height = height + "px";
zonesSVG.style.width = width ? width : '100%';
zonesSVG.style.height = height;
}
}
$('scale').set('value', '' );
@ -297,12 +298,12 @@ function changeSize() {
function changeScale() {
var scale = $('scale').get('value');
$('width').set('value', '');
$('height').set('value', '');
Cookie.write( 'zmMontageScale', scale, {duration: 10*365} );
Cookie.write( 'zmMontageWidth', '', {duration: 10*365} );
Cookie.write( 'zmMontageHeight', '', {duration: 10*365} );
if ( ! scale ) {
$('width').set('value', 'auto');
$('height').set('value', 'auto');
Cookie.write('zmMontageScale', scale, {duration: 10*365});
Cookie.write('zmMontageWidth', '', {duration: 10*365});
Cookie.write('zmMontageHeight', '', {duration: 10*365});
if ( !scale ) {
selectLayout('#zmMontageLayout');
return;
}
@ -317,12 +318,13 @@ function changeScale() {
console.log("Error finding frame for " + monitor.id );
continue;
}
if ( width ) {
monitor_frame.css('width', width+'px');
}
if ( height ) {
monitor_frame.css('height', height+'px');
if ( newWidth ) {
monitor_frame.css('width', newWidth);
}
// We don't set the frame height because it has the status bar as well
//if ( height ) {
////monitor_frame.css('height', height+'px');
//}
/*Stream could be an applet so can't use moo tools*/
var streamImg = $j('#liveStream'+monitor.id )[0];
if ( streamImg ) {

View File

@ -142,7 +142,6 @@ function getStreamCmdFailure(xhr) {
}
function getStreamCmdResponse(respObj, respText) {
watchdogOk("stream");
console.log('stream');
if ( streamCmdTimer ) {
streamCmdTimer = clearTimeout(streamCmdTimer);
}

View File

@ -49,7 +49,7 @@ xhtmlHeaders(__FILE__, translate('Function'));
The following monitors will have these settings update when you click Save:<br/><br/>
<?php echo implode('<br/>', array_map(function($m){return $m->Id().' ' .$m->Name();}, $monitors)); ?>
<form name="contentForm" id="contentForm" method="post" action="?" onsubmit="$j('#contentButtons').hide();return true;">
<input type="hidden" name="view" value="none"/>
<input type="hidden" name="view" value="monitors"/>
<input type="hidden" name="action" value="save"/>
<input type="hidden" name="object" value="Monitor"/>
<?php
@ -57,7 +57,7 @@ The following monitors will have these settings update when you click Save:<br/>
"\n",
array_map(function($m){
return '<input type="hidden" name="mids[]" value="'.$m->Id().'"/>';
}, $monitors)
}, $monitors)
);
if ( count($ServersById) > 0 ) { ?>
<p class="Server"><label><?php echo translate('Server')?></label>
@ -73,7 +73,7 @@ The following monitors will have these settings update when you click Save:<br/>
<?php
}
?>
<p><label><?php echo translate('Function') ?></label>
<p class="Function"><label><?php echo translate('Function') ?></label>
<?php
$options = array();
foreach ( getEnumValues('Monitors', 'Function') as $opt ) {

View File

@ -33,27 +33,27 @@ if ( isset($_REQUEST['showZones']) ) {
}
}
$widths = array(
'' => 'auto',
160 => 160,
320 => 320,
352 => 352,
640 => 640,
1280 => 1280 );
'auto' => 'auto',
'160px' => '160px',
'320px' => '320px',
'352px' => '352px',
'640px' => '640px',
'1280px' => '1280px' );
$heights = array(
'' => 'auto',
240 => 240,
480 => 480,
'auto' => 'auto',
'240px' => '240px',
'480px' => '480px',
'720px' => '720px',
'1080px' => '1080px',
);
$scale = '100'; # actual
if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']);
ZM\Logger::Debug("Setting scale from request to $scale");
} else if ( isset($_COOKIE['zmMontageScale']) ) {
$scale = $_COOKIE['zmMontageScale'];
ZM\Logger::Debug("Setting scale from cookie to $scale");
}
if ( ! $scale )
@ -121,10 +121,10 @@ foreach( $displayMonitors as &$row ) {
$showControl = true;
$row['connKey'] = generateConnKey();
if ( ! isset($widths[$row['Width']]) ) {
$widths[$row['Width']] = $row['Width'];
$widths[$row['Width'].'px'] = $row['Width'].'px';
}
if ( ! isset($heights[$row['Height']]) ) {
$heights[$row['Height']] = $row['Height'];
$heights[$row['Height'].'px'] = $row['Height'].'px';
}
$monitors[] = new ZM\Monitor($row);
} # end foreach Monitor
@ -195,7 +195,7 @@ if ( $showZones ) {
foreach ( $monitors as $monitor ) {
$connkey = $monitor->connKey(); // Minor hack
?>
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>" style="<?php echo $options['width'] ? 'width:'.$options['width'].'px;':''?>">
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>" style="<?php echo $options['width'] ? 'width:'.$options['width'].';':''?>">
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
<div
id="imageFeed<?php echo $monitor->Id() ?>"
@ -225,8 +225,8 @@ foreach ( $monitors as $monitor ) {
echo getWebSiteUrl(
'liveStream'.$monitor->Id(),
$monitor->Path(),
reScale($monitor->Width(), $scale),
reScale($monitor->Height(), $scale),
(isset($options['width']) ? $options['width'] : reScale($monitor->Width(), $scale).'px' ),
( isset($options['height']) ? $options['height'] : reScale($monitor->Height(), $scale).'px' ),
$monitor->Name()
);
} else {
@ -239,17 +239,17 @@ foreach ( $monitors as $monitor ) {
$width = $options['width'];
if ( !$options['height'] ) {
$scale = (int)( 100 * $options['width'] / $monitor->Width() );
$height = reScale($monitor->Height(), $scale);
$height = reScale($monitor->Height(), $scale).'px';
}
} else if ( $options['height'] ) {
$height = $options['height'];
if ( !$options['width'] ) {
$scale = (int)( 100 * $options['height'] / $monitor->Height() );
$width = reScale($monitor->Width(), $scale);
$width = reScale($monitor->Width(), $scale).'px';
}
} else if ( $scale ) {
$width = reScale($monitor->Width(), $scale);
$height = reScale($monitor->Height(), $scale);
$width = reScale($monitor->Width(), $scale).'px';
$height = reScale($monitor->Height(), $scale).'px';
}
$zones = array();