continue conversion from array to class of Monitor

This commit is contained in:
Isaac Connor 2015-09-17 16:06:47 -04:00
parent 4c2545a5ca
commit ba1100fc03
5 changed files with 61 additions and 56 deletions

View File

@ -216,19 +216,18 @@
* *
*/ */
Configure::write('Session', array( Configure::write('Session', array(
'defaults' => 'php', 'defaults' => 'php'
'cookie'=>'ZMSESSID'
)); ));
/** /**
* A random string used in security hashing methods. * 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. * 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). * Apply timestamps with the last modified time to static assets (js, css, images).

View File

@ -13,6 +13,9 @@ class Monitor {
if ( $this->{'Controllable'} ) { if ( $this->{'Controllable'} ) {
$s = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $this->{'ControlId'} ) ); $s = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $this->{'ControlId'} ) );
foreach ($s as $k => $v) { foreach ($s as $k => $v) {
if ( $k == 'Id' ) {
continue;
}
$this->{$k} = $v; $this->{$k} = $v;
} }
} }
@ -33,7 +36,7 @@ class Monitor {
public function getStreamSrc( $args, $querySep='&' ) { public function getStreamSrc( $args, $querySep='&' ) {
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) { if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
$Server = new Server( $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 { } else {
$streamSrc = ZM_BASE_URL.ZM_PATH_ZMS; $streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;
} }

View File

@ -21,6 +21,9 @@ class Server {
return $this->{'Name'}; return $this->{'Name'};
} }
public function Hostname() { public function Hostname() {
if ( ! isset( $this->{'Hostname'} ) ) {
return $this->{'Name'};
}
return $this->{'Hostname'}; return $this->{'Hostname'};
} }
} }

View File

@ -30,13 +30,13 @@ function getControlCommands( $monitor )
$cmds['PresetGoto'] = "presetGoto"; $cmds['PresetGoto'] = "presetGoto";
$cmds['PresetHome'] = "presetHome"; $cmds['PresetHome'] = "presetHome";
if ( !empty($monitor['CanZoom']) ) if ( !empty($monitor->CanZoom) )
{ {
if ( $monitor['CanZoomCon'] ) if ( $monitor->CanZoomCon )
$cmds['ZoomRoot'] = "zoomCon"; $cmds['ZoomRoot'] = "zoomCon";
elseif ( $monitor['CanZoomRel'] ) elseif ( $monitor->CanZoomRel )
$cmds['ZoomRoot'] = "zoomRel"; $cmds['ZoomRoot'] = "zoomRel";
elseif ( $monitor['CanZoomAbs'] ) elseif ( $monitor->CanZoomAbs )
$cmds['ZoomRoot'] = "zoomAbs"; $cmds['ZoomRoot'] = "zoomAbs";
$cmds['ZoomTele'] = $cmds['ZoomRoot']."Tele"; $cmds['ZoomTele'] = $cmds['ZoomRoot']."Tele";
$cmds['ZoomWide'] = $cmds['ZoomRoot']."Wide"; $cmds['ZoomWide'] = $cmds['ZoomRoot']."Wide";
@ -45,13 +45,13 @@ function getControlCommands( $monitor )
$cmds['ZoomMan'] = "zoomMan"; $cmds['ZoomMan'] = "zoomMan";
} }
if ( !empty($monitor['CanFocus']) ) if ( !empty($monitor->CanFocus) )
{ {
if ( $monitor['CanFocusCon'] ) if ( $monitor->CanFocusCon )
$cmds['FocusRoot'] = "focusCon"; $cmds['FocusRoot'] = "focusCon";
elseif ( $monitor['CanFocusRel'] ) elseif ( $monitor->CanFocusRel )
$cmds['FocusRoot'] = "focusRel"; $cmds['FocusRoot'] = "focusRel";
elseif ( $monitor['CanFocusAbs'] ) elseif ( $monitor->CanFocusAbs )
$cmds['FocusRoot'] = "focusAbs"; $cmds['FocusRoot'] = "focusAbs";
$cmds['FocusFar'] = $cmds['FocusRoot']."Far"; $cmds['FocusFar'] = $cmds['FocusRoot']."Far";
$cmds['FocusNear'] = $cmds['FocusRoot']."Near"; $cmds['FocusNear'] = $cmds['FocusRoot']."Near";
@ -60,13 +60,13 @@ function getControlCommands( $monitor )
$cmds['FocusMan'] = "focusMan"; $cmds['FocusMan'] = "focusMan";
} }
if ( !empty($monitor['CanIris']) ) if ( !empty($monitor->CanIris) )
{ {
if ( $monitor['CanIrisCon'] ) if ( $monitor->CanIrisCon )
$cmds['IrisRoot'] = "irisCon"; $cmds['IrisRoot'] = "irisCon";
elseif ( $monitor['CanIrisRel'] ) elseif ( $monitor->CanIrisRel )
$cmds['IrisRoot'] = "irisRel"; $cmds['IrisRoot'] = "irisRel";
elseif ( $monitor['CanIrisAbs'] ) elseif ( $monitor->CanIrisAbs )
$cmds['IrisRoot'] = "irisAbs"; $cmds['IrisRoot'] = "irisAbs";
$cmds['IrisOpen'] = $cmds['IrisRoot']."Open"; $cmds['IrisOpen'] = $cmds['IrisRoot']."Open";
$cmds['IrisClose'] = $cmds['IrisRoot']."Close"; $cmds['IrisClose'] = $cmds['IrisRoot']."Close";
@ -75,13 +75,13 @@ function getControlCommands( $monitor )
$cmds['IrisMan'] = "irisMan"; $cmds['IrisMan'] = "irisMan";
} }
if ( !empty($monitor['CanWhite']) ) if ( !empty($monitor->CanWhite) )
{ {
if ( $monitor['CanWhiteCon'] ) if ( $monitor->CanWhiteCon )
$cmds['WhiteRoot'] = "whiteCon"; $cmds['WhiteRoot'] = "whiteCon";
elseif ( $monitor['CanWhiteRel'] ) elseif ( $monitor->CanWhiteRel )
$cmds['WhiteRoot'] = "whiteRel"; $cmds['WhiteRoot'] = "whiteRel";
elseif ( $monitor['CanWhiteAbs'] ) elseif ( $monitor->CanWhiteAbs )
$cmds['WhiteRoot'] = "whiteAbs"; $cmds['WhiteRoot'] = "whiteAbs";
$cmds['WhiteIn'] = $cmds['WhiteRoot']."In"; $cmds['WhiteIn'] = $cmds['WhiteRoot']."In";
$cmds['WhiteOut'] = $cmds['WhiteRoot']."Out"; $cmds['WhiteOut'] = $cmds['WhiteRoot']."Out";
@ -89,13 +89,13 @@ function getControlCommands( $monitor )
$cmds['WhiteMan'] = "whiteMan"; $cmds['WhiteMan'] = "whiteMan";
} }
if ( !empty($monitor['CanGain']) ) if ( !empty($monitor->CanGain) )
{ {
if ( $monitor['CanGainCon'] ) if ( $monitor->CanGainCon )
$cmds['GainRoot'] = "gainCon"; $cmds['GainRoot'] = "gainCon";
elseif ( $monitor['CanGainRel'] ) elseif ( $monitor->CanGainRel )
$cmds['GainRoot'] = "gainRel"; $cmds['GainRoot'] = "gainRel";
elseif ( $monitor['CanGainAbs'] ) elseif ( $monitor->CanGainAbs )
$cmds['GainRoot'] = "gainAbs"; $cmds['GainRoot'] = "gainAbs";
$cmds['GainUp'] = $cmds['GainRoot']."Up"; $cmds['GainUp'] = $cmds['GainRoot']."Up";
$cmds['GainDown'] = $cmds['GainRoot']."Down"; $cmds['GainDown'] = $cmds['GainRoot']."Down";
@ -103,19 +103,19 @@ function getControlCommands( $monitor )
$cmds['GainMan'] = "gainMan"; $cmds['GainMan'] = "gainMan";
} }
if ( !empty($monitor['CanMove']) ) if ( !empty($monitor->CanMove) )
{ {
if ( $monitor['CanMoveCon'] ) if ( $monitor->CanMoveCon )
{ {
$cmds['MoveRoot'] = "moveCon"; $cmds['MoveRoot'] = "moveCon";
$cmds['Center'] = "moveStop"; $cmds['Center'] = "moveStop";
} }
elseif ( $monitor['CanMoveRel'] ) elseif ( $monitor->CanMoveRel )
{ {
$cmds['MoveRoot'] = "moveRel"; $cmds['MoveRoot'] = "moveRel";
$cmds['Center'] = $cmds['PresetHome']; $cmds['Center'] = $cmds['PresetHome'];
} }
elseif ( $monitor['CanMoveAbs'] ) elseif ( $monitor->CanMoveAbs )
{ {
$cmds['MoveRoot'] = "moveAbs"; $cmds['MoveRoot'] = "moveAbs";
$cmds['Center'] = $cmds['PresetHome']; $cmds['Center'] = $cmds['PresetHome'];
@ -246,9 +246,9 @@ function controlPanTilt( $monitor, $cmds )
<div class="pantilLabel"><?php echo translate('PanTilt') ?></div> <div class="pantilLabel"><?php echo translate('PanTilt') ?></div>
<div class="pantiltButtons"> <div class="pantiltButtons">
<?php <?php
$hasPan = $monitor['CanPan']; $hasPan = $monitor->CanPan;
$hasTilt = $monitor['CanTilt']; $hasTilt = $monitor->CanTilt;
$hasDiag = $hasPan && $hasTilt && $monitor['CanMoveDiag']; $hasDiag = $hasPan && $hasTilt && $monitor->CanMoveDiag;
?> ?>
<div class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></div> <div class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></div>
<div class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></div> <div class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></div>
@ -271,14 +271,14 @@ function controlPresets( $monitor, $cmds )
define( "MAX_PRESETS", "12" ); define( "MAX_PRESETS", "12" );
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."'"; $sql = 'select * from ControlPresets where MonitorId = ?';
$labels = array(); $labels = array();
foreach( dbFetchAll( $sql ) as $row ) foreach( dbFetchAll( $sql, NULL, array( $monitor->Id ) ) as $row )
{ {
$labels[$row['Preset']] = $row['Label']; $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(); ob_start();
?> ?>
@ -286,7 +286,7 @@ function controlPresets( $monitor, $cmds )
<!--<div><?php echo translate('Presets') ?></div>--> <!--<div><?php echo translate('Presets') ?></div>-->
<div> <div>
<?php <?php
for ( $i = 1; $i <= $monitor['NumPresets']; $i++ ) for ( $i = 1; $i <= $monitor->NumPresets; $i++ )
{ {
?><input type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?$labels[$i]:"" ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/><?php ?><input type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?$labels[$i]:"" ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/><?php
if ( $i && (($i%$presetBreak) == 0) ) if ( $i && (($i%$presetBreak) == 0) )
@ -298,16 +298,16 @@ function controlPresets( $monitor, $cmds )
</div> </div>
<div> <div>
<?php <?php
if ( $monitor['HasHomePreset'] ) if ( $monitor->HasHomePreset )
{ {
?> ?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/> <input type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/>
<?php <?php
} }
if ( canEdit( 'Monitors') && $monitor['CanSetPresets'] ) if ( canEdit( 'Monitors') && $monitor->CanSetPresets )
{ {
?> ?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Set') ?>" onclick="createPopup( '?view=controlpreset&amp;mid=<?php echo $monitor['Id'] ?>', 'zmPreset', 'preset' );"/> <input type="button" class="ptzTextBtn" value="<?php echo translate('Set') ?>" onclick="createPopup( '?view=controlpreset&amp;mid=<?php echo $monitor->Id ?>', 'zmPreset', 'preset' );"/>
<?php <?php
} }
?> ?>
@ -327,19 +327,19 @@ function controlPower( $monitor, $cmds )
<div class="powerLabel"><?php echo translate('Control') ?></div> <div class="powerLabel"><?php echo translate('Control') ?></div>
<div> <div>
<?php <?php
if ( $monitor['CanWake'] ) if ( $monitor->CanWake )
{ {
?> ?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Wake') ?>" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"/> <input type="button" class="ptzTextBtn" value="<?php echo translate('Wake') ?>" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"/>
<?php <?php
} }
if ( $monitor['CanSleep'] ) if ( $monitor->CanSleep )
{ {
?> ?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Sleep') ?>" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"/> <input type="button" class="ptzTextBtn" value="<?php echo translate('Sleep') ?>" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"/>
<?php <?php
} }
if ( $monitor['CanReset'] ) if ( $monitor->CanReset )
{ {
?> ?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Reset') ?>" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"/> <input type="button" class="ptzTextBtn" value="<?php echo translate('Reset') ?>" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"/>
@ -359,22 +359,22 @@ function ptzControls( $monitor )
?> ?>
<div class="controlsPanel"> <div class="controlsPanel">
<?php <?php
if ( $monitor['CanFocus'] ) if ( $monitor->CanFocus )
echo controlFocus( $monitor, $cmds ); echo controlFocus( $monitor, $cmds );
if ( $monitor['CanZoom'] ) if ( $monitor->CanZoom )
echo controlZoom( $monitor, $cmds ); echo controlZoom( $monitor, $cmds );
if ( $monitor['CanIris'] ) if ( $monitor->CanIris )
echo controlIris( $monitor, $cmds ); echo controlIris( $monitor, $cmds );
if ( $monitor['CanWhite'] ) if ( $monitor->CanWhite )
echo controlWhite( $monitor, $cmds ); echo controlWhite( $monitor, $cmds );
if ( $monitor['CanMove'] || ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] ) ) if ( $monitor->CanMove || ( $monitor->CanWake || $monitor->CanSleep || $monitor->CanReset ) )
{ {
?> ?>
<div class="pantiltPanel"> <div class="pantiltPanel">
<?php <?php
if ( $monitor['CanMove'] ) if ( $monitor->CanMove )
echo controlPanTilt( $monitor, $cmds ); echo controlPanTilt( $monitor, $cmds );
if ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] ) if ( $monitor->CanWake || $monitor->CanSleep || $monitor->CanReset )
echo controlPower( $monitor, $cmds ); echo controlPower( $monitor, $cmds );
?> ?>
</div> </div>
@ -383,7 +383,7 @@ function ptzControls( $monitor )
?> ?>
</div> </div>
<?php <?php
if ( $monitor['HasPresets'] ) if ( $monitor->HasPresets )
echo controlPresets( $monitor, $cmds ); echo controlPresets( $monitor, $cmds );
return( ob_get_clean() ); return( ob_get_clean() );
} }

View File

@ -56,7 +56,7 @@ if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
elseif ( canStream() ) elseif ( canStream() )
{ {
$streamMode = "jpeg"; $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 else
{ {
@ -99,7 +99,7 @@ if ( $showPtzControls )
if ( canView( 'Control' ) && $monitor->Type() == "Local" ) if ( canView( 'Control' ) && $monitor->Type() == "Local" )
{ {
?> ?>
<div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor['Id'], 'zmSettings'.$monitor['Id'], 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div> <div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor->Id, 'zmSettings'.$monitor->Id, 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div>
<?php <?php
} }
?> ?>
@ -110,18 +110,18 @@ if ( canView( 'Control' ) && $monitor->Type() == "Local" )
<?php <?php
if ( $streamMode == "mpeg" ) if ( $streamMode == "mpeg" )
{ {
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT, $monitor['Name'] ); outputVideoStream( "liveStream", $streamSrc, reScale( $monitor->Width, $scale ), reScale( $monitor->Height, $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name );
} }
elseif ( $streamMode == "jpeg" ) elseif ( $streamMode == "jpeg" )
{ {
if ( canStreamNative() ) 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() ) 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 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 );
} }
?> ?>
</div> </div>