mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 12:20:42 -05:00
local_prepend and template changes for nginx/php-fpm
This commit is contained in:
@@ -14,6 +14,19 @@
|
||||
* named in /etc/php/php.ini like this:
|
||||
* auto_prepend_file="/usr/local/emhttp/webGui/include/local_prepend.php"
|
||||
*/
|
||||
function csrf_terminate($reason) {
|
||||
shell_exec("logger error: {$_SERVER['REQUEST_URI']}: $reason csrf_token");
|
||||
exit;
|
||||
}
|
||||
putenv('PATH=.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin');
|
||||
chdir('/usr/local/emhttp');
|
||||
setlocale(LC_ALL,'en_US.UTF-8');
|
||||
date_default_timezone_set(substr(readlink('/etc/localtime-copied-from'),20));
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!isset($var)) $var = parse_ini_file('state/var.ini');
|
||||
if (!isset($var['csrf_token'])) csrf_terminate("uninitialized");
|
||||
if (!isset($_POST['csrf_token'])) csrf_terminate("missing");
|
||||
if ($var['csrf_token'] != $_POST['csrf_token']) csrf_terminate("wrong");
|
||||
unset($_POST['csrf_token']);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -23,6 +23,20 @@ require_once "$docroot/webGui/include/PageBuilder.php";
|
||||
// prev=<path> prev path, e.g., prev=Main (used to determine if page was refreshed)
|
||||
extract($_GET);
|
||||
|
||||
// Need the following to make php-fpm & nginx work
|
||||
if (empty($path)) {
|
||||
$path = substr(explode("?", $_SERVER["REQUEST_URI"])[0], 1);
|
||||
$prev = '';
|
||||
|
||||
if (empty($path)) {
|
||||
$path = 'Main';
|
||||
}
|
||||
}
|
||||
|
||||
// Tell emhttp to refresh vars
|
||||
$var = parse_ini_file('state/var.ini');
|
||||
file_get_contents("http://127.0.0.1:81/update.htm?cmdStatus=Apply&csrf_token={$var['csrf_token']}");
|
||||
|
||||
// The current "task" is the first element of the path
|
||||
$task = strtok($path, '/');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user