PHP8 support

This commit is contained in:
bergware
2023-02-27 17:34:07 +01:00
parent e582a9b214
commit d7ee9ed919
6 changed files with 59 additions and 49 deletions
@@ -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,
@@ -20,7 +20,7 @@ extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = 'plugins';
$login_locale = $display['locale'];
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
$nchan = $argv[$argc-1] == 'nchan'; // console or nchan output
@@ -46,7 +46,7 @@ function write(...$messages){
}
write(_("Checking connectivity")." ...\n");
if (exec("wget --spider --no-check-certificate -nv -T10 -t1 https://www.msftncsi.com/ncsi.txt 2>&1|grep -o 'OK'")) {
if (exec("wget --spider --no-check-certificate -nv -T10 -t1 https://www.msftncsi.com/ncsi.txt 2>&1|grep -om1 'OK'")) {
$check = popen('plugin checkall','r');
while (!feof($check)) write(fgets($check));
pclose($check);
@@ -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,
@@ -17,17 +17,23 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$var = parse_ini_file('/var/local/emhttp/var.ini');
$unraid = parse_plugin_cfg('dynamix', true);
extract(parse_plugin_cfg('dynamix', true));
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
// Multi-language support
$_SERVER['REQUEST_URI'] = "scripts";
$login_locale = $unraid['display']['locale'];
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
function apos($text) {
// So that "&apos;" doesn't show up in email
return str_replace("&apos;","'",$text);
}
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['language_notify'];
$notify = "$docroot/webGui/scripts/notify";
$output = _var($notify,'language_notify');
$script = "$docroot/webGui/scripts/notify";
$tmp = '/tmp/plugins';
$plugins = '/var/log/plugins';
@@ -37,13 +43,13 @@ foreach (glob("/$tmp/lang-*.xml", GLOB_NOSORT) as $file) {
$lang = language('LanguageLocal', $file);
$new = language('Version', $file);
$old = language('Version', "$plugins/$name");
// silently suppress bad download of XML file
if (strcmp($new, $old) > 0) {
// So that "&apos;" doesn't show up in email
$event = str_replace("&apos;","'",_("Language")." - $lang [$new]");
$subject = str_replace("&apos;","'",sprintf(_("Notice [%s] - Version update %s"),$server,$new));
$description = str_replace("&apos;","'",sprintf(_("A new version of %s is available"),$lang));
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -l '/Apps' -x");
$event = apos(_("Language")." - $lang [$new]");
$subject = apos(sprintf(_("Notice [%s] - Version update %s"),$server,$new));
$description = apos(sprintf(_("A new version of %s is available"),$lang));
exec("$script -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -l '/Apps' -x");
}
}
exit(0);
@@ -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,
@@ -12,8 +12,8 @@
*/
?>
<?
$method = $argv[1];
$plugins = explode('*',$argv[2]);
$method = $argv[1]??'';
$plugins = explode('*',$argv[2]??'');
$nchan = $argv[$argc-1] == 'nchan'; // console or nchan output
$call = ['plg' => 'plugin', 'xml' => 'language', '' => 'language'];
@@ -38,7 +38,7 @@ function write(...$messages){
}
foreach ($plugins as $plugin) {
if (!$plugin || (!$cmd = $call[pathinfo($plugin)['extension']])) continue;
if (!$plugin || (!$cmd = $call[pathinfo($plugin,PATHINFO_EXTENSION)])) continue;
$line = '';
$pluginArg = $method == "update" ? basename($plugin) : $plugin;
$run = popen("$cmd $method $pluginArg",'r');
@@ -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,
@@ -17,23 +17,25 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$var = parse_ini_file('/var/local/emhttp/var.ini');
$unraid = parse_plugin_cfg('dynamix', true);
extract(parse_plugin_cfg('dynamix',true));
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
// Multi-language support
$_SERVER['REQUEST_URI'] = "scripts";
$login_locale = $unraid['display']['locale'];
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
function apos($text) {
// So that "&apos;" doesn't show up in email
return str_replace("&apos;","'",$text);
}
$current = parse_ini_file('/etc/unraid-version');
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['plugin'];
$server = strtoupper(_var($var,'NAME','tower'));
$output = _var($notify,'plugin');
$builtin = ['unRAIDServer','unRAIDServer-'];
$notify = "$docroot/webGui/scripts/notify";
$script = "$docroot/webGui/scripts/notify";
$tmp = '/tmp/plugins';
$plugins = '/var/log/plugins';
@@ -50,7 +52,7 @@ foreach (glob("/$tmp/*.plg", GLOB_NOSORT) as $file) {
$event = apos(_("Plugin")." - $name [$new]");
$subject = apos(sprintf(_("Notice [%s] - Version update %s"),$server,$new));
$description = apos(sprintf(_("A new version of %s is available"),$name));
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -l '/Plugins' -x");
exec("$script -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -l '/Plugins' -x");
}
}
exit(0);
@@ -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,
@@ -19,10 +19,10 @@ extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = 'plugins';
$login_locale = $display['locale'];
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
$file = realpath($argv[1] ?? '');
$file = realpath($argv[1]??'');
$valid = ['/var/tmp/','/tmp/plugins/'];
$good = false;
@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?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,
@@ -12,32 +12,34 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
// Multi-language support
if (!function_exists('_')) {
function _($text) {return $text;}
}
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
extract(parse_plugin_cfg('dynamix', true));
$var = parse_ini_file('/var/local/emhttp/var.ini');
$current = parse_ini_file('/etc/unraid-version');
$unraid = parse_plugin_cfg('dynamix', true);
$notify = "$docroot/webGui/scripts/notify";
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['plugin'];
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$script = "$docroot/webGui/scripts/notify";
$server = strtoupper(_var($var,'NAME','server'));
$output = _var($notify,'plugin');
$builtin = ['unRAIDServer'];
foreach ($builtin as $name) {
$plg = "$name.plg";
$plg = "$name.plg";
plugin('check',$plg);
$file = "/tmp/plugins/$plg";
$old = plugin('version', "/var/log/plugins/$plg");
$new = plugin('version', $file);
$old = plugin('version', "/var/log/plugins/$plg");
$new = plugin('version', $file);
// silently suppress bad download of PLG file
if (version_compare($new,$old,'>')) {
exec("$notify -e ".escapeshellarg("System - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -l '/Tools/Update' -x");
exec("$script -e ".escapeshellarg("System - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -l '/Tools/Update' -x");
}
}
exit(0);