mirror of
https://github.com/unraid/webgui.git
synced 2026-01-13 21:20:01 -06:00
Informational functions which call "openChanges" are now processed using post requests, this solves the issue that sometimes an empty window is displayed.
72 lines
2.8 KiB
PHP
Executable File
72 lines
2.8 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";
|
|
extract(parse_plugin_cfg('dynamix',true));
|
|
|
|
// add translations
|
|
$_SERVER['REQUEST_URI'] = 'settings';
|
|
$login_locale = $display['locale'];
|
|
require_once "$docroot/webGui/include/Translations.php";
|
|
|
|
$file = $argv[1];
|
|
$path = realpath('/etc/wireguard'.($argv[2]??''));
|
|
$root = '/boot/config/wireguard';
|
|
|
|
$style = ["<style>"];
|
|
$style[] = "pre h2{text-decoration:underline}";
|
|
$style[] = "input#download{margin:0 0 10px 0}";
|
|
$style[] = "pre.config{font-family:bitstream;margin:0;border:none}";
|
|
$style[] = "img{display:block;margin:20px 0}";
|
|
$style[] = "img:hover{transform:scale(1.1)}";
|
|
$style[] = "</style>";
|
|
|
|
$script = ["<script>"];
|
|
$script[] = "function config_cleanUp(id,file) {";
|
|
$script[] = " if (document.hasFocus()) {";
|
|
$script[] = " $('#'+id).val(\""._('Download')."\").prop('disabled',false);";
|
|
$script[] = " $.post('/webGui/include/Download.php',{cmd:'delete',file:file});";
|
|
$script[] = " } else {";
|
|
$script[] = " setTimeout(function(){config_cleanUp(id,file);},1000);";
|
|
$script[] = " }";
|
|
$script[] = "}";
|
|
$script[] = "function config_download(id,source,file) {";
|
|
$script[] = " $('#'+id).val(\""._('Downloading')."...\").prop('disabled',true);";
|
|
$script[] = " $.post('/webGui/include/Download.php',{cmd:'save',source:source+'.conf',file:file,opts:'qj'},function(){";
|
|
$script[] = " $.post('/webGui/include/Download.php',{cmd:'save',source:source+'.png',file:file,opts:'qj'},function(zip){";
|
|
$script[] = " location = zip;";
|
|
$script[] = " setTimeout(function(){config_cleanUp(id,file);},1000);";
|
|
$script[] = " });";
|
|
$script[] = " });";
|
|
$script[] = "}";
|
|
$script[] = "</script>";
|
|
|
|
$html = [];
|
|
$html[] = "<h2>".($argv[2] ? _('Remote peer configuration') : _('Local server configuration'))."</h2>";
|
|
$html[] = "<div><input type='button' id='download' value=\""._('Download')."\" onclick=\"config_download(this.id,'$path/$file','$file.zip')\"></div>";
|
|
$html[] = "<pre class='config'>";
|
|
$html[] = @file_get_contents("$path/$file.conf");
|
|
$html[] = "\n";
|
|
$html[] = "</pre>";
|
|
if (is_file("$path/$file.png")) {
|
|
@unlink("$docroot/$file.png");
|
|
symlink("$path/$file.png", "$docroot/$file.png");
|
|
$html[] = "<img src=\"/$file.png?v=".filemtime("$path/$file.png")."\">";
|
|
}
|
|
|
|
echo implode($style),implode($script),implode($html);
|
|
?>
|