2015-04-16 10:08:19 +00:00
|
|
|
<?php
|
|
|
|
|
2018-07-17 03:19:29 -05:00
|
|
|
use LibreNMS\Config;
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach ($_GET as $key => $get_var) {
|
|
|
|
if (strstr($key, 'opt')) {
|
2020-09-21 15:40:17 +02:00
|
|
|
[$name, $value] = explode('|', $get_var);
|
|
|
|
if (! isset($value)) {
|
2015-07-13 20:10:26 +02:00
|
|
|
$value = 'yes';
|
|
|
|
}
|
|
|
|
|
2021-03-28 17:25:30 -05:00
|
|
|
$vars[$name] = strip_tags($value);
|
2015-07-13 20:10:26 +02:00
|
|
|
}
|
2015-04-16 10:08:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 03:19:29 -05:00
|
|
|
$base_url = parse_url(Config::get('base_url'));
|
2021-07-14 09:26:33 -05:00
|
|
|
$uri = explode('?', $_SERVER['REQUEST_URI'], 2)[0] ?? ''; // remove query, that is handled below with $_GET
|
|
|
|
|
2015-08-11 14:22:20 -07:00
|
|
|
// don't parse the subdirectory, if there is one in the path
|
2018-07-17 03:19:29 -05:00
|
|
|
if (isset($base_url['path']) && strlen($base_url['path']) > 1) {
|
2021-07-14 09:26:33 -05:00
|
|
|
$segments = explode('/', trim(str_replace($base_url['path'], '', $uri), '/'));
|
2016-08-18 20:28:22 -05:00
|
|
|
} else {
|
2021-07-14 09:26:33 -05:00
|
|
|
$segments = explode('/', trim($uri, '/'));
|
2015-08-11 14:22:20 -07:00
|
|
|
}
|
2015-04-16 10:08:19 +00:00
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach ($segments as $pos => $segment) {
|
|
|
|
$segment = urldecode($segment);
|
2020-04-29 07:25:13 -05:00
|
|
|
if ($pos === 0) {
|
2016-02-10 13:54:22 +00:00
|
|
|
$vars['page'] = $segment;
|
2016-08-18 20:28:22 -05:00
|
|
|
} else {
|
2020-09-21 15:40:17 +02:00
|
|
|
[$name, $value] = explode('=', $segment);
|
|
|
|
if ($value == '' || ! isset($value)) {
|
2020-04-29 07:25:13 -05:00
|
|
|
if ($vars['page'] == 'device' && $pos < 3) {
|
|
|
|
// translate laravel device routes properly
|
|
|
|
$vars[$pos === 1 ? 'device' : 'tab'] = $name;
|
|
|
|
} else {
|
|
|
|
$vars[$name] = 'yes';
|
|
|
|
}
|
2016-08-18 20:28:22 -05:00
|
|
|
} else {
|
2016-02-10 13:54:22 +00:00
|
|
|
$vars[$name] = $value;
|
2015-07-13 20:10:26 +02:00
|
|
|
}
|
2015-04-16 10:08:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach ($_GET as $name => $value) {
|
2021-03-28 17:25:30 -05:00
|
|
|
$vars[$name] = strip_tags($value);
|
2015-04-16 10:08:19 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach ($_POST as $name => $value) {
|
2016-11-01 11:20:12 -06:00
|
|
|
$vars[$name] = ($value);
|
2015-04-16 10:08:19 +00:00
|
|
|
}
|
2018-05-24 11:29:12 -05:00
|
|
|
|
|
|
|
// don't leak login data
|
2021-07-14 09:26:33 -05:00
|
|
|
unset($vars['username'], $vars['password'], $uri, $base_url);
|