#!/usr/bin/php -q
<?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.
 */
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

// add translations
$_SERVER['REQUEST_URI'] = 'plugins';
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";

$file  = realpath($argv[1]??'');
$valid = ['/var/tmp/','/tmp/plugins/','/boot/previous'];
$good  = false;

foreach ($valid as $check) if (strncmp($file,$check,strlen($check))===0) $good = true;
if ($file && $good && pathinfo($file)['extension']=='txt') {
  echo Markdown(file_get_contents($file));
} else {
  echo Markdown("*"._('No release notes available')."!*");
}
?>
