Private GIT

Skip to content
Snippets Groups Projects
Commit 80124aa5 authored by Gary Allan's avatar Gary Allan
Browse files

Bugfix: Bandwidth calculator - 400 Bad Request. Fixes #1807 #2648

parent 2052f321
No related branches found
No related tags found
No related merge requests found
......@@ -136,8 +136,7 @@ if($User->is_admin(false)) {
} else {
$active = "";
}
list($l0, $l1) = explode('/', $i['href']);
print "<li class='$active'><a href='".create_link("tools",$l0, $l1)."'>"._($i['name'])."</a></li>";
print "<li class='$active'><a href='".create_link("tools",$i['href'])."'>"._($i['name'])."</a></li>";
}
}
}
......
......@@ -59,54 +59,41 @@ function create_link ($l0 = null, $l1 = null, $l2 = null, $l3 = null, $l4 = null
# get settings
global $User;
$parts = [];
for($i=0; $i<=6; $i++) {
if (is_null(${"l$i"})) continue;
foreach(explode('/', ${"l$i"}) as $p) {
// url encode all
if(!is_null($l6)) { $l6 = urlencode($l6); }
if(!is_null($l5)) { $l5 = urlencode($l5); }
if(!is_null($l4)) { $l4 = urlencode($l4); }
if(!is_null($l3)) { $l3 = urlencode($l3); }
if(!is_null($l2)) { $l2 = urlencode($l2); }
if(!is_null($l1)) { $l1 = urlencode($l1); }
if(!is_null($l0)) { $l0 = urlencode($l0); }
$parts[] = urlencode($p);
}
}
if (empty($parts))
return BASE;
# Pretty Links
if($User->settings->prettyLinks=="Yes") {
$link = BASE.implode('/', $parts);
# IP search fix
if (!is_null($parts[6]) || ($parts[0]=="tools" && $parts[1]=="search" && isset($parts[2])))
return $link;
return $link.'/';
}
# set normal link array
# Normal links
$el = array("page", "section", "subnetId", "sPage", "ipaddrid", "tab");
// override for search
if ($l0=="tools" && $l1=="search")
$el = array("page", "section", "ip", "addresses", "subnets", "vlans", "ip");
# set rewrite
if($User->settings->prettyLinks=="Yes") {
if(!is_null($l6)) { $link = "$l0/$l1/$l2/$l3/$l4/$l5/$l6"; }
elseif(!is_null($l5)) { $link = "$l0/$l1/$l2/$l3/$l4/$l5/"; }
elseif(!is_null($l4)) { $link = "$l0/$l1/$l2/$l3/$l4/"; }
elseif(!is_null($l3)) { $link = "$l0/$l1/$l2/$l3/"; }
elseif(!is_null($l2)) { $link = "$l0/$l1/$l2/"; }
elseif(!is_null($l1)) { $link = "$l0/$l1/"; }
elseif(!is_null($l0)) { $link = "$l0/"; }
else { $link = ""; }
# IP search fix
if ($l0=="tools" && $l1=="search" && isset($l2) && substr($link,-1)=="/") {
$link = substr($link, 0, -1);
}
foreach($parts as $i=>$p) {
$parts[$i] = "$el[$i]=$p";
}
# normal
else {
if(!is_null($l6)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1&$el[2]=$l2&$el[3]=$l3&$el[4]=$l4&$el[5]=$l5&$el[6]=$l6"; }
elseif(!is_null($l5)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1&$el[2]=$l2&$el[3]=$l3&$el[4]=$l4&$el[5]=$l5"; }
elseif(!is_null($l4)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1&$el[2]=$l2&$el[3]=$l3&$el[4]=$l4"; }
elseif(!is_null($l3)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1&$el[2]=$l2&$el[3]=$l3"; }
elseif(!is_null($l2)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1&$el[2]=$l2"; }
elseif(!is_null($l1)) { $link = "index.php?$el[0]=$l0&$el[1]=$l1"; }
elseif(!is_null($l0)) { $link = "index.php?$el[0]=$l0"; }
else { $link = ""; }
}
# prepend base
$link = BASE.$link;
# result
return $link;
return BASE."index.php?".implode('&', $parts);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment