2008-07-14 21:54:50 +08:00
< ? php
//
2020-04-21 20:30:42 +08:00
// ZoneMinder web function library
2008-07-25 17:48:16 +08:00
// Copyright (C) 2001-2008 Philip Coombes
2008-07-14 21:54:50 +08:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
2016-12-26 23:23:16 +08:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2008-07-14 21:54:50 +08:00
//
2019-05-29 20:40:48 +08:00
function xhtmlHeaders ( $file , $title ) {
2020-08-04 22:47:37 +08:00
ob_start ();
2017-06-05 09:42:56 +08:00
global $css ;
global $skin ;
2018-02-09 01:29:42 +08:00
global $view ;
2020-08-04 22:47:37 +08:00
global $cspNonce ;
2020-09-03 02:38:38 +08:00
global $basename ;
2017-12-22 10:46:21 +08:00
# This idea is that we always include the classic css files,
# and then any different skin only needs to contain things that are different.
2019-05-29 20:40:48 +08:00
$baseCssPhpFile = getSkinFile ( 'css/base/skin.css.php' );
2017-12-22 10:46:21 +08:00
2019-05-29 20:40:48 +08:00
$skinCssPhpFile = getSkinFile ( 'css/' . $css . '/skin.css.php' );
2014-11-27 00:18:03 +08:00
2008-07-14 21:54:50 +08:00
2019-05-29 20:40:48 +08:00
$basename = basename ( $file , '.php' );
2017-12-22 10:46:21 +08:00
2019-09-29 02:23:23 +08:00
$baseViewCssPhpFile = getSkinFile ( '/css/base/views/' . $basename . '.css.php' );
2019-05-29 20:40:48 +08:00
$viewCssPhpFile = getSkinFile ( '/css/' . $css . '/views/' . $basename . '.css.php' );
2008-07-14 21:54:50 +08:00
2020-09-25 08:21:38 +08:00
function output_link_if_exists ( $files , $cache_bust = true ) {
2018-02-09 01:29:42 +08:00
global $skin ;
2017-12-22 10:46:21 +08:00
$html = array ();
foreach ( $files as $file ) {
2019-05-29 20:40:48 +08:00
if ( getSkinFile ( $file ) ) {
2020-09-25 08:21:38 +08:00
if ( $cache_bust ) {
2019-05-29 20:40:48 +08:00
$html [] = '<link rel="stylesheet" href="' . cache_bust ( 'skins/' . $skin . '/' . $file ) . '" type="text/css"/>' ;
2020-09-25 08:21:38 +08:00
} else {
$html [] = '<link rel="stylesheet" href="skins/' . $skin . '/' . $file . '" type="text/css"/>' ;
}
2017-12-22 10:46:21 +08:00
}
}
2020-07-26 03:05:12 +08:00
$html [] = '' ; // So we ge a trailing \n
2020-08-04 00:50:36 +08:00
return implode ( PHP_EOL , $html );
2020-07-26 03:05:12 +08:00
}
2020-09-25 08:21:38 +08:00
function output_script_if_exists ( $files , $cache_bust = true ) {
2020-09-24 21:13:25 +08:00
global $skin ;
$html = array ();
foreach ( $files as $file ) {
2020-09-28 21:49:07 +08:00
if ( file_exists ( 'skins/' . $skin . '/' . $file ) ) {
if ( $cache_bust ) {
$html [] = '<script src="' . cache_bust ( 'skins/' . $skin . '/' . $file ) . '"></script>' ;
} else {
$html [] = '<script src="skins/' . $skin . '/' . $file . '"></script>' ;
}
} else if ( file_exists ( $file ) ) {
if ( $cache_bust ) {
$html [] = '<script src="' . cache_bust ( $file ) . '"></script>' ;
} else {
$html [] = '<script src="' . $file . '"></script>' ;
}
2020-09-25 08:21:38 +08:00
}
2020-09-24 21:13:25 +08:00
}
$html [] = '' ; // So we ge a trailing \n
return implode ( PHP_EOL , $html );
}
2020-07-26 03:05:12 +08:00
function output_cache_busted_stylesheet_links ( $files ) {
$html = array ();
foreach ( $files as $file ) {
$html [] = '<link rel="stylesheet" href="' . cache_bust ( $file ) . '" type="text/css"/>' ;
}
2020-09-24 21:13:25 +08:00
if ( ! count ( $html ) ) {
ZM\Warning ( " No files found for $files " );
}
2020-08-03 23:49:45 +08:00
$html [] = '' ; // So we ge a trailing \n
2020-08-04 00:50:36 +08:00
return implode ( PHP_EOL , $html );
2017-12-22 10:46:21 +08:00
}
2008-07-14 21:54:50 +08:00
?>
2016-03-16 12:17:05 +08:00
<! DOCTYPE html >
< html lang = " en " >
2008-07-14 21:54:50 +08:00
< head >
2016-03-16 12:17:05 +08:00
< meta charset = " utf-8 " >
< meta http - equiv = " X-UA-Compatible " content = " IE=edge " >
2020-07-26 03:05:12 +08:00
< meta name = " viewport " content = " width=device-width, initial-scale=1 " >
2020-08-03 23:49:45 +08:00
< title >< ? php echo validHtmlStr ( ZM_WEB_TITLE_PREFIX ) . ' - ' . validHtmlStr ( $title ) ?> </title>
2017-10-02 23:55:36 +08:00
< ? php
2020-07-26 03:05:12 +08:00
if ( file_exists ( " skins/ $skin /css/ $css /graphics/favicon.ico " ) ) {
2017-11-03 21:24:13 +08:00
echo "
< link rel = \ " icon \" type= \" image/ico \" href= \" skins/ $skin /css/ $css /graphics/favicon.ico \" />
< link rel = \ " shortcut icon \" href= \" skins/ $skin /css/ $css /graphics/favicon.ico \" />
" ;
2017-10-02 23:55:36 +08:00
} else {
2017-10-18 01:10:20 +08:00
echo '
< link rel = " icon " type = " image/ico " href = " graphics/favicon.ico " />
< link rel = " shortcut icon " href = " graphics/favicon.ico " />
' ;
2017-10-02 23:55:36 +08:00
}
2020-07-26 03:05:12 +08:00
echo output_cache_busted_stylesheet_links ( array (
'css/reset.css' ,
2020-08-16 04:44:54 +08:00
'css/font-awesome.min.css' ,
2020-07-26 03:05:12 +08:00
'css/bootstrap.min.css' ,
2020-08-16 04:27:58 +08:00
'css/bootstrap-table.min.css' ,
2020-08-27 20:46:52 +08:00
'css/bootstrap-table-page-jump-to.min.css' ,
2020-07-26 03:05:12 +08:00
));
2020-08-03 23:49:45 +08:00
echo output_link_if_exists ( array (
2018-01-11 23:57:07 +08:00
'css/base/skin.css' ,
'css/base/views/' . $basename . '.css' ,
2018-12-05 22:05:10 +08:00
'js/dateTimePicker/jquery-ui-timepicker-addon.css' ,
'js/jquery-ui-1.12.1/jquery-ui.structure.min.css' ,
2020-08-03 23:49:45 +08:00
));
2019-06-23 02:10:55 +08:00
if ( $css != 'base' )
2020-08-03 23:49:45 +08:00
echo output_link_if_exists ( array (
2019-06-23 02:10:55 +08:00
'css/' . $css . '/skin.css' ,
'css/' . $css . '/views/' . $basename . '.css' ,
'css/' . $css . '/jquery-ui-theme.css' ,
2020-08-03 23:49:45 +08:00
));
2018-01-13 03:25:15 +08:00
?>
2020-08-03 23:49:45 +08:00
< link rel = " stylesheet " href = " skins/classic/js/jquery-ui-1.12.1/jquery-ui.theme.min.css " type = " text/css " />
< ? php #Chosen can't be cache-busted because it loads sprites by relative path ?>
< link rel = " stylesheet " href = " skins/classic/js/chosen/chosen.min.css " type = " text/css " />
2018-01-13 03:25:15 +08:00
< ? php
2019-02-13 05:41:08 +08:00
if ( $basename == 'watch' ) {
2020-02-25 02:13:54 +08:00
echo output_link_if_exists ( array ( '/css/base/views/control.css' ));
if ( $css != 'base' )
echo output_link_if_exists ( array ( '/css/' . $css . '/views/control.css' ));
2020-09-24 21:13:25 +08:00
} else if ( $basename == 'monitor' ) {
2020-09-25 08:21:38 +08:00
echo output_link_if_exists ( array ( 'js/leaflet/leaflet.css' ), false );
2017-05-31 23:16:55 +08:00
}
2008-07-14 21:54:50 +08:00
?>
2020-09-03 05:27:31 +08:00
< style >
2008-07-14 21:54:50 +08:00
< ? php
2019-09-29 02:23:23 +08:00
if ( $baseViewCssPhpFile ) {
require_once ( $baseViewCssPhpFile );
}
if ( $viewCssPhpFile ) {
2019-02-13 05:41:08 +08:00
require_once ( $viewCssPhpFile );
2019-09-29 02:23:23 +08:00
}
2008-07-14 21:54:50 +08:00
?>
</ style >
2017-12-22 10:46:21 +08:00
2008-07-14 21:54:50 +08:00
</ head >
< ? php
2020-08-04 22:47:37 +08:00
echo ob_get_clean ();
2017-06-16 00:13:40 +08:00
} // end function xhtmlHeaders( $file, $title )
2016-05-07 02:30:32 +08:00
2018-11-08 01:33:54 +08:00
// Outputs an opening body tag, and any additional content that should go at the very top, like warnings and error messages.
function getBodyTopHTML () {
echo '
< body >
< noscript >
< div style = " background-color:red;color:white;font-size:x-large; " >
2019-02-10 10:06:21 +08:00
'. validHtmlStr(ZM_WEB_TITLE) .' requires Javascript . Please enable Javascript in your browser for this site .
2018-11-08 01:33:54 +08:00
</ div >
</ noscript >
' ;
global $error_message ;
if ( $error_message ) {
2022-02-09 02:32:37 +08:00
echo '<div id="error">' . $error_message . '</div>' ;
2018-11-08 01:33:54 +08:00
}
} // end function getBodyTopHTML
2020-08-03 02:01:20 +08:00
function getNavBarHTML () {
2019-02-12 06:14:33 +08:00
# Provide a facility to turn off the headers if you put navbar=0 into the url
2020-07-28 00:15:37 +08:00
if ( isset ( $_REQUEST [ 'navbar' ]) and $_REQUEST [ 'navbar' ] == '0' )
2018-10-11 02:02:46 +08:00
return '' ;
2017-10-05 09:51:30 +08:00
2016-10-21 01:38:12 +08:00
global $running ;
2016-05-07 03:16:48 +08:00
global $user ;
2017-10-10 22:38:13 +08:00
global $bandwidth_options ;
2017-10-02 23:25:51 +08:00
global $view ;
2020-08-27 05:28:11 +08:00
global $skin ;
2020-08-03 02:01:20 +08:00
ob_start ();
2020-08-02 05:16:23 +08:00
2020-08-01 05:03:37 +08:00
if ( ZM_WEB_NAVBAR_TYPE == " normal " ) {
2020-08-27 06:06:01 +08:00
echo getNormalNavBarHTML ( $running , $user , $bandwidth_options , $view , $skin );
2020-07-31 05:44:58 +08:00
} else {
2020-08-27 06:06:01 +08:00
echo getCollapsedNavBarHTML ( $running , $user , $bandwidth_options , $view , $skin );
2020-07-31 05:44:58 +08:00
}
2020-08-02 05:16:23 +08:00
return ob_get_clean ();
2020-07-31 05:44:58 +08:00
}
2020-08-01 05:03:37 +08:00
//
2020-07-31 05:44:58 +08:00
// The legacy navigation bar that collapses into a pulldown menu on small screens.
2020-08-01 05:03:37 +08:00
//
2020-08-27 06:06:01 +08:00
function getNormalNavBarHTML ( $running , $user , $bandwidth_options , $view , $skin ) {
2020-07-31 05:44:58 +08:00
2020-08-03 02:01:20 +08:00
$status = runtimeStatus ( $running );
2020-07-24 01:52:21 +08:00
2016-05-07 02:30:32 +08:00
?>
2022-02-09 02:32:37 +08:00
< div class = " container-fluid p-0 " >
2020-07-26 02:18:09 +08:00
< nav class = " navbar navbar-expand-md navbar-dark bg-dark justify-content-center flex-row " >
2020-07-29 01:20:18 +08:00
< div class = " navbar-brand justify-content-start align-self-start " >
2020-07-26 02:18:09 +08:00
< ? php echo getNavBrandHTML () ?>
2020-07-23 02:12:59 +08:00
</ div >
2020-07-26 02:18:09 +08:00
<!-- the Navigation Bar Hamburger Button -->
2020-07-27 23:13:02 +08:00
< div class = " nav justify-content-end flex-grow-1 " >
< button type = " button " class = " navbar-toggler " data - toggle = " collapse " data - target = " #main-header-nav " aria - expanded = " false " >
< span class = " sr-only " > Toggle navigation </ span >
< span class = " navbar-toggler-icon " ></ span >
</ button >
</ div >
2020-07-26 02:18:09 +08:00
2020-07-23 02:12:59 +08:00
< div class = " collapse navbar-collapse " id = " main-header-nav " >
2019-12-03 01:33:13 +08:00
< ? php
2020-07-24 01:52:21 +08:00
// *** Build the navigation bar menu items ***
if ( $user and $user [ 'Username' ] ) {
2020-07-31 05:56:38 +08:00
echo '<ul class="navbar-nav align-self-start justify-content-center">' ;
2020-07-26 02:18:09 +08:00
echo getConsoleHTML ();
echo getOptionsHTML ();
echo getLogHTML ();
echo getDevicesHTML ();
2020-07-31 05:14:41 +08:00
echo getGroupsHTML ( $view );
2020-08-27 06:06:01 +08:00
echo getFilterHTML ( $view );
2020-07-31 05:14:41 +08:00
echo getCycleHTML ( $view );
echo getMontageHTML ( $view );
echo getMontageReviewHTML ( $view );
2021-03-12 22:26:23 +08:00
echo getSnapshotsHTML ( $view );
2020-07-31 05:14:41 +08:00
echo getRprtEvntAuditHTML ( $view );
2020-07-26 02:18:09 +08:00
echo getHeaderFlipHTML ();
2020-07-24 01:52:21 +08:00
echo '</ul>' ;
2020-07-29 01:20:18 +08:00
echo '<ul class="nav navbar-nav justify-content-end align-self-start flex-grow-1">' ;
2021-01-13 03:20:05 +08:00
echo getAccountCircleHTML ( $skin , $user );
2020-07-24 01:52:21 +08:00
echo getStatusBtnHTML ( $status );
echo '</ul>' ;
2020-07-26 02:18:09 +08:00
}
2020-07-24 01:52:21 +08:00
?>
2020-07-26 02:18:09 +08:00
</ div >
</ nav ><!-- End First Navbar -->
< nav class = " navbar navbar-expand-md bg-dark justify-content-center p-0 " >
< div class = " container-fluid " id = " panel " < ? php echo ( isset ( $_COOKIE [ 'zmHeaderFlip' ]) and $_COOKIE [ 'zmHeaderFlip' ] == 'down' ) ? 'style="display:none;"' : '' ?> >
2017-12-02 11:15:29 +08:00
< ? php
2020-07-24 01:52:21 +08:00
2020-07-28 00:15:37 +08:00
if ( ( ! ZM_OPT_USE_AUTH ) or $user ) {
2020-07-24 01:52:21 +08:00
// *** Build the statistics shown on the navigation bar ***
2017-12-02 11:15:29 +08:00
?>
2020-07-28 00:15:37 +08:00
< div id = " reload " class = " container-fluid " >
< ul id = " Bandwidth " class = " navbar-nav justify-content-start " >
< ? php echo getBandwidthHTML ( $bandwidth_options , $user ) ?>
</ ul >
2020-08-01 05:03:37 +08:00
< ul class = " navbar-nav list-inline justify-content-center " >
2020-07-28 00:15:37 +08:00
< ? php
echo getSysLoadHTML ();
echo getDbConHTML ();
echo getStorageHTML ();
2021-10-15 01:31:35 +08:00
echo getRamHTML ();
#echo getShmHTML();
2021-03-23 05:46:56 +08:00
#echo getLogIconHTML();
2020-07-28 00:15:37 +08:00
?>
</ ul >
< ul id = " Version " class = " nav navbar-nav justify-content-end " >
2020-07-31 20:31:40 +08:00
< ? php echo getZMVersionHTML () ?>
2020-07-28 00:15:37 +08:00
</ ul >
</ div >
< ? php
} // end if (!ZM_OPT_USE_AUTH) or $user )
?>
2020-07-31 00:55:54 +08:00
</ div ><!-- End Collapsible Panel -->
2020-07-26 02:18:09 +08:00
</ nav ><!-- End Second Navbar -->
2020-08-03 02:48:15 +08:00
< nav class = " navbar navbar-expand-md bg-dark justify-content-center p-0 " >
< ? php echo getConsoleBannerHTML () ?>
</ nav ><!-- End Third Navbar -->
2020-07-26 02:18:09 +08:00
</ div >
2020-07-23 02:12:59 +08:00
< ? php
2020-07-31 05:44:58 +08:00
} // end function getNormalNavBarHTML()
2020-07-24 01:52:21 +08:00
2020-07-31 05:44:58 +08:00
//
2020-08-01 05:03:37 +08:00
// A new, slimmer navigation bar, permanently collapsed into a dropdown
2020-07-31 05:44:58 +08:00
//
2020-08-27 06:06:01 +08:00
function getCollapsedNavBarHTML ( $running , $user , $bandwidth_options , $view , $skin ) {
2020-08-01 22:07:21 +08:00
2020-08-03 02:01:20 +08:00
$status = runtimeStatus ( $running );
2020-08-01 22:07:21 +08:00
2020-08-01 05:03:37 +08:00
?>
2020-08-03 02:48:15 +08:00
< div class = " fixed-top container-fluid p-0 " >
2020-12-17 23:16:54 +08:00
< nav class = " navbar navbar-dark bg-dark px-1 flex-nowrap " >
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
< div class = " navbar-brand align-self-start px-0 " >
< ? php echo getNavBrandHTML () ?>
</ div >
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
< nav class = " navbar navbar-expand-md align-self-start px-0 " >
2021-01-13 03:29:53 +08:00
< ? php
2020-08-01 05:03:37 +08:00
2020-08-01 22:07:21 +08:00
// *** Build the statistics shown on the navigation bar ***
if ( ( ! ZM_OPT_USE_AUTH ) or $user ) {
2021-01-13 03:29:53 +08:00
?>
2020-12-17 23:16:54 +08:00
< div id = " reload " class = " collapse navbar-collapse px-0 " >
2021-01-13 03:37:25 +08:00
< ul id = " Version " class = " pr-2 navbar-nav " >
2020-12-17 23:16:54 +08:00
< ? php echo getZMVersionHTML () ?>
</ ul >
2021-01-13 03:37:25 +08:00
< ul id = " Bandwidth " class = " px-2 navbar-nav " >
2020-12-17 23:16:54 +08:00
< ? php echo getBandwidthHTML ( $bandwidth_options , $user ) ?>
</ ul >
2021-01-13 03:37:25 +08:00
< ul class = " nav navbar-nav list-group px-0 " >
2020-12-17 23:16:54 +08:00
< ? php
echo getSysLoadHTML ();
echo getDbConHTML ();
echo getStorageHTML ();
2021-10-15 01:31:35 +08:00
echo getRamHTML ();
#echo getShmHTML();
2020-12-17 23:16:54 +08:00
echo getLogIconHTML ();
?>
2021-01-13 03:37:25 +08:00
</ ul >
2020-12-17 23:16:54 +08:00
</ div >
2020-08-01 22:07:21 +08:00
< ? php
} // end if (!ZM_OPT_USE_AUTH) or $user )
?>
2020-12-17 23:16:54 +08:00
</ nav >
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
< ul class = " list-group list-group-horizontal ml-auto " >
2020-08-01 05:03:37 +08:00
< ? php
2021-01-13 03:37:25 +08:00
echo getAccountCircleHTML ( $skin , $user );
2020-08-01 05:03:37 +08:00
echo getStatusBtnHTML ( $status );
?>
</ ul >
<!-- the Navigation Bar Hamburger Button -->
2020-08-01 22:07:21 +08:00
< ? php if ( ( ! ZM_OPT_USE_AUTH ) or $user ) { ?>
2020-08-02 05:16:23 +08:00
< button type = " button " class = " navbar-toggler " data - toggle = " collapse " data - target = " #main-header-nav " aria - haspopup = " true " aria - expanded = " false " >
2020-08-01 05:03:37 +08:00
< span class = " sr-only " > Toggle navigation </ span >
< span class = " navbar-toggler-icon " ></ span >
</ button >
2020-08-01 22:07:21 +08:00
< ? php } ?>
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
< div style = " background-color:#485460 " class = " dropdown-menu dropdown-menu-right px-3 " id = " main-header-nav " >
< ? php
if ( $user and $user [ 'Username' ] ) {
echo '<ul class="navbar-nav">' ;
echo getConsoleHTML ();
echo getOptionsHTML ();
echo getLogHTML ();
echo getDevicesHTML ();
echo getGroupsHTML ( $view );
echo getFilterHTML ( $view );
echo getCycleHTML ( $view );
echo getMontageHTML ( $view );
echo getMontageReviewHTML ( $view );
2021-03-12 22:26:23 +08:00
echo getSnapshotsHTML ( $view );
2020-12-17 23:16:54 +08:00
echo getRprtEvntAuditHTML ( $view );
echo '</ul>' ;
}
?>
</ div >
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
</ nav ><!-- End First Navbar -->
2020-08-01 05:03:37 +08:00
2020-12-17 23:16:54 +08:00
< nav class = " navbar navbar-expand-md bg-dark justify-content-center p-0 " >
< ? php echo getConsoleBannerHTML () ?>
</ nav ><!-- End Second Navbar -->
2020-08-03 02:48:15 +08:00
</ div >
2020-08-01 05:03:37 +08:00
< ? php
2020-07-31 05:44:58 +08:00
} // End function getCollapsedNavBarHTML
2020-07-23 02:12:59 +08:00
2020-07-23 23:52:12 +08:00
// Returns the html representing the current unix style system load
2020-07-23 02:12:59 +08:00
function getSysLoadHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'System' ) ) return $result ;
2020-07-23 02:12:59 +08:00
2020-08-03 00:31:36 +08:00
$result .= '<li id="getSysLoadHTML" class="Load nav-item mx-2">' . PHP_EOL ;
$result .= '<i class="material-icons md-18">trending_up</i>' . PHP_EOL ;
$result .= ' ' . translate ( 'Load' ) . ': ' . getLoad () . PHP_EOL ;
$result .= '</li>' . PHP_EOL ;
return $result ;
2020-07-23 02:12:59 +08:00
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the current number of connections made to the database
2020-07-23 02:12:59 +08:00
function getDbConHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'System' ) ) return $result ;
2019-12-14 06:47:51 +08:00
$connections = dbFetchOne ( 'SHOW status WHERE variable_name=\'threads_connected\'' , 'Value' );
$max_connections = dbFetchOne ( 'SHOW variables WHERE variable_name=\'max_connections\'' , 'Value' );
2018-10-29 21:59:26 +08:00
$percent_used = $max_connections ? 100 * $connections / $max_connections : 100 ;
2020-08-03 23:49:45 +08:00
$class = ( $percent_used > 90 ) ? ' text-warning' : '' ;
2020-07-23 02:12:59 +08:00
2020-08-03 23:49:45 +08:00
$result .= '<li id="getDbConHTML" class="nav-item dropdown mx-2' . $class . '">' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
$result .= '<i class="material-icons md-18 mr-1">storage</i>' . PHP_EOL ;
$result .= translate ( 'DB' ) . ': ' . $connections . '/' . $max_connections . PHP_EOL ;
$result .= '</li>' . PHP_EOL ;
return $result ;
2020-07-23 02:12:59 +08:00
}
2020-08-03 23:49:45 +08:00
// Returns an html dropdown showing capacity of all storage areas
2020-07-23 02:12:59 +08:00
function getStorageHTML () {
2020-09-08 01:28:55 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'System' ) ) return $result ;
2020-07-23 02:12:59 +08:00
$func = function ( $S ) {
2018-04-18 05:14:40 +08:00
$class = '' ;
if ( $S -> disk_usage_percent () > 98 ) {
2020-07-26 23:41:05 +08:00
$class = 'text-danger' ;
2018-04-18 05:14:40 +08:00
} else if ( $S -> disk_usage_percent () > 90 ) {
2020-07-26 23:41:05 +08:00
$class = 'text-warning' ;
2018-04-18 05:14:40 +08:00
}
$title = human_filesize ( $S -> disk_used_space ()) . ' of ' . human_filesize ( $S -> disk_total_space ()) .
( ( $S -> disk_used_space () != $S -> event_disk_space () ) ? ' ' . human_filesize ( $S -> event_disk_space ()) . ' used by events' : '' );
2020-08-05 05:05:33 +08:00
return '<a class="dropdown-item ' . $class . '" title="' . $title . '" href="?view=options&tab=storage">' . $S -> Name () . ': ' . $S -> disk_usage_percent () . '%' . '</a>' ;
2020-07-23 02:12:59 +08:00
};
2018-04-18 05:14:40 +08:00
2020-07-23 02:12:59 +08:00
$storage_areas = ZM\Storage :: find ( array ( 'Enabled' => true ));
2020-08-03 23:43:24 +08:00
$num_storage_areas = count ( $storage_areas );
$full_warning = 0 ;
$full_error = 0 ;
foreach ( $storage_areas as $area ) {
if ( $area -> disk_usage_percent () > 98 ) { $full_error ++ ; continue ; }
if ( $area -> disk_usage_percent () > 90 ) $full_warning ++ ;
}
2020-08-05 05:53:39 +08:00
$class = '' ;
2020-08-03 23:43:24 +08:00
if ( $full_error ) {
$class = 'text-danger' ;
} else if ( $full_warning ) {
$class = 'text-warning' ;
2020-07-23 02:12:59 +08:00
}
2020-08-03 23:43:24 +08:00
2020-08-05 05:53:39 +08:00
$result .= '<li id="getStorageHTML" class="nav-item dropdown mx-2">' . PHP_EOL ;
$result .= '<a class="dropdown-toggle mr-2 ' . $class . '" href="#" id="dropdown_storage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="material-icons md-18 mr-1">folder_shared</i>Storage</a>' . PHP_EOL ;
2020-08-14 00:39:51 +08:00
$result .= '<div class="dropdown-menu" aria-labelledby="dropdown_storage">' . PHP_EOL ;
2020-08-03 23:43:24 +08:00
foreach ( $storage_areas as $area ) {
$result .= $func ( $area ) . PHP_EOL ;
}
$result .= '</div>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
$result .= '</li>' . PHP_EOL ;
return $result ;
2020-07-23 02:12:59 +08:00
}
2021-10-15 01:31:35 +08:00
function getRamHTML () {
$result = '' ;
if ( ! canView ( 'System' ) ) return $result ;
$contents = file_get_contents ( '/proc/meminfo' );
preg_match_all ( '/(\w+):\s+(\d+)\s/' , $contents , $matches );
2021-10-15 21:40:58 +08:00
$meminfo = array_combine ( $matches [ 1 ], array_map ( function ( $v ){ return 1024 * $v ;}, $matches [ 2 ]));
2021-10-15 01:31:35 +08:00
$mem_used = $meminfo [ 'MemTotal' ] - $meminfo [ 'MemFree' ] - $meminfo [ 'Buffers' ] - $meminfo [ 'Cached' ];
$mem_used_percent = ( int )( 100 * $mem_used / $meminfo [ 'MemTotal' ]);
$used_class = '' ;
if ( $mem_used_percent > 95 ) {
$used_class = 'text-danger' ;
} else if ( $mem_used_percent > 90 ) {
$used_class = 'text-warning' ;
}
2021-10-15 21:40:58 +08:00
$result .= ' <li id="getRamHTML" class="nav-item dropdown mx-2">' .
2022-02-08 23:04:19 +08:00
'<span class="' . $used_class . '" title="' . human_filesize ( $mem_used ) . ' of ' . human_filesize ( $meminfo [ 'MemTotal' ]) . '">' . translate ( 'Memory' ) . ': ' . $mem_used_percent . '%</span> ' ;
if ( $meminfo [ 'SwapTotal' ]) {
$swap_used = $meminfo [ 'SwapTotal' ] - $meminfo [ 'SwapFree' ];
$swap_used_percent = ( int )( 100 * $swap_used / $meminfo [ 'SwapTotal' ]);
$swap_class = '' ;
if ( $swap_used_percent > 95 ) {
$swap_class = 'text-danger' ;
} else if ( $swap_used_percent > 90 ) {
$swap_class = 'text-warning' ;
}
$result .= '<span class="' . $swap_class . '" title="' . human_filesize ( $swap_used ) . ' of ' . human_filesize ( $meminfo [ 'SwapTotal' ]) . '">' . translate ( 'Swap' ) . ': ' . $swap_used_percent . '%</span> ' ;
} # end if SwapTotal
$result .= '</li>' . PHP_EOL ;
2021-10-15 01:31:35 +08:00
return $result ;
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the current capacity of mapped memory filesystem (usually /dev/shm)
2020-07-23 02:12:59 +08:00
function getShmHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'System' ) ) return $result ;
2020-08-03 00:31:36 +08:00
2020-02-11 03:20:46 +08:00
$shm_percent = getDiskPercent ( ZM_PATH_MAP );
2020-05-22 01:32:33 +08:00
$shm_total_space = disk_total_space ( ZM_PATH_MAP );
2020-05-22 01:34:09 +08:00
$shm_used = $shm_total_space - disk_free_space ( ZM_PATH_MAP );
2020-05-22 01:32:33 +08:00
2020-02-11 03:20:46 +08:00
$class = '' ;
if ( $shm_percent > 98 ) {
2020-07-26 23:41:05 +08:00
$class = 'text-danger' ;
2020-02-11 03:20:46 +08:00
} else if ( $shm_percent > 90 ) {
2020-07-26 23:41:05 +08:00
$class = 'text-warning' ;
2020-02-11 03:20:46 +08:00
}
2020-08-05 06:06:49 +08:00
$result .= ' <li id="getShmHTML" class="nav-item dropdown mx-2' . $class . '" title="' . human_filesize ( $shm_used ) . ' of ' . human_filesize ( $shm_total_space ) . '">' . ZM_PATH_MAP . ': ' . $shm_percent . '%</li>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 02:12:59 +08:00
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the optional web console banner text
2020-07-23 02:12:59 +08:00
function getConsoleBannerHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-07-23 02:12:59 +08:00
if ( defined ( 'ZM_WEB_CONSOLE_BANNER' ) and ZM_WEB_CONSOLE_BANNER != '' ) {
2020-08-03 02:48:15 +08:00
$result .= '<h2 id="getConsoleBannerHTML">' . validHtmlStr ( ZM_WEB_CONSOLE_BANNER ) . '</h2>' ;
2020-07-23 02:12:59 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 02:12:59 +08:00
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the current high,medium,low bandwidth setting
2020-08-03 23:49:45 +08:00
function getBandwidthHTML ( $bandwidth_options , $user ) {
2020-08-08 23:07:26 +08:00
# Limit available options to what are available in user
if ( $user && ! empty ( $user [ 'MaxBandwidth' ]) ) {
if ( $user [ 'MaxBandwidth' ] == 'low' ) {
unset ( $bandwidth_options [ 'high' ]);
unset ( $bandwidth_options [ 'medium' ]);
} else if ( $user [ 'MaxBandwidth' ] == 'medium' ) {
unset ( $bandwidth_options [ 'high' ]);
}
}
2020-08-14 00:39:51 +08:00
$result = '<li id="getBandwidthHTML" class="nav-item dropdown mx-2">' . PHP_EOL ;
2020-12-04 09:33:10 +08:00
$result .= '<a class="dropdown-toggle mr-2" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="dropdown_bandwidth"><i class="material-icons md-18 mr-1">network_check</i>' . translate ( $bandwidth_options [ $_COOKIE [ 'zmBandwidth' ]]) . '</a>' . PHP_EOL ;
2020-08-08 23:07:26 +08:00
2020-12-04 09:33:10 +08:00
$result .= '<div class="dropdown-menu" aria-labelledby="dropdown_bandwidth">' . PHP_EOL ;
2020-08-14 00:39:51 +08:00
if ( count ( $bandwidth_options ) > 1 ) {
if ( isset ( $bandwidth_options [ 'high' ]) )
2020-12-04 09:33:10 +08:00
$result .= '<a data-pdsa-dropdown-val="high" class="dropdown-item bwselect" href="#">' . translate ( 'High' ) . '</a>' . PHP_EOL ;
2020-08-14 00:39:51 +08:00
if ( isset ( $bandwidth_options [ 'medium' ]) )
2020-12-04 09:33:10 +08:00
$result .= '<a data-pdsa-dropdown-val="medium" class="dropdown-item bwselect" href="#">' . translate ( 'Medium' ) . '</a>' . PHP_EOL ;
2020-08-14 00:39:51 +08:00
# low is theoretically always available
2020-12-04 09:33:10 +08:00
$result .= '<a data-pdsa-dropdown-val="low" class="dropdown-item bwselect" href="#">' . translate ( 'Low' ) . '</a>' . PHP_EOL ;
2020-08-14 00:39:51 +08:00
}
2020-08-08 23:07:26 +08:00
$result .= '</div>' . PHP_EOL ;
$result .= '</li>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 02:12:59 +08:00
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the version of ZoneMinder
2020-07-31 20:31:40 +08:00
function getZMVersionHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'System' ) ) return $result ;
2020-08-10 03:18:44 +08:00
$content = '' ;
2020-08-03 00:31:36 +08:00
2020-08-10 01:20:11 +08:00
if ( ZM_DYN_DB_VERSION && ( ZM_DYN_DB_VERSION != ZM_VERSION ) ) { // Must upgrade before proceeding
$class = 'text-danger' ;
$tt_text = translate ( 'RunLocalUpdate' );
2020-08-10 03:18:44 +08:00
$content = 'v' . ZM_VERSION . PHP_EOL ;
2020-10-01 21:46:58 +08:00
} else if ( verNum ( ZM_DYN_LAST_VERSION ) <= verNum ( ZM_VERSION ) || ! ZM_CHECK_FOR_UPDATES || ZM_DYN_NEXT_REMINDER > time () ) { // No update needed
2020-08-10 01:20:11 +08:00
$class = '' ; // Don't change the text color under normal conditions
$tt_text = translate ( 'UpdateNotNecessary' );
2020-08-10 03:18:44 +08:00
$content = 'v' . ZM_VERSION . PHP_EOL ;
} else if ( canEdit ( 'System' ) ) { // An update is available and the user is an administrator
2020-08-10 01:20:11 +08:00
$class = 'text-warning' ;
$tt_text = translate ( 'UpdateAvailable' );
2020-08-14 00:39:51 +08:00
$content = '<a class="dropdown ' . $class . '" data-toggle="dropdown" href="#" id="dropdown_reminder">v' . ZM_VERSION . '</a>' . PHP_EOL ;
$content .= '<div class="dropdown-menu" aria-labelledby="dropdown_reminder">' . PHP_EOL ;
2020-08-10 03:18:44 +08:00
$content .= '<h6 class="dropdown-header">' . translate ( 'UpdateAvailable' ) . '</h6>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="ignore" href="#">' . translate ( 'VersionIgnore' ) . '</a>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="hour" href="#">' . translate ( 'VersionRemindHour' ) . '</a>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="day" href="#">' . translate ( 'VersionRemindDay' ) . '</a>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="week" href="#">' . translate ( 'VersionRemindWeek' ) . '</a>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="month" href="#">' . translate ( 'VersionRemindMonth' ) . '</a>' . PHP_EOL ;
$content .= '<a class="dropdown-item" data-pdsa-dropdown-val="never" href="#">' . translate ( 'VersionRemindNever' ) . '</a>' . PHP_EOL ;
$content .= '</div>' . PHP_EOL ;
} else { // An update is available and the user is NOT an administrator
$class = 'text-warning' ;
$tt_text = translate ( 'UpdateAvailable' );
$content = 'v' . ZM_VERSION . PHP_EOL ;
2020-08-10 01:20:11 +08:00
}
2020-08-14 00:39:51 +08:00
$result .= '<li id="getZMVersionHTML" class="nav-item dropdown ' . $class . '" data-placement="bottom" title="' . $tt_text . '">' . PHP_EOL ;
2020-08-10 03:18:44 +08:00
$result .= $content ;
2020-08-10 01:20:11 +08:00
$result .= '</li>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 02:12:59 +08:00
}
2017-07-13 22:07:23 +08:00
2020-08-04 04:22:46 +08:00
// Returns the html representing the ZoneMinder logo and about menu
2020-07-24 01:52:21 +08:00
function getNavBrandHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-04 04:22:46 +08:00
2020-08-04 04:45:27 +08:00
if ( ZM_HOME_ABOUT ) {
2020-08-04 04:22:46 +08:00
$result .= '<a id="getNavBrandHTML" class="dropdown" data-toggle="dropdown" href="#">ZoneMinder</a>' . PHP_EOL ;
$result .= '<ul style="background-color:#485460" class="dropdown-menu">' . PHP_EOL ;
2020-08-04 04:45:27 +08:00
$result .= '<li><a class="dropdown-item" href="https://zoneminder.com/" target="_blank">ZoneMinder</a></li>' . PHP_EOL ;
$result .= '<li><a class="dropdown-item" href="https://zoneminder.readthedocs.io/en/stable/" target="_blank">Documentation</a></li>' . PHP_EOL ;
$result .= '<li><a class="dropdown-item" href="https://forums.zoneminder.com/" target="_blank">Support</a></li>' . PHP_EOL ;
2020-08-04 04:22:46 +08:00
$result .= '</ul>' . PHP_EOL ;
} else {
2020-08-03 00:31:36 +08:00
$result .= '<a id="getNavBrandHTML" href="' . validHtmlStr ( ZM_HOME_URL ) . '" target="' . validHtmlStr ( ZM_WEB_TITLE ) . '">' . ZM_HOME_CONTENT . '</a>' . PHP_EOL ;
2020-08-04 04:22:46 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-24 01:52:21 +08:00
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the Console menu item
function getConsoleHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'Monitors' ) ) {
2020-08-03 00:31:36 +08:00
$result .= '<li id="getConsoleHTML" class="nav-item dropdown"><a class="nav-link" href="?view=console">' . translate ( 'Console' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Options menu item
function getOptionsHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'System' ) ) {
2020-08-03 00:31:36 +08:00
$result .= '<li id="getOptionsHTML" class="nav-item dropdown"><a class="nav-link" href="?view=options">' . translate ( 'Options' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Log menu item
function getLogHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'System' ) ) {
if ( ZM\logToDatabase () > ZM\Logger :: NOLOG ) {
2020-07-26 23:41:05 +08:00
$logstate = logState ();
2020-07-30 03:42:06 +08:00
$class = ( $logstate == 'ok' ) ? 'text-success' : ( $logstate == 'alert' ? 'text-warning' : (( $logstate == 'alarm' ? 'text-danger' : '' )));
2020-09-20 01:59:15 +08:00
$result .= '<li id="getLogHTML" class="nav-item dropdown mx-2">' . makeLink ( '?view=log' , '<span class="nav-link ' . $class . '">' . translate ( 'Log' ) . '</span>' ) . '</li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 03:49:19 +08:00
// Returns the html representing the log icon
function getLogIconHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 03:49:19 +08:00
if ( canView ( 'System' ) ) {
if ( ZM\logToDatabase () > ZM\Logger :: NOLOG ) {
$logstate = logState ();
2020-08-03 23:43:24 +08:00
$class = ( $logstate == 'alert' ) ? 'text-warning' : (( $logstate == 'alarm' ) ? 'text-danger' : '' );
2020-08-03 23:49:45 +08:00
$result .= '<li id="getLogIconHTML" class="nav-item dropdown">' .
2020-09-20 01:59:15 +08:00
makeLink ( '?view=log' , '<span class="mx-1 ' . $class . '"><i class="material-icons md-18">report</i>' . translate ( 'Log' ) . '</span>' ) .
2020-08-03 23:49:45 +08:00
'</li>' . PHP_EOL ;
2020-08-03 03:49:19 +08:00
}
}
return $result ;
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the X10 Devices menu item
function getDevicesHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( ZM_OPT_X10 && canView ( 'Devices' ) ) {
2020-08-03 00:31:36 +08:00
$result .= '<li id="getDevicesHTML" class="nav-item dropdown"><a class="nav-link" href="?view=devices">Devices</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Groups menu item
2020-07-31 05:14:41 +08:00
function getGroupsHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'Groups' ) ) return $result ;
2020-08-03 00:05:52 +08:00
$class = $view == 'groups' ? ' selected' : '' ;
2020-08-03 02:01:20 +08:00
$result .= '<li id="getGroupsHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=groups">' . translate ( 'Groups' ) . '</a></li>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Filter menu item
2020-08-27 06:06:01 +08:00
function getFilterHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2021-03-13 00:40:46 +08:00
if ( ! canView ( 'Events' ) ) return $result ;
2020-08-03 00:31:36 +08:00
2020-08-03 00:05:52 +08:00
$class = $view == 'filter' ? ' selected' : '' ;
2020-08-27 06:06:01 +08:00
$result .= '<li id="getFilterHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=filter">' . translate ( 'Filters' ) . '</a></li>' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Cycle menu item
2020-07-31 05:14:41 +08:00
function getCycleHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'Stream' ) ) {
2020-08-03 00:05:52 +08:00
$class = $view == 'cycle' ? ' selected' : '' ;
2020-08-03 02:01:20 +08:00
$result .= '<li id="getCycleHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=cycle">' . translate ( 'Cycle' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the Montage menu item
2020-07-31 05:14:41 +08:00
function getMontageHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'Stream' ) ) {
2021-03-12 22:26:23 +08:00
$class = $view == 'montage' ? ' selected' : '' ;
2020-08-03 02:01:20 +08:00
$result .= '<li id="getMontageHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=montage">' . translate ( 'Montage' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the MontageReview menu item
2020-07-31 05:14:41 +08:00
function getMontageReviewHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'Events' ) ) {
if ( isset ( $_REQUEST [ 'filter' ][ 'Query' ][ 'terms' ][ 'attr' ]) ) {
$terms = $_REQUEST [ 'filter' ][ 'Query' ][ 'terms' ];
$count = 0 ;
foreach ( $terms as $term ) {
if ( $term [ 'attr' ] == 'StartDateTime' ) {
$count += 1 ;
if ( $term [ 'op' ] == '>=' ) $minTime = $term [ 'val' ];
if ( $term [ 'op' ] == '<=' ) $maxTime = $term [ 'val' ];
}
}
if ( $count == 2 ) {
$montageReviewQuery = '&minTime=' . $minTime . '&maxTime=' . $maxTime ;
}
}
$live = isset ( $montageReviewQuery ) ? '&fit=1' . $montageReviewQuery . '&live=0' : '' ;
2020-08-03 00:05:52 +08:00
$class = $view == 'montagereview' ? ' selected' : '' ;
2020-08-03 02:01:20 +08:00
$result .= '<li id="getMontageReviewHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=montagereview' . $live . '">' . translate ( 'MontageReview' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
2021-03-12 22:26:23 +08:00
// Returns the html representing the Montage menu item
function getSnapshotsHTML ( $view ) {
$result = '' ;
2021-05-05 01:19:40 +08:00
if ( defined ( 'ZM_FEATURES_SNAPSHOTS' ) and ZM_FEATURES_SNAPSHOTS and canView ( 'Snapshots' )) {
2021-03-12 22:26:23 +08:00
$class = $view == 'snapshots' ? ' selected' : '' ;
$result .= '<li id="getSnapshotsHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=snapshots">' . translate ( 'Snapshots' ) . '</a></li>' . PHP_EOL ;
}
return $result ;
}
2020-07-23 23:52:12 +08:00
// Returns the html representing the Audit Events Report menu item
2020-07-31 05:14:41 +08:00
function getRprtEvntAuditHTML ( $view ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( canView ( 'Events' ) ) {
2020-08-03 00:05:52 +08:00
$class = $view == 'report_event_audit' ? ' selected' : '' ;
2020-08-03 02:01:20 +08:00
$result .= '<li id="getRprtEvntAuditHTML" class="nav-item dropdown"><a class="nav-link' . $class . '" href="?view=report_event_audit">' . translate ( 'ReportEventAudit' ) . '</a></li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the header collapse toggle menu item
function getHeaderFlipHTML () {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
$header = ( isset ( $_COOKIE [ 'zmHeaderFlip' ]) and $_COOKIE [ 'zmHeaderFlip' ] == 'down' ) ? 'down' : 'up' ;
2020-08-03 00:31:36 +08:00
$result .= '<li id="getHeaderFlipHTML" class="nav-item dropdown"><a class="nav-link" href="#"><i id="flip" class="material-icons md-18">keyboard_arrow_' . $header . '</i></a></li>' . PHP_EOL ;
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the logged in user name and avatar
2021-01-13 03:20:05 +08:00
function getAccountCircleHTML ( $skin , $user = null ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2020-07-23 23:52:12 +08:00
if ( ZM_OPT_USE_AUTH and $user ) {
2021-01-30 09:37:34 +08:00
$result .= '<li id="getAccountCircleHTML" class="navbar-text navbar-nav mr-2">' . PHP_EOL ;
2020-08-27 05:28:11 +08:00
$result .= makeLink ( '#' , '<i class="material-icons">account_circle</i> ' . $user [ 'Username' ],
2020-10-17 02:51:47 +08:00
( ZM_AUTH_TYPE == 'builtin' ), 'id="logoutButton" data-toggle="modal" data-target="#modalLogout" data-backdrop="false"' ) . PHP_EOL ;
2021-01-30 09:37:34 +08:00
$result .= '</li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
// Returns the html representing the runtime status button
function getStatusBtnHTML ( $status ) {
2020-08-03 23:49:45 +08:00
$result = '' ;
2020-08-03 00:31:36 +08:00
2021-07-28 22:12:32 +08:00
if ( canEdit ( 'System' )) {
2021-01-30 09:37:34 +08:00
$result .= '<li id="getStatusBtnHTML">' . PHP_EOL ;
2020-09-20 01:36:04 +08:00
$result .= '<button type="button" class="btn btn-default navbar-btn" id="stateModalBtn">' . $status . '</button>' . PHP_EOL ;
2021-01-30 09:37:34 +08:00
$result .= '</li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
2021-07-28 22:12:32 +08:00
if ( ZM_SYSTEM_SHUTDOWN ) {
$result .= '<li class="pr-2">' . PHP_EOL ;
$result .= '<button id="shutdownButton" class="btn btn-default navbar-btn" data-on-click="getShutdownModal" data-toggle="tooltip" data-placement="top" title="' . translate ( 'Shutdown' ) . '"><i class="material-icons md-18">power_settings_new</i></button>' . PHP_EOL ;
2021-01-30 09:37:34 +08:00
$result .= '</li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2021-07-28 22:12:32 +08:00
} else if ( canView ( 'System' )) {
2021-01-30 09:37:34 +08:00
$result .= '<li id="getStatusBtnHTML" class="navbar-text">' . PHP_EOL ;
2020-08-03 00:31:36 +08:00
$result .= $status . PHP_EOL ;
2021-01-30 09:37:34 +08:00
$result .= '</li>' . PHP_EOL ;
2020-07-23 23:52:12 +08:00
}
2021-07-28 22:12:32 +08:00
2020-08-03 00:31:36 +08:00
return $result ;
2020-07-23 23:52:12 +08:00
}
2020-07-31 05:14:41 +08:00
function runtimeStatus ( $running = null ) {
if ( $running == null )
$running = daemonCheck ();
if ( $running ) {
$state = dbFetchOne ( 'SELECT Name FROM States WHERE isActive=1' , 'Name' );
if ( $state == 'default' )
$state = '' ;
}
return $running ? ( $state ? $state : translate ( 'Running' )) : translate ( 'Stopped' );
}
2020-09-13 00:53:53 +08:00
function getStatsTableHTML ( $eid , $fid , $row = '' ) {
if ( ! canView ( 'Events' ) ) return ;
$result = '' ;
$sql = 'SELECT S.*,E.*,Z.Name AS ZoneName,Z.Units,Z.Area,M.Name AS MonitorName FROM Stats AS S LEFT JOIN Events AS E ON S.EventId = E.Id LEFT JOIN Zones AS Z ON S.ZoneId = Z.Id LEFT JOIN Monitors AS M ON E.MonitorId = M.Id WHERE S.EventId = ? AND S.FrameId = ? ORDER BY S.ZoneId' ;
$stats = dbFetchAll ( $sql , NULL , array ( $eid , $fid ) );
$result .= '<table id="contentStatsTable' . $row . '"' . PHP_EOL ;
2020-10-17 20:28:14 +08:00
$result .= 'data-locale="' . i18n () . '"' . PHP_EOL ;
2020-09-13 00:53:53 +08:00
$result .= 'data-toggle="table"' . PHP_EOL ;
$result .= 'data-toolbar="#toolbar"' . PHP_EOL ;
$result .= 'class="table-sm table-borderless contentStatsTable"' . PHP_EOL ;
$result .= 'cellspacing="0">' . PHP_EOL ;
$result .= '<caption>' . translate ( 'Stats' ) . ' - ' . $eid . ' - ' . $fid . '</caption>' . PHP_EOL ;
$result .= '<thead>' . PHP_EOL ;
$result .= '<tr>' . PHP_EOL ;
$result .= '<th class="colZone font-weight-bold" data-align="center">' . translate ( 'Zone' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colPixelDiff font-weight-bold" data-align="center">' . translate ( 'PixelDiff' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colAlarmPx font-weight-bold" data-align="center">' . translate ( 'AlarmPx' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colFilterPx font-weight-bold" data-align="center">' . translate ( 'FilterPx' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colBlobPx font-weight-bold" data-align="center">' . translate ( 'BlobPx' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colBlobs font-weight-bold" data-align="center">' . translate ( 'Blobs' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colBlobSizes font-weight-bold" data-align="center">' . translate ( 'BlobSizes' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colAlarmLimits font-weight-bold" data-align="center">' . translate ( 'AlarmLimits' ) . '</th>' . PHP_EOL ;
$result .= '<th class="colScore font-weight-bold" data-align="center">' . translate ( 'Score' ) . '</th>' . PHP_EOL ;
$result .= '</tr>' . PHP_EOL ;
$result .= '</thead>' . PHP_EOL ;
$result .= '<tbody>' . PHP_EOL ;
if ( count ( $stats ) ) {
foreach ( $stats as $stat ) {
$result .= '<tr>' . PHP_EOL ;
$result .= '<td class="colZone">' . validHtmlStr ( $stat [ 'ZoneName' ]) . '</td>' . PHP_EOL ;
$result .= '<td class="colPixelDiff">' . validHtmlStr ( $stat [ 'PixelDiff' ]) . '</td>' . PHP_EOL ;
$result .= '<td class="colAlarmPx">' . sprintf ( " %d (%d%%) " , $stat [ 'AlarmPixels' ], ( 100 * $stat [ 'AlarmPixels' ] / $stat [ 'Area' ]) ) . '</td>' . PHP_EOL ;
$result .= '<td class="colFilterPx">' . sprintf ( " %d (%d%%) " , $stat [ 'FilterPixels' ], ( 100 * $stat [ 'FilterPixels' ] / $stat [ 'Area' ]) ) . '</td>' . PHP_EOL ;
$result .= '<td class="colBlobPx">' . sprintf ( " %d (%d%%) " , $stat [ 'BlobPixels' ], ( 100 * $stat [ 'BlobPixels' ] / $stat [ 'Area' ]) ) . '</td>' . PHP_EOL ;
$result .= '<td class="colBlobs">' . validHtmlStr ( $stat [ 'Blobs' ]) . '</td>' . PHP_EOL ;
if ( $stat [ 'Blobs' ] > 1 ) {
$result .= '<td class="colBlobSizes">' . sprintf ( " %d-%d (%d%%-%d%%) " , $stat [ 'MinBlobSize' ], $stat [ 'MaxBlobSize' ], ( 100 * $stat [ 'MinBlobSize' ] / $stat [ 'Area' ]), ( 100 * $stat [ 'MaxBlobSize' ] / $stat [ 'Area' ]) ) . '</td>' . PHP_EOL ;
} else {
$result .= '<td class="colBlobSizes">' . sprintf ( " %d (%d%%) " , $stat [ 'MinBlobSize' ], 100 * $stat [ 'MinBlobSize' ] / $stat [ 'Area' ] ) . '</td>' . PHP_EOL ;
}
$result .= '<td class="colAlarmLimits">' . validHtmlStr ( $stat [ 'MinX' ] . " , " . $stat [ 'MinY' ] . " - " . $stat [ 'MaxX' ] . " , " . $stat [ 'MaxY' ]) . '</td>' . PHP_EOL ;
$result .= '<td class="colScore">' . $stat [ 'Score' ] . '</td>' . PHP_EOL ;
}
} else {
$result .= '<tr>' . PHP_EOL ;
$result .= '<td class="rowNoStats" colspan="9">' . translate ( 'NoStatisticsRecorded' ) . '</td>' . PHP_EOL ;
$result .= '</tr>' . PHP_EOL ;
}
$result .= '</tbody>' . PHP_EOL ;
$result .= '</table>' . PHP_EOL ;
2020-09-14 22:50:04 +08:00
return $result ;
}
2020-09-16 00:06:16 +08:00
// Use this function to manually insert the csrf key into the form when using a modal generated via ajax call
function getCSRFinputHTML () {
if ( isset ( $GLOBALS [ 'csrf' ][ 'key' ]) ) {
$result = '<input type="hidden" name="__csrf_magic" value="key:' . csrf_hash ( $GLOBALS [ 'csrf' ][ 'key' ]) . '" />' . PHP_EOL ;
} else {
$result = '' ;
}
return $result ;
}
2017-07-13 00:49:01 +08:00
function xhtmlFooter () {
2020-09-03 02:38:38 +08:00
global $css ;
2019-01-16 22:59:58 +08:00
global $cspNonce ;
2017-07-13 22:07:23 +08:00
global $view ;
2017-07-13 00:49:01 +08:00
global $skin ;
2020-09-03 02:38:38 +08:00
global $basename ;
$skinJsPhpFile = getSkinFile ( 'js/skin.js.php' );
$viewJsFile = getSkinFile ( 'views/js/' . $basename . '.js' );
$viewJsPhpFile = getSkinFile ( 'views/js/' . $basename . '.js.php' );
?>
2021-04-01 06:27:43 +08:00
< script src = " <?php echo cache_bust('skins/'. $skin .'/js/jquery.min.js'); ?> " ></ script >
2020-12-15 00:02:43 +08:00
< script src = " skins/<?php echo $skin ; ?>/js/jquery-ui-1.12.1/jquery-ui.min.js " ></ script >
2022-01-21 00:50:25 +08:00
< script src = " <?php echo cache_bust('js/ajaxQueue.js') ?> " ></ script >
2021-11-01 03:19:26 +08:00
< script src = " skins/<?php echo $skin ; ?>/js/bootstrap-4.5.0.min.js " ></ script >
2020-09-28 21:49:07 +08:00
< ? php echo output_script_if_exists ( array (
2021-02-19 10:22:19 +08:00
'js/tableExport.min.js' ,
2020-09-28 21:49:07 +08:00
'js/bootstrap-table.min.js' ,
2020-10-17 20:23:26 +08:00
'js/bootstrap-table-locale-all.min.js' ,
2020-09-28 21:49:07 +08:00
'js/bootstrap-table-export.min.js' ,
'js/bootstrap-table-page-jump-to.min.js' ,
'js/bootstrap-table-cookie.min.js' ,
'js/bootstrap-table-toolbar.min.js' ,
'js/bootstrap-table-auto-refresh.min.js' ,
'js/chosen/chosen.jquery.min.js' ,
'js/dateTimePicker/jquery-ui-timepicker-addon.js' ,
'js/Server.js' ,
), true );
?>
2020-09-03 02:38:38 +08:00
< ? php
if ( $view == 'event' ) {
?>
< link href = " skins/<?php echo $skin ?>/js/video-js.css " rel = " stylesheet " >
< link href = " skins/<?php echo $skin ?>/js/video-js-skin.css " rel = " stylesheet " >
< script src = " skins/<?php echo $skin ?>/js/video.js " ></ script >
< script src = " ./js/videojs.zoomrotate.js " ></ script >
< ? php
}
?>
< script src = " skins/<?php echo $skin ?>/js/moment.min.js " ></ script >
< ? php
?>
2022-01-21 00:50:25 +08:00
< script nonce = " <?php echo $cspNonce ; ?> " >
var $j = jQuery . noConflict ();
2020-09-03 02:38:38 +08:00
< ? php
if ( $skinJsPhpFile ) {
require_once ( $skinJsPhpFile );
}
if ( $viewJsPhpFile ) {
require_once ( $viewJsPhpFile );
}
?>
</ script >
< ? php
if ( $viewJsFile ) {
2017-07-13 00:49:01 +08:00
?>
2020-09-03 02:38:38 +08:00
< script src = " <?php echo cache_bust( $viewJsFile ) ?> " ></ script >
< ? php
}
$skinJsFile = getSkinFile ( 'js/skin.js' );
?>
< script src = " <?php echo cache_bust( $skinJsFile ) ?> " ></ script >
< script src = " <?php echo cache_bust('js/logger.js')?> " ></ script >
2020-09-24 21:13:25 +08:00
< ? php
2021-01-05 03:51:03 +08:00
if ( $basename == 'monitor' ) {
2020-09-25 08:21:38 +08:00
echo output_script_if_exists ( array ( 'js/leaflet/leaflet.js' ), false );
2020-09-24 21:13:25 +08:00
} ?>
2019-01-16 22:59:58 +08:00
< script nonce = " <?php echo $cspNonce ; ?> " > $j ( '.chosen' ) . chosen (); </ script >
2018-06-06 23:40:38 +08:00
</ body >
2017-12-14 05:15:03 +08:00
</ html >
2017-07-13 00:49:01 +08:00
< ? php
} // end xhtmlFooter
2008-07-14 21:54:50 +08:00
?>