Merge pull request #2152 from connortechnology/server_path_prefix
Server path prefix
This commit is contained in:
commit
be07e4413f
|
@ -556,7 +556,11 @@ INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');
|
|||
DROP TABLE IF EXISTS `Servers`;
|
||||
CREATE TABLE `Servers` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Protocol` TEXT,
|
||||
`Hostname` TEXT,
|
||||
`Port` INTEGER UNSIGNED,
|
||||
`PathToIndex` TEXT,
|
||||
`PathToZMS` TEXT,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`State_Id` int(10) unsigned,
|
||||
`Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown',
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
ALTER TABLE Frames MODIFY COLUMN EventId bigint unsigned NOT NULL;
|
||||
|
||||
|
|
|
@ -280,3 +280,67 @@ UPDATE Monitors INNER JOIN (
|
|||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace;
|
||||
|
||||
--
|
||||
-- Add Protocol column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Protocol'
|
||||
) > 0,
|
||||
"SELECT 'Column Protocol already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Protocol` TEXT AFTER `Id`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- 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 = 'PathToIndex'
|
||||
) > 0,
|
||||
"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;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add Port column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Port'
|
||||
) > 0,
|
||||
"SELECT 'Column Port already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Port` INTEGER UNSIGNED AFTER `Hostname`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
|
@ -198,26 +198,28 @@ class Event {
|
|||
|
||||
public function getStreamSrc( $args=array(), $querySep='&' ) {
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
$streamSrc = '';
|
||||
$Server = null;
|
||||
if ( $this->Storage()->ServerId() ) {
|
||||
# The Event may have been moved to Storage on another server,
|
||||
# So prefer viewing the Event from the Server that is actually
|
||||
# storing the video
|
||||
$Server = $this->Storage()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( $this->Monitor()->ServerId() ) {
|
||||
# Assume that the server that recorded it has it
|
||||
$Server = $this->Monitor()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
# A default Server will result in the use of ZM_DIR_EVENTS
|
||||
$Server = new Server();
|
||||
}
|
||||
|
||||
# If we are in a multi-port setup, then use the multiport, else by
|
||||
# passing null Server->Url will use the Port set in the Server setting
|
||||
$streamSrc .= $Server->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} :
|
||||
null);
|
||||
|
||||
if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) {
|
||||
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php';
|
||||
$args['eid'] = $this->{'Id'};
|
||||
|
@ -238,10 +240,10 @@ class Event {
|
|||
if ( ZM_OPT_USE_AUTH ) {
|
||||
if ( ZM_AUTH_RELAY == 'hashed' ) {
|
||||
$args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
|
||||
} elseif ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
$args['pass'] = $_SESSION['password'];
|
||||
} elseif ( ZM_AUTH_RELAY == 'none' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'none' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
}
|
||||
}
|
||||
|
@ -328,25 +330,20 @@ class Event {
|
|||
# The thumbnail is theoretically the image with the most motion.
|
||||
# We always store at least 1 image when capturing
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
$streamSrc = '';
|
||||
$Server = null;
|
||||
if ( $this->Storage()->ServerId() ) {
|
||||
$Server = $this->Storage()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( $this->Monitor()->ServerId() ) {
|
||||
# Assume that the server that recorded it has it
|
||||
$Server = $this->Monitor()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$Server = new Server();
|
||||
}
|
||||
$streamSrc .= $Server->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} :
|
||||
null);
|
||||
|
||||
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php';
|
||||
$args['eid'] = $this->{'Id'};
|
||||
|
@ -358,10 +355,10 @@ class Event {
|
|||
if ( ZM_OPT_USE_AUTH ) {
|
||||
if ( ZM_AUTH_RELAY == 'hashed' ) {
|
||||
$args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
|
||||
} elseif ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
$args['pass'] = $_SESSION['password'];
|
||||
} elseif ( ZM_AUTH_RELAY == 'none' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'none' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,20 +280,13 @@ private $control_fields = array(
|
|||
}
|
||||
}
|
||||
|
||||
public function getStreamSrc( $args, $querySep='&' ) {
|
||||
public function getStreamSrc($args, $querySep='&') {
|
||||
|
||||
$streamSrc = $this->Server()->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'Id'} :
|
||||
null);
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
|
||||
$Server = new Server( $this->{'ServerId'} );
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'});
|
||||
}
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$streamSrc .= ZM_PATH_ZMS;
|
||||
|
||||
$args['monitor'] = $this->{'Id'};
|
||||
|
@ -315,9 +308,9 @@ private $control_fields = array(
|
|||
$args['rand'] = time();
|
||||
}
|
||||
|
||||
$streamSrc .= '?'.http_build_query( $args,'', $querySep );
|
||||
$streamSrc .= '?'.http_build_query($args,'', $querySep);
|
||||
|
||||
return( $streamSrc );
|
||||
return $streamSrc;
|
||||
} // end function getStreamSrc
|
||||
|
||||
public function Width($new = null) {
|
||||
|
@ -600,13 +593,15 @@ private $control_fields = array(
|
|||
$source = preg_replace( '/^.*\//', '', $this->{'Path'} );
|
||||
} elseif ( $this->{'Type'} == 'Ffmpeg' || $this->{'Type'} == 'Libvlc' || $this->{'Type'} == 'WebSite' ) {
|
||||
$url_parts = parse_url( $this->{'Path'} );
|
||||
if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) { # Filter out everything but the hostname
|
||||
if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) {
|
||||
# Filter out everything but the hostname
|
||||
if ( isset($url_parts['host']) ) {
|
||||
$source = $url_parts['host'];
|
||||
} else {
|
||||
$source = $this->{'Path'};
|
||||
}
|
||||
} elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) { # Filter out sensitive and common items
|
||||
} elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) {
|
||||
# Filter out sensitive and common items
|
||||
unset($url_parts['user']);
|
||||
unset($url_parts['pass']);
|
||||
#unset($url_parts['scheme']);
|
||||
|
|
|
@ -5,23 +5,25 @@ $server_cache = array();
|
|||
|
||||
class Server {
|
||||
private $defaults = array(
|
||||
'Id' => null,
|
||||
'Name' => '',
|
||||
'Hostname' => '',
|
||||
'zmaudit' => 1,
|
||||
'zmstats' => 1,
|
||||
'zmtrigger' => 0,
|
||||
'Id' => null,
|
||||
'Name' => '',
|
||||
'Protocol' => '',
|
||||
'Hostname' => '',
|
||||
'Port' => null,
|
||||
'PathPrefix' => '/zm',
|
||||
'zmaudit' => 1,
|
||||
'zmstats' => 1,
|
||||
'zmtrigger' => 0,
|
||||
);
|
||||
|
||||
|
||||
public function __construct( $IdOrRow = NULL ) {
|
||||
global $server_cache;
|
||||
public function __construct($IdOrRow = NULL) {
|
||||
global $server_cache;
|
||||
$row = NULL;
|
||||
if ( $IdOrRow ) {
|
||||
if ( is_integer($IdOrRow) or ctype_digit($IdOrRow) ) {
|
||||
$row = dbFetchOne('SELECT * FROM Servers WHERE Id=?', NULL, array($IdOrRow));
|
||||
if ( !$row ) {
|
||||
Error("Unable to load Server record for Id=" . $IdOrRow);
|
||||
Error('Unable to load Server record for Id='.$IdOrRow);
|
||||
}
|
||||
} elseif ( is_array($IdOrRow) ) {
|
||||
$row = $IdOrRow;
|
||||
|
@ -33,13 +35,58 @@ class Server {
|
|||
}
|
||||
$server_cache[$row['Id']] = $this;
|
||||
} else {
|
||||
$this->{'Name'} = '';
|
||||
$this->{'Hostname'} = '';
|
||||
# Set defaults
|
||||
foreach ( $this->defaults as $k => $v ) $this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
public function Hostname( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'Hostname'} = $new;
|
||||
|
||||
if ( isset( $this->{'Hostname'}) and ( $this->{'Hostname'} != '' ) ) {
|
||||
return $this->{'Hostname'};
|
||||
} else if ( $this->Id() ) {
|
||||
return $this->{'Name'};
|
||||
}
|
||||
return $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
|
||||
public function Protocol( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'Protocol'} = $new;
|
||||
|
||||
if ( isset($this->{'Protocol'}) and ( $this->{'Protocol'} != '' ) ) {
|
||||
return $this->{'Protocol'};
|
||||
}
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
|
||||
}
|
||||
|
||||
public function Port( $new = '' ) {
|
||||
if ( $new != '' )
|
||||
$this->{'Port'} = $new;
|
||||
|
||||
if ( isset($this->{'Port'}) and $this->{'Port'} ) {
|
||||
return $this->{'Port'};
|
||||
}
|
||||
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 = ZM_BASE_PROTOCOL . '://';
|
||||
$url = $this->Protocol().'://';
|
||||
if ( $this->Id() ) {
|
||||
$url .= $this->Hostname();
|
||||
} else {
|
||||
|
@ -48,17 +95,25 @@ class Server {
|
|||
if ( $port ) {
|
||||
$url .= ':'.$port;
|
||||
} else {
|
||||
$url .= ':'.$_SERVER['SERVER_PORT'];
|
||||
$url .= ':'.$this->Port();
|
||||
}
|
||||
$url .= $_SERVER['PHP_SELF'];
|
||||
return $url;
|
||||
}
|
||||
public function Hostname() {
|
||||
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
|
||||
return $this->{'Hostname'};
|
||||
}
|
||||
return $this->{'Name'};
|
||||
}
|
||||
|
||||
public function PathToIndex( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'PathToIndex'} = $new;
|
||||
|
||||
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];
|
||||
|
@ -66,13 +121,13 @@ class Server {
|
|||
if ( array_key_exists($fn, $this) ) {
|
||||
return $this->{$fn};
|
||||
} else {
|
||||
if ( array_key_exists( $fn, $this->defaults ) ) {
|
||||
if ( array_key_exists($fn, $this->defaults) ) {
|
||||
return $this->defaults{$fn};
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
$file = $backTrace[1]['file'];
|
||||
$line = $backTrace[1]['line'];
|
||||
Warning( "Unknown function call Server->$fn from $file:$line" );
|
||||
Warning("Unknown function call Server->$fn from $file:$line");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +172,7 @@ class Server {
|
|||
}
|
||||
$results = dbFetchAll( $sql, NULL, $values );
|
||||
if ( $results ) {
|
||||
return array_map( function($id){ return new Server($id); }, $results );
|
||||
return array_map(function($id){ return new Server($id); }, $results);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
@ -137,5 +192,5 @@ class Server {
|
|||
return $results[0];
|
||||
}
|
||||
|
||||
}
|
||||
} # end class Server
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class Server {
|
||||
constructor(json) {
|
||||
for( var k in json ) {
|
||||
this[k] = json[k];
|
||||
}
|
||||
}
|
||||
url(port=0){
|
||||
return location.protocol+'//'+this.Hostname+
|
||||
(port ? ':'+port : '') +
|
||||
( ( this.PathPrefix && this.PathPrefix != 'null') ? this.PathPrefix : '');
|
||||
}
|
||||
};
|
|
@ -584,6 +584,8 @@ $SLANG = array(
|
|||
'Parameter' => 'Parameter',
|
||||
'Password' => 'Password',
|
||||
'PasswordsDifferent' => 'The new and confirm passwords are different',
|
||||
'PathToIndex' => 'Path To Index',
|
||||
'PathToZMS' => 'Path To ZMS',
|
||||
'Paths' => 'Paths',
|
||||
'Pause' => 'Pause',
|
||||
'PhoneBW' => 'Phone B/W',
|
||||
|
|
|
@ -119,6 +119,7 @@ echo output_link_if_exists( array(
|
|||
<script src="skins/<?php echo $skin; ?>/js/chosen/chosen.jquery.min.js"></script>
|
||||
<script src="skins/<?php echo $skin; ?>/js/dateTimePicker/jquery-ui-timepicker-addon.js"></script>
|
||||
|
||||
<script src="<?php echo cache_bust('js/Server.js'); ?>"></script>
|
||||
<script>
|
||||
jQuery(document).ready(function(){
|
||||
jQuery("#flip").click(function(){
|
||||
|
@ -127,16 +128,8 @@ echo output_link_if_exists( array(
|
|||
Cookie.write( 'zmHeaderFlip', jQuery('#flip').hasClass('glyphicon-menu-up') ? 'up' : 'down', { duration: 10*365 } );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//<![CDATA[
|
||||
<!--
|
||||
var $j = jQuery.noConflict();
|
||||
// $j is now an alias to the jQuery function; creating the new alias is optional.
|
||||
|
||||
//-->
|
||||
//]]>
|
||||
</script>
|
||||
<script src="skins/<?php echo $skin; ?>/views/js/state.js"></script>
|
||||
<?php
|
||||
|
|
|
@ -205,7 +205,6 @@ if ( currentView != 'none' && currentView != 'login' ) {
|
|||
}
|
||||
|
||||
function setNavBar(data) {
|
||||
console.log(data);
|
||||
if ( data.auth ) {
|
||||
if ( data.auth != auth_hash ) {
|
||||
// Update authentication token.
|
||||
|
|
|
@ -31,6 +31,7 @@ var navBarRefresh = <?php echo 1000*ZM_WEB_REFRESH_NAVBAR ?>;
|
|||
var currentView = '<?php echo $view ?>';
|
||||
var thisUrl = "<?php echo ZM_BASE_URL.$_SERVER['PHP_SELF'] ?>";
|
||||
var skinPath = "<?php echo ZM_SKIN_PATH ?>";
|
||||
var serverId = '<?php echo defined('ZM_SERVER_ID') ? ZM_SERVER_ID : '' ?>';
|
||||
|
||||
var canEditSystem = <?php echo canEdit('System' )?'true':'false' ?>;
|
||||
var canViewSystem = <?php echo canView('System' )?'true':'false' ?>;
|
||||
|
|
|
@ -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() ?>'
|
||||
|
|
|
@ -117,24 +117,21 @@ function getImageSource( monId, time ) {
|
|||
Event = events[Frame.EventId];
|
||||
|
||||
var storage = Storage[Event.StorageId];
|
||||
if ( storage.ServerId ) {
|
||||
var server = Servers[storage.ServerId];
|
||||
if ( server ) {
|
||||
//console.log( server.Hostname + " for event " + eId[i] );
|
||||
return location.protocol + '//' + server.Hostname +
|
||||
//'/cgi-bin/zms?mode=jpeg&replay=single&event=' + event_id +
|
||||
//'&frame='+Frame.FrameId +
|
||||
'/zm/index.php?view=image&eid=' + Frame.EventId + '&fid='+Frame.FrameId +
|
||||
"&width=" + monitorCanvasObj[monId].width +
|
||||
"&height=" + monitorCanvasObj[monId].height;
|
||||
} else {
|
||||
console.log("No server found for " + storage.ServerId );
|
||||
}
|
||||
var server = storage.ServerId ? Servers[storage.ServerId] : Servers[serverId];
|
||||
if ( server ) {
|
||||
return server.url() +
|
||||
//location.protocol + '//' + server.Hostname +
|
||||
//'/cgi-bin/zms?mode=jpeg&replay=single&event=' + event_id +
|
||||
//'&frame='+Frame.FrameId +
|
||||
'/index.php?view=image&eid=' + Frame.EventId + '&fid='+Frame.FrameId +
|
||||
"&width=" + monitorCanvasObj[monId].width +
|
||||
"&height=" + monitorCanvasObj[monId].height;
|
||||
}
|
||||
console.log("No server found for " + ( storage.ServerId ? storage.ServerId : serverId ));
|
||||
//console.log("No storage found for " + eStorageId[i] );
|
||||
return '/zm/index.php?view=image&eid=' + Frame.EventId + '&fid='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
//return "/cgi-bin/zms?mode=single&replay=single&event=" + Frame.EventId + '&time='+time+ "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
return "/cgi-bin/zms?mode=jpeg&replay=single&event=" + Frame.EventId + '&frame='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
//return "/cgi-bin/zms?mode=jpeg&replay=single&event=" + Frame.EventId + '&frame='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
} // end found Frame
|
||||
return '';
|
||||
//return "no data";
|
||||
|
@ -168,7 +165,7 @@ function imagedone( obj, monId, success ) {
|
|||
}
|
||||
} else {
|
||||
if ( monitorLoadingStageURL[monId] == "" ) {
|
||||
console.log("Not showing image for " + monId );
|
||||
//console.log("Not showing image for " + monId );
|
||||
// This means that there wasn't a loading image placeholder.
|
||||
// So we weren't actually loading an image... which seems weird.
|
||||
return;
|
||||
|
@ -246,7 +243,7 @@ console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval + "
|
|||
setSpeed(0);
|
||||
outputUpdate(currentTimeSecs);
|
||||
} else {
|
||||
console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval );
|
||||
//console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval );
|
||||
outputUpdate(playSecsperInterval + currentTimeSecs);
|
||||
}
|
||||
return;
|
||||
|
@ -368,7 +365,7 @@ function drawGraph() {
|
|||
underSlider=undefined;
|
||||
return;
|
||||
}
|
||||
var rowHeight=parseInt(cHeight / (numMonitors + 1) ); // Leave room for a scale of some sort
|
||||
var rowHeight = parseInt(cHeight / (numMonitors + 1) ); // Leave room for a scale of some sort
|
||||
|
||||
// first fill in the bars for the events (not alarms)
|
||||
|
||||
|
@ -473,7 +470,7 @@ function outputUpdate(time) {
|
|||
drawSliderOnGraph(time);
|
||||
for ( var i=0; i < numMonitors; i++ ) {
|
||||
var src = getImageSource(monitorPtr[i],time);
|
||||
console.log("New image src: " + src);
|
||||
//console.log("New image src: " + src);
|
||||
loadImage2Monitor(monitorPtr[i],src);
|
||||
}
|
||||
currentTimeSecs = time;
|
||||
|
|
|
@ -118,13 +118,13 @@ echo " };\n";
|
|||
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
|
||||
} // end if initialmodeislive
|
||||
|
||||
echo "var Storage = [];\n";
|
||||
echo "\nvar Storage = [];\n";
|
||||
foreach ( Storage::find() as $Storage ) {
|
||||
echo 'Storage[' . $Storage->Id() . '] = ' . json_encode($Storage). ";\n";
|
||||
echo 'Storage[' . $Storage->Id() . '] = ' . json_encode($Storage). ";\n";
|
||||
}
|
||||
echo "\nvar Servers = [];\n";
|
||||
foreach ( Server::find() as $Server ) {
|
||||
echo 'Servers[' . $Server->Id() . '] = ' . json_encode($Server). ";\n";
|
||||
echo 'Servers[' . $Server->Id() . '] = new Server(' . json_encode($Server). ");\n";
|
||||
}
|
||||
echo '
|
||||
var monitorName = [];
|
||||
|
|
|
@ -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() ) ?>';
|
||||
|
||||
|
|
|
@ -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( '/&/', '&', $streamSrc ) ?>";
|
||||
|
||||
|
|
|
@ -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 ?>;
|
||||
|
||||
|
|
|
@ -208,7 +208,9 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
|||
<thead class="thead-highlight">
|
||||
<tr>
|
||||
<th class="colName"><?php echo translate('Name') ?></th>
|
||||
<th class="colHostname"><?php echo translate('Hostname') ?></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>
|
||||
|
@ -222,27 +224,33 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach( dbFetchAll( 'SELECT *,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers ORDER BY Id' ) as $row ) {
|
||||
$monitor_counts = dbFetchAssoc('SELECT Id,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers', 'Id', 'MonitorCount');
|
||||
foreach ( Server::find() as $Server ) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="colName"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Name']), $canEdit ) ?></td>
|
||||
<td class="colHostname"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Hostname']), $canEdit ) ?></td>
|
||||
<td class="colStatus
|
||||
<?php if ( $row['Status'] == 'NotRunning' ) { echo 'danger'; } ?>
|
||||
"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Status']), $canEdit ) ?></td>
|
||||
<td class="colMonitorCount"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['MonitorCount']), $canEdit ) ?></td>
|
||||
<td class="colCpuLoad
|
||||
<?php if ( $row['CpuLoad'] > 5 ) { echo 'danger'; } ?>
|
||||
"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server',$row['CpuLoad'], $canEdit ) ?></td>
|
||||
<td class="colMemory
|
||||
<?php if ( $row['FreeMem']/$row['TotalMem'] < .1 ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeMem']) . ' / ' . human_filesize($row['TotalMem']), $canEdit ) ?></td>
|
||||
<td class="colSwap
|
||||
<?php if ( (!$row['TotalSwap']) or ($row['FreeSwap']/$row['TotalSwap'] < .1) ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeSwap']) . ' / ' . human_filesize($row['TotalSwap']) , $canEdit ) ?></td>
|
||||
<td class="colStats"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmstats'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colAudit"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmaudit'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colTrigger"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmtrigger'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colName"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?></td>
|
||||
<td class="colUrl"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?></td>
|
||||
<td class="colPathToIndex"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?></td>
|
||||
<td class="colPathToZMS"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?></td>
|
||||
<td class="colStatus <?php if ( $Server->Status() == 'NotRunning' ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?></td>
|
||||
<td class="colMonitorCount">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($monitor_counts[$Server->Id()]), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colCpuLoad <?php if ( $Server->CpuLoad() > 5 ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server',$Server->CpuLoad(), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colMemory <?php if ( $Server->FreeMem()/$Server->TotalMem() < .1 ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', human_filesize($Server->FreeMem()) . ' / ' . human_filesize($Server->TotalMem()), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colSwap <?php if ( (!$Server->TotalSwap()) or ($Server->FreeSwap()/$Server->TotalSwap() < .1) ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', human_filesize($Server->FreeSwap()) . ' / ' . human_filesize($Server->TotalSwap()) , $canEdit) ?>
|
||||
</td>
|
||||
<td class="colStats"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmstats() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
<td class="colAudit"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmaudit() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
<td class="colTrigger"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmtrigger() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
|
||||
<td class="colMark"><input type="checkbox" name="markIds[]" value="<?php echo $row['Id'] ?>" onclick="configureDeleteButton( this );"<?php if ( !$canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
|
||||
<td class="colMark"><input type="checkbox" name="markIds[]" value="<?php echo $Server->Id() ?>" onclick="configureDeleteButton(this);"<?php if ( !$canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
|
||||
</tr>
|
||||
<?php } #end foreach Server ?>
|
||||
</tbody>
|
||||
|
|
|
@ -23,31 +23,23 @@ if ( !canEdit('System') ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( $_REQUEST['id'] ) {
|
||||
if ( !($newServer = dbFetchOne('SELECT * FROM Servers WHERE Id = ?', NULL, ARRAY($_REQUEST['id'])) ) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$newServer = array();
|
||||
$newServer['Name'] = translate('NewServer');
|
||||
$newServer['Hostname'] = '';
|
||||
$newServer['zmstats'] = '';
|
||||
$newServer['zmaudit'] = '';
|
||||
$newServer['zmtrigger'] = '';
|
||||
$Server = new Server($_REQUEST['id']);
|
||||
if ( $_REQUEST['id'] and ! $Server->Id() ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
|
||||
xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name());
|
||||
?>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
<h2><?php echo translate('Server').' - '.$newServer['Name'] ?></h2>
|
||||
<h2><?php echo translate('Server').' - '.$Server->Name() ?></h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($newServer['Name'])?'true':'false' ?>)">
|
||||
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($Server->Name())?'true':'false' ?>)">
|
||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
||||
<input type="hidden" name="object" value="server"/>
|
||||
<input type="hidden" name="id" value="<?php echo validHtmlStr($_REQUEST['id']) ?>"/>
|
||||
|
@ -55,31 +47,47 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
|
|||
<tbody>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Name') ?></th>
|
||||
<td><input type="text" name="newServer[Name]" value="<?php echo $newServer['Name'] ?>"/></td>
|
||||
<td><input type="text" name="newServer[Name]" value="<?php echo $Server->Name() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Protocol') ?></th>
|
||||
<td><input type="text" name="newServer[Protocol]" value="<?php echo $Server->Protocol() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Hostname') ?></th>
|
||||
<td><input type="text" name="newServer[Hostname]" value="<?php echo $newServer['Hostname'] ?>"/></td>
|
||||
<td><input type="text" name="newServer[Hostname]" value="<?php echo $Server->Hostname() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Port') ?></th>
|
||||
<td><input type="number" name="newServer[Port]" value="<?php echo $Server->Port() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('PathToIndex') ?></th>
|
||||
<td><input type="text" name="newServer[PathToIndex]" value="<?php echo $Server->PathToIndex() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('PathToZMS') ?></th>
|
||||
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $Server->PathToZMS() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunStats') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $newServer['zmstats'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $newServer['zmstats'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $Server->zmstats() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $Server->zmstats() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunAudit') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $newServer['zmaudit'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $newServer['zmaudit'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $Server->zmaudit() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $Server->zmaudit() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunTrigger') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $newServer['zmtrigger'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $newServer['zmtrigger'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $Server->zmtrigger() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $Server->zmtrigger() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue