add code to allow unauth graphs by IP range, useful for control panels who can use a passthrough (ie php fpassthru) of 'secret' urls, or stats pages, or...

git-svn-id: http://www.observium.org/svn/observer/trunk@1750 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-12-02 17:41:12 +00:00
parent f71eac502f
commit 76abee7ffa
2 changed files with 79 additions and 50 deletions

View File

@@ -1,12 +1,17 @@
<?php
if(isset($_GET['debug'])) {
include_once("Net/IPv4.php");
if (isset($_GET['debug']))
{
$debug = TRUE;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', E_ALL);
} else {
}
else
{
$debug = FALSE;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
@@ -46,12 +51,29 @@ if(isset($_GET['debug'])) {
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
if(is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) {
if (is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php"))
{
if (isset($config['allow_unauth_graphs_cidr']) && count($config['allow_unauth_graphs_cidr']) > 0)
{
foreach ($config['allow_unauth_graphs_cidr'] as $range)
{
if (Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $range))
{
$auth = TRUE;
}
}
}
if (!$auth)
{
include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php");
if($auth) {
}
if ($auth)
{
include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php");
}
} else {
}
else
{
graph_error("Graph Template Missing");
}
@@ -98,15 +120,21 @@ if(!$auth)
header('Content-type: image/png');
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
unlink($graphfile);
} else {
}
else
{
if ($width < 200)
{
graph_error("Draw Error");
} else {
}
else
{
graph_error("Error Drawing Graph");
}
}
} else {
}
else
{
if ($width < 200)
{
graph_error("Def Error");

View File

@@ -171,6 +171,7 @@ $config['device_traffic_descr'] = array('/loopback/','/vlan/','/tunnel/','/:\d
### Authentication
$config['allow_unauth_graphs'] = 0; ## Allow graphs to be viewed by anyone
$config['allow_unauth_graphs_cidr'] = array(); # Allow graphs to be viewed without authorisation from certain IP ranges
$config['auth_mechanism'] = "mysql"; # Auth Type.
### Sensors