Files
webgui/plugins/dynamix.plugin.manager/scripts/languagecheck
2020-06-09 09:10:32 +02:00

45 lines
1.6 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, 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.
*/
?>
<?
// 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";
$var = parse_ini_file('/var/local/emhttp/var.ini');
$unraid = parse_plugin_cfg('dynamix', true);
$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/dynamix.*.xml", GLOB_NOSORT) as $file) {
$name = str_replace('dynamix.', '', basename($file));
$lang = language('Language', $file);
$new = language('Version', $file);
$old = language('Version', "$plugins/dynamix.$name");
// silently suppress bad download of XML file
if (strcmp($new, $old) > 0) {
exec("$notify -e ".escapeshellarg("Language - $lang [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $lang is available")." -i ".escapeshellarg("normal $output")." -x");
}
}
exit(0);
?>