rework from Url() to PathToIndex(), PathToZMS(), UrlToIndex() and UrlToZMS()

This commit is contained in:
Isaac Connor 2018-11-27 17:35:25 -05:00
parent c5f7fb7b18
commit f8b2ff5c77
9 changed files with 59 additions and 23 deletions

View File

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

View File

@ -2,12 +2,6 @@
-- This updates a 1.32.2 database to 1.32.3
--
--
-- Add some additional monitor preset values
--
INSERT INTO MonitorPresets VALUES (NULL,'D-link DCS-930L, 640x480, mjpeg','Remote','http',0,0,'http','simple','<ip-address>',80,'/mjpeg.cgi',NULL,640,480,3,NULL,0,NULL,NULL,NULL,100,100);
--
-- Add Protocol column to Storage
--
@ -25,16 +19,32 @@ PREPARE stmt FROM @s;
EXECUTE stmt;
--
-- Add Prefix column to Storage
-- Add PathToIndex column to Storage
--
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Servers'
AND column_name = 'PathPrefix'
AND column_name = 'PathToIndex'
) > 0,
"SELECT 'Column PathPrefix already exists in Servers'",
"ALTER TABLE Servers ADD `PathPrefix` TEXT AFTER `Hostname`"
"SELECT 'Column PathToIndex already exists in Servers'",
"ALTER TABLE Servers ADD `PathToIndex` TEXT AFTER `Hostname`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
--
-- Add PathToZMS column to Storage
--
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Servers'
AND column_name = 'PathToZMS'
) > 0,
"SELECT 'Column PathToZMS already exists in Servers'",
"ALTER TABLE Servers ADD `PathToZMS` TEXT AFTER `PathToIndex`"
));
PREPARE stmt FROM @s;

View File

@ -72,6 +72,19 @@ class Server {
return $_SERVER['SERVER_PORT'];
}
public function PathToZMS( $new = null ) {
if ( $new != null )
$this{'PathToZMS'} = $new;
if ( $this->Id() and $this->{'PathToZMS'} ) {
return $this->{'PathToZMS'};
} else {
return ZM_PATH_ZMS;
}
}
public function UrlToZMS( ) {
return $this->Url().$this->PathToZMS();
}
public function Url( $port = null ) {
$url = $this->Protocol().'://';
if ( $this->Id() ) {
@ -84,20 +97,23 @@ class Server {
} else {
$url .= ':'.$this->Port();
}
$url .= $this->PathPrefix();
return $url;
}
public function PathPrefix( $new = null ) {
public function PathToIndex( $new = null ) {
if ( $new != null )
$this->{'PathPrefix'} = $new;
$this->{'PathToIndex'} = $new;
if ( isset($this->{'PathPrefix'}) and $this->{'PathPrefix'} ) {
return $this->{'PathPrefix'};
if ( isset($this->{'PathToIndex'}) and $this->{'PathToIndex'} ) {
return $this->{'PathToIndex'};
}
return $_SERVER['PHP_SELF'];
}
public function UrlToIndex( ) {
return $this->Url().$this->PathToIndex();
}
public function __call($fn, array $args){
if ( count($args) ) {
$this->{$fn} = $args[0];

View File

@ -35,7 +35,7 @@ monitorData[monitorData.length] = {
'connKey': <?php echo $monitor->connKey() ?>,
'width': <?php echo $monitor->Width() ?>,
'height':<?php echo $monitor->Height() ?>,
'url': '<?php echo $monitor->Url() ?>',
'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() ?>'

View File

@ -48,7 +48,7 @@ var maxDisplayEvents = <?php echo 2 * MAX_EVENTS ?>;
var monitorId = <?php echo $monitor->Id() ?>;
var monitorWidth = <?php echo $monitor->Width() ?>;
var monitorHeight = <?php echo $monitor->Height() ?>;
var monitorUrl = '<?php echo $monitor->Url(); ?>';
var monitorUrl = '<?php echo $monitor->UrlToIndex(); ?>';
var monitorType = '<?php echo ( $monitor->Type() ) ?>';
var monitorRefresh = '<?php echo ( $monitor->Refresh() ) ?>';

View File

@ -101,7 +101,7 @@ var streamMode = "<?php echo $streamMode ?>";
var connKey = '<?php echo $connkey ?>';
var monitorId = <?php echo $monitor->Id() ?>;
var monitorUrl = '<?php echo ( $monitor->Url() ) ?>';
var monitorUrl = '<?php echo ( $monitor->UrlToIndex() ) ?>';
var streamSrc = "<?php echo preg_replace( '/&amp;/', '&', $streamSrc ) ?>";

View File

@ -1,4 +1,4 @@
var connKey = '<?php echo $connkey ?>';
var monitorUrl = '<?php echo ( $monitor->Url() ) ?>';
var monitorUrl = '<?php echo ( $monitor->UrlToIndex() ) ?>';
var CMD_QUIT = <?php echo CMD_QUIT ?>;

View File

@ -209,6 +209,8 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
<tr>
<th class="colName"><?php echo translate('Name') ?></th>
<th class="colUrl"><?php echo translate('Url') ?></th>
<th class="colPathToIndex"><?php echo translate('PathToIndex') ?></th>
<th class="colPathToZMS"><?php echo translate('PathToZMS') ?></th>
<th class="colStatus"><?php echo translate('Status') ?></th>
<th class="colMonitorCount"><?php echo translate('Monitors') ?></th>
<th class="colCpuLoad"><?php echo translate('CpuLoad') ?></th>
@ -228,6 +230,8 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
<tr>
<td class="colName"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $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="colPathToZMS"><?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?></td>
<td class="colStatus <?php if ( $row['Status'] == 'NotRunning' ) { echo 'danger'; } ?>">
<?php echo makePopupLink('?view=server&amp;id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?></td>
<td class="colMonitorCount">

View File

@ -33,7 +33,8 @@ if ( $_REQUEST['id'] ) {
$newServer['Name'] = translate('NewServer');
$newServer['Protocol'] = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
$newServer['Hostname'] = '';
$newServer['PathPrefix'] = '/zm';
$newServer['PathToIndex'] = '/zm/index.php';
$newServer['PathToZMS'] = ZM_PATH_ZMS;
$newServer['zmstats'] = '';
$newServer['zmaudit'] = '';
$newServer['zmtrigger'] = '';
@ -72,8 +73,12 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
<td><input type="number" name="newServer[Port]" value="<?php echo $newServer['Port'] ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('PathPrefix') ?></th>
<td><input type="text" name="newServer[PathPrefix]" value="<?php echo $newServer['PathPrefix'] ?>"/></td>
<th scope="row"><?php echo translate('PathToIndex') ?></th>
<td><input type="text" name="newServer[PathToIndex]" value="<?php echo $newServer['PathToIndex'] ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('PathToZMS') ?></th>
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $newServer['PathToZMS'] ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('RunStats') ?></th>