mirror of
https://github.com/unraid/webgui.git
synced 2026-02-05 16:39:01 -06:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -18,14 +18,13 @@ Cond="strpos($disks[$name]['status'],'_NP')===false"
|
||||
<script>
|
||||
$(function() {
|
||||
$.post("/webGui/include/SmartInfo.php",{cmd:'capabilities',port:'<?=addslashes(htmlspecialchars($dev))?>',name:'<?=addslashes(htmlspecialchars($name))?>'}, function(data) {
|
||||
$('#disk_capabilities').html(data);
|
||||
$('#disk_capabilities_div').html(data);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<table class='share_status small'>
|
||||
<thead><td style="width:33%">_(Feature)_</td><td>_(Value)_</td><td>_(Information)_</td></thead>
|
||||
<tbody id="disk_capabilities"><tr><td colspan='3'><div class="spinner"></div></td></tr></tbody>
|
||||
</table>
|
||||
<div id="disk_capabilities_div" class='share_status small'>
|
||||
|
||||
</div>
|
||||
<input type="button" value="_(Done)_" onclick="done()">
|
||||
|
||||
:smart_capabilities_help:
|
||||
|
||||
60
plugins/dynamix/include/InstallKey.php
Normal file
60
plugins/dynamix/include/InstallKey.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, 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,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$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;
|
||||
if ($cli) {
|
||||
$json = @json_decode($mutatedResult,true);
|
||||
if (!empty($json['error'])) {
|
||||
echo 'Error: '.$json['error'].PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
exit($cli_success_msg.PHP_EOL);
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
http_response_code($httpcode);
|
||||
exit((string)$mutatedResult);
|
||||
}
|
||||
|
||||
$cli = php_sapi_name()=='cli';
|
||||
$url = unscript($_GET['url']??'');
|
||||
$host = parse_url($url)['host'];
|
||||
|
||||
if (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") {
|
||||
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'));
|
||||
}
|
||||
} else {
|
||||
response_complete(406, array('error' => _('download error') . " $return_var"));
|
||||
}
|
||||
} else {
|
||||
response_complete(406, array('error' => _('bad or missing key file') . ": $url"));
|
||||
}
|
||||
?>
|
||||
@@ -98,23 +98,76 @@ case "attributes":
|
||||
if ($empty) echo "<tr><td colspan='10' style='text-align:center;padding-top:12px'>"._('Can not read attributes')."</td></tr>";
|
||||
break;
|
||||
case "capabilities":
|
||||
echo '<table id="disk_capabilities_table" class="share_status small"><thead><td style="width:33%">'._('Feature').'</td><td>'._('Value').'</td><td>'._('Information').'</td></thead><tbody>' ;
|
||||
exec("smartctl -n standby -c $type ".escapeshellarg("/dev/$port")."|awk 'NR>5'",$output);
|
||||
$row = ['','',''];
|
||||
$empty = true;
|
||||
if (substr($port,0,4)=="nvme") $nvme=true ;
|
||||
$nvme_section="info" ;
|
||||
foreach ($output as $line) {
|
||||
if (!$line) continue;
|
||||
if (!$line) {echo "<tr></tr>" ;continue;}
|
||||
$line = preg_replace('/^_/','__',preg_replace(['/__+/','/_ +_/'],'_',str_replace([chr(9),')','('],'_',$line)));
|
||||
$info = array_map('trim', explode('_', preg_replace('/_( +)_ /','__',$line), 3));
|
||||
if ($nvme && $info[0]=="Supported Power States" ) { $nvme_section="psheading" ;echo "</body></table><div id='title'><span>${line}</span></div>"; $row = ['','',''] ; continue ;}
|
||||
if ($nvme && $info[0]=="Supported LBA Sizes" ) {
|
||||
echo "</body></table><div id='title'>${info[0]} ${info[1]} ${info[2]}</span></div>";
|
||||
$row = ['','',''];
|
||||
$nvme_section="lbaheading" ;
|
||||
continue ;
|
||||
}
|
||||
append($row[0],$info[0]);
|
||||
append($row[1],$info[1]);
|
||||
append($row[2],$info[2]);
|
||||
if (substr($row[2],-1)=='.') {
|
||||
|
||||
if (substr($row[2],-1)=='.' || ($nvme && $nvme_section=="info")) {
|
||||
echo "<tr><td>${row[0]}</td><td>${row[1]}</td><td>${row[2]}</td></tr>";
|
||||
$row = ['','',''];
|
||||
$empty = false;
|
||||
}
|
||||
|
||||
if ($nvme && $nvme_section == "psheading") {
|
||||
echo '<table id="disk_capabilities_table2" class="share_status small"><thead>' ;
|
||||
$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>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr></thead><tbody>' ;
|
||||
}
|
||||
if ($nvme && $nvme_section == "psdetail") {
|
||||
$nvme_section = "psdetail";
|
||||
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>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr>' ;
|
||||
}
|
||||
if ($nvme && $nvme_section == "lbaheading") {
|
||||
echo '<table id="disk_capabilities_table3" class="share_status small"><thead>' ;
|
||||
$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>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</thead><tbody>' ;
|
||||
}
|
||||
if ($nvme && $nvme_section == "lbadetail") {
|
||||
$nvme_section = "lbadetail";
|
||||
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>" ;
|
||||
}
|
||||
$row = ['','',''];
|
||||
echo '</tr>' ;
|
||||
}
|
||||
}
|
||||
if ($empty) echo "<tr><td colspan='3' style='text-align:center;padding-top:12px'>"._('Can not read capabilities')."</td></tr>";
|
||||
echo "</tbody></table>" ;
|
||||
break;
|
||||
case "identify":
|
||||
$passed = ['PASSED','OK'];
|
||||
|
||||
Reference in New Issue
Block a user