Merge pull request #1235 from bergware/master

Miscellaneous Updates
This commit is contained in:
tom mortensen
2023-01-18 08:50:34 -08:00
committed by GitHub
28 changed files with 360 additions and 144 deletions

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2015-2022, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2022, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* 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,
@@ -72,7 +72,7 @@ function cpu_pinning() {
if (isset($_POST['contName'])) {
$postXML = postToXML($_POST, true);
$dry_run = $_POST['dryRun']=='true' ? true : false;
$dry_run = isset($_POST['dryRun']) && $_POST['dryRun']=='true' ? true : false;
$existing = $_POST['existingContainer'] ?? false;
$create_paths = $dry_run ? false : true;
// Get the command line

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2014-2022, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2022, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* 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,
@@ -17,7 +17,7 @@ libxml_use_internal_errors(true); # Suppress any warnings from xml errors.
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
if ($_SERVER['REQUEST_URI'] != 'docker' && substr($_SERVER['REQUEST_URI'],0,7) != '/Docker') {
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']!='docker' && substr($_SERVER['REQUEST_URI'],0,7) != '/Docker') {
$_SERVER['REQUEST_URI'] = 'docker';
require_once "$docroot/webGui/include/Translations.php";
}
@@ -52,7 +52,7 @@ $defaults = @parse_ini_file("$docroot/plugins/dynamix.docker.manager/default.cfg
$dockercfg = array_replace_recursive($defaults, parse_ini_file($docker_cfgfile));
function var_split($item, $i=0) {
return explode(' ',$item)[$i];
return array_pad(explode(' ',$item),$i+1,'')[$i];
}
#######################################
@@ -251,7 +251,7 @@ class DockerTemplates {
if ($doc->getElementsByTagName('Name')->item(0)->nodeValue !== $name)
continue;
if ($Repository == $TemplateRepository) {
$TemplateField = $doc->getElementsByTagName($field)->item(0)->nodeValue;
$TemplateField = $doc->getElementsByTagName($field)->item(0)->nodeValue ?? '';
return trim($TemplateField);
}
}
@@ -299,11 +299,12 @@ class DockerTemplates {
$tmp['paused'] = $ct['Paused'];
$tmp['autostart'] = in_array($name, $autoStart);
$tmp['cpuset'] = $ct['CPUset'];
$tmp['url'] = $tmp['url'] ?? '';
// read docker label for WebUI & Icon
if ($ct['Url'] && !$tmp['url']) $tmp['url'] = $ct['Url'];
if ($ct['Icon']) $tmp['icon'] = $ct['Icon'];
if ($ct['Shell']) $tmp['shell'] = $ct['Shell'];
if ( ! $communityApplications ) {
if (isset($ct['Url']) && !$tmp['url']) $tmp['url'] = $ct['Url'];
if (isset($ct['Icon'])) $tmp['icon'] = $ct['Icon'];
if (isset($ct['Shell'])) $tmp['shell'] = $ct['Shell'];
if (!$communityApplications) {
if (!is_file($tmp['icon']) || $reload) $tmp['icon'] = $this->getIcon($image,$name,$tmp['icon']);
}
if ($ct['Running']) {
@@ -323,12 +324,12 @@ class DockerTemplates {
$tmp['Project'] = $tmp['Project'] ?? $this->getTemplateValue($image, 'Project');
$tmp['DonateLink'] = $tmp['DonateLink'] ?? $this->getTemplateValue($image, 'DonateLink');
$tmp['ReadMe'] = $tmp['ReadMe'] ?? $this->getTemplateValue($image, 'ReadMe');
if (!$tmp['updated'] || $reload) {
if (empty($tmp['updated']) || $reload) {
if ($reload) $DockerUpdate->reloadUpdateStatus($image);
$tmp['updated'] = var_export($DockerUpdate->getUpdateStatus($image),true);
}
if (!$com) $tmp['updated'] = 'undef';
if (!$tmp['template'] || $reload) $tmp['template'] = $this->getUserTemplate($name);
if (empty($tmp['template']) || $reload) $tmp['template'] = $this->getUserTemplate($name);
if ($reload) $DockerUpdate->updateUserTemplate($name);
//$this->debug("\n$name");
//foreach ($tmp as $c => $d) $this->debug(sprintf(' %-10s: %s', $c, $d));

View File

@@ -69,13 +69,13 @@ foreach ($containers as $ct) {
$paused = $info['paused'] ? 1 : 0;
$is_autostart = $info['autostart'] ? 'true':'false';
$updateStatus = substr($ct['NetworkMode'],-4)==':???' ? 2 : ($info['updated']=='true' ? 0 : ($info['updated']=='false' ? 1 : 3));
$template = $info['template'];
$shell = $info['shell'];
$webGui = html_entity_decode($info['url']);
$support = html_entity_decode($info['Support']);
$project = html_entity_decode($info['Project']);
$registry = html_entity_decode($info['registry']);
$donateLink = html_entity_decode($info['DonateLink']);
$template = $info['template']??'';
$shell = $info['shell']??'';
$webGui = html_entity_decode($info['url']??'');
$support = html_entity_decode($info['Support']??'');
$project = html_entity_decode($info['Project']??'');
$registry = html_entity_decode($info['registry']??'');
$donateLink = html_entity_decode($info['DonateLink']??'');
$readme = html_entity_decode($info['ReadMe']);
$menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s', '%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project),addslashes($registry),addslashes($donateLink),addslashes($readme));
$docker[] = "docker.push({name:'$name',id:'$id',state:$running,pause:$paused,update:$updateStatus});";
@@ -85,7 +85,7 @@ foreach ($containers as $ct) {
$update = $updateStatus==1 ? 'blue-text' : '';
$icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png';
$image = substr($icon,-4)=='.png' ? "<img src='$icon?".filemtime("$docroot{$info['icon']}")."' class='img' onerror=this.src='/plugins/dynamix.docker.manager/images/question.png';>" : (substr($icon,0,5)=='icon-' ? "<i class='$icon img'></i>" : "<i class='fa fa-$icon img'></i>");
$wait = var_split($autostart[array_search($name,$names)],1);
$wait = var_split($autostart[array_search($name,$names)]??'',1);
$ports = [];
foreach ($ct['Ports'] as $port) {
$intern = $running ? ($ct['NetworkMode']=='host' ? $host : $port['IP']) : $null;

View File

@@ -43,7 +43,7 @@ function postToXML($post, $setOwnership=false) {
$xml->Network = xml_encode($post['contNetwork']);
$xml->MyIP = xml_encode($post['contMyIP']);
$xml->Shell = xml_encode($post['contShell']);
$xml->Privileged = strtolower($post['contPrivileged'])=='on' ? 'true' : 'false';
$xml->Privileged = strtolower($post['contPrivileged']??'')=='on' ? 'true' : 'false';
$xml->Support = xml_encode($post['contSupport']);
$xml->Project = xml_encode($post['contProject']);
$xml->Overview = xml_encode($post['contOverview']);

View File

@@ -1,6 +1,6 @@
#!/usr/bin/php
#!/usr/bin/php -q
<?PHP
/* Copyright 2015-2016, Lime Technology
/* Copyright 2015-2023, Lime Technology
* Copyright 2015-2016, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
@@ -30,7 +30,7 @@ if (file_exists($cfgfile)) {
unset($cfg_new);
}
}
if ($cfg_new) {
if (isset($cfg_new)) {
foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n";
file_put_contents($cfgfile, $tmp);
}

View File

@@ -163,12 +163,6 @@ function resetSorting() {
$('input[type=button]').prop('disabled',true);
$.post('/plugins/dynamix.vm.manager/include/UserPrefs.php',{reset:true},function(){loadlist();});
}
var sortableHelper = function(e,i){
i.children().each(function(){
$(this).width($(this).width());
});
return i;
};
function changemedia(uuid,dev,bus,file) {
if (file === "--select") getisoimage(uuid,dev,bus,file) ;
if (file === "--eject") ajaxVMDispatch({action:"change-media", uuid:uuid , cdrom:"" , dev:dev , bus:bus , file:file}, "loadlist");
@@ -218,24 +212,41 @@ function dialogStyle() {
$('.ui-dialog-content').css({'padding-top':'15px','vertical-align':'bottom'});
$('.ui-button-text').css({'padding':'0px 5px'});
}
function loadlist() {
timers.vm = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.get('/plugins/dynamix.vm.manager/include/VMMachines.php',{show:$.cookie('vmshow')},function(d) {
clearTimeout(timers.vm);
var data = d.split(/\0/);
$('#kvm_list').html(data[0]).sortable({helper:sortableHelper,items:'tr.sortable',cursor:'move',axis:'y',containment:'parent',delay:100,opacity:0.5,zIndex:9999,
var sortableHelper = function(e,ui){
ui.children().each(function(){$(this).width($(this).width());});
return ui;
};
function LockButton() {
if ($.cookie('lockbutton') == null) {
$.cookie('lockbutton','lockbutton');
<?if ($themes1):?>
$('div.nav-item.LockButton').find('a').prop('title',"_(Lock sortable items)_");
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock red-text').addClass('icon-u-lock-open green-text');
<?endif;?>
$('div.nav-item.LockButton').find('span').text("_(Lock sortable items)_");
$('#kvm_list').sortable({helper:sortableHelper,items:'tr.sortable',cursor:'move',axis:'y',containment:'parent',delay:100,opacity:0.5,zIndex:9999,forcePlaceholderSize:true,
update:function(e,ui){
$('#kvm_list').find('tr.sortable').each(function(){
var parent = $(this).attr('parent-id');
var child = $('tr[child-id="'+parent+'"]');
child.detach().insertAfter($(this));
});
var row = $('#kvm_list').find('tr:first');
var names = ''; var index = '';
row.parent().children().find('td.vm-name').each(function(){names+=$(this).find('a').text()+';';index+=$(this).parent().parent().children().index($(this).parent())+';';});
$.post('/plugins/dynamix.vm.manager/include/UserPrefs.php',{names:names,index:index});
}});
} else {
$.removeCookie('lockbutton');
<?if ($themes1):?>
$('div.nav-item.LockButton').find('a').prop('title',"_(Unlock sortable items)_");
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock-open green-text').addClass('icon-u-lock red-text');
<?endif;?>
$('div.nav-item.LockButton').find('span').text("_(Unlock sortable items)_");
$('#kvm_list').sortable('destroy');
}
}
function loadlist() {
timers.vm = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.get('/plugins/dynamix.vm.manager/include/VMMachines.php',{show:$.cookie('vmshow')},function(d) {
clearTimeout(timers.vm);
var data = d.split(/\0/);
$('#kvm_list').html(data[0]);
$('head').append('<script>'+data[1]+'<\/script>');
<?if ($display['resize']):?>
resize();
@@ -274,6 +285,7 @@ $(function() {
$('#countdown').html("<span class='<?=$color?>'><?=_($msg)?></span>");
<?endif;?>
$('#btnAddVM').click(function AddVMEvent(){$('.tab>input#tab2').click();});
$.removeCookie('lockbutton');
loadlist();
});
</script>

View File

@@ -1,6 +1,6 @@
#!/usr/bin/php
#!/usr/bin/php -q
<?PHP
/* Copyright 2015-2016, Lime Technology
/* Copyright 2015-2023, Lime Technology
* Copyright 2015-2016, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
@@ -34,7 +34,7 @@ if (file_exists($cfgfile)) {
unset($cfg_new);
}
}
if ($cfg_new) {
if (isset($cfg_new)) {
foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n";
file_put_contents($cfgfile, $tmp);
}

View File

@@ -192,6 +192,7 @@ span.wg1{font-size:1.1rem;text-indent:24px}
span.wg2{font-size:1.1rem}
span[id^=cpu],span[id^=sys]{width:0}
span[class^="fa "]{font-size:1.6rem;margin-right:18px}
span.load{font-size:85%}
span.fan{width:36%;display:inline-block}
span.w18{width:18%;display:inline-block;float:left}
span.w26{width:26%;display:inline-block;float:left}
@@ -303,22 +304,22 @@ foreach ($cpus as $pair) {
</tbody>
<tbody title="_(Memory Utilization)_">
<tr><td><i class='icon-ram f32'></i><div class='section'>_(Memory)_<br><span><?="$memory_installed $unit $memory_type $ecc"?></span><br><br></div>
<tr><td><i class='icon-ram f32'></i><div class='section'>_(Memory)_<br><span><i class='ups fa fa-line-chart'></i><?="$memory_installed $unit $memory_type $ecc"?></span><br><br></div>
<a href='/Dashboard/Tools/Processes' title="_(View Running Processes)_"><i class='fa fa-fw fa-info-circle control'></i></a>
</td></tr>
<tr><td>_(Usable size)_: <?=my_scale($total,$unit,1,null,1024)." $unit"?>&nbsp;&nbsp;---&nbsp;&nbsp;_(Maximum size)_: <?="$memory_maximum $unit"?><?=$low?'*':''?></td></tr>
<tr><td><span class='w26'>_(RAM)_</span><span class='w72'><span class='sys0 load'>0%</span><div class='usage-disk sys'><span id='sys0'></span><span></span></div></span></td></tr>
<tr><td><span class='w26'>_(Flash)_</span><span class='w72'><span class='sys1 load'>0%</span><div class='usage-disk sys'><span id='sys1'></span><span></span></div></span></td></tr>
<tr><td><span class='w26'>_(Log)_</span><span class='w72'><span class='sys2 load'>0%</span><div class='usage-disk sys'><span id='sys2'></span><span></span></div></span></td></tr>
<tr><td><span class='w36'><i class='ups fa fa-compress'></i>_(Usable size)_: <?=my_scale($total,$unit,1,null,1024)." $unit"?></span><i class='ups fa fa-expand'></i>_(Maximum size)_: <?="$memory_maximum $unit"?><?=$low?'*':''?></td></tr>
<tr><td><span class='w26'><i class='ups fa fa-fw fa-microchip'></i>_(RAM)_</span><span class='w72'><span class='sys0 load'>0%</span><div class='usage-disk sys'><span id='sys0'></span><span></span></div></span></td></tr>
<tr><td><span class='w26'><i class='ups fa fa-fw fa-suitcase'></i>_(Flash)_</span><span class='w72'><span class='sys1 load'>0%</span><div class='usage-disk sys'><span id='sys1'></span><span></span></div></span></td></tr>
<tr><td><span class='w26'><i class='ups fa fa-fw fa-file-text'></i>_(Log)_</span><span class='w72'><span class='sys2 load'>0%</span><div class='usage-disk sys'><span id='sys2'></span><span></span></div></span></td></tr>
<?if (exec("df /var/lib/docker|grep -om1 '^/'")):?>
<tr><td><span class='w26'>_(Docker)_</span><span class='w72'><span class='sys3 load'>0%</span><div class='usage-disk sys'><span id='sys3'></span><span></span></div></span></td></tr>
<tr><td><span class='w26'><i class='ups fa fa-fw fa-docker'></i>_(Docker)_</span><span class='w72'><span class='sys3 load'>0%</span><div class='usage-disk sys'><span id='sys3'></span><span></span></div></span></td></tr>
<?endif;?>
</tbody>
<tbody title="_(Interface Information)_">
<tr><td><i class='icon-ethernet f32'></i><div class='section'>_(Interface)_<br>
<span><span class='dense'>_(Inbound)_: <span id='inbound'>---</span></span><span class='dense'>_(Outbound)_: <span id='outbound'>---</span></span>
<select name="port_select" onchange="portSelect(this.value)">
<span><span class='dense'><i class='ups fa fa-angle-double-down'></i>_(Inbound)_: <span id='inbound'>---</span></span><span class='dense'><i class='ups fa fa-angle-double-up'></i>_(Outbound)_: <span id='outbound'>---</span></span>
<i class='ups fa fa-angle-right'></i><select name="port_select" onchange="portSelect(this.value)">
<?foreach ($ports as $port):?>
<?=mk_option("",$port,_($port))?>
<?endforeach;?>
@@ -365,7 +366,7 @@ foreach ($ports as $port) {
<?if ($wireguard):?>
<tbody title="_(VPN Connections)_">
<tr><td><i class='icon-vpn f32'></i><div class='section'>_(VPN)_<br><span><span class='dense'>_(Active tunnels)_: <span id='vpn-active'><?=$up?></span></span>_(Inactive tunnels)_: <span id='vpn-inactive'><?=$down?></span></span><br><br></div>
<tr><td><i class='icon-vpn f32'></i><div class='section'>_(VPN)_<br><span><span class='dense'><i class='ups fa fa-play-circle'></i>_(Active tunnels)_: <span id='vpn-active'><?=$up?></span></span><i class='ups fa fa-pause-circle'></i>_(Inactive tunnels)_: <span id='vpn-inactive'><?=$down?></span></span><br><br></div>
<a href='/Settings/VPNmanager' title="_(Go to VPN settings)_"><i class='fa fa-fw fa-cog control'></i></a>
</td></tr>
<?foreach ($conf as $wg):?>
@@ -382,7 +383,7 @@ foreach ($ports as $port) {
<?if ($apcupsd):?>
<tbody title="_(Power Status)_">
<tr><td><i class='icon-ups f32'></i><div class='section'>_(Power)_<br>
<span><i class='ups fa fa-shield'></i>_(UPS Model)_: </span><span id='ups_model'></span><br><br></div>
<span><i class='ups fa fa-bar-chart'></i>_(UPS Model)_: </span><span id='ups_model'></span><br><br></div>
<a href='/Dashboard/Settings/UPSsettings' title="_(Go to UPS settings)_"><i class='fa fa-fw fa-cog control'></i></a>
</td></tr>
<tr><td>
@@ -398,7 +399,7 @@ foreach ($ports as $port) {
<?if ($fans):?>
<tbody title="_(Fan Information)_">
<tr><td><i class='icon-fan f32'></i><div class='section'>_(Airflow)_<br><span>_(Fan count)_: <?=$fans?></span><br><br></div>
<tr><td><i class='icon-fan f32'></i><div class='section'>_(Airflow)_<br><span><i class='ups fa fa-dot-circle-o'></i>_(Fan count)_: <?=$fans?></span><br><br></div>
<?if ($autofan):?>
<a href='/Dashboard/Settings/FanSettings' title="_(Go to fan settings)_"><i class='fa fa-fw fa-cog control'></i></a>
@@ -629,7 +630,7 @@ if (!$group) {
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=1600">
<meta name="robots" content="noindex, nofollow">
<meta name="referrer" content="same-origin">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-fonts.css")?>">

View File

@@ -19,8 +19,8 @@ require_once "$docroot/webGui/include/Preselect.php";
$unassigned = array_key_exists($name, $devs);
$disks = array_merge_recursive($disks, $devs);
$disk = &$disks[$name];
$dev = $disk['device'];
$id = $disk['id'];
$dev = $disk['device']??'';
$id = $disk['id']??'';
$events = explode('|',$disk['smEvents'] ?? $var['smEvents'] ?? $numbers);
$bgcolor = in_array($display['theme'],['white','azure']) ? '#f2f2f2' : '#1c1c1c';
$yes = _('Yes');
@@ -39,11 +39,11 @@ function maintenance_mode() {
global $var, $disk;
return ($var['fsState']=="Started" && $var['startMode']=="Maintenance" && $disk['luksState']<=1);
}
$sheets = []; $n = 0;
$sheets = []; $i = $n = 0;
foreach ($disks as $sheet) {
if ((isset($sheet['type']) && $sheet['type']=='Flash') || (isset($sheet['color']) && $sheet['color']=='grey-off')) continue;
$sheets[] = $sheet['name'];
if ($sheet['name']==$name) { $i = $n; }
if ($sheet['name']==$name) {$i = $n;}
$n++;
}
$tag = $disk['name'];
@@ -452,7 +452,7 @@ _(Identification)_:
<?endif;?>
<?if (!$unassigned):?>
<?if ((isset($disk['type']) && ($disk['type']=='Data' || $disk['type']=='Cache')) && in_array($disk['name'],$pools)):?>
<?if ($disk['type']??''=='Data' || (($disk['type']??'')=='Cache' && in_array($disk['name'],$pools))):?>
_(Comments)_:
: <input type="text" name="diskComment.<?=$disk['idx']?>" maxlength="256" value="<?=htmlspecialchars($disk['comment'])?>">
@@ -460,32 +460,32 @@ _(Comments)_:
<?endif;?>
_(Partition size)_:
: <?=my_number($disk['sizeSb'])?> KB (K=1024)
: <?=my_number($disk['sizeSb']??0)?> KB (K=1024)
_(Partition format)_:
: <?=_($disk['format'])?>
: <?=_($disk['format']??'')?>
<?if ($var['spinupGroups']=="yes" && (isset($disk['type']) && ($disk['type']=="Data" || $disk['type']=="Parity"))):?>
<?if ($var['spinupGroups']=="yes" && in_array($disk['type']??'',['Data','Parity'])):?>
_(Spinup group(s))_:
: <input type="text" name="diskSpinupGroup.<?=$disk['idx']?>" maxlength="256" value="<?=$disk['spinupGroup']?>">
<?endif;?>
_(Spin down delay)_:
: <select name="diskSpindownDelay.<?=$disk['idx']?>">
<?=mk_option($disk['spindownDelay'], "-1", _('Use default'))?>
<?=mk_option($disk['spindownDelay'], "0", _('Never'))?>
<?=mk_option($disk['spindownDelay'], "15", "15 "._('minutes'))?>
<?=mk_option($disk['spindownDelay'], "30", "30 "._('minutes'))?>
<?=mk_option($disk['spindownDelay'], "45", "45 "._('minutes'))?>
<?=mk_option($disk['spindownDelay'], "1", "1 "._('hour'))?>
<?=mk_option($disk['spindownDelay'], "2", "2 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "3", "3 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "4", "4 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "5", "5 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "6", "6 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "7", "7 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "8", "8 "._('hours'))?>
<?=mk_option($disk['spindownDelay'], "9", "9 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "-1", _('Use default'))?>
<?=mk_option($disk['spindownDelay']??'', "0", _('Never'))?>
<?=mk_option($disk['spindownDelay']??'', "15", "15 "._('minutes'))?>
<?=mk_option($disk['spindownDelay']??'', "30", "30 "._('minutes'))?>
<?=mk_option($disk['spindownDelay']??'', "45", "45 "._('minutes'))?>
<?=mk_option($disk['spindownDelay']??'', "1", "1 "._('hour'))?>
<?=mk_option($disk['spindownDelay']??'', "2", "2 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "3", "3 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "4", "4 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "5", "5 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "6", "6 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "7", "7 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "8", "8 "._('hours'))?>
<?=mk_option($disk['spindownDelay']??'', "9", "9 "._('hours'))?>
</select><span id="smart_selftest" class='orange-text'></span>
<?endif;?>

View File

@@ -0,0 +1,166 @@
Menu="WebGui"
Title="PHP Settings"
Icon="icon-template"
Tag="edit"
---
<?PHP
/* 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,
* 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.
*/
?>
<?
$log = "/var/log/phplog";
$ini = "/etc/php.d/errors-php.ini";
$conf = file_exists($ini) ? parse_ini_file($ini) : [];
if (!file_exists($log)) touch($log);
?>
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-$theme.css")?>">
<style>
div#templateWindow,div#dialogWindow{display:none}
</style>
<div markdown="1" style="width:43%;margin-bottom:40px;padding:5px 15px;border:solid 1px">
:php_settings_plug:
This utility is used for development purposes only and allows Plugin Authors to verify their PHP code by enabling different levels of PHP error reporting.
By default error logging is minimum and any errors are shown on screen. Changing the **Error reporting level** will capture the selected level of errors
into a LOG file, which can be opened in a separate window to monitor in real-time the events when visiting various GUI pages or executing background
processes on the server.
The LOG file can quickly grow large when multiple errors exists, it is advised to use it only during development and use the default setting
under normal running conditions.
:end
</div>
<form markdown="1" name="php_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="preset(this)">
<input type="hidden" name="#cleanup" value="1">
<input type="hidden" name="#file" value="<?=$ini?>">
<input type="hidden" name="error_log" value="<?=$log?>">
<input type="hidden" name="display_startup_errors" value="0">
<input type="hidden" name="display_errors" value="0">
<input type="hidden" name="log_errors" value="1">
_(Error reporting level)_:
: <select name="error_reporting">
<?=mk_option($conf['error_reporting']??'', "", "_(Default)_");?>
<?=mk_option($conf['error_reporting']??'', "32767", "_(All Categories)_");?>
<?=mk_option($conf['error_reporting']??'', "1", "_(Errors Only)_");?>
<?=mk_option($conf['error_reporting']??'', "2", "_(Warnings Only)_");?>
<?=mk_option($conf['error_reporting']??'', "8", "_(Notices Only)_");?>
<?=mk_option($conf['error_reporting']??'', "8192", "_(Deprecated Only)_");?>
</select>
<input type="button" value="_(PHP Info)_" onclick="PHPinfo()"><input type="button" value="_(Clear Log)_" onclick="clearLog()"><input type="button" id="viewlog" value="_(View Log)_" onclick="viewLog()" disabled>
: <input type="submit" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
</form>
<div id="dialogWindow"></div>
<div markdown="1" id="templateWindow">
<!--!
<html <?=$display['rtl']?>lang="<?=strtok($locale,'_')?:'en'?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<meta name="referrer" content="same-origin">
</head>
<style>
table{box-shadow:1px 2px 3px rgba(0,0,0,0.2);width:90%}
.center{text-align:center;color:#f2f2f2!important;background-color:#1c1b1b}
.center table{margin:1em auto;text-align:left}
.center th{text-align:center!important}
td,th{border:1px solid #505153;vertical-align:baseline;padding:4px 5px!important;color:#f2f2f2}
th{position:sticky;top:0}
img{float:right;border:0}
hr{width:90%;background-color:#505153;border:0;height:1px}
h1{font-size:150%}
h2{font-size:125%}
h2 a{color:#f2f2f2!important}
.p{text-align:left}
.e{background-color:#404A77;width:300px}
.h{background-color:#4F5B93}
.v{background-color:#333;max-width:300px;overflow-x:auto;word-wrap:break-word}
.v i{color:#999}
.h td,td.e,th{border-color:#606A90}
</style>
<body>
<?
ob_start();
phpinfo();
echo str_replace('</body></html>','',preg_replace('/^<!DOCTYPE html .*<body>/s','',ob_get_clean()));
?>
</body>
</html>
!-->
</div>
<script>
String.prototype.build = function(){return this.replace(/\n(<!--!|!-->)\n/g,'');}
var box = null;
function viewLog() {
openTerminal('log','PHP Error Log','phplog');
}
function clearLog() {
$.post('/webGui/include/PHPsettings.php',{cmd:'clear'},function(){
swal({title:"_(PHP Log File)_",text:"_(Log file cleared)_",type:'success',html:true,confirmButtonText:"_(Ok)_"},function(){
if (tty_window==null) viewLog();
tty_window.close();
});
});
}
function PHPinfo() {
box = $("#dialogWindow");
box.html($("#templateWindow").html().build());
box.dialog({
title: "_(PHP Information)_",
resizable: false,
height: Math.min(window.innerHeight-80,800),
width: Math.min(window.innerWidth,1200),
modal: true,
show: {effect:'fade', duration:250},
hide: {effect:'fade', duration:250},
buttons: {
"_(Done)_": function(){
box.dialog('close');
}
}
});
$('.ui-dialog-titlebar-close').css({'display':'none'});
$('.ui-dialog-title').css({'text-align':'center','width':'100%','font-size':'1.8rem'});
$('.ui-button-text').css({'padding':'0 5px'});
}
function preset(form) {
// reset to default settings
if (form.error_reporting.selectedIndex==0) {
form.error_log.value = "";
form.display_startup_errors.value = "";
form.display_errors.value = "";
form.log_errors.value = "";
}
$.cookie('reload_php',1);
}
$(function(){
if (document.php_settings.error_reporting.selectedIndex > 0) {
$('#viewlog').prop('disabled',false);
}
if ($.cookie('reload_php')==1) {
$.removeCookie('reload_php');
$.post('/webGui/include/PHPsettings.php',{cmd:'reload'});
}
});
</script>

View File

@@ -4,8 +4,8 @@ Icon="icon-vars"
Tag="code"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, 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,
@@ -32,6 +32,5 @@ $globals = $GLOBALS;
ksort($globals);
if (isset($globals['_SERVER']['PHP_AUTH_PW'])) $globals['_SERVER']['PHP_AUTH_PW'] = "***";
echo ($display['resize'] ? "<pre class='up' style='display:none'>" : "<pre class='up'>").htmlspecialchars(print_r($globals,true))."</pre>";
phpinfo();
?>
<input type="button" value="_(Done)_" onclick="done()">

View File

@@ -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,
@@ -17,10 +17,10 @@ $_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
$cpus = explode(';',$_POST['cpus']);
$cpus = explode(';',$_POST['cpus']??'');
function scan($area, $text) {
return strpos($area,$text)!==false;
return isset($area) ? strpos($area,$text)!==false : false;
}
function create($id, $name, $vcpu) {
@@ -39,6 +39,7 @@ function create($id, $name, $vcpu) {
[$cpu1, $cpu2] = my_preg_split('/[,-]/',$cpus[$c*32+$n]);
$check1 = in_array($cpu1, $vcpu) ? 'checked':'';
$check2 = $cpu2 ? (in_array($cpu2, $vcpu) ? 'checked':''):'';
if (empty($text[$n])) $text[$n] = '';
$text[$n] .="<label class='checkbox'><input type='checkbox' name='$name:$cpu1' $check1><span class='checkmark'></span></label><br>";
if ($cpu2) $text[$n] .= "<label class='checkbox'><input type='checkbox' name='$name:$cpu2' $check2><span class='checkmark'></span></label><br>";
}
@@ -50,7 +51,7 @@ switch ($_POST['id']) {
case 'vm':
// create the current vm assignments
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$vms = $libvirt_running=='yes' ? $lv->get_domains() : [];
$vms = $libvirt_running=='yes' ? ($lv->get_domains() ?: []) : [];
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
// list vms per user preference
if (file_exists($user_prefs)) {

View File

@@ -111,6 +111,9 @@ var before = new Date();
const timers = {};
timers.bannerWarning = null;
// tty window
var tty_window = null;
const addAlert = {};
addAlert.text = $.cookie('addAlert-text');
addAlert.cmd = $.cookie('addAlert-cmd');
@@ -400,7 +403,6 @@ function escapeQuotes(form) {
}
// Banner warning system
var bannerWarnings = [];
var currentBannerWarning = 0;
var osUpgradeWarning = false;
@@ -609,7 +611,7 @@ foreach ($tasks as $button) {
unset($tasks);
echo "</div>";
echo "<div class='nav-tile right'>";
if ($task == 'Dashboard' or $task == 'Docker') {
if (in_array($task,['Dashboard','Docker','VMs'])) {
$title = $themes2 ? "" : _('Unlock sortable items');
echo "<div class='nav-item LockButton util'><a 'href='#' class='hand' onclick='LockButton();return false;' title=\"$title\"><b class='icon-u-lock system red-text'></b><span>"._('Unlock sortable items')."</span></a></div>";
}

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -48,7 +48,7 @@ function shareInclude($name) {
}
function sharesOnly($disk) {
return strpos('Data,Cache',$disk['type'])!==false && $disk['exportable']=='yes';
return in_array($disk['type'],['Data','Cache']) && ($disk['exportable']??'')=='yes';
}
// filter disk shares
@@ -58,7 +58,7 @@ $disks = array_filter($disks,'sharesOnly');
$crypto = false;
foreach ($disks as $name => $disk) {
if ($compute=='yes') exec("webGui/scripts/disk_size ".escapeshellarg($name)." ssz2");
$crypto |= strpos($disk['fsType'],'luks:')!==false;
$crypto |= strpos($disk['fsType']??'','luks:')!==false;
}
// global shares include/exclude

View File

@@ -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,
@@ -19,6 +19,7 @@ $plugins = '/var/log/plugins';
$boot = "/boot/config/plugins";
$safepaths = ["$boot/dynamix"];
$safeexts = ['.png'];
$result = false;
require_once "$docroot/webGui/include/Helpers.php";

View File

@@ -39,7 +39,7 @@ function my_scale($value, &$unit, $decimals=NULL, $scale=NULL, $kilo=1000) {
}
function my_number($value) {
global $display;
$number = $display['number'];
$number = $display['number']??'';
return number_format($value, 0, $number[0], ($value>=10000 ? $number[1] : ''));
}
function my_time($time, $fmt=NULL) {
@@ -134,7 +134,7 @@ function my_check($time, $speed) {
$days = floor($time/86400);
$hmss = $time-$days*86400;
$hour = floor($hmss/3600);
$mins = $hmss/60%60;
$mins = floor($hmss/60)%60;
$secs = $hmss%60;
return plus($days,'day',($hour|$mins|$secs)==0).plus($hour,'hour',($mins|$secs)==0).plus($mins,'minute',$secs==0).plus($secs,'second',true).". "._('Average speed').": ".(is_numeric($speed) ? my_scale($speed,$unit,1)." $unit/s" : $speed);
}

View File

@@ -0,0 +1,28 @@
<?PHP
/* 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,
* 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.
*/
?>
<?
switch ($_POST['cmd']) {
case 'clear':
$log = "/var/log/phplog";
// delete existing file and recreate an empty file
if (file_exists($log)) unlink($log);
touch($log);
break;
case 'reload':
$ini = "/etc/php.d/errors-php.ini";
if (file_exists($ini) && filesize($ini)==0) unlink($ini);
exec("/etc/rc.d/rc.php-fpm reload 1>/dev/null 2>&1");
break;
}
?>

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -11,8 +11,8 @@
*/
?>
<?
$file = $_POST['file'];
$model = $_POST['model'];
$file = $_POST['file']??'';
$model = $_POST['model']??'';
$root = "/boot/config/plugins/dynamix";
$name = "$root/$file";

View File

@@ -102,15 +102,15 @@ case "capabilities":
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 = substr($port,0,4)=="nvme";
$nvme_section="info" ;
foreach ($output as $line) {
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 class='title'><span>${line}</span></div>"; $row = ['','',''] ; continue ;}
if ($nvme && $info[0]=="Supported Power States" ) { $nvme_section="psheading" ;echo "</body></table><div class='title'><span>{$line}</span></div>"; $row = ['','',''] ; continue ;}
if ($nvme && $info[0]=="Supported LBA Sizes" ) {
echo "</body></table><div class='title'>${info[0]} ${info[1]} ${info[2]}</span></div>";
echo "</body></table><div class='title'>{$info[0]} {$info[1]} {$info[2]}</span></div>";
$row = ['','',''];
$nvme_section="lbaheading" ;
continue ;
@@ -120,7 +120,7 @@ case "capabilities":
append($row[2],$info[2]);
if (substr($row[2],-1)=='.' || ($nvme && $nvme_section=="info")) {
echo "<tr><td>${row[0]}</td><td>${row[1]}</td><td>${row[2]}</td></tr>";
echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td></tr>";
$row = ['','',''];
$empty = false;
}
@@ -194,10 +194,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>"._('Date of purchase').":</td><td><input type='date' class='narrow' value='{$info['purchase']}' onchange='disklog(\"$disk\",\"purchase\",this.value)'></td></tr>";
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>"._('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'".($info['warranty']??''==$period?" selected":"").">$period "._('months')."</option>";
echo "</select></td></tr>";
}
break;

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -25,7 +25,7 @@ if (isset($_POST['kill']) && $_POST['kill'] > 1) {
}
$start = $_POST['start'] ?? 0;
[$command,$args] = explode(' ',unscript($_POST['cmd']??''),2);
[$command,$args] = array_pad(explode(' ',unscript($_POST['cmd']??''),2),2,'');
// find absolute path of command
foreach (glob("$docroot/plugins/*/scripts",GLOB_NOSORT) as $path) {

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -114,7 +114,7 @@ case 't1':
foreach ($groups as $line) {
if (!$line) continue;
if ($line[0]=='I') {
if ($spacer) echo "<tr><td colspan='2' class='thin'></td>"; else $spacer = true;
if (isset($spacer)) echo "<tr><td colspan='2' class='thin'></td>"; else $spacer = true;
echo "</tr><tr><td>$line:</td><td>";
$iommu = substr($line, 12);
$append = true;
@@ -146,7 +146,7 @@ case 't1':
unset($outputvfio);
switch (true) {
case (strpos($line, 'USB controller') !== false):
if ($isbound) {
if (isset($isbound)) {
echo '<tr><td></td><td></td><td></td><td></td><td style="padding-left: 50px;">'._('This controller is bound to vfio, connected USB devices are not visible').'.</td></tr>';
} else {
exec('for usb_ctrl in $(find /sys/bus/usb/devices/usb* -maxdepth 0 -type l);do path="$(realpath "${usb_ctrl}")";if [[ $path == *'.$pciaddress.'* ]];then bus="$(cat "${usb_ctrl}/busnum")";lsusb -s $bus:|sort;fi;done',$getusb);
@@ -166,7 +166,7 @@ case 't1':
case (strpos($line, 'IDE interface') !== false):
case (strpos($line, 'Mass storage controller') !== false):
case (strpos($line, 'Non-Volatile memory controller') !== false):
if ($isbound) {
if (isset($isbound)) {
echo '<tr><td></td><td></td><td></td><td></td><td style="padding-left: 50px;">'._('This controller is bound to vfio, connected drives are not visible').'.</td></tr>';
} else {
exec('ls -al /sys/block/sd* /sys/block/hd* /sys/block/sr* /sys/block/nvme* 2>/dev/null | grep -i "'.$pciaddress.'"',$getsata);
@@ -190,7 +190,7 @@ case 't1':
if (file_exists("/var/log/vfio-pci") && filesize("/var/log/vfio-pci")) {
echo '<input id="viewlog" type="button" value="'._('View VFIO-PCI Log').'" onclick="openTerminal(\'log\',\'vfio-pci\',\'vfio-pci\')">';
}
echo '<input id="applycfg" type="submit" disabled value="'._('Bind selected to VFIO at Boot').'" onclick="applyCfg();" '.($noiommu ? "style=\"display:none\"" : "").'>';
echo '<input id="applycfg" type="submit" disabled value="'._('Bind selected to VFIO at Boot').'" onclick="applyCfg();" '.(isset($noiommu) ? "style=\"display:none\"" : "").'>';
echo '<span id="warning"></span>';
echo '</td></tr>';
echo <<<EOT

View File

@@ -112,7 +112,7 @@ function escapeQuotes($text) {
}
function translate($key) {
// replaces multi-line sections
global $language;
global $language,$netpool,$netpool6,$netport,$nginx;
if ($plug = isset($language[$key])) eval('?>'.Markdown($language[$key]));
return !$plug;
}

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -15,7 +15,7 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
// special case when script is called on form-submit and processed by update.php
if (!isset($_SESSION['locale'])) $_SESSION['locale'] = $_POST['#locale'];
if (!isset($_SESSION['locale'])) $_SESSION['locale'] = $_POST['#locale']??'';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";

View File

@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -38,7 +38,7 @@ function model($id) {
}
function device_info(&$disk,$online) {
global $pools, $var, $crypto;
if (!$online || ($disk['type']=='Parity' || ($disk['type']=='Cache' && !in_array($disk['name'],$pools)))) {
if (!$online || (in_array($disk['type'],['Parity','Cache']) && !in_array($disk['name'],$pools))) {
$view = "<a class='view'></a>";
} else {
$dir = $disk['name']=='flash' ? "/boot" : "/mnt/{$disk['name']}";

View File

@@ -133,7 +133,7 @@ function device_name(&$disk) {
case 'Cache' : $type = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme'; break;
}
$name = my_disk($disk['name']);
[$p1,$p2] = explode(' ',$name);
[$p1,$p2] = my_explode(' ',$name);
$name = _($p1).($p2?" $p2":"");
return "<i class='icon-$type f14'></i> <a href=\"".htmlspecialchars("/Dashboard/Main/Settings/Device?name={$disk['name']}")."\" title=\"$name settings\">$name</a>";
}
@@ -204,7 +204,7 @@ function device_smart(&$disk, &$fail, &$smart) {
function device_usage(&$disk, &$full, &$high) {
global $display;
$text = $display['text'];
$used = ($disk['type']!='Parity' && $disk['type']!='Extra' && $disk['fsStatus']=='Mounted') ? (($disk['fsSize'] ? round((1-$disk['fsFree']/$disk['fsSize'])*100):0).'%') : false;
$used = ($disk['type']!='Parity' && $disk['type']!='Extra' && isset($disk['fsStatus']) && $disk['fsStatus']=='Mounted') ? ((isset($disk['fsSize']) ? round((1-$disk['fsFree']/$disk['fsSize'])*100):0).'%') : false;
if ($used) {
if ($text==2 || $text==21) {
$load = substr($used,0,-1);

View File

@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -98,7 +98,7 @@ function check_smart(&$disk,$port,$text,$info) {
}
break;
case 1:
$attr = "$name.${id}n";
$attr = "$name.{$id}n";
$last = $saved[$item][$attr] ?? 255;
if (($thres>0 && $value<=$thres*$level) || $fail) {
if ($value*($value>$thres?$level:1)<$last) {
@@ -128,7 +128,7 @@ function check_usage(&$disk,$used,$text,$info) {
$last = $saved[$item][$name] ?? 0;
if ($warn) {
if ($used>$last) {
exec("$notify -l '/Main' -e ".escapeshellarg("Unraid $text disk utilization")." -s ".escapeshellarg(ucfirst($warn)." [$server] - $text is ".($warn=='alert'?'low on space':'high on usage')." (${used}%)")." -d ".escapeshellarg("$info")." -i \"$warn\" 2>/dev/null");
exec("$notify -l '/Main' -e ".escapeshellarg("Unraid $text disk utilization")." -s ".escapeshellarg(ucfirst($warn)." [$server] - $text is ".($warn=='alert'?'low on space':'high on usage')." ({$used}%)")." -d ".escapeshellarg("$info")." -i \"$warn\" 2>/dev/null");
$saved[$item][$name] = max($critical,$used);
}
} else {
@@ -294,12 +294,12 @@ if ($retval===0 && exec("df /var/lib/docker|grep -Po '^/dev/\Kloop'")) {
$warn = exec("df /var/lib/docker|awk '/^\//{print $5*1}'");
if ($warn>=$high1 && $high1>0) {
if ($warn>$last) {
exec("$notify -l '/Docker' -e \"Docker critical image disk utilization\" -s ".escapeshellarg("Alert [$server] - Docker image disk utilization of ${warn}%")." -d ".escapeshellarg("$info")." -i \"alert\" 2>/dev/null");
exec("$notify -l '/Docker' -e \"Docker critical image disk utilization\" -s ".escapeshellarg("Alert [$server] - Docker image disk utilization of {$warn}%")." -d ".escapeshellarg("$info")." -i \"alert\" 2>/dev/null");
$saved[$item][$name] = $warn;
}
} elseif ($warn>=$high2 && $high2>0) {
if ($warn>$last) {
exec("$notify -l '/Docker' -e \"Docker high image disk utilization\" -s ".escapeshellarg("Warning [$server] - Docker image disk utilization of ${warn}%")." -d ".escapeshellarg("$info")." -i \"warning\" 2>/dev/null");
exec("$notify -l '/Docker' -e \"Docker high image disk utilization\" -s ".escapeshellarg("Warning [$server] - Docker image disk utilization of {$warn}%")." -d ".escapeshellarg("$info")." -i \"warning\" 2>/dev/null");
$saved[$item][$name] = $warn;
}
} else {

View File

@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2012-2021, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2012, Andrew Hamer-Adams, http://www.pixeleyes.co.nz.
*
* This program is free software; you can redistribute it and/or
@@ -110,7 +110,7 @@ $agents_dir = "/boot/config/plugins/dynamix/notifications/agents";
if (is_dir($agents_dir)) {
$agents = [];
foreach (array_diff(scandir($agents_dir), ['.','..']) as $p) {
if (file_exists("${agents_dir}/${p}")) $agents[] = "${agents_dir}/${p}";
if (file_exists("{$agents_dir}/{$p}")) $agents[] = "{$agents_dir}/{$p}";
}
} else {
$agents = NULL;
@@ -171,7 +171,8 @@ case 'add':
$ticket = $timestamp;
$mailtest = false;
$overrule = false;
$noBrowser = false;
$options = getopt("l:e:s:d:i:m:r:xtb");
foreach ($options as $option => $value) {
switch ($option) {
@@ -235,7 +236,7 @@ case 'get':
if (!$field) continue;
list($key,$val) = explode('=', $field);
if ($time) {$val = date($notify['date'].' '.$notify['time'], $val); $time = false;}
$output[$i][trim($key)] = trim($val);
$output[$i][trim($key)] = trim($val);
}
$output[$i++]["file"] = basename($file);
chmod($file,0000);

View File

@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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,
@@ -13,10 +13,14 @@
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
// Get the webGui configuration preferences
extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
$login_locale = $display['locale'];
$login_locale = $display['locale']??'';
require_once "$docroot/webGui/include/Translations.php";
function write(...$messages){