From ba1100fc03ac2b838f5ad8d400189c7918820ed8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 16:06:47 -0400 Subject: [PATCH] continue conversion from array to class of Monitor --- web/api/app/Config/core.php | 7 +- web/includes/Monitor.php | 5 +- web/includes/Server.php | 3 + .../classic/includes/control_functions.php | 90 +++++++++---------- web/skins/classic/views/watch.php | 12 +-- 5 files changed, 61 insertions(+), 56 deletions(-) diff --git a/web/api/app/Config/core.php b/web/api/app/Config/core.php index 5902a2235..feb8779bf 100644 --- a/web/api/app/Config/core.php +++ b/web/api/app/Config/core.php @@ -216,19 +216,18 @@ * */ Configure::write('Session', array( - 'defaults' => 'php', - 'cookie'=>'ZMSESSID' + 'defaults' => 'php' )); /** * A random string used in security hashing methods. */ - Configure::write('Security.salt', 'Q0MjGG2xRQEhJVQR85WhFJKI7f2St8RYMlVR7GNQ'); + Configure::write('Security.salt', 'URWfoFspTQASBP8afw8enOLNCSMWZnrh2TRwoGaF'); /** * A random numeric string (digits only) used to encrypt/decrypt strings. */ - Configure::write('Security.cipherSeed', '02670120062639232092038865362'); + Configure::write('Security.cipherSeed', '07283205205652438276688533540'); /** * Apply timestamps with the last modified time to static assets (js, css, images). diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 9ebe76c3e..983bbbd86 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -13,6 +13,9 @@ class Monitor { if ( $this->{'Controllable'} ) { $s = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $this->{'ControlId'} ) ); foreach ($s as $k => $v) { + if ( $k == 'Id' ) { + continue; + } $this->{$k} = $v; } } @@ -33,7 +36,7 @@ class Monitor { public function getStreamSrc( $args, $querySep='&' ) { if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) { $Server = new Server( $this->{'ServerId'} ); - $streamSrc = ZM_BASE_PROTOCOL.'://'.$Server->Hostname.ZM_PATH_ZMS; + $streamSrc = ZM_BASE_PROTOCOL.'://'.$Server->Hostname().ZM_PATH_ZMS; } else { $streamSrc = ZM_BASE_URL.ZM_PATH_ZMS; } diff --git a/web/includes/Server.php b/web/includes/Server.php index ec01ea032..97361e544 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -21,6 +21,9 @@ class Server { return $this->{'Name'}; } public function Hostname() { + if ( ! isset( $this->{'Hostname'} ) ) { + return $this->{'Name'}; + } return $this->{'Hostname'}; } } diff --git a/web/skins/classic/includes/control_functions.php b/web/skins/classic/includes/control_functions.php index b09a53138..d77818fbf 100644 --- a/web/skins/classic/includes/control_functions.php +++ b/web/skins/classic/includes/control_functions.php @@ -30,13 +30,13 @@ function getControlCommands( $monitor ) $cmds['PresetGoto'] = "presetGoto"; $cmds['PresetHome'] = "presetHome"; - if ( !empty($monitor['CanZoom']) ) + if ( !empty($monitor->CanZoom) ) { - if ( $monitor['CanZoomCon'] ) + if ( $monitor->CanZoomCon ) $cmds['ZoomRoot'] = "zoomCon"; - elseif ( $monitor['CanZoomRel'] ) + elseif ( $monitor->CanZoomRel ) $cmds['ZoomRoot'] = "zoomRel"; - elseif ( $monitor['CanZoomAbs'] ) + elseif ( $monitor->CanZoomAbs ) $cmds['ZoomRoot'] = "zoomAbs"; $cmds['ZoomTele'] = $cmds['ZoomRoot']."Tele"; $cmds['ZoomWide'] = $cmds['ZoomRoot']."Wide"; @@ -45,13 +45,13 @@ function getControlCommands( $monitor ) $cmds['ZoomMan'] = "zoomMan"; } - if ( !empty($monitor['CanFocus']) ) + if ( !empty($monitor->CanFocus) ) { - if ( $monitor['CanFocusCon'] ) + if ( $monitor->CanFocusCon ) $cmds['FocusRoot'] = "focusCon"; - elseif ( $monitor['CanFocusRel'] ) + elseif ( $monitor->CanFocusRel ) $cmds['FocusRoot'] = "focusRel"; - elseif ( $monitor['CanFocusAbs'] ) + elseif ( $monitor->CanFocusAbs ) $cmds['FocusRoot'] = "focusAbs"; $cmds['FocusFar'] = $cmds['FocusRoot']."Far"; $cmds['FocusNear'] = $cmds['FocusRoot']."Near"; @@ -60,13 +60,13 @@ function getControlCommands( $monitor ) $cmds['FocusMan'] = "focusMan"; } - if ( !empty($monitor['CanIris']) ) + if ( !empty($monitor->CanIris) ) { - if ( $monitor['CanIrisCon'] ) + if ( $monitor->CanIrisCon ) $cmds['IrisRoot'] = "irisCon"; - elseif ( $monitor['CanIrisRel'] ) + elseif ( $monitor->CanIrisRel ) $cmds['IrisRoot'] = "irisRel"; - elseif ( $monitor['CanIrisAbs'] ) + elseif ( $monitor->CanIrisAbs ) $cmds['IrisRoot'] = "irisAbs"; $cmds['IrisOpen'] = $cmds['IrisRoot']."Open"; $cmds['IrisClose'] = $cmds['IrisRoot']."Close"; @@ -75,13 +75,13 @@ function getControlCommands( $monitor ) $cmds['IrisMan'] = "irisMan"; } - if ( !empty($monitor['CanWhite']) ) + if ( !empty($monitor->CanWhite) ) { - if ( $monitor['CanWhiteCon'] ) + if ( $monitor->CanWhiteCon ) $cmds['WhiteRoot'] = "whiteCon"; - elseif ( $monitor['CanWhiteRel'] ) + elseif ( $monitor->CanWhiteRel ) $cmds['WhiteRoot'] = "whiteRel"; - elseif ( $monitor['CanWhiteAbs'] ) + elseif ( $monitor->CanWhiteAbs ) $cmds['WhiteRoot'] = "whiteAbs"; $cmds['WhiteIn'] = $cmds['WhiteRoot']."In"; $cmds['WhiteOut'] = $cmds['WhiteRoot']."Out"; @@ -89,13 +89,13 @@ function getControlCommands( $monitor ) $cmds['WhiteMan'] = "whiteMan"; } - if ( !empty($monitor['CanGain']) ) + if ( !empty($monitor->CanGain) ) { - if ( $monitor['CanGainCon'] ) + if ( $monitor->CanGainCon ) $cmds['GainRoot'] = "gainCon"; - elseif ( $monitor['CanGainRel'] ) + elseif ( $monitor->CanGainRel ) $cmds['GainRoot'] = "gainRel"; - elseif ( $monitor['CanGainAbs'] ) + elseif ( $monitor->CanGainAbs ) $cmds['GainRoot'] = "gainAbs"; $cmds['GainUp'] = $cmds['GainRoot']."Up"; $cmds['GainDown'] = $cmds['GainRoot']."Down"; @@ -103,19 +103,19 @@ function getControlCommands( $monitor ) $cmds['GainMan'] = "gainMan"; } - if ( !empty($monitor['CanMove']) ) + if ( !empty($monitor->CanMove) ) { - if ( $monitor['CanMoveCon'] ) + if ( $monitor->CanMoveCon ) { $cmds['MoveRoot'] = "moveCon"; $cmds['Center'] = "moveStop"; } - elseif ( $monitor['CanMoveRel'] ) + elseif ( $monitor->CanMoveRel ) { $cmds['MoveRoot'] = "moveRel"; $cmds['Center'] = $cmds['PresetHome']; } - elseif ( $monitor['CanMoveAbs'] ) + elseif ( $monitor->CanMoveAbs ) { $cmds['MoveRoot'] = "moveAbs"; $cmds['Center'] = $cmds['PresetHome']; @@ -246,9 +246,9 @@ function controlPanTilt( $monitor, $cmds )
CanPan; + $hasTilt = $monitor->CanTilt; + $hasDiag = $hasPan && $hasTilt && $monitor->CanMoveDiag; ?>
@@ -271,14 +271,14 @@ function controlPresets( $monitor, $cmds ) define( "MAX_PRESETS", "12" ); - $sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."'"; + $sql = 'select * from ControlPresets where MonitorId = ?'; $labels = array(); - foreach( dbFetchAll( $sql ) as $row ) + foreach( dbFetchAll( $sql, NULL, array( $monitor->Id ) ) as $row ) { $labels[$row['Preset']] = $row['Label']; } - $presetBreak = (int)(($monitor['NumPresets']+1)/((int)(($monitor['NumPresets']-1)/MAX_PRESETS)+1)); + $presetBreak = (int)(($monitor->NumPresets+1)/((int)(($monitor->NumPresets-1)/MAX_PRESETS)+1)); ob_start(); ?> @@ -286,7 +286,7 @@ function controlPresets( $monitor, $cmds )
NumPresets; $i++ ) { ?>" value="" onclick="controlCmd('');"/>
HasHomePreset ) { ?> CanSetPresets ) { ?> - + @@ -327,19 +327,19 @@ function controlPower( $monitor, $cmds )
CanWake ) { ?> CanSleep ) { ?> CanReset ) { ?> @@ -359,22 +359,22 @@ function ptzControls( $monitor ) ?>
CanFocus ) echo controlFocus( $monitor, $cmds ); - if ( $monitor['CanZoom'] ) + if ( $monitor->CanZoom ) echo controlZoom( $monitor, $cmds ); - if ( $monitor['CanIris'] ) + if ( $monitor->CanIris ) echo controlIris( $monitor, $cmds ); - if ( $monitor['CanWhite'] ) + if ( $monitor->CanWhite ) echo controlWhite( $monitor, $cmds ); - if ( $monitor['CanMove'] || ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] ) ) + if ( $monitor->CanMove || ( $monitor->CanWake || $monitor->CanSleep || $monitor->CanReset ) ) { ?>
CanMove ) echo controlPanTilt( $monitor, $cmds ); - if ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] ) + if ( $monitor->CanWake || $monitor->CanSleep || $monitor->CanReset ) echo controlPower( $monitor, $cmds ); ?>
@@ -383,7 +383,7 @@ function ptzControls( $monitor ) ?>
HasPresets ) echo controlPresets( $monitor, $cmds ); return( ob_get_clean() ); } diff --git a/web/skins/classic/views/watch.php b/web/skins/classic/views/watch.php index a93d05c89..ad1857f9a 100644 --- a/web/skins/classic/views/watch.php +++ b/web/skins/classic/views/watch.php @@ -56,7 +56,7 @@ if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) elseif ( canStream() ) { $streamMode = "jpeg"; - $streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor->StreamReplayBuffer() ) ); + $streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor->StreamReplayBuffer ) ); } else { @@ -99,7 +99,7 @@ if ( $showPtzControls ) if ( canView( 'Control' ) && $monitor->Type() == "Local" ) { ?> -
+
Id, 'zmSettings'.$monitor->Id, 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?>
@@ -110,18 +110,18 @@ if ( canView( 'Control' ) && $monitor->Type() == "Local" ) Width, $scale ), reScale( $monitor->Height, $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name ); } elseif ( $streamMode == "jpeg" ) { if ( canStreamNative() ) - outputImageStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] ); + outputImageStream( "liveStream", $streamSrc, reScale( $monitor->Width, $scale ), reScale( $monitor->Height, $scale ), $monitor->Name ); elseif ( canStreamApplet() ) - outputHelperStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] ); + outputHelperStream( "liveStream", $streamSrc, reScale( $monitor->Width, $scale ), reScale( $monitor->Height, $scale ), $monitor->Name ); } else { - outputImageStill( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] ); + outputImageStill( "liveStream", $streamSrc, reScale( $monitor->Width, $scale ), reScale( $monitor->Height, $scale ), $monitor->Name ); } ?>