mirror of
https://github.com/unraid/webgui.git
synced 2026-05-03 08:19:27 -05:00
PHP8 support
This commit is contained in:
@@ -22,9 +22,9 @@ function validpath($file) {
|
||||
switch ($_POST['cmd']) {
|
||||
case 'save':
|
||||
if (!validpath($file)) break;
|
||||
$source = $_POST['source'];
|
||||
$source = $_POST['source']??'';
|
||||
$opts = $_POST['opts'] ?? 'qlj';
|
||||
if (in_array(pathinfo($source, PATHINFO_EXTENSION),['txt','conf','png'])) {
|
||||
if ($source && in_array(pathinfo($source,PATHINFO_EXTENSION),['txt','conf','png'])) {
|
||||
exec("zip -$opts ".escapeshellarg("$docroot/$file")." ".escapeshellarg($source));
|
||||
} else {
|
||||
$tmp = "/var/tmp/".basename($source).".txt";
|
||||
|
||||
@@ -66,7 +66,7 @@ if (is_low($rootdir) && is_dir($rootdir)) {
|
||||
foreach ($files as $name) {
|
||||
$htmlRel = htmlspecialchars($rootdir.$name);
|
||||
$htmlName = htmlspecialchars($name);
|
||||
$ext = mb_strtolower(pathinfo($name)['extension']??'');
|
||||
$ext = mb_strtolower(pathinfo($name,PATHINFO_EXTENSION));
|
||||
foreach ($filters as $filter) if (empty($filter)||$ext==$filter) {
|
||||
if (empty($match)||preg_match("/$match/",$name)) echo "<li class='file ext_$ext'>$checkbox<a href='#' rel=\"$htmlRel\">$htmlName</a></li>";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -11,17 +11,19 @@
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
// add translations
|
||||
$_SERVER['REQUEST_URI'] = 'settings';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
/**
|
||||
* @name response_complete
|
||||
* @param {HTTP Response Status Code} $httpcode https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
||||
* @param {String|Array} $result - strings are assumed to be encoded JSON. Arrays will be encoded to JSON.
|
||||
* @param {String} $cli_success_msg
|
||||
*/
|
||||
|
||||
function response_complete($httpcode, $result, $cli_success_msg='') {
|
||||
global $cli;
|
||||
$mutatedResult = is_array($result) ? json_encode($result) : $result;
|
||||
@@ -38,15 +40,16 @@ function response_complete($httpcode, $result, $cli_success_msg='') {
|
||||
exit((string)$mutatedResult);
|
||||
}
|
||||
|
||||
$cli = php_sapi_name()=='cli';
|
||||
$url = unscript($_GET['url']??'');
|
||||
$host = parse_url($url)['host'];
|
||||
$cli = php_sapi_name()=='cli';
|
||||
$url = unscript(_var($_GET,'url'));
|
||||
$host = parse_url($url)['host']??'';
|
||||
|
||||
if (in_array($host,['keys.lime-technology.com','lime-technology.com'])) {
|
||||
if ($host && in_array($host,['keys.lime-technology.com','lime-technology.com'])) {
|
||||
$key_file = basename($url);
|
||||
exec("/usr/bin/wget -q -O ".escapeshellarg("/boot/config/$key_file")." ".escapeshellarg($url), $output, $return_var);
|
||||
if ($return_var === 0) {
|
||||
if (parse_ini_file('/var/local/emhttp/var.ini')['mdState'] == "STARTED") {
|
||||
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
|
||||
if (_var($var,'mdState')=="STARTED") {
|
||||
response_complete(200, array('status' => _('Please Stop array to complete key installation')), _('success').', '._('Please Stop array to complete key installation'));
|
||||
} else {
|
||||
response_complete(200, array('status' => ''), _('success'));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$notify = "$docroot/webGui/scripts/notify";
|
||||
|
||||
switch ($_POST['cmd']) {
|
||||
switch ($_POST['cmd']??'') {
|
||||
case 'init':
|
||||
shell_exec("$notify init");
|
||||
break;
|
||||
@@ -48,11 +48,11 @@ case 'get':
|
||||
break;
|
||||
case 'hide':
|
||||
$file = $_POST['file']??'';
|
||||
if (file_exists($file) && $file==realpath($file) && pathinfo($file)['extension']=='notify') chmod($file,0400);
|
||||
if (file_exists($file) && $file==realpath($file) && pathinfo($file,PATHINFO_EXTENSION)=='notify') chmod($file,0400);
|
||||
break;
|
||||
case 'archive':
|
||||
$file = $_POST['file']??'';
|
||||
if (strlen($file) && strpos($file,'/')===false) shell_exec("$notify archive ".escapeshellarg($file));
|
||||
if ($file && strpos($file,'/')===false) shell_exec("$notify archive ".escapeshellarg($file));
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -12,11 +12,14 @@
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
|
||||
switch ($_GET['protocol']??'') {
|
||||
case 'smb': $data = parse_ini_file('state/sec.ini',true); break;
|
||||
case 'nfs': $data = parse_ini_file('state/sec_nfs.ini',true); break;
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
switch (_var($_GET,'protocol')) {
|
||||
case 'smb': $data = @parse_ini_file('state/sec.ini',true) ?: []; break;
|
||||
case 'nfs': $data = @parse_ini_file('state/sec_nfs.ini',true) ?: []; break;
|
||||
}
|
||||
echo json_encode($data[unscript($_GET['name']??'')]);
|
||||
$name = unscript(_var($_GET,'name'));
|
||||
echo json_encode(_var($data,$name));
|
||||
?>
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
switch ($_POST['cmd']??'') {
|
||||
case 'config':
|
||||
$config = "/boot/config";
|
||||
@@ -26,22 +31,20 @@ case 'config':
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $flag ) break;
|
||||
if ($flag) break;
|
||||
}
|
||||
echo $flag;
|
||||
break;
|
||||
case 'notice':
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
$tmp = "/tmp/reboot_notifications";
|
||||
$notices = file_exists($tmp) ? file($tmp,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) : [];
|
||||
echo implode("\n",array_map('unbundle',$notices));
|
||||
break;
|
||||
case 'state':
|
||||
$pools = explode(',',$_POST['pools']);
|
||||
$disks = parse_ini_file('state/disks.ini',true);
|
||||
$pools = explode(',',_var($_POST,'pools'));
|
||||
$disks = @parse_ini_file('state/disks.ini',true) ?: [];
|
||||
$error = [];
|
||||
foreach ($pools as $pool) if (stripos($disks[$pool]['state'],'ERROR:')===0) $error[] = $pool.' - '.str_ireplace('ERROR:','',$disks[$pool]['state']);
|
||||
foreach ($pools as $pool) if (stripos(_var($disks[$pool],'state'),'ERROR:')===0) $error[] = $pool.' - '.str_ireplace('ERROR:','',$disks[$pool]['state']);
|
||||
echo implode('<br>',$error);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ $root = "/boot/config/plugins/dynamix";
|
||||
$name = "$root/$file";
|
||||
|
||||
if (realpath(dirname($name)) == $root) {
|
||||
switch ($_POST['mode']) {
|
||||
switch ($_POST['mode']??'') {
|
||||
case 'set':
|
||||
if ($model) file_put_contents($name,$model);
|
||||
break;
|
||||
@@ -27,7 +27,7 @@ if (realpath(dirname($name)) == $root) {
|
||||
case 'file':
|
||||
$case = 'case-model.png';
|
||||
file_put_contents($name,$case);
|
||||
file_put_contents("$root/$case",base64_decode(str_replace('data:image/png;base64,','',$_POST['data'])));
|
||||
file_put_contents("$root/$case",base64_decode(str_replace('data:image/png;base64,','',$_POST['data']??'')));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -12,8 +12,11 @@
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
|
||||
$shares = parse_ini_file('state/shares.ini',true);
|
||||
echo json_encode($shares[unscript($_GET['name']??'')]);
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$shares = @parse_ini_file('state/shares.ini',true) ?: [];
|
||||
$name = unscript(_var($_GET,'name'));
|
||||
echo json_encode(_var($shares,$name));
|
||||
?>
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
// add translations
|
||||
$_SERVER['REQUEST_URI'] = 'main';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
$disks = array_merge_recursive((array)parse_ini_file('state/disks.ini',true), (array)parse_ini_file('state/devs.ini',true));
|
||||
$disks = array_merge_recursive(@parse_ini_file('state/disks.ini',true)?:[], @parse_ini_file('state/devs.ini',true)?:[]);
|
||||
require_once "$docroot/webGui/include/CustomMerge.php";
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/Preselect.php";
|
||||
@@ -40,8 +41,8 @@ function duration(&$hrs) {
|
||||
function append(&$ref, &$info) {
|
||||
if ($info) $ref .= ($ref ? " " : "").$info;
|
||||
}
|
||||
$name = $_POST['name'] ?? '';
|
||||
$port = $_POST['port'] ?? '';
|
||||
$name = $_POST['name']??'';
|
||||
$port = $_POST['port']??'';
|
||||
if ($name) {
|
||||
$disk = &$disks[$name];
|
||||
$type = get_value($disk,'smType','');
|
||||
@@ -51,14 +52,14 @@ if ($name) {
|
||||
$type = '';
|
||||
}
|
||||
$port = port_name($disk['smDevice'] ?? $port);
|
||||
switch ($_POST['cmd']) {
|
||||
switch ($_POST['cmd']??'') {
|
||||
case "attributes":
|
||||
$select = get_value($disk,'smSelect',0);
|
||||
$level = get_value($disk,'smLevel',1);
|
||||
$events = explode('|',get_value($disk,'smEvents',$numbers));
|
||||
$unraid = parse_plugin_cfg('dynamix',true);
|
||||
$max = $disk['maxTemp'] ?? $unraid['display']['max'];
|
||||
$hot = $disk['hotTemp'] ?? $unraid['display']['hot'];
|
||||
extract(parse_plugin_cfg('dynamix',true));
|
||||
$max = ($disk['maxTemp'] ?? $display['max'] ?? 0) ?: 0;
|
||||
$hot = ($disk['hotTemp'] ?? $display['hot'] ?? 0) ?: 0;
|
||||
$top = $_POST['top'] ?? 120;
|
||||
$empty = true;
|
||||
exec("smartctl -n standby -A $type ".escapeshellarg("/dev/$port"),$output);
|
||||
@@ -139,7 +140,7 @@ case "capabilities":
|
||||
$nvme_section = "psdetail";
|
||||
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S+)\s+(?P<data3>\S+)\s+(?P<data4>\S+)\s+(?P<data5>\S+)\s+(?P<data6>\S+)\s+(?P<data7>\S+)\s+(?P<data8>\S+)\s+(?P<data9>\S+)\s+(?P<data10>\S+)\s+(?P<data11>\S+)$/',$line, $psheadings);
|
||||
for ($i = 1; $i <= 11; $i++) {
|
||||
echo "<td>".($psheadings['data'.$i]??'')."</td>" ;
|
||||
echo "<td>"._var($psheadings,'data'.$i)."</td>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr></thead><tbody>' ;
|
||||
@@ -149,7 +150,7 @@ case "capabilities":
|
||||
echo '<tr>' ;
|
||||
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S\s+)\s+(?P<data3>\S+)\s+(?P<data4>\S\s+)\s+(?P<data5>\S+)\s+(?P<data6>\S+)\s+(?P<data7>\S+)\s+(?P<data8>\S+)\s+(?P<data9>\S+)\s+(?P<data10>\S+)\s+(?P<data11>\S+)$/',$line, $psdetails);
|
||||
for ($i = 1; $i <= 11; $i++) {
|
||||
echo "<td>".($psdetails['data'.$i]??'')."</td>" ;
|
||||
echo "<td>"._var($psdetails,'data'.$i])."</td>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr>' ;
|
||||
@@ -159,7 +160,7 @@ case "capabilities":
|
||||
$nvme_section = "lbadetail";
|
||||
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S+)\s+(?P<data3>\S+)\s+(?P<data4>\S+)\s+(?P<data5>\S+)$/',$line, $lbaheadings);
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
echo "<td>".($lbaheadings['data'.$i]??'')."</td>" ;
|
||||
echo "<td>"._var($lbaheadings,'data'.$i)."</td>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</thead><tbody>' ;
|
||||
@@ -169,7 +170,7 @@ case "capabilities":
|
||||
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S\s+)\s+(?P<data3>\S+)\s+(?P<data4>\S\s+)\s+(?P<data5>\S+)$/',$line, $lbadetails);
|
||||
echo '<tr>' ;
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
echo "<td>".($lbadetails['data'.$i]??'')."</td>" ;
|
||||
echo "<td>"._var($lbadetails,'data'.$i)."</td>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr>' ;
|
||||
@@ -203,10 +204,10 @@ case "identify":
|
||||
$disk = $disks[$name]['id'];
|
||||
$info = &$extra[$disk];
|
||||
$periods = ['6','12','18','24','36','48','60'];
|
||||
echo "<tr><td>"._('Manufacturing date').":</td><td><input type='date' class='narrow' value='".($info['date']??'')."' onchange='disklog(\"$disk\",\"date\",this.value)'></td></tr>";
|
||||
echo "<tr><td>"._('Manufacturing date').":</td><td><input type='date' class='narrow' value='"._var($info,'date')."' onchange='disklog(\"$disk\",\"date\",this.value)'></td></tr>";
|
||||
echo "<tr><td>"._('Date of purchase').":</td><td><input type='date' class='narrow' value='".($info['purchase']??'')."' onchange='disklog(\"$disk\",\"purchase\",this.value)'></td></tr>";
|
||||
echo "<tr><td>"._('Warranty period').":</td><td><select class='noframe' onchange='disklog(\"$disk\",\"warranty\",this.value)'><option value=''>"._('unknown')."</option>";
|
||||
foreach ($periods as $period) echo "<option value='$period'".(($info['warranty']??'')==$period?" selected":"").">$period "._('months')."</option>";
|
||||
foreach ($periods as $period) echo "<option value='$period'".(_var($info,'warranty')==$period?" selected":"").">$period "._('months')."</option>";
|
||||
echo "</select></td></tr>";
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user