2009-09-07 11:07:59 +00:00
< ? php
2011-05-12 23:17:44 +00:00
2012-05-09 10:01:42 +00:00
/**
2016-08-20 12:16:55 +01:00
* LibreNMS
2012-05-09 10:01:42 +00:00
*
2016-08-20 12:16:55 +01:00
* This file is part of LibreNMS.
2012-05-09 10:01:42 +00:00
*
2016-08-20 12:16:55 +01:00
* @package librenms
2012-05-09 10:01:42 +00:00
* @subpackage webinterface
* @copyright (C) 2006 - 2012 Adam Armstrong
*
*/
2015-12-03 13:23:37 -06:00
if ( empty ( $_SERVER [ 'PATH_INFO' ])) {
2016-08-18 20:28:22 -05:00
if ( strstr ( $_SERVER [ 'SERVER_SOFTWARE' ], " nginx " ) && isset ( $_SERVER [ 'PATH_TRANSLATED' ]) && isset ( $_SERVER [ 'ORIG_SCRIPT_FILENAME' ])) {
2016-05-31 22:28:34 -05:00
$_SERVER [ 'PATH_INFO' ] = str_replace ( $_SERVER [ 'PATH_TRANSLATED' ] . $_SERVER [ 'PHP_SELF' ], " " , $_SERVER [ 'ORIG_SCRIPT_FILENAME' ]);
2016-08-18 20:28:22 -05:00
} else {
2016-05-31 22:28:34 -05:00
$_SERVER [ 'PATH_INFO' ] = isset ( $_SERVER [ 'ORIG_PATH_INFO' ]) ? $_SERVER [ 'ORIG_PATH_INFO' ] : '' ;
2015-12-03 13:23:37 -06:00
}
2015-04-17 16:53:31 +00:00
}
2015-02-18 23:51:49 +00:00
2016-09-14 04:05:49 -05:00
if ( strpos ( $_SERVER [ 'REQUEST_URI' ], " debug " )) {
$debug = true ;
2015-07-13 20:10:26 +02:00
ini_set ( 'display_errors' , 0 );
ini_set ( 'display_startup_errors' , 1 );
ini_set ( 'log_errors' , 1 );
ini_set ( 'error_reporting' , E_ALL );
2017-08-26 14:07:34 -05:00
set_error_handler ( function ( $errno , $errstr , $errfile , $errline ) {
global $php_debug ;
$php_debug [] = array ( 'errno' => $errno , 'errstr' => $errstr , 'errfile' => $errfile , 'errline' => $errline );
});
register_shutdown_function ( function () {
$last_error = error_get_last ();
if ( $last_error [ 'type' ] == 1 ) {
$log_error = array ( $last_error [ 'type' ], $last_error [ 'message' ], $last_error [ 'file' ], $last_error [ 'line' ]);
print_r ( $log_error );
}
});
2016-09-14 04:05:49 -05:00
$sql_debug = array ();
$php_debug = array ();
2016-08-18 20:28:22 -05:00
} else {
$debug = false ;
2015-07-13 20:10:26 +02:00
ini_set ( 'display_errors' , 0 );
ini_set ( 'display_startup_errors' , 0 );
ini_set ( 'log_errors' , 0 );
ini_set ( 'error_reporting' , 0 );
2015-02-18 23:51:49 +00:00
}
2015-02-01 16:52:26 +00:00
// Set variables
$msg_box = array ();
2015-04-30 11:35:43 +01:00
// Check for install.inc.php
2015-07-13 20:10:26 +02:00
if ( ! file_exists ( '../config.php' ) && $_SERVER [ 'PATH_INFO' ] != '/install.php' ) {
// no config.php does so let's redirect to the install
2017-05-03 14:48:23 +01:00
header ( " Location: { $config [ 'base_url' ] } /install.php " );
2015-07-13 20:10:26 +02:00
exit ;
2015-04-30 11:35:43 +01:00
}
2015-02-01 16:52:26 +00:00
2016-11-21 14:12:59 -06:00
$init_modules = array ( 'web' , 'auth' );
require realpath ( __DIR__ . '/..' ) . '/includes/init.php' ;
2016-08-17 20:24:27 -05:00
2015-09-30 15:20:06 +00:00
$config [ 'memcached' ][ 'ttl' ] = $config [ 'time' ][ 'now' ] + 300 ;
2016-08-21 08:07:14 -05:00
LibreNMS\Plugins :: start ();
2012-02-06 17:39:31 +00:00
2016-01-08 13:33:32 +01:00
$runtime_start = microtime ( true );
2012-02-06 17:39:31 +00:00
2011-03-17 11:48:03 +00:00
ob_start ();
ini_set ( 'allow_url_fopen' , 0 );
ini_set ( 'display_errors' , 0 );
2007-11-23 11:37:28 +00:00
2015-07-13 20:10:26 +02:00
if ( strstr ( $_SERVER [ 'REQUEST_URI' ], 'widescreen=yes' )) {
$_SESSION [ 'widescreen' ] = 1 ;
}
if ( strstr ( $_SERVER [ 'REQUEST_URI' ], 'widescreen=no' )) {
unset ( $_SESSION [ 'widescreen' ]);
}
2011-09-04 21:50:48 +00:00
2011-03-17 11:48:03 +00:00
# Load the settings for Multi-Tenancy.
2015-07-13 20:10:26 +02:00
if ( isset ( $config [ 'branding' ]) && is_array ( $config [ 'branding' ])) {
2017-05-17 16:38:00 -05:00
if ( isset ( $config [ 'branding' ][ $_SERVER [ 'SERVER_NAME' ]])) {
$config = array_replace_recursive ( $config , $config [ 'branding' ][ $_SERVER [ 'SERVER_NAME' ]]);
2016-08-18 20:28:22 -05:00
} else {
2017-05-17 16:38:00 -05:00
$config = array_replace_recursive ( $config , $config [ 'branding' ][ 'default' ]);
2011-03-17 11:48:03 +00:00
}
}
2012-04-17 10:53:24 +00:00
# page_title_prefix is displayed, unless page_title is set
2015-07-13 20:10:26 +02:00
if ( isset ( $config [ 'page_title' ])) {
$config [ 'page_title_prefix' ] = $config [ 'page_title' ];
}
2012-04-17 15:27:17 +00:00
2007-04-03 14:10:23 +00:00
?>
2011-09-02 19:25:54 +00:00
<!DOCTYPE HTML>
<html>
2007-04-03 14:10:23 +00:00
<head>
2014-01-28 14:59:15 +00:00
<title><?php echo($config['page_title_suffix']); ?></title>
2008-03-15 17:58:15 +00:00
<base href="<?php echo($config['base_url']); ?>" />
2009-03-17 20:29:54 +00:00
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
2014-01-13 07:59:31 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2015-03-10 20:36:44 +00:00
<?php
if (empty($config['favicon'])) {
?>
2017-01-27 12:02:49 -06:00
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="images/manifest.json">
<link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="images/favicon.ico">
<meta name="msapplication-config" content="images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
2015-03-10 20:36:44 +00:00
<?php
2016-08-18 20:28:22 -05:00
} else {
2015-03-10 20:36:44 +00:00
echo(' <link rel="shortcut icon" href="'.$config['favicon'].'" />' . "\n");
}
?>
2014-01-13 07:59:31 +00:00
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
2014-10-28 07:46:08 +10:00
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
2014-06-14 23:05:31 +01:00
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
2014-10-01 00:14:26 +01:00
<link href="css/toastr.min.css" rel="stylesheet" type="text/css" />
2014-11-30 17:49:52 +00:00
<link href="css/jquery-ui.min.css" rel="stylesheet" type="text/css" />
2015-03-27 16:28:09 +00:00
<link href="css/jquery.bootgrid.min.css" rel="stylesheet" type="text/css" />
2014-11-30 17:49:52 +00:00
<link href="css/tagmanager.css" rel="stylesheet" type="text/css" />
2015-03-23 21:49:37 +00:00
<link href="css/mktree.css" rel="stylesheet" type="text/css" />
2015-03-28 13:59:23 +00:00
<link href="css/vis.min.css" rel="stylesheet" type="text/css" />
2015-03-26 13:44:54 +00:00
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
2015-07-21 23:01:57 +01:00
<link href="css/jquery.gridster.min.css" rel="stylesheet" type="text/css" />
2015-07-20 15:10:56 +01:00
<link href="css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.Default.css" rel="stylesheet" type="text/css" />
<link href="css/leaflet.awesome-markers.css" rel="stylesheet" type="text/css" />
2017-04-05 07:54:55 +01:00
<link href="<?php echo($config['stylesheet']); ?>?ver=291727421" rel="stylesheet" type="text/css" />
2017-02-24 03:59:30 -06:00
<link href="css/<?php echo $config['site_style']; ?>.css?ver=632417639" rel="stylesheet" type="text/css" />
2016-10-28 06:55:40 +01:00
<?php
foreach ((array)$config['webui']['custom_css'] as $custom_css) {
echo '<link href="' . $custom_css . '" rel="stylesheet" type="text/css" />';
}
?>
2014-01-13 07:59:31 +00:00
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-hover-dropdown.min.js"></script>
2014-06-14 23:05:31 +01:00
<script src="js/bootstrap-switch.min.js"></script>
2014-01-13 07:59:31 +00:00
<script src="js/hogan-2.0.0.js"></script>
<script src="js/jquery.cycle2.min.js"></script>
2014-10-28 07:47:52 +10:00
<script src="js/moment.min.js"></script>
2014-10-29 10:48:18 +00:00
<script src="js/bootstrap-datetimepicker.min.js"></script>
2015-04-29 15:18:14 +01:00
<script src="js/typeahead.bundle.min.js"></script>
2014-11-30 17:49:52 +00:00
<script src="js/jquery-ui.min.js"></script>
<script src="js/tagmanager.js"></script>
2015-03-23 21:49:37 +00:00
<script src="js/mktree.js"></script>
2015-03-27 16:28:09 +00:00
<script src="js/jquery.bootgrid.min.js"></script>
2015-04-29 15:18:14 +01:00
<script src="js/handlebars.min.js"></script>
2015-05-01 11:02:18 -03:00
<script src="js/pace.min.js"></script>
2017-02-23 23:19:22 -05:00
<script src="js/qrcode.min.js"></script>
2015-12-09 15:50:10 +00:00
<?php
2016-08-18 20:28:22 -05:00
if ($config['enable_lazy_load'] === true) {
2015-12-09 15:50:10 +00:00
?>
2015-07-16 12:42:58 -04:00
<script src="js/jquery.lazyload.min.js"></script>
<script src="js/lazyload.js"></script>
2015-12-09 15:50:10 +00:00
<?php
2016-08-18 20:28:22 -05:00
}
2015-12-09 15:50:10 +00:00
?>
2015-10-20 21:35:08 +00:00
<script src="js/librenms.js"></script>
2011-09-14 13:38:01 +00:00
<script type="text/javascript">
2014-02-26 02:29:31 +00:00
<!-- Begin
function popUp(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
}
// End -->
2011-03-23 09:54:56 +00:00
</script>
2011-09-29 12:57:44 +00:00
<script type="text/javascript" src="js/overlib_mini.js"></script>
2014-10-01 00:14:26 +01:00
<script type="text/javascript" src="js/toastr.min.js"></script>
2014-01-13 07:59:31 +00:00
</head>
<body>
2007-04-03 14:10:23 +00:00
2011-03-26 19:28:39 +00:00
<?php
2007-04-03 14:10:23 +00:00
2016-08-18 20:28:22 -05:00
if (empty($_SESSION['screen_width']) && empty($_SESSION['screen_height'])) {
2015-11-20 12:47:56 +00:00
echo "<script>updateResolution();</script>";
}
2015-03-01 17:06:38 +00:00
if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) {
2015-07-13 20:10:26 +02:00
if ($_SESSION['authenticated']) {
require 'includes/print-menubar.php';
}
2016-08-18 20:28:22 -05:00
} else {
2015-05-29 01:17:23 +01:00
echo "<style>body { padding-top: 0px !important;
2015-07-13 20:10:26 +02:00
padding-bottom: 0px !important; }</style>";
2011-09-14 13:38:01 +00:00
}
2007-04-03 14:10:23 +00:00
2011-03-26 19:28:39 +00:00
?>
2014-01-13 07:59:31 +00:00
<br />
2014-02-23 11:57:39 +00:00
<div class="container-fluid">
2014-02-26 02:29:31 +00:00
<div class="row">
<div class="col-md-12">
2007-04-03 14:10:23 +00:00
<?php
2011-09-15 21:18:57 +00:00
2016-02-17 13:59:58 +00:00
// To help debug the new URLs :)
if (isset($devel) || isset($vars['devel'])) {
echo("<pre>");
print_r($_GET);
print_r($vars);
echo("</pre>");
}
2015-07-13 20:10:26 +02:00
if ($_SESSION['authenticated']) {
// Authenticated. Print a page.
if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) {
require "pages/" . $vars['page'] . ".inc.php";
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
if (isset($config['front_page']) && is_file($config['front_page'])) {
require $config['front_page'];
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
require 'pages/front/default.php';
}
2007-04-03 14:10:23 +00:00
}
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
// Not Authenticated. Show status page if enabled
2016-08-18 20:28:22 -05:00
if ($config['public_status'] === true) {
2015-07-13 20:10:26 +02:00
if (isset($vars['page']) && strstr("login", $vars['page'])) {
require 'pages/logon.inc.php';
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
echo '<div id="public-status">';
require 'pages/public.inc.php';
echo '</div>';
echo '<div id="public-logon" style="display:none;">';
echo '<div class="well"><h3>Logon<button class="btn btn-default" type="submit" style="float:right;" id="ToggleStatus">Status</button></h3></div>';
require 'pages/logon.inc.php';
echo '</div>';
}
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
require 'pages/logon.inc.php';
2014-06-21 09:50:24 -04:00
}
2011-03-17 11:48:03 +00:00
}
2007-04-03 14:10:23 +00:00
?>
2014-02-26 02:29:31 +00:00
</div>
</div>
</div>
2007-04-03 14:10:23 +00:00
<?php
2014-02-26 02:29:31 +00:00
2016-01-08 13:33:32 +01:00
$runtime_end = microtime(true);
2015-07-13 20:10:26 +02:00
$runtime = $runtime_end - $runtime_start;
2012-02-06 17:39:31 +00:00
$gentime = substr($runtime, 0, 5);
2010-03-27 22:20:57 +00:00
2013-11-05 10:23:15 +10:00
# FIXME - move this
2015-07-13 20:10:26 +02:00
if ($config['page_gen']) {
2016-11-23 00:57:19 -06:00
echo '<br />';
printStats();
2015-07-13 20:10:26 +02:00
$fullsize = memory_get_usage();
unset($cache);
$cachesize = $fullsize - memory_get_usage();
if ($cachesize < 0) {
$cachesize = 0;
} // Silly PHP!
echo(' <br />Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.');
echo(' <br />Generated in ' . $gentime . ' seconds.');
2011-03-17 11:48:03 +00:00
}
2011-09-19 11:15:01 +00:00
2015-07-13 20:10:26 +02:00
if (isset($pagetitle) && is_array($pagetitle)) {
# if prefix is set, put it in front
if ($config['page_title_prefix']) {
2016-08-18 20:28:22 -05:00
array_unshift($pagetitle, $config['page_title_prefix']);
2015-07-13 20:10:26 +02:00
}
2012-04-17 15:27:17 +00:00
2015-07-13 20:10:26 +02:00
# if suffix is set, put it in the back
if ($config['page_title_suffix']) {
$pagetitle[] = $config['page_title_suffix'];
}
2012-04-17 15:27:17 +00:00
2015-07-13 20:10:26 +02:00
# create and set the title
2016-08-18 20:28:22 -05:00
$title = join(" - ", $pagetitle);
2015-07-13 20:10:26 +02:00
echo("<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>");
2011-10-18 14:27:21 +00:00
}
?>
2015-01-02 23:15:35 +00:00
<?php
2016-08-18 20:28:22 -05:00
if ($config['enable_footer'] == 1 && (isset($vars['bare']) && $vars['bare'] != "yes")) {
2015-01-02 23:15:35 +00:00
?>
2015-03-26 23:51:13 +00:00
<nav class="navbar navbar-default <?php echo $navbar; ?> navbar-fixed-bottom">
2014-02-26 02:29:31 +00:00
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
2014-01-13 07:59:31 +00:00
<?php
2017-01-02 02:03:23 +02:00
echo('<h5>Powered by <a href="' . $config['project_home'] . '" target="_blank" rel="noopener" class="red">' . $config['project_name'].'</a>.</h5>');
2014-01-13 07:59:31 +00:00
?>
2014-02-26 02:29:31 +00:00
</div>
</div>
</div>
2015-03-26 23:51:13 +00:00
</nav>
2014-10-01 00:14:26 +01:00
<?php
2015-01-02 23:15:35 +00:00
}
2014-10-01 00:14:26 +01:00
2017-05-15 22:18:23 -05:00
if (dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `last_polled` <= DATE_ADD(NOW(), INTERVAL - 15 minute) AND `ignore` = 0 AND `disabled` = 0 AND status = 1", array()) > 0) {
2016-06-21 20:12:32 +01:00
$msg_box[] = array('type' => 'warning', 'message' => "<a href=\"poll-log/filter=unpolled/\">It appears as though you have some devices that haven't completed polling within the last 15 minutes, you may want to check that out :)</a>",'title' => 'Devices unpolled');
2015-02-01 16:42:09 +00:00
}
2017-08-29 09:32:24 -05:00
foreach (dbFetchRows('SELECT `notifications`.* FROM `notifications` WHERE NOT exists( SELECT 1 FROM `notifications_attribs` WHERE `notifications`.`notifications_id` = `notifications_attribs`.`notifications_id` AND `notifications_attribs`.`user_id` = ?) AND `severity` > 1', array($_SESSION['user_id'])) as $notification) {
2017-08-26 15:35:39 -05:00
$msg_box[] = array(
'type' => 'error',
'message' => "<a href='notifications/'>${notification['body']}</a>",
'title' => $notification['title']
);
}
2016-08-18 20:28:22 -05:00
if (is_array($msg_box)) {
2015-07-13 20:10:26 +02:00
echo("<script>
toastr.options.timeout = 10;
toastr.options.extendedTimeOut = 20;
");
foreach ($msg_box as $message) {
$message['type'] = mres($message['type']);
$message['message'] = mres($message['message']);
$message['title'] = mres($message['title']);
echo "toastr.".$message['type']."('".$message['message']."','".$message['title']."');\n";
}
echo("</script>");
2014-10-01 00:14:26 +01:00
}
2016-08-18 20:28:22 -05:00
if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === true) {
2015-07-13 20:10:26 +02:00
require_once "includes/print-debug.php";
2015-02-18 23:03:23 +00:00
}
2016-08-18 20:28:22 -05:00
if ($no_refresh !== true && $config['page_refresh'] != 0) {
2015-03-06 15:49:35 +00:00
$refresh = $config['page_refresh'] * 1000;
2015-03-08 21:33:40 +00:00
echo('<script type="text/javascript">
2015-03-06 15:49:35 +00:00
$(document).ready(function() {
2017-01-21 13:24:05 +02:00
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
2015-03-08 21:33:40 +00:00
var Countdown = {
sec: '. $config['page_refresh'] .',
Start: function() {
var cur = this;
this.interval = setInterval(function() {
2017-01-21 13:24:05 +02:00
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
2015-03-08 21:33:40 +00:00
cur.sec -= 1;
display_time = cur.sec;
if (display_time == 0) {
location.reload();
}
if (display_time % 1 === 0 && display_time <= 300) {
2017-01-21 13:24:05 +02:00
$("#countdown_timer").html("<i class=\"fa fa-clock-o fa-fw fa-lg\"></i> Refresh in " + display_time);
2015-03-08 21:33:40 +00:00
}
}, 1000);
},
Pause: function() {
clearInterval(this.interval);
2017-01-21 13:24:05 +02:00
$("#countdown_timer_status").html("<i class=\"fa fa-play fa-fw fa-lg\"></i> Resume");
2015-03-08 21:33:40 +00:00
delete this.interval;
},
Resume: function() {
if (!this.interval) this.Start();
}
};
Countdown.Start();
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
if (Countdown.interval) {
Countdown.Pause();
} else {
Countdown.Resume();
}
});
$("#countdown_timer").click("", function(event) {
event.preventDefault();
});
2015-03-06 15:49:35 +00:00
2015-03-08 21:33:40 +00:00
});
2015-03-06 15:49:35 +00:00
</script>');
2016-08-18 20:28:22 -05:00
} else {
echo('<script type="text/javascript">
2016-09-20 09:21:46 -05:00
var no_refresh = ' . var_export((bool)$no_refresh, true) . ';
2015-04-29 18:08:16 +01:00
$(document).ready(function() {
$("#countdown_timer").html("Refresh disabled");
2017-01-21 13:24:05 +02:00
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i>");
2015-04-29 18:08:16 +01:00
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
});
});
</script>');
2015-03-06 15:49:35 +00:00
}
?>
2015-03-26 23:51:13 +00:00
</body>
2007-04-03 14:10:23 +00:00
</html>