Move client authorization checks to a separate function

This commit is contained in:
Paul Gear
2015-06-13 22:45:03 +10:00
parent e884bfa860
commit c873cafbae

View File

@ -38,34 +38,11 @@ $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"))
{
$auth = is_client_authorized($_SERVER['REMOTE_ADDR']);
include($config['install_dir'] . "/html/includes/graphs/$type/auth.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;
}
}
}
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
{