diff --git a/emhttp/plugins/dynamix/nchan/update_2 b/emhttp/plugins/dynamix/nchan/update_2 index 87556f092..aa3d31015 100755 --- a/emhttp/plugins/dynamix/nchan/update_2 +++ b/emhttp/plugins/dynamix/nchan/update_2 @@ -1,7 +1,7 @@ #!/usr/bin/php -q 'green', 'operational' => 'orange']); - return " / ".number_format($power,$power<10?2:1,$number[0]).' '._('W').""; + return " / ".number_format($power, $power < 10 ? 2 : 1, $number[0]).' '._('W').""; } + function my_clock($time) { if (!$time) return _('less than a minute'); $days = floor($time/1440); @@ -45,12 +46,14 @@ function my_clock($time) { $mins = $time%60; return plus($days,'day',($hour|$mins)==0).plus($hour,'hour',$mins==0).plus($mins,'minute',true); } + function find_day($D) { global $days; if ($days[0] == '*') return $D; foreach ($days as $d) if ($d >= $D) return $d; return $days[0]; } + function find_month($M) { global $months, $Y; if ($M > 12) {$M = 1; $Y++;} @@ -58,6 +61,7 @@ function find_month($M) { foreach ($months as $m) if ($m >= $M) return $m; return $months[0]; } + function today($D) { global $days, $M, $Y; if ($days[0]=='*') return date('w',mktime(0,0,0,$M,$D,$Y)); @@ -66,18 +70,22 @@ function today($D) { if (in_array($day,$days)) return $day; } } + function next_day($D) { return find_day(($D+1)%7); } + function last_day() { global $M, $Y; return date('t',mktime(0,0,0,$M,1,$Y)); } + function mkdate($D, $s) { global $M, $Y; if ($s > last_day()) {$s = 1; $M = find_month($M+1);} for ($d = $s; $d < $s+7; $d++) if ($D == date('w',mktime(0,0,0,$M,$d,$Y))) return $d; } + function stage($i) { global $h, $m, $D, $M, $Y, $time, $now; if ($i < 0) { @@ -123,14 +131,17 @@ function stage($i) { } return $t; } + function normalize($type,$count) { $words = explode('_',$type); foreach ($words as &$word) $word = $word==strtoupper($word) ? $word : preg_replace(['/^(ct|cnt)$/','/^blk$/'],['count','block'],strtolower($word)); return ucfirst(implode(' ',$words)).": ".str_replace('_',' ',strtolower($count))."\n"; } + function active_disks($disk) { return substr(_var($disk,'status'),0,7)!='DISK_NP' && in_array(_var($disk,'type'),['Parity','Data']); } + function device_name(&$disk) { switch (_var($disk,'type')) { case 'Extra' : @@ -142,6 +153,7 @@ function device_name(&$disk) { $fancy = _(my_disk(native($name,1)),3); return " $fancy"; } + function yellow_text($disk) { global $var; if (_var($disk, 'type')=='Parity') { @@ -153,6 +165,7 @@ function yellow_text($disk) { } return $text; } + function device_status(&$disk, &$error, &$warning) { global $var; if (_var($disk,'type')!='Extra' && _var($var,'fsState')=='Stopped') { @@ -171,6 +184,7 @@ function device_status(&$disk, &$error, &$warning) { } return ""._($text); } + function device_temp(&$disk, &$red, &$orange) { global $display; $spin = strpos(_var($disk,'color'),'blink')===false; @@ -189,6 +203,7 @@ function device_temp(&$disk, &$red, &$orange) { } return ($spin ? "".my_temp($temp)."" : "*").($nvme ? my_power($dev) : ""); } + function device_smart(&$disk, &$fail, &$smart) { global $numbers,$saved; if (!_var($disk,'device') || strpos(_var($disk,'color'),'blink')!==false) return "-"; @@ -222,6 +237,7 @@ function device_smart(&$disk, &$fail, &$smart) { $title .= _('Click for context menu'); return "$text"; } + function device_usage(&$disk, &$full, &$high) { global $display; $text = $display['text']; @@ -242,6 +258,7 @@ function device_usage(&$disk, &$full, &$high) { return $text%10==0 ? "-" : "-
"; } } + function array_group($type, $pool=false) { global $disks,$error,$warning,$red,$orange,$fail,$smart,$full,$high; if ($type != 'Data') {$error = $warning = $red = $orange = $fail = $smart = $full = $high = 0;} @@ -257,6 +274,7 @@ function array_group($type, $pool=false) { } return implode($echo); } + function extra_group() { global $devs,$error,$warning,$red,$orange,$fail,$smart,$full,$high; $error = $warning = $red = $orange = $fail = $smart = $full = $high = 0; @@ -275,6 +293,7 @@ function extra_group() { } return implode($echo); } + function update_translation($locale) { global $docroot,$language; $language = []; @@ -293,9 +312,11 @@ function update_translation($locale) { } } } + function create_sync($file) { return file_exists($file) ? explode(',',file_get_contents($file)) : []; } + function print_error($error) { return sprintf(_('Finding **%s** error'.($error==1?'':'s')),$error?:'0'); }