From b7aed12d4f00cc8c91a7ee03b487ef687a52c57d Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 24 Oct 2016 09:26:24 +0200 Subject: [PATCH 01/23] Replace deprecated HTML5 tags
--- plugins/dynamix/CacheSettings.page | 2 +- plugins/dynamix/DashStats.page | 22 +++++---- plugins/dynamix/DeviceAttributes.page | 2 +- plugins/dynamix/DeviceCapabilities.page | 2 +- plugins/dynamix/Identification.page | 2 +- plugins/dynamix/NetworkRules.page | 2 +- plugins/dynamix/NewConfig.page | 2 +- plugins/dynamix/NewPerms.page | 2 +- plugins/dynamix/Registration.page | 59 ++++++++++++----------- plugins/dynamix/SMBsettings.page | 2 +- plugins/dynamix/SecurityAFP.page | 2 +- plugins/dynamix/SecurityNFS.page | 2 +- plugins/dynamix/SecuritySMB.page | 2 +- plugins/dynamix/ShareSettings.page | 2 +- plugins/dynamix/Shares.page | 2 +- plugins/dynamix/include/ParityHistory.php | 4 +- plugins/dynamix/include/ShareList.php | 9 ++-- plugins/dynamix/include/SmartInfo.php | 26 +++++----- plugins/dynamix/include/Watchdog.php | 8 +-- 19 files changed, 81 insertions(+), 73 deletions(-) diff --git a/plugins/dynamix/CacheSettings.page b/plugins/dynamix/CacheSettings.page index ff72b955d..02ac1d654 100644 --- a/plugins/dynamix/CacheSettings.page +++ b/plugins/dynamix/CacheSettings.page @@ -60,5 +60,5 @@ Min. free space: > **2000000** => 2,048,000,000 bytes   -: >Array must be **Stopped** to change +: >Array must be Stopped to change diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index d8550c636..f1fcc8962 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -112,9 +112,6 @@ function active_disks($disk) { $disks = array_filter($disks,'active_disks'); $slots = count($disks) + count($devs); ?> - - - Array Status".implode('',$row0); - + @@ -355,7 +352,7 @@ foreach ($shares as $name => $share): $security = export_settings($var['shareSMBEnabled'], $sec[$name]); echo ""; endforeach; -if (!count($shares)) echo ""; +if (!count($shares)) echo ""; ?> @@ -368,7 +365,7 @@ foreach ($shares as $name => $share): $security = export_settings($var['shareAFPEnabled'], $sec_afp[$name]); echo ""; endforeach; -if (!count($shares)) echo ""; +if (!count($shares)) echo ""; ?> @@ -381,7 +378,7 @@ foreach ($shares as $name => $share): $security = export_settings($var['shareNFSEnabled'], $sec_nfs[$name]); echo ""; endforeach; -if (!count($shares)) echo ""; +if (!count($shares)) echo ""; ?> @@ -393,7 +390,7 @@ foreach ($shares as $name => $share): $comment = truncate($share['comment'],28); echo ""; endforeach; -if (!count($shares)) echo ""; +if (!count($shares)) echo ""; ?> @@ -459,15 +456,20 @@ function update30() { clearTimeout(timer2); timer2 = setTimeout(heatAlarm,2000); $('[id^="smart-"]').each(function() { - var opts = []; + var opts = [{header:$(this).attr('id'), image:'/webGui/icons/smart.png'}]; var id = '#'+$(this).attr('id'); var page = $(this).attr('name'); var view = $(this).attr('class'); var disk = id.substr(id.indexOf('-')+1); opts.push({text:'Attributes',icon:'fa-sitemap',action:function(e){e.preventDefault();attributes(page,disk);}}); + opts.push({divider:true}); opts.push({text:'Capabilities',icon:'fa-user',action:function(e){e.preventDefault();capabilities(page,disk);}}); + opts.push({divider:true}); opts.push({text:'Identity',icon:'fa-home',action:function(e){e.preventDefault();identity(page,disk);}}); - if (view == 'alert') opts.push({text:'Acknowledge',icon:'fa-check-square-o',action:function(e){e.preventDefault();acknowledge(disk);}}); + if (view == 'alert') { + opts.push({divider:true}); + opts.push({text:'Acknowledge',icon:'fa-check-square-o',action:function(e){e.preventDefault();acknowledge(disk);}}); + } context.attach(id,opts); }); timer30 = setTimeout(update30,30000); diff --git a/plugins/dynamix/DeviceAttributes.page b/plugins/dynamix/DeviceAttributes.page index b8dc1bc78..7e53139f6 100644 --- a/plugins/dynamix/DeviceAttributes.page +++ b/plugins/dynamix/DeviceAttributes.page @@ -23,7 +23,7 @@ $(function() { - + diff --git a/plugins/dynamix/DeviceCapabilities.page b/plugins/dynamix/DeviceCapabilities.page index 97ce20e09..13f26f336 100644 --- a/plugins/dynamix/DeviceCapabilities.page +++ b/plugins/dynamix/DeviceCapabilities.page @@ -23,7 +23,7 @@ $(function() { - + diff --git a/plugins/dynamix/Identification.page b/plugins/dynamix/Identification.page index e511468dc..2cddd837d 100644 --- a/plugins/dynamix/Identification.page +++ b/plugins/dynamix/Identification.page @@ -41,7 +41,7 @@ Model: > This is the server model number.   -: >Array must be **Stopped** to change +: >Array must be Stopped to change - - + diff --git a/plugins/dynamix/DeviceInfo.page b/plugins/dynamix/DeviceInfo.page index 336c81195..d93d1d1bb 100644 --- a/plugins/dynamix/DeviceInfo.page +++ b/plugins/dynamix/DeviceInfo.page @@ -81,7 +81,7 @@ $(function() {
Name: -: +: Partition size: : KB (K=1024) @@ -123,7 +123,7 @@ File system type: - Array must be **Stopped** to change + Array must be Stopped to change 1):?> @@ -209,7 +209,7 @@ btrfs filesystem df: 1):?> - +
Balance Status
@@ -253,7 +253,7 @@ btrfs balance status: - +
Scrub Status
@@ -297,7 +297,7 @@ btrfs scrub status: - +
Check Filesystem Status
@@ -349,7 +349,7 @@ reiserfsck status: - +
Check Filesystem Status
diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index ec7f56c60..480664114 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -16,7 +16,7 @@ Png="ethernet.png" ?>   -: STOPPED to change" : ""?> +: Stopped to change" : ""?>
diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index 0c257f36c..af091294e 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -263,5 +263,5 @@ Network mask:   -: STOPPED to change"?> +: Stopped to change"?> diff --git a/plugins/dynamix/SmtpSettings.page b/plugins/dynamix/SmtpSettings.page index 04b63ee87..65cccdaaa 100644 --- a/plugins/dynamix/SmtpSettings.page +++ b/plugins/dynamix/SmtpSettings.page @@ -14,7 +14,7 @@ Title="SMTP Settings" */ ?> "); " : "
";
 $logs = glob('/var/log/syslog*',GLOB_NOSORT);
diff --git a/plugins/dynamix/include/DeleteLogFile.php b/plugins/dynamix/include/DeleteLogFile.php
index 26fc109db..9fdbd97f8 100644
--- a/plugins/dynamix/include/DeleteLogFile.php
+++ b/plugins/dynamix/include/DeleteLogFile.php
@@ -11,7 +11,8 @@
  */
 ?>
 
 0, 'temp'=>0, 'fsSize'=>0, 'fsUsed'=>0, 'fsFree'=>0, 'numReads'=>0, 'numWrites'=>0, 'numErrors'=>0];
+$new   = '/var/tmp/diskio';
+$old   = '/var/tmp/lastio';
 extract(parse_plugin_cfg('dynamix',true));
 
-require_once 'CustomMerge.php';
+require_once "$docroot/webGui/include/CustomMerge.php";
 
 function in_parity_log($log,$timestamp) {
   if (file_exists($log)) {
@@ -77,7 +80,7 @@ function assignment(&$disk) {
   $out .= "";
   return $out;
 }
+$time = time();
+$last = @parse_ini_file($new);
+if ($_POST['diskio'] && $time-$last['time']>8) {
+  @copy($new, $old);
+  $lastio = $last;
+  exec("grep -o '\(sd[a-z]*\|nvme[0-9]n1\) .*' /proc/diskstats",$diskio);
+  disk_map($diskio);
+  $diskio['time'] = $time;
+  $keys = [];
+  foreach ($diskio as $key => $data) $keys[] = "$key=$data";
+  file_put_contents($new, implode("\n",$keys));
+} else {
+  $lastio = @parse_ini_file($old);
+  $diskio = $last;
+}
 switch ($_POST['device']) {
 case 'array':
   if ($var['fsState']=='Stopped') {
@@ -284,8 +326,8 @@ case 'flash':
   echo "".device_info($disk)."";
   echo "".device_desc($disk)."";
   echo "*";
-  echo "".my_number($disk['numReads'])."";
-  echo "".my_number($disk['numWrites'])."";
+  echo "".my_diskio($disk['device'],0)."".my_number($disk['numReads'])."";
+  echo "".my_diskio($disk['device'],1)."".my_number($disk['numWrites'])."";
   echo "".my_number($disk['numErrors'])."";
   fs_info($disk);
   echo "";
@@ -309,22 +351,24 @@ case 'open':
     echo "".device_info($dev)."";
     echo "".device_desc($dev)."";
     echo "".my_temp($dev['temp'])."";
+    echo "".my_diskio($dev['device'],0)."-";
+    echo "".my_diskio($dev['device'],1)."-";
     if (file_exists("/tmp/preclear_stat_{$dev['device']}")) {
       $text = exec("cut -d'|' -f3 /tmp/preclear_stat_{$dev['device']}|sed 's:\^n:\:g'");
       if (strpos($text,'Total time')===false) $text = 'Preclear in progress... '.$text;
-      echo "$text";
+      echo "$text";
     } else
-      echo "";
+      echo "";
     echo "";
   }
   break;
 case 'parity':
-  $data = array();
+  $data = [];
   if ($var['mdResync']>0) {
     $data[] = my_scale($var['mdResync']*1024,$unit)." $unit";
     $data[] = my_clock(floor(($var['currTime']-$var['sbUpdated'])/60));
     $data[] = my_scale($var['mdResyncPos']*1024,$unit)." $unit (".number_format(($var['mdResyncPos']/($var['mdResync']/100+1)),1,substr($display['number'],0,1),'')." %)";
-    $data[] = my_scale($var['mdResyncDb']/$var['mdResyncDt']*1024,$unit, 1)." $unit/sec";
+    $data[] = my_scale($var['mdResyncDb']*1024/$var['mdResyncDt'],$unit, 1)." $unit/sec";
     $data[] = my_clock(round(((($var['mdResyncDt']*(($var['mdResync']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0));
     $data[] = $var['sbSyncErrs'];
     echo implode(';',$data);
diff --git a/plugins/dynamix/include/DiskList.php b/plugins/dynamix/include/DiskList.php
index 684ecf67d..feaf4c5de 100644
--- a/plugins/dynamix/include/DiskList.php
+++ b/plugins/dynamix/include/DiskList.php
@@ -11,7 +11,8 @@
  */
 ?>
 
 
 

Thank You!

'+data.message+'

'; + var success_message = '

Thank You!

'+data.message+'

'; $('#thanks_panel').html(success_message).fadeIn('fast', function() { var resetfunction = window[url_parts[4]+'_reset']; diff --git a/plugins/dynamix/include/InstallKey.php b/plugins/dynamix/include/InstallKey.php index 2343abed7..a49d6bd06 100644 --- a/plugins/dynamix/include/InstallKey.php +++ b/plugins/dynamix/include/InstallKey.php @@ -10,9 +10,11 @@ */ ?> addLog('$line');"; } -readfile("/usr/local/emhttp/logging.htm"); +readfile("$docroot/logging.htm"); $var = parse_ini_file('state/var.ini'); $parsed_url = parse_url($_GET['url']); diff --git a/plugins/dynamix/include/Notify.php b/plugins/dynamix/include/Notify.php index 908c8b640..9527bb958 100644 --- a/plugins/dynamix/include/Notify.php +++ b/plugins/dynamix/include/Notify.php @@ -12,7 +12,9 @@ */ ?> diff --git a/plugins/dynamix/include/PageBuilder.php b/plugins/dynamix/include/PageBuilder.php index afc746235..056062f69 100644 --- a/plugins/dynamix/include/PageBuilder.php +++ b/plugins/dynamix/include/PageBuilder.php @@ -11,7 +11,7 @@ */ ?> /dev/null & echo $!',$op); $pid = (int)$op[0]; @@ -31,7 +33,7 @@ function PsEnded($pid) { function PsKill($pid) { exec("kill -9 $pid"); } -if (PsExecute("/usr/local/emhttp/webGui/scripts/notify -s 'unRAID SMTP Test' -d 'Test message received!' -i 'alert' -t")) { +if (PsExecute("$docroot/webGui/scripts/notify -s 'unRAID SMTP Test' -d 'Test message received!' -i 'alert' -t")) { $result = exec("tail -3 /var/log/syslog|awk '/sSMTP/ {getline;print}'|cut -d']' -f2|cut -d'(' -f1"); $color = strpos($result, 'Sent mail') ? 'green' : 'red'; echo "Test result$result"; diff --git a/plugins/dynamix/include/Wrappers.php b/plugins/dynamix/include/Wrappers.php index 9680fb3d0..980bc8380 100644 --- a/plugins/dynamix/include/Wrappers.php +++ b/plugins/dynamix/include/Wrappers.php @@ -11,11 +11,14 @@ */ ?> diff --git a/plugins/dynamix/scripts/disk_log b/plugins/dynamix/scripts/disk_log index d9336b7a7..d675f3974 100755 --- a/plugins/dynamix/scripts/disk_log +++ b/plugins/dynamix/scripts/disk_log @@ -14,7 +14,8 @@ ErrorWarningSystemArray

\n"; -require_once '/usr/local/emhttp/webGui/include/ColorCoding.php'; +$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; +require_once "$docroot/webGui/include/ColorCoding.php"; $ata = exec("ls -n /sys/block/{$argv[1]}|grep -Po 'ata\d+'"); $dev = $ata ? "${argv[1]}|${ata}[.:]" : $argv[1]; diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index 667b718a3..8ae2ca3be 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -18,11 +18,12 @@ $disks = parse_ini_file("/var/local/emhttp/disks.ini",true); $var = parse_ini_file("/var/local/emhttp/var.ini"); $devs = parse_ini_file("/var/local/emhttp/devs.ini",true); -require_once '/usr/local/emhttp/webGui/include/Wrappers.php'; -require_once '/usr/local/emhttp/webGui/include/Preselect.php'; -require_once '/usr/local/emhttp/webGui/include/CustomMerge.php'; +$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; +require_once "$docroot/webGui/include/Wrappers.php"; +require_once "$docroot/webGui/include/Preselect.php"; +require_once "$docroot/webGui/include/CustomMerge.php"; -$notify = "/usr/local/emhttp/webGui/scripts/notify"; +$notify = "$docroot/webGui/scripts/notify"; $ram = "/var/local/emhttp/monitor.ini"; $rom = "/boot/config/plugins/dynamix/monitor.ini"; $saved = @parse_ini_file($ram,true); diff --git a/plugins/dynamix/scripts/notify b/plugins/dynamix/scripts/notify index 679c8ffbe..9c3507412 100755 --- a/plugins/dynamix/scripts/notify +++ b/plugins/dynamix/scripts/notify @@ -13,8 +13,9 @@ */ ?> /dev/null\n\n"; + $text = empty($notify['status']) ? "" : "# Generated array status check schedule:\n{$notify['status']} $docroot/plugins/dynamix/scripts/statuscheck &> /dev/null\n\n"; parse_cron_cfg("dynamix", "status-check", $text); - $text = empty($notify['version']) ? "" : "# Generated plugins version check schedule:\n{$notify['version']} /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null\n\n"; + $text = empty($notify['version']) ? "" : "# Generated plugins version check schedule:\n{$notify['version']} $docroot/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null\n\n"; parse_cron_cfg("dynamix", "plugin-check", $text); - $text = empty($notify['system']) ? "" : "# Generated system monitoring schedule:\n{$notify['system']} /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null\n\n"; + $text = empty($notify['system']) ? "" : "# Generated system monitoring schedule:\n{$notify['system']} $docroot/plugins/dynamix/scripts/monitor &> /dev/null\n\n"; parse_cron_cfg("dynamix", "monitor", $text); - $text = empty($notify['docker_update']) ? "" : "# Generated docker monitoring schedule:\n{$notify['docker_update']} /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate.php check &> /dev/null\n\n"; + $text = empty($notify['docker_update']) ? "" : "# Generated docker monitoring schedule:\n{$notify['docker_update']} $docroot/plugins/dynamix.docker.manager/scripts/dockerupdate.php check &> /dev/null\n\n"; parse_cron_cfg("dynamix", "docker-update", $text); break; @@ -206,9 +207,9 @@ case 'get': $time = true; foreach ($fields as $field) { if (!$field) continue; - $item = explode('=', $field); - if ($time) {$item[1] = date("{$notify['date']} {$notify['time']}", $item[1]); $time = false;} - $output[$i][] = '\"'.trim($item[0]).'\":\"'.trim($item[1]).'\"'; + list($key,$val) = explode('=', $field); + if ($time) {$val = date($notify['date'].' '.$notify['time'], $val); $time = false;} + $output[$i][] = '\"'.trim($key).'\":\"'.trim($val).'\"'; } $output[$i++][] = '\"file\":\"'.basename($file).'\"'; chmod($file,0000); diff --git a/plugins/dynamix/scripts/statuscheck b/plugins/dynamix/scripts/statuscheck index 5cbf0e924..ccc6401c6 100755 --- a/plugins/dynamix/scripts/statuscheck +++ b/plugins/dynamix/scripts/statuscheck @@ -12,10 +12,11 @@ */ ?> =10000 ? $number[1] : '')); @@ -116,7 +117,7 @@ function my_array(&$disk) { if ($fail) $fail .= ')'; $status = $fail ? ' [NOK]' : ' [OK]'; $color = strtok($disk['color'],'-'); - if ($color=='red'||$color=='yellow') { $error3++; $status = ' ['.str_replace(array('NP_','_'),array('',' '),$disk['status']).']'; } + if ($color=='red'||$color=='yellow') { $error3++; $status = ' ['.str_replace(['NP_','_'],['',' '],$disk['status']).']'; } $info = "{$disk['id']} ({$disk['device']})"; if ($info==" ()") $info = 'No device identification present'; $data[] = my_disk($name)." - $info".my_temp($temp).$fail.$status; diff --git a/plugins/dynamix/scripts/tail_log b/plugins/dynamix/scripts/tail_log index d81bd39d9..b34f37a99 100755 --- a/plugins/dynamix/scripts/tail_log +++ b/plugins/dynamix/scripts/tail_log @@ -14,7 +14,8 @@ ErrorWarningSystemArray

\n"; -require_once '/usr/local/emhttp/webGui/include/ColorCoding.php'; +$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; +require_once "$docroot/webGui/include/ColorCoding.php"; $handle = popen('/usr/bin/tail -n 40 -f '.escapeshellarg("/var/log/{$argv[1]}").' 2>&1', 'r'); while (!feof($handle)) { diff --git a/plugins/dynamix/template.php b/plugins/dynamix/template.php index 9f0361f45..cee1fb26a 100644 --- a/plugins/dynamix/template.php +++ b/plugins/dynamix/template.php @@ -11,23 +11,23 @@ */ ?> page path, e.g., path=Main/Disk -// prev= prev path, e.g., prev=Main (used to deterine if page was refreshed) +// prev= prev path, e.g., prev=Main (used to determine if page was refreshed) extract($_GET); -// Define some paths -$docroot = $_SERVER['DOCUMENT_ROOT']; - // The current "task" is the first element of the path $task = strtok($path, '/'); // Get the webGui configuration preferences -extract(parse_plugin_cfg("dynamix",true)); +extract(parse_plugin_cfg('dynamix',true)); // Read emhttp status $var = parse_ini_file('state/var.ini'); @@ -43,7 +43,7 @@ $sec_afp = parse_ini_file('state/sec_afp.ini',true); extract(parse_ini_file('state/network.ini',true)); // Merge SMART settings -require_once 'include/CustomMerge.php'; +require_once "$docroot/webGui/include/CustomMerge.php"; // Build webGui pages first, then plugins pages $site = []; @@ -54,9 +54,9 @@ foreach (glob('plugins/*', GLOB_ONLYDIR) as $plugin) { // Here's the page we're rendering $myPage = $site[basename($path)]; -$pageroot = "{$docroot}/".dirname($myPage['file']); +$pageroot = $docroot.'/'.dirname($myPage['file']); $update = $display['refresh']>0 || ($display['refresh']<0 && $var['mdResync']==0); // Giddyup -require_once 'include/DefaultPageLayout.php'; +require_once "$docroot/webGui/include/DefaultPageLayout.php"; ?> From e784f23b636a7a3202d3e7b6eda3263f041e7aad Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 24 Oct 2016 09:33:11 +0200 Subject: [PATCH 03/23] Replace array() notation with PHP preferred square brackets [] --- plugins/dynamix/Browse.page | 13 ++++------ plugins/dynamix/Disk.page | 2 +- plugins/dynamix/MoverSettings.page | 4 ++-- plugins/dynamix/ParityCheck.page | 6 ++--- plugins/dynamix/Share.page | 2 +- plugins/dynamix/ShareEdit.page | 24 +++++++++---------- plugins/dynamix/include/Helpers.php | 14 ++++++----- .../dynamix/include/NotificationsArchive.php | 12 ++++++---- plugins/dynamix/include/SystemInformation.php | 6 ++--- plugins/dynamix/include/update.file.php | 2 +- 10 files changed, 44 insertions(+), 41 deletions(-) diff --git a/plugins/dynamix/Browse.page b/plugins/dynamix/Browse.page index 84502fef0..6822e492b 100644 --- a/plugins/dynamix/Browse.page +++ b/plugins/dynamix/Browse.page @@ -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]; diff --git a/plugins/dynamix/Disk.page b/plugins/dynamix/Disk.page index 0c957a10e..8fc8b8e65 100644 --- a/plugins/dynamix/Disk.page +++ b/plugins/dynamix/Disk.page @@ -15,7 +15,7 @@ Type="xmenu"
@@ -127,14 +149,14 @@ $('.tabs').append(" - Started + Started disabled> Stop will take the array off-line.$parity":($mover?"
$mover":"")?> 0):?> Unmountable disk present:
-".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> +".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> Format will create a file system in all Unmountable disks, discarding all data currently on those disks.
Yes I want to do this @@ -211,26 +233,26 @@ $('.tabs').append(" Read-Check in progress. - + Cancel will stop the Read-Check. Parity-Check in progress. - + Cancel will stop the Parity-Check. Parity-Sync/Data-Rebuild in progress. - + Cancel will stop Parity-Sync/Data-Rebuild.
WARNING: canceling may leave the array unprotected! Clearing in progress. - + Cancel will stop Clearing. @@ -270,35 +292,35 @@ $('.tabs').append("% complete... + Copying, % complete... - Clearing, % complete... + Clearing, % complete... - Stopping... + Stopping... @@ -306,25 +328,25 @@ $('.tabs').append(" - Stopped. + Stopped. Invalid, missing or expired registration key. - Stopped. + Stopped. Too many attached devices. Please consider upgrading your registration key. - Stopped. + Stopped. Cannot contact key-server. Please check your network settings. - Stopped. + Stopped. This unRAID Server OS release has been withdrawn and may no longer be used. Please update your server. @@ -333,26 +355,26 @@ $('.tabs').append(" - Stopped. Configuration valid. + Stopped. Configuration valid. Start will bring the array on-line and start Parity-Sync and/or Data-Rebuild. - Stopped. New data disks(s) detected. + Stopped. New data disks(s) detected. Start will bring the array on-line and start Clearing new data disk(s). - Stopped. Unclean shutdown detected. + Stopped. Unclean shutdown detected. Start will bring the array on-line and start Parity-Check.
Write corrections to parity - Stopped. Configuration valid. + Stopped. Configuration valid. Start will bring the array on-line. @@ -362,14 +384,14 @@ $('.tabs').append(" - Stopped. Configuration valid. + Stopped. Configuration valid. Start will record all disk information and bring the array on-line.
The array will be immediately available, but unprotected since parity has not been assigned. - Stopped. Configuration valid. + Stopped. Configuration valid. Start will record all disk information, bring the array on-line, and start Parity-Sync.
The array will be immediately available, but unprotected until Parity-Sync completes. @@ -380,8 +402,8 @@ $('.tabs').append(" new disk.
-".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> + Stopped. Found new disk.
+".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> Start will record the new disk information and bring the expanded array on-line. @@ -390,8 +412,8 @@ $('.tabs').append(" - Stopped. Found new erased disk.
-".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> + Stopped. Found new erased disk.
+".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> Start will record the new disk information and bring the expanded array on-line.
Yes I want to do this @@ -399,8 +421,8 @@ $('.tabs').append(" new disk.
-".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> + Stopped. Found new disk.
+".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> Clear will completely clear (set to zero) the new disk.
Once clear completes, the array may be Started, expanding the array to include the new disk. @@ -412,7 +434,7 @@ $('.tabs').append(" - Stopped. Ugrading disk/swapping parity. + Stopped. Ugrading disk/swapping parity. Start will expand the file system of the data disk (if possible); then bring the array on-line and start Data-Rebuild.
Yes I want to do this @@ -440,7 +462,7 @@ $('.tabs').append("".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> + Stopped. Two or more disks are wrong.
+".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")";?> Start will just record the new disk positions and bring the array on-line.
We recommend you start a Parity-Check afterwards just to be safe. @@ -461,21 +483,21 @@ $('.tabs').append(" - + + + + Used / Free columns: diff --git a/plugins/dynamix/UserList.page b/plugins/dynamix/UserList.page index 4f9b6f16c..79f0fb5f3 100644 --- a/plugins/dynamix/UserList.page +++ b/plugins/dynamix/UserList.page @@ -19,7 +19,7 @@ if ($submenu) $path = './Users'; ?> -

+

diff --git a/plugins/dynamix/include/DashUpdate.php b/plugins/dynamix/include/DashUpdate.php index 0a7d91eff..e7a3e01ac 100644 --- a/plugins/dynamix/include/DashUpdate.php +++ b/plugins/dynamix/include/DashUpdate.php @@ -11,6 +11,8 @@ */ ?> 7{print $1,$2,$4,$6,$9,$10}' $file 2>/dev/null", $codes); @@ -37,11 +40,13 @@ function my_smart(&$source,$name,$page) { list($id,$class,$value,$thres,$when,$raw) = explode(' ',$code); $fail = strpos($when,'FAILING_NOW')!==false; if (!$fail && !in_array($id,$events)) continue; - if ($fail || ($select ? $thres>0 && $value<=$thres*$level : $raw>0)) {$thumb = 'alert'; break;}; + if ($fail || ($select ? $thres>0 && $value<=$thres*$level : $raw>0)) $title .= normalize($class,$fail?$when:$raw); } + if ($title) $thumb = 'alert'; else $title = "No errors reported\n"; } } - my_insert($source, ""); + $title .= "Click for context menu"; + my_insert($source, ""); } function my_usage(&$source,$used) { my_insert($source, $used ? "
$used
" : "-"); @@ -71,8 +76,8 @@ case 'disk': $disks = @array_filter(parse_ini_file('state/disks.ini',true),'active_disks'); $devs = @parse_ini_file('state/devs.ini',true); $saved = @parse_ini_file('state/monitor.ini',true); - require_once 'CustomMerge.php'; - require_once 'Preselect.php'; + require_once "$docroot/webGui/include/CustomMerge.php"; + require_once "$docroot/webGui/include/Preselect.php"; $slots = $_POST['slots']; $row1 = array_fill(0,31,''); my_insert($row1[0],'Active'); $row2 = array_fill(0,31,''); my_insert($row2[0],'Inactive'); @@ -103,8 +108,11 @@ case 'disk': $temp = $disk['temp']; $hot = strlen($disk['hotTemp']) ? $disk['hotTemp'] : $_POST['hot']; $max = strlen($disk['maxTemp']) ? $disk['maxTemp'] : $_POST['max']; - $beep = $temp>=$max && $max>0 ? 'max' : ($temp>=$hot && $hot>0 ? 'hot' : ''); - if ($beep) my_insert($row5[$n],""); + $heat = $temp>=$max && $max>0 ? 'max' : ($temp>=$hot && $hot>0 ? 'hot' : ''); + if ($heat) + my_insert($row5[$n],""); + else + if (!strpos($state,'blink') && $temp>0) my_insert($row5[$n],"".my_temp($temp,$_POST['unit']).""); if ($disk['device'] && !strpos($state,'blink')) my_smart($row6[$n],$disk['name'],'Device'); my_usage($row7[$n],($disk['type']!='Parity' && $disk['fsStatus']=='Mounted')?(round((1-$disk['fsFree']/$disk['fsSize'])*100).'%'):''); } diff --git a/plugins/dynamix/include/DefaultPageLayout.php b/plugins/dynamix/include/DefaultPageLayout.php index e7e69e3ed..cfc37cc29 100644 --- a/plugins/dynamix/include/DefaultPageLayout.php +++ b/plugins/dynamix/include/DefaultPageLayout.php @@ -20,7 +20,8 @@ - + + "> "> @@ -157,27 +158,77 @@ function showNotice(data,plugin) { if (timers.countDown) {clearTimeout(timers.countDown);$('#countdown').html('');} } function notifier() { - $.post('/webGui/include/Notify.php',{cmd:'get'},function(data) { - if (data) { - var json = $.parseJSON(data); - $.each(json, function(i, object) { - var notify = $.parseJSON(object); - $.jGrowl(notify.subject+'
'+notify.description, { - sticky: true, - position: '', - header: notify.event+': '+notify.timestamp, - theme: notify.importance+' '+notify.file, - themeState: '', - beforeOpen: function(e,m,o) {if ($('.jGrowl-notify').hasClass(notify.file)) {return(false);}}, - close: function(e,m,o) {$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file}); return(false);} - }); + var tub1 = 0, tub2 = 0, tub3 = 0; + $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { + var data = $.parseJSON(json); + $.each(data, function(i, object) { + var notify = $.parseJSON(object); + + switch (notify.importance) { + case 'alert' : tub1++; break; + case 'warning': tub2++; break; + case 'normal' : tub3++; break; + } + + $.jGrowl(notify.subject+'
'+notify.description, { + group: notify.importance, + header: notify.event+': '+notify.timestamp, + theme: notify.file, + beforeOpen: function(e,m,o){if ($('div.jGrowl-notify').hasClass(notify.file)) return(false);}, + beforeClose: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file});} }); - - timers.notifier = setTimeout(notifier,); - } + }); + + $('#txt-tub1').removeClass('one two three').addClass(digits(tub1)).text(tub1); + $('#txt-tub2').removeClass('one two three').addClass(digits(tub2)).text(tub2); + $('#txt-tub3').removeClass('one two three').addClass(digits(tub3)).text(tub3); + if (tub1) $('#box-tub1').removeClass('grey-text').addClass('red-text'); else $('#box-tub1').removeClass('red-text').addClass('grey-text'); + if (tub2) $('#box-tub2').removeClass('grey-text').addClass('orange-text'); else $('#box-tub2').removeClass('orange-text').addClass('grey-text'); + if (tub3) $('#box-tub3').removeClass('grey-text').addClass('green-text'); else $('#box-tub3').removeClass('green-text').addClass('grey-text'); + + + timers.notifier = setTimeout(notifier,5000); + }); } +function digits(number) { + if (number < 10) return 'one'; + if (number < 100) return 'two'; + return 'three'; +} +function openNotifier(filter) { + $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { + var data = $.parseJSON(json); + $.each(data, function(i, object) { + var notify = $.parseJSON(object); + if (notify.importance == filter) { + $.jGrowl(notify.subject+'
'+notify.description, { + group: notify.importance, + header: notify.event+': '+notify.timestamp, + theme: notify.file, + beforeOpen: function(e,m,o){if ($('div.jGrowl-notify').hasClass(notify.file)) return(false);}, + beforeClose: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file});} + }); + } + }); + }); +} +function closeNotifier(filter) { + clearTimeout(timers.notifier); + $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { + var data = $.parseJSON(json); + $.each(data, function(i, object) { + var notify = $.parseJSON(object); + if (notify.importance == filter) $.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file}); + }); + $('div.jGrowl').find('.'+filter).find('div.jGrowl-close').trigger('click'); + setTimeout(notifier,100); + }); +} +function viewHistory(filter) { + location.replace('/Tools/NotificationsArchive?filter='+filter); +} function watchdog() { $.post('/webGui/include/Watchdog.php',{mode:,dot:''},function(data) { if (data) { @@ -208,7 +259,12 @@ $(function() { if (update>3) timers.countDown = setTimeout(countDown,1000); updateTime(); - $.jGrowl.defaults.closer = false; + $.jGrowl.defaults.closeTemplate = ''; + $.jGrowl.defaults.closerTemplate = '':'
'?>[ close all notifications ]
'; + $.jGrowl.defaults.sticky = true; + $.jGrowl.defaults.check = 100; + $.jGrowl.defaults.position = ''; + $.jGrowl.defaults.themeState = ''; Shadowbox.setup('a.sb-enable', {modal:true}); }); var mobiles=['ipad','iphone','ipod','android']; @@ -218,7 +274,7 @@ for (var i=0,mobile; mobile=mobiles[i]; i++) { } - +
"; // Build page content echo "
"; $tab = 1; $view = $myPage['name']; -$pages = array(); +$pages = []; if ($myPage['text']) $pages[$view] = $myPage; if ($myPage['Type']=='xmenu') $pages = array_merge($pages, find_pages($view)); if (isset($myPage['Tabs'])) $display['tabs'] = strtolower($myPage['Tabs'])=='true' ? 0 : 1; @@ -308,16 +369,16 @@ foreach ($pages as $page) { echo '"; -
RebootBringing system down... 0
+
RebootSystem is going down... 0
diff --git a/shutdown.htm b/shutdown.htm index 51ba28826..3b827fe8b 100644 --- a/shutdown.htm +++ b/shutdown.htm @@ -15,14 +15,14 @@ function timer() { return Math.round((now.getTime()-start.getTime())/1000); } function online() { - $.ajax({url:'/webGui/include/ProcessStatus.php',type:'POST',data:{name:'emhttp'},timeout:5000}) - .done(function(){$('div.notice').html('ShutdownBringing system down... '+timer()); setTimeout(online,5000);}) - .fail(function(){$('div.notice').html('ShutdownSystem goes offline... 0'); start=new Date(); setTimeout(offline,5000);}); + $.ajax({url:'/webGui/include/ProcessStatus.php',type:'POST',data:{name:'emhttp',update:true},timeout:5000}) + .done(function(){$('div.notice').html('ShutdownSystem is going down... '+timer()); setTimeout(online,5000);}) + .fail(function(){$('div.notice').html('ShutdownSystem is offline... 0'); start=new Date(); setTimeout(offline,5000);}); } function offline() { var time = timer(); if (time < 30) { - $('div.notice').html('ShutdownSystem goes offline... '+time); + $('div.notice').html('ShutdownSystem is offline... '+time); setTimeout(offline,5000); } else { $('div.notice').html('ShutdownSystem is powered off...'); @@ -30,5 +30,5 @@ function offline() { } -
ShutdownBringing system down... 0
+
ShutdownSystem is going down... 0
From ff9b8ebff6004ea41e2391b400cda2a675e88d37 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 24 Oct 2016 09:39:27 +0200 Subject: [PATCH 08/23] Replace deprecated HTML5 tags
--- plugins/dynamix.apcupsd/UPSdetails.page | 4 ++-- plugins/dynamix.apcupsd/UPSsummary.page | 2 +- plugins/dynamix.apcupsd/include/UPSstatus.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/dynamix.apcupsd/UPSdetails.page b/plugins/dynamix.apcupsd/UPSdetails.page index 92b9a3b6b..d15484997 100644 --- a/plugins/dynamix.apcupsd/UPSdetails.page +++ b/plugins/dynamix.apcupsd/UPSdetails.page @@ -22,7 +22,7 @@ function getUPSstatus() { $('#ups_summary').html(data[0]); $('#ups_status').html(data[1]); } -0 || ($display['refresh']<0 && $var['mdResync']==0))):?> + setTimeout(getUPSstatus,); }); @@ -32,5 +32,5 @@ $(getUPSstatus); - +
KeyValueKeyValue
Please wait, retrieving UPS information...
Please wait, retrieving UPS information...
diff --git a/plugins/dynamix.apcupsd/UPSsummary.page b/plugins/dynamix.apcupsd/UPSsummary.page index e521122ba..b217cf6b2 100644 --- a/plugins/dynamix.apcupsd/UPSsummary.page +++ b/plugins/dynamix.apcupsd/UPSsummary.page @@ -23,7 +23,7 @@ table.ups tbody tr td{padding-left:10px;font-weight:bold;} function getUPSstatus() { $.get('/plugins/dynamix.apcupsd/include/UPSstatus.php',{all:'false'},function(data) { if (data) $('#ups_summary').html(data); -0 || ($display['refresh']<0 && $var['mdResync']==0))):?> + setTimeout(getUPSstatus, ); }); diff --git a/plugins/dynamix.apcupsd/include/UPSstatus.php b/plugins/dynamix.apcupsd/include/UPSstatus.php index 1ed6c7b1e..b615a2bd3 100644 --- a/plugins/dynamix.apcupsd/include/UPSstatus.php +++ b/plugins/dynamix.apcupsd/include/UPSstatus.php @@ -26,7 +26,7 @@ $green = "class='green-text'"; $orange = "class='orange-text'"; $status = array_fill(0,6,"-"); $all = $_GET['all']=='true'; -$result = array(); +$result = []; if (file_exists("/var/run/apcupsd.pid")) { exec("/sbin/apcaccess 2>/dev/null", $rows); @@ -62,7 +62,7 @@ if (file_exists("/var/run/apcupsd.pid")) { if ($all && count($rows)%2==1) $result[] = ""; if ($power && $load) $status[4] = ($load>=90 ? "" : "").intval($power*$load/100)." Watts"; } -if ($all && !$rows) $result[] = "
No information available
"; +if ($all && !$rows) $result[] = "No information available"; echo "".implode('', $status).""; if ($all) echo "\n".implode('', $result); From bba74f4cf10407bf0639400bc776fa1957b27371 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 24 Oct 2016 09:42:23 +0200 Subject: [PATCH 09/23] Replace fixed path with docroot variable --- .../dynamix.docker.manager/AddContainer.page | 2 +- .../DockerContainers.page | 5 ++--- .../DockerRepositories.page | 2 +- .../dynamix.docker.manager/DockerSettings.page | 5 +++-- .../UpdateContainer.page | 2 +- .../include/DockerClient.php | 18 +++++++++--------- .../dynamix.docker.manager/include/Events.php | 9 ++++++--- .../dynamix.docker.manager/include/Exec.php | 6 ++++-- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/plugins/dynamix.docker.manager/AddContainer.page b/plugins/dynamix.docker.manager/AddContainer.page index 3b27af837..77b4040f3 100644 --- a/plugins/dynamix.docker.manager/AddContainer.page +++ b/plugins/dynamix.docker.manager/AddContainer.page @@ -18,5 +18,5 @@ Markdown="false" Advanced View
\ No newline at end of file diff --git a/plugins/dynamix.docker.manager/DockerContainers.page b/plugins/dynamix.docker.manager/DockerContainers.page index 85ea6a07d..149e02419 100644 --- a/plugins/dynamix.docker.manager/DockerContainers.page +++ b/plugins/dynamix.docker.manager/DockerContainers.page @@ -17,14 +17,14 @@ Markdown="false" ?> - - \ No newline at end of file diff --git a/plugins/dynamix.vm.manager/templates/Custom.form.php b/plugins/dynamix.vm.manager/templates/Custom.form.php index 7c6ed7b13..4017a0f11 100644 --- a/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -11,9 +11,10 @@ */ ?> Date: Mon, 24 Oct 2016 09:50:08 +0200 Subject: [PATCH 17/23] Replace array() notation with PHP preferred square bracktes [] --- plugins/dynamix.vm.manager/VMMachines.page | 20 +++--- .../dynamix.vm.manager/classes/libvirt.php | 68 +++++++++---------- .../classes/libvirt_helpers.php | 29 ++++---- 3 files changed, 59 insertions(+), 58 deletions(-) diff --git a/plugins/dynamix.vm.manager/VMMachines.page b/plugins/dynamix.vm.manager/VMMachines.page index d1c45c090..235e5b0a8 100644 --- a/plugins/dynamix.vm.manager/VMMachines.page +++ b/plugins/dynamix.vm.manager/VMMachines.page @@ -40,8 +40,8 @@ if ($action) { 'Error: '.$lv->get_last_error(); } elseif ($subaction == 'disk-resize') { - $capacity = str_replace(array("KB","MB","GB","TB","PB", " ", ","), array("K","M","G","T","P", "", ""), strtoupper($_POST['cap'])); - $oldcap = str_replace(array("KB","MB","GB","TB","PB", " ", ","), array("K","M","G","T","P", "", ""), strtoupper($_GET['oldcap'])); + $capacity = str_replace(["KB","MB","GB","TB","PB", " ", ","], ["K","M","G","T","P", "", ""], strtoupper($_POST['cap'])); + $oldcap = str_replace(["KB","MB","GB","TB","PB", " ", ","], ["K","M","G","T","P", "", ""], strtoupper($_GET['oldcap'])); if (substr($oldcap,0,-1) < substr($capacity,0,-1)){ shell_exec("qemu-img resize -q " . escapeshellarg($_GET['disk']) . " $capacity"); $msg = $domName." disk capacity has been changed to $capacity"; @@ -124,7 +124,7 @@ if ($action) { } } else { sort($doms); - $contextMenus = array(); + $contextMenus = []; for ($i = 0; $i < sizeof($doms); $i++) { $name = $doms[$i]; @@ -196,8 +196,8 @@ if ($action) { if (!empty($vmtemplateicon)) { if (file_exists($vmtemplateicon)) { $vmicon = $vmtemplateicon; - } else if (file_exists('/usr/local/emhttp/plugins/dynamix.vm.manager/templates/images/' . $vmtemplateicon)) { - $vmicon = '/plugins/dynamix.vm.manager/templates/images/' . $vmtemplateicon; + } else if (file_exists("$docroot/plugins/dynamix.vm.manager/templates/images/".$vmtemplateicon)) { + $vmicon = "/plugins/dynamix.vm.manager/templates/images/".$vmtemplateicon; } } @@ -243,7 +243,7 @@ if ($action) { if($bootdev == 'cdrom') echo "selected "; echo "value='?subaction=bootdev-change&uuid=$uuid&bootdev=cdrom'>cd - (boot) + (boot) Driver type Dev Name @@ -465,10 +465,10 @@ if ($action) { unset($name, $val); if($msg){ if(strpos($msg, "rror:")) - $color = 'red'; + $color = 'red-text'; else - $color = 'green'; - echo ""; + $color = 'green-text'; + echo ""; } ?> @@ -478,7 +478,7 @@ if($msg){