From 527773d72768a0f0657a8e38436bf1becfbb533e Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 13 Mar 2016 20:32:36 +0100 Subject: [PATCH] whitespace --- src/www/diag_smart.php | 750 ++++++++++++++++++++--------------------- 1 file changed, 373 insertions(+), 377 deletions(-) diff --git a/src/www/diag_smart.php b/src/www/diag_smart.php index 69c0a768e..d3cfd610a 100644 --- a/src/www/diag_smart.php +++ b/src/www/diag_smart.php @@ -1,31 +1,31 @@
-
-
+
+
-
+
' . gettext("PASSED") . ''; - $replacements[1] = '' . gettext("FAILED") . ''; - $replacements[2] = '' . gettext("Warning") . ''; - ksort($patterns); - ksort($replacements); - return preg_replace($patterns, $replacements, $string); + // To add words keep arrayes matched by numbers + $patterns[0] = '/PASSED/'; + $patterns[1] = '/FAILED/'; + $patterns[2] = '/Warning/'; + $replacements[0] = '' . gettext("PASSED") . ''; + $replacements[1] = '' . gettext("FAILED") . ''; + $replacements[2] = '' . gettext("Warning") . ''; + ksort($patterns); + ksort($replacements); + return preg_replace($patterns, $replacements, $string); } // Edits smartd.conf file, adds or removes email for failed disk reporting function update_email($email) { - // Did they pass an email? - if(!empty($email)) - { - // Put it in the smartd.conf file - shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN -H -m " . escapeshellarg($email) . "/' /usr/local/etc/smartd.conf"); - } - // Nope - else - { - // Remove email flags in smartd.conf - shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN/' /usr/local/etc/smartd.conf"); - } + // Did they pass an email? + if (!empty($email)) { + // Put it in the smartd.conf file + shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN -H -m " . escapeshellarg($email) . "/' /usr/local/etc/smartd.conf"); + } else { + // Remove email flags in smartd.conf + shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN/' /usr/local/etc/smartd.conf"); + } } function smartmonctl($action) { - global $start_script; - shell_exec($start_script . escapeshellarg($action)); + global $start_script; + shell_exec($start_script . escapeshellarg($action)); } // What page, aka. action is being wanted @@ -99,395 +95,395 @@ function smartmonctl($action) $action = (isset($_POST['action']) ? $_POST['action'] : $_GET['action']); $targetdev = basename($_POST['device']); if (!file_exists('/dev/' . $targetdev)) { - echo "Device does not exist, bailing."; - return; + echo "Device does not exist, bailing."; + return; } switch($action) { - // Testing devices - case 'test': - { - $test = $_POST['testType']; - if (!in_array($test, $valid_test_types)) { - echo "Invalid test type, bailing."; - return; - } - $output = add_colors(shell_exec($smartctl . " -t " . escapeshellarg($test) . " /dev/" . escapeshellarg($targetdev))); - echo '
' . $output . '
-		
- - - -
-
'; - break; - } + // Testing devices + case 'test': + { + $test = $_POST['testType']; + if (!in_array($test, $valid_test_types)) { + echo "Invalid test type, bailing."; + return; + } + $output = add_colors(shell_exec($smartctl . " -t " . escapeshellarg($test) . " /dev/" . escapeshellarg($targetdev))); + echo '
' . $output . '
+    
+ + + +
+
'; + break; + } - // Info on devices - case 'info': - { - $type = $_POST['type']; - if (!in_array($type, $valid_info_types)) { - echo "Invalid info type, bailing."; - return; - } - $output = add_colors(shell_exec($smartctl . " -" . escapeshellarg($type) . " /dev/" . escapeshellarg($targetdev))); - echo "
$output
"; - break; - } + // Info on devices + case 'info': + { + $type = $_POST['type']; + if (!in_array($type, $valid_info_types)) { + echo "Invalid info type, bailing."; + return; + } + $output = add_colors(shell_exec($smartctl . " -" . escapeshellarg($type) . " /dev/" . escapeshellarg($targetdev))); + echo "
$output
"; + break; + } - // View logs - case 'logs': - { - $type = $_POST['type']; - if (!in_array($type, $valid_log_types)) { - echo "Invalid log type, bailing."; - return; - } - $output = add_colors(shell_exec($smartctl . " -l " . escapeshellarg($type) . " /dev/" . escapeshellarg($targetdev))); - echo "
$output
"; - break; - } + // View logs + case 'logs': + { + $type = $_POST['type']; + if (!in_array($type, $valid_log_types)) { + echo "Invalid log type, bailing."; + return; + } + $output = add_colors(shell_exec($smartctl . " -l " . escapeshellarg($type) . " /dev/" . escapeshellarg($targetdev))); + echo "
$output
"; + break; + } - // Abort tests - case 'abort': - { - $output = shell_exec($smartctl . " -X /dev/" . escapeshellarg($targetdev)); - echo "
$output
"; - break; - } + // Abort tests + case 'abort': + { + $output = shell_exec($smartctl . " -X /dev/" . escapeshellarg($targetdev)); + echo "
$output
"; + break; + } - // Config changes, users email in xml config and write changes to smartd.conf - case 'config': - { - if(isset($_POST['submit'])) - { - // DOES NOT WORK YET... - if($_POST['testemail']) - { -// FIXME shell_exec($smartd . " -M test -m " . $config['system']['smartmonemail']); - $savemsg = sprintf(gettext("Email sent to %s"), $config['system']['smartmonemail']); - smartmonctl("stop"); - smartmonctl("start"); - } - else - { - $config['system']['smartmonemail'] = $_POST['smartmonemail']; - write_config(); + // Config changes, users email in xml config and write changes to smartd.conf + case 'config': + { + if(isset($_POST['submit'])) + { + // DOES NOT WORK YET... + if($_POST['testemail']) + { +// FIXME shell_exec($smartd . " -M test -m " . $config['system']['smartmonemail']); + $savemsg = sprintf(gettext("Email sent to %s"), $config['system']['smartmonemail']); + smartmonctl("stop"); + smartmonctl("start"); + } + else + { + $config['system']['smartmonemail'] = $_POST['smartmonemail']; + write_config(); - // Don't know what all this means, but it addes the config changed header when config is saved - $retval = 0; - if(stristr($retval, "error") <> true) - $savemsg = get_std_save_message(); - else - $savemsg = $retval; + // Don't know what all this means, but it addes the config changed header when config is saved + $retval = 0; + if(stristr($retval, "error") <> true) + $savemsg = get_std_save_message(); + else + $savemsg = $retval; - if($_POST['email']) - { - // Write the changes to the smartd.conf file - update_email($_POST['smartmonemail']); - } + if($_POST['email']) + { + // Write the changes to the smartd.conf file + update_email($_POST['smartmonemail']); + } - // Send sig HUP to smartd, rereads the config file - shell_exec("/usr/bin/killall -HUP smartd"); - } - } - // Was the config changed? if so , print the message - if (isset($savemsg)) print_info_box($savemsg); - // Get users email from the xml file - $pconfig['smartmonemail'] = $config['system']['smartmonemail']; + // Send sig HUP to smartd, rereads the config file + shell_exec("/usr/bin/killall -HUP smartd"); + } + } + // Was the config changed? if so , print the message + if (isset($savemsg)) print_info_box($savemsg); + // Get users email from the xml file + $pconfig['smartmonemail'] = $config['system']['smartmonemail']; - ?> - - - - - -
- -
+ ?> + + + + + +
+ +
-
- - - - - - - - - - - - - - -
- -
  - - - " class="formbtn" /> -
-
+
+ + + + + + + + + + + + + + +
+ +
  + + + " class="formbtn" /> +
+
-
- - - - - - - - - - - - - - -
  - -
  - - - " class="formbtn" /> -
-
+
+ + + + + + + + + + + + + + +
  + +
  + + + " class="formbtn" /> +
+
- + // Get all AD* and DA* (IDE and SCSI) devices currently installed and stores them in the $devs array + exec("ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'", $devs); + ?> - 0) print_input_errors($input_errors); ?> + 0) print_input_errors($input_errors); ?>
-

-
+

+ -
-
-
- - - - - - - - - - - - - - - -
- - - - - -
-
- -
  - - " /> -
-
-
-
+
+
+
+ + + + + + + + + + + + + + + +
+ + + + +
- +
+ +
  + + " /> +
+
+
+
+
+
-
+
-

-
+

+ -
-
-
- - - - - - - - - - - - - - - -
-
- - - - -
-
- -
  - - " /> -
-
-
-
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + + + +
+
+ +
  + + " /> +
+
+
+
-
+
-
+
-

-
+

+ -
-
-
- - - - - - - - - - - - - - - -
-
- - -
-
- -
  - - " /> -
-
-
-
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + +
+
+ +
  + + " /> +
+
+
+
-
+
-
+
-

-
+

+ -
-
-
- - - - - - - - - - - -
- -
  - - " class="btn btn-primary" onclick="return confirm('')" /> -
-
-
-
+
+
+
+ + + + + + + + + + + +
+ +
  + + " class="btn btn-primary" onclick="return confirm('')" /> +
+
+
+
-
+
- ' . gettext("Back") . ''; + echo '
' . gettext("Back") . ''; } ?>
" . $ulmsg . "

\n"; ?> -
-
+
+