fix missing bits. Implement UrlToIndex in Monitor and fix use of Url(). Implement PathToApi as well

This commit is contained in:
Isaac Connor 2018-11-29 14:26:30 -05:00
parent 1e915e9567
commit 1c17f334d3
8 changed files with 48 additions and 12 deletions

View File

@ -561,6 +561,7 @@ CREATE TABLE `Servers` (
`Port` INTEGER UNSIGNED, `Port` INTEGER UNSIGNED,
`PathToIndex` TEXT, `PathToIndex` TEXT,
`PathToZMS` TEXT, `PathToZMS` TEXT,
`PathToApi` TEXT,
`Name` varchar(64) NOT NULL default '', `Name` varchar(64) NOT NULL default '',
`State_Id` int(10) unsigned, `State_Id` int(10) unsigned,
`Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown', `Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown',

View File

@ -329,6 +329,22 @@ SET @s = (SELECT IF(
PREPARE stmt FROM @s; PREPARE stmt FROM @s;
EXECUTE stmt; EXECUTE stmt;
--
-- Add PathToApi column to Storage
--
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Servers'
AND column_name = 'PathToApi'
) > 0,
"SELECT 'Column PathToApi already exists in Servers'",
"ALTER TABLE Servers ADD `PathToApi` TEXT AFTER `PathToZMS`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
-- --
-- Add Port column to Storage -- Add Port column to Storage
-- --

View File

@ -221,11 +221,11 @@ class Event {
null); null);
if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) { if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) {
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php'; $streamSrc .= $Server->PathToIndex();
$args['eid'] = $this->{'Id'}; $args['eid'] = $this->{'Id'};
$args['view'] = 'view_video'; $args['view'] = 'view_video';
} else { } else {
$streamSrc .= ZM_PATH_ZMS; $streamSrc .= $Server->PathToZMS();
$args['source'] = 'event'; $args['source'] = 'event';
$args['event'] = $this->{'Id'}; $args['event'] = $this->{'Id'};
@ -340,12 +340,11 @@ class Event {
} else { } else {
$Server = new Server(); $Server = new Server();
} }
$streamSrc .= $Server->Url( $streamSrc .= $Server->UrlToIndex(
ZM_MIN_STREAMING_PORT ? ZM_MIN_STREAMING_PORT ?
ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} : ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} :
null); null);
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php';
$args['eid'] = $this->{'Id'}; $args['eid'] = $this->{'Id'};
$args['fid'] = 'snapshot'; $args['fid'] = 'snapshot';
$args['view'] = 'image'; $args['view'] = 'image';
@ -573,7 +572,7 @@ class Event {
$Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server(); $Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server();
if ( $Server->Id() != ZM_SERVER_ID ) { if ( $Server->Id() != ZM_SERVER_ID ) {
$url = $Server->Url() . '/zm/api/events/'.$this->{'Id'}.'.json'; $url = $Server->UrlToApi() . '/events/'.$this->{'Id'}.'.json';
if ( ZM_OPT_USE_AUTH ) { if ( ZM_OPT_USE_AUTH ) {
if ( ZM_AUTH_RELAY == 'hashed' ) { if ( ZM_AUTH_RELAY == 'hashed' ) {
$url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS );
@ -617,7 +616,7 @@ class Event {
$Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server(); $Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server();
if ( $Server->Id() != ZM_SERVER_ID ) { if ( $Server->Id() != ZM_SERVER_ID ) {
$url = $Server->Url() . '/zm/api/events/'.$this->{'Id'}.'.json'; $url = $Server->UrlToApi() . '/events/'.$this->{'Id'}.'.json';
if ( ZM_OPT_USE_AUTH ) { if ( ZM_OPT_USE_AUTH ) {
if ( ZM_AUTH_RELAY == 'hashed' ) { if ( ZM_AUTH_RELAY == 'hashed' ) {
$url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS );

View File

@ -282,13 +282,11 @@ private $control_fields = array(
public function getStreamSrc($args, $querySep='&') { public function getStreamSrc($args, $querySep='&') {
$streamSrc = $this->Server()->Url( $streamSrc = $this->Server()->UrlToZMS(
ZM_MIN_STREAMING_PORT ? ZM_MIN_STREAMING_PORT ?
ZM_MIN_STREAMING_PORT+$this->{'Id'} : ZM_MIN_STREAMING_PORT+$this->{'Id'} :
null); null);
$streamSrc .= ZM_PATH_ZMS;
$args['monitor'] = $this->{'Id'}; $args['monitor'] = $this->{'Id'};
if ( ZM_OPT_USE_AUTH ) { if ( ZM_OPT_USE_AUTH ) {
@ -620,8 +618,8 @@ private $control_fields = array(
return $source; return $source;
} // end function Source } // end function Source
public function Url() { public function UrlToIndex() {
return $this->Server()->Url( 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 } // end class Monitor

View File

@ -10,7 +10,9 @@ class Server {
'Protocol' => '', 'Protocol' => '',
'Hostname' => '', 'Hostname' => '',
'Port' => null, 'Port' => null,
'PathPrefix' => '/zm', 'PathToIndex' => '/zm',
'PathToZMS' => ZM_PATH_ZMS,
'PathToApi' => '/zm/api',
'zmaudit' => 1, 'zmaudit' => 1,
'zmstats' => 1, 'zmstats' => 1,
'zmtrigger' => 0, 'zmtrigger' => 0,
@ -81,6 +83,7 @@ class Server {
return ZM_PATH_ZMS; return ZM_PATH_ZMS;
} }
} }
public function UrlToZMS( ) { public function UrlToZMS( ) {
return $this->Url().$this->PathToZMS(); return $this->Url().$this->PathToZMS();
} }
@ -113,6 +116,18 @@ class Server {
public function UrlToIndex( ) { public function UrlToIndex( ) {
return $this->Url().$this->PathToIndex(); return $this->Url().$this->PathToIndex();
} }
public function UrlToApi( ) {
return $this->Url().$this->PathToApi();
}
public function PathToApi( $new = null ) {
if ( $new != null )
$this->{'PathToApi'} = $new;
if ( isset($this->{'PathToApi'}) and $this->{'PathToApi'} ) {
return $this->{'PathToApi'};
}
return '/zm/api';
}
public function __call($fn, array $args){ public function __call($fn, array $args){
if ( count($args) ) { if ( count($args) ) {

View File

@ -586,6 +586,7 @@ $SLANG = array(
'PasswordsDifferent' => 'The new and confirm passwords are different', 'PasswordsDifferent' => 'The new and confirm passwords are different',
'PathToIndex' => 'Path To Index', 'PathToIndex' => 'Path To Index',
'PathToZMS' => 'Path To ZMS', 'PathToZMS' => 'Path To ZMS',
'PathToApi' => 'Path To Api',
'Paths' => 'Paths', 'Paths' => 'Paths',
'Pause' => 'Pause', 'Pause' => 'Pause',
'PhoneBW' => 'Phone B/W', 'PhoneBW' => 'Phone B/W',

View File

@ -211,6 +211,7 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
<th class="colUrl"><?php echo translate('Url') ?></th> <th class="colUrl"><?php echo translate('Url') ?></th>
<th class="colPathToIndex"><?php echo translate('PathToIndex') ?></th> <th class="colPathToIndex"><?php echo translate('PathToIndex') ?></th>
<th class="colPathToZMS"><?php echo translate('PathToZMS') ?></th> <th class="colPathToZMS"><?php echo translate('PathToZMS') ?></th>
<th class="colPathToApi"><?php echo translate('PathToApi') ?></th>
<th class="colStatus"><?php echo translate('Status') ?></th> <th class="colStatus"><?php echo translate('Status') ?></th>
<th class="colMonitorCount"><?php echo translate('Monitors') ?></th> <th class="colMonitorCount"><?php echo translate('Monitors') ?></th>
<th class="colCpuLoad"><?php echo translate('CpuLoad') ?></th> <th class="colCpuLoad"><?php echo translate('CpuLoad') ?></th>
@ -232,6 +233,7 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
<td class="colUrl"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?></td> <td class="colUrl"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?></td>
<td class="colPathToIndex"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?></td> <td class="colPathToIndex"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?></td>
<td class="colPathToZMS"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?></td> <td class="colPathToZMS"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?></td>
<td class="colPathToApi"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToApi()), $canEdit) ?></td>
<td class="colStatus <?php if ( $Server->Status() == 'NotRunning' ) { echo 'danger'; } ?>"> <td class="colStatus <?php if ( $Server->Status() == 'NotRunning' ) { echo 'danger'; } ?>">
<?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?></td> <?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?></td>
<td class="colMonitorCount"> <td class="colMonitorCount">

View File

@ -69,6 +69,10 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name());
<th scope="row"><?php echo translate('PathToZMS') ?></th> <th scope="row"><?php echo translate('PathToZMS') ?></th>
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $Server->PathToZMS() ?>"/></td> <td><input type="text" name="newServer[PathToZMS]" value="<?php echo $Server->PathToZMS() ?>"/></td>
</tr> </tr>
<tr>
<th scope="row"><?php echo translate('PathToApi') ?></th>
<td><input type="text" name="newServer[PathToApi]" value="<?php echo $Server->PathToApi() ?>"/></td>
</tr>
<tr> <tr>
<th scope="row"><?php echo translate('RunStats') ?></th> <th scope="row"><?php echo translate('RunStats') ?></th>
<td> <td>