mirror of
https://github.com/unraid/webgui.git
synced 2026-04-24 02:58:57 -05:00
Replace array() notation with PHP preferred square brackets []
This commit is contained in:
@@ -23,33 +23,30 @@ function sort_by($field, $opt, $show_disk) {
|
||||
// read directory contents into 'list' array
|
||||
global $docroot,$dir;
|
||||
$path = $docroot.preg_replace('/([\'" &()[\]\\\\])/','\\\\$1',$dir).'/*';
|
||||
$file = array(); $list = array();
|
||||
$file = []; $list = [];
|
||||
$i = 0;
|
||||
exec("shopt -s dotglob ; stat -L -c'%F|%n|%s|%Y' $path 2>/dev/null", $file);
|
||||
foreach ($file as $entry) {
|
||||
$attr = explode('|', $entry);
|
||||
$info = pathinfo($attr[1]);
|
||||
$list[] = array(
|
||||
$list[] = [
|
||||
'type' => $attr[0],
|
||||
'name' => $info['basename'],
|
||||
'fext' => strtolower($info['extension']),
|
||||
'size' => $attr[2],
|
||||
'time' => $attr[3],
|
||||
'disk' => $show_disk?my_disk(exec("shopt -s dotglob ; getfattr --no-dereference --absolute-names --only-values -n system.LOCATIONS ".escapeshellarg($attr[1]))):'');
|
||||
'disk' => $show_disk?my_disk(exec("shopt -s dotglob ; getfattr --no-dereference --absolute-names --only-values -n system.LOCATIONS ".escapeshellarg($attr[1]))):''];
|
||||
}
|
||||
// sort by input 'field'
|
||||
if ($field=='name') {
|
||||
$type = array();
|
||||
$name = array();
|
||||
$type = []; $name = [];
|
||||
foreach ($list as $row) {
|
||||
$type[] = $row['type'];
|
||||
$name[] = strtolower($row['name']);
|
||||
}
|
||||
array_multisort($type,$opt, $name,$opt, $list);
|
||||
} else {
|
||||
$type = array();
|
||||
$indx = array();
|
||||
$name = array();
|
||||
$type = []; $indx = []; $name = [];
|
||||
foreach ($list as $row) {
|
||||
$type[] = $row['type'];
|
||||
$indx[] = $row[$field];
|
||||
|
||||
@@ -15,7 +15,7 @@ Type="xmenu"
|
||||
|
||||
<?
|
||||
if (count($pages)==2) $tabbed = false;
|
||||
$refs = array(); $n = 0;
|
||||
$refs = []; $n = 0;
|
||||
|
||||
foreach ($disks as $ref) {
|
||||
if ($ref['type']=='Flash') continue;
|
||||
|
||||
@@ -18,8 +18,8 @@ Cond="(($var['shareUser']!='-')&&(isset($disks['cache']))&&($disks['cache']['sta
|
||||
<?
|
||||
$cron = explode(' ',$var['shareMoverSchedule']);
|
||||
$move = $cron[2]!='*' ? 3 : ($cron[4]!='*' ? 2 : (substr($cron[1],0,1)!='*' ? 1 : 0));
|
||||
$mode = array('Hourly','Daily','Weekly','Monthly');
|
||||
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
|
||||
$mode = ['Hourly','Daily','Weekly','Monthly'];
|
||||
$days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
|
||||
?>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
@@ -16,9 +16,9 @@ Cond="($disks['parity']['status']!='DISK_NP_DSBL')"
|
||||
?>
|
||||
|
||||
<?
|
||||
$mode = array('Disabled','Daily','Weekly','Monthly','Yearly','Custom');
|
||||
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
|
||||
$months = array('January','February','March','April','May','June','July','August','September','October','November','December');
|
||||
$mode = ['Disabled','Daily','Weekly','Monthly','Yearly','Custom'];
|
||||
$days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
|
||||
$months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
||||
$memory = '/tmp/memory.tmp';
|
||||
if (file_exists($memory)) {
|
||||
parse_str(file_get_contents($memory), $parity);
|
||||
|
||||
@@ -14,7 +14,7 @@ Type="xmenu"
|
||||
?>
|
||||
<?if ($name):?>
|
||||
<?
|
||||
$refs = array(); $n = 0;
|
||||
$refs = []; $n = 0;
|
||||
|
||||
foreach ($shares as $ref) {
|
||||
$sname = $ref['name'];
|
||||
|
||||
@@ -17,16 +17,16 @@ Title="Share Settings"
|
||||
<?
|
||||
if ($name == "") {
|
||||
/* default values when adding new share */
|
||||
$share = array("nameOrig" => "",
|
||||
"name" => "",
|
||||
"comment" => "",
|
||||
"allocator" => "highwater",
|
||||
"floor" => "",
|
||||
"splitLevel" => "",
|
||||
"include" => "",
|
||||
"exclude" => "",
|
||||
"useCache" => "no",
|
||||
"cow" => "auto");
|
||||
$share = ["nameOrig" => "",
|
||||
"name" => "",
|
||||
"comment" => "",
|
||||
"allocator" => "highwater",
|
||||
"floor" => "",
|
||||
"splitLevel" => "",
|
||||
"include" => "",
|
||||
"exclude" => "",
|
||||
"useCache" => "no",
|
||||
"cow" => "auto"];
|
||||
} else if (array_key_exists($name, $shares)) {
|
||||
/* edit existing share */
|
||||
$share = $shares[$name];
|
||||
@@ -354,7 +354,7 @@ Enable Copy-on-write:
|
||||
: <input type="submit" name="cmdEditShare" value="Add Share"><input type="button" value="Done" onclick="done()">
|
||||
<?elseif (shareEmpty($name)):?>
|
||||
Share status:
|
||||
: <big>Share is empty</big>
|
||||
: <span class="big">Share is empty</span>
|
||||
|
||||
> Share does *not* contain any data and may be deleted if not needed any longer.
|
||||
|
||||
@@ -362,7 +362,7 @@ Delete<input type="checkbox" name="confirmDelete" onchange="chkDelete(this.form,
|
||||
: <input type="submit" name="cmdEditShare" value="Apply"><input type="button" value="Done" onclick="done()">
|
||||
<?else:?>
|
||||
Share status:
|
||||
: <big>Share contains data</big>
|
||||
: <span class="big">Share contains data</span>
|
||||
|
||||
> Share can *not* be deleted as long as it contains data. Be aware that some data can be hidden. See also [SMB Settings](/Settings/SMB) -> Hide "dot" files.
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once 'Wrappers.php';
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
// Helper functions
|
||||
function my_scale($value, &$unit, $decimals = NULL) {
|
||||
global $display;
|
||||
$scale = $display['scale'];
|
||||
$number = $display['number'];
|
||||
$units = array('B','KB','MB','GB','TB','PB');
|
||||
$units = ['B','KB','MB','GB','TB','PB'];
|
||||
if ($scale==0 && $decimals===NULL) {
|
||||
$decimals = 0;
|
||||
$unit = '';
|
||||
@@ -61,7 +62,7 @@ function my_id($id) {
|
||||
return ($display['wwn'] || substr($wwn,0,2)!='_3' || preg_match('/.[_-]/',$wwn)) ? $id : substr($id,0,$len-18);
|
||||
}
|
||||
function my_word($num) {
|
||||
$words = array('zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty');
|
||||
$words = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','twenty-one','twenty-two','twenty-three','twenty-four','twenty-five','twenty-six','twenty-seven','twenty-eight','twenty-nine','thirty'];
|
||||
return $num<count($words) ? $words[$num] : $num;
|
||||
}
|
||||
function my_usage() {
|
||||
@@ -78,7 +79,7 @@ function my_usage() {
|
||||
$used = $arraysize ? 100-round(100*$arrayfree/$arraysize) : 0;
|
||||
echo "<div class='usage-bar'><span style='width:{$used}%' class='".usage_color($display,$used,false)."'><span>{$used}%</span></span></div>";
|
||||
} else {
|
||||
echo "<div class='usage-bar'><span><center>".($var['fsState']=='Started'?'Maintenance':'off-line')."</center></span></div>";
|
||||
echo "<div class='usage-bar'><span style='text-align:center'>".($var['fsState']=='Started'?'Maintenance':'off-line')."</span></div>";
|
||||
}
|
||||
}
|
||||
function usage_color(&$disk,$limit,$free) {
|
||||
@@ -226,8 +227,9 @@ function is_block($path) {
|
||||
}
|
||||
function autov($file) {
|
||||
global $docroot;
|
||||
clearstatcache(true, $docroot.$file);
|
||||
echo "$file?v=".filemtime($docroot.$file);
|
||||
$path = $docroot.$file;
|
||||
clearstatcache(true, $path);
|
||||
echo "$file?v=".filemtime($path);
|
||||
}
|
||||
function transpose_user_path($path) {
|
||||
if (strpos($path, '/mnt/user/') === 0 && file_exists($path)) {
|
||||
|
||||
@@ -11,15 +11,19 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once 'Wrappers.php';
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$dynamix = parse_plugin_cfg('dynamix',true);
|
||||
$filter = $_GET['filter'];
|
||||
$files = glob("{$dynamix['notify']['path']}/archive/*.notify", GLOB_NOSORT);
|
||||
usort($files, create_function('$a,$b', 'return filemtime($b)-filemtime($a);'));
|
||||
|
||||
$row = 1;
|
||||
$row = 1; $empty = true;
|
||||
foreach ($files as $file) {
|
||||
$fields = explode(PHP_EOL, file_get_contents($file));
|
||||
if ($filter && $filter != substr($fields[4],11)) continue;
|
||||
$empty = false;
|
||||
$archive = basename($file);
|
||||
if ($extra = count($fields)>6) {
|
||||
$td_ = "<td rowspan='3'><a href='#' onclick='openClose($row)'>"; $_td = "</a></td>";
|
||||
@@ -29,7 +33,7 @@ foreach ($files as $file) {
|
||||
$c = 0;
|
||||
foreach ($fields as $field) {
|
||||
if ($c==5) break;
|
||||
$item = $field ? explode('=', $field, 2) : array("","-");
|
||||
$item = $field ? explode('=', $field, 2) : ["","-"];
|
||||
echo (!$c++) ? "<tr>$td_".date("{$dynamix['notify']['date']} {$dynamix['notify']['time']}", $item[1])."$_td" : "<td>{$item[1]}</td>";
|
||||
}
|
||||
echo "<td style='text-align:right'><a href='#' onclick='$.post(\"/webGui/include/DeleteLogFile.php\",{log:\"$archive\"},function(){archiveList();});return false' title='Delete notification'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
@@ -39,5 +43,5 @@ foreach ($files as $file) {
|
||||
$row++;
|
||||
}
|
||||
}
|
||||
if (empty($files)) echo "<tr><td colspan='6' style='text-align:center'><em>No notifications available</em></td></tr>";
|
||||
if ($empty) echo "<tr><td colspan='6' style='text-align:center;padding-top:12px'><em>No notifications present</em></td></tr>";
|
||||
?>
|
||||
|
||||
@@ -54,11 +54,11 @@ echo exec("dmidecode -q -t 2|awk -F: '/^\tManufacturer:/{m=$2;}; /^\tProduct Nam
|
||||
<div><span class="key">CPU:</span>
|
||||
<?
|
||||
function write($number) {
|
||||
$words = array('zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty');
|
||||
$words = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','twenty-one','twenty-two','twenty-three','twenty-four','twenty-five','twenty-six','twenty-seven','twenty-eight','twenty-nine','thirty'];
|
||||
return $number<=count($words) ? $words[$number] : $number;
|
||||
}
|
||||
$cpu = explode('#',exec("dmidecode -q -t 4|awk -F: '/^\tVersion:/{v=$2;}; /^\tCurrent Speed:/{s=$2;} END{print v\"#\"s}'"));
|
||||
$cpumodel = str_ireplace(array("Processor","(C)","(R)","(TM)"),array("","©","®","™"),$cpu[0]);
|
||||
$cpumodel = str_ireplace(["Processor","(C)","(R)","(TM)"],["","©","®","™"],$cpu[0]);
|
||||
if (strpos($cpumodel,'@')===false) {
|
||||
$cpuspeed = explode(' ',$cpu[1]);
|
||||
if ($cpuspeed[0]>=1000 && $cpuspeed[1]=='MHz') {
|
||||
@@ -122,7 +122,7 @@ if (strpos($cpumodel,'@')===false) {
|
||||
$cache = explode('#',exec("dmidecode -q -t 7|awk -F: '/^\tSocket Designation:/{c=c$2\";\";}; /^\tInstalled Size:/{s=s$2\";\";} END{print c\"#\"s}'"));
|
||||
$socket = array_map('trim',explode(';',$cache[0]));
|
||||
$volume = array_map('trim',explode(';',$cache[1]));
|
||||
$name = array();
|
||||
$name = [];
|
||||
$size = "";
|
||||
for ($i=0; $i<count($socket); $i++) {
|
||||
if ($volume[$i] && $volume[$i]!='0 kB' && !in_array($socket[$i],$name)) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// write syslinux file
|
||||
write_log("Saving file $file");
|
||||
exec("mkdir -p ".dirname($file));
|
||||
file_put_contents($file, str_replace(array("\r\n","\r"), "\n", $_POST['text']));
|
||||
file_put_contents($file, str_replace(["\r\n","\r"], "\n", $_POST['text']));
|
||||
// discard settings
|
||||
$save = false;
|
||||
?>
|
||||
Reference in New Issue
Block a user