Tony Murray 7cde27338b Fix errors in vars.inc.php (#8913)
DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
2018-07-17 09:19:29 +01:00

48 lines
1.2 KiB
PHP

<?php
use LibreNMS\Config;
foreach ($_GET as $key => $get_var) {
if (strstr($key, 'opt')) {
list($name, $value) = explode('|', $get_var);
if (!isset($value)) {
$value = 'yes';
}
$vars[$name] = clean($value);
}
}
$base_url = parse_url(Config::get('base_url'));
// don't parse the subdirectory, if there is one in the path
if (isset($base_url['path']) && strlen($base_url['path']) > 1) {
$segments = explode('/', trim(str_replace($base_url["path"], "", $_SERVER['REQUEST_URI']), '/'));
} else {
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
}
foreach ($segments as $pos => $segment) {
$segment = urldecode($segment);
if ($pos == '0') {
$vars['page'] = $segment;
} else {
list($name, $value) = explode('=', $segment);
if ($value == '' || !isset($value)) {
$vars[$name] = 'yes';
} else {
$vars[$name] = $value;
}
}
}
foreach ($_GET as $name => $value) {
$vars[$name] = clean($value);
}
foreach ($_POST as $name => $value) {
$vars[$name] = ($value);
}
// don't leak login data
unset($vars['username'], $vars['password']);