Move client authorization checks to a separate function

This commit is contained in:
Paul Gear
2015-06-16 08:27:57 +10:00
parent e884bfa860
commit c873cafbae
+2 -25
View File
@@ -38,35 +38,12 @@ $graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
if (is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php"))
{
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs'])
{
$auth = "1"; // hardcode auth for all with config function
}
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 = "1";
if ($debug) { echo("matched $range"); }
break;
}
}
}
$auth = is_client_authorized($_SERVER['REMOTE_ADDR']);
include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php");
if (isset($auth) && $auth)
{
if ($auth && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) {
include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php");
}
}
else
{
graph_error("$type*$subtype ");//Graph Template Missing");