Files
webgui/plugins/dynamix.plugin.manager/scripts/languagecheck
2022-07-06 08:50:22 +02:00

51 lines
1.9 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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.
*/
?>
<?
$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);
// Multi-language support
$_SERVER['REQUEST_URI'] = "scripts";
$login_locale = $unraid['display']['locale'];
require_once "$docroot/webGui/include/Translations.php";
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['language_notify'];
$notify = "$docroot/webGui/scripts/notify";
$tmp = '/tmp/plugins';
$plugins = '/var/log/plugins';
language('checkall');
foreach (glob("/$tmp/lang-*.xml", GLOB_NOSORT) as $file) {
$name = basename($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");
}
}
exit(0);
?>