Replace nchan communication for post request

Informational functions which call "openChanges" are now processed using post requests, this solves the issue that sometimes an empty window is displayed.
This commit is contained in:
bergware
2022-11-08 22:15:15 +01:00
parent 1b66da4edd
commit 7207cb07ec
8 changed files with 23 additions and 153 deletions
+1 -16
View File
@@ -22,21 +22,6 @@ $_SERVER['REQUEST_URI'] = '';
$login_locale = $display['locale'];
require_once "$docroot/webGui/include/Translations.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/feedback?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
}
$var = parse_ini_file('state/var.ini');
$unraid = parse_ini_file('/etc/unraid-version');
$keyfile = trim(base64_encode(@file_get_contents($var['regFILE'])));
@@ -190,5 +175,5 @@ $script[] = " \$('#optFeatureRequest').click();";
$script[] = "});";
$script[] = "</script>";
write(implode($style).implode($html).implode($script),'_DONE_','');
echo implode($style),implode($html),implode($script);
?>
+1 -15
View File
@@ -24,20 +24,6 @@ require_once "$docroot/webGui/include/Translations.php";
$month = [' Jan '=>'-01-',' Feb '=>'-02-',' Mar '=>'-03-',' Apr '=>'-04-',' May '=>'-05-',' Jun '=>'-06-',' Jul '=>'-07-',' Aug '=>'-08-',' Sep '=>'-09-',' Oct '=>'-10-',' Nov '=>'-11-',' Dec '=>'-12-'];
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/phistory?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
}
function this_plus($val, $word, $last) {
return $val>0 ? (($val||$last)?($val.' '.$word.($last?'':', ')):'') : '';
}
@@ -80,5 +66,5 @@ if ($list) {
} else {
$list[] = "<tr><td colspan='7' style='text-align:center;padding-top:12px'>"._('No parity check history present')."!</td></tr>";
}
write($head.implode($list)."</table>",'_DONE_','');
echo $head,implode($list),"</table>";
?>
+1 -16
View File
@@ -22,21 +22,6 @@ $_SERVER['REQUEST_URI'] = 'dashboard';
$login_locale = $display['locale'];
require_once "$docroot/webGui/include/Translations.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/selectcase?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
}
$boot = "/boot/config/plugins/dynamix";
$file = $argv[1];
$exist = is_file("$boot/$file");
@@ -86,5 +71,5 @@ $html[] = "</div></div>";
$html[] = "<input type='file' id='file' accept='.png' onchange='importFile(this.files[0])' style='display:none'>";
$html[] = "</div>";
write(implode($style).implode($script).implode($html),'_DONE_','');
echo implode($style),implode($script),implode($html);
?>
+1 -15
View File
@@ -22,20 +22,6 @@ $_SERVER['REQUEST_URI'] = '';
$login_locale = $display['locale'];
require_once "$docroot/webGui/include/Translations.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/sysinfo?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
}
function dmidecode($key, $n, $all=true) {
$entries = array_filter(explode($key,shell_exec("dmidecode -qt$n")));
$properties = [];
@@ -192,5 +178,5 @@ $list[] = "<tr><td>"._('Kernel').":</td><td>$kernel</td></tr>";
$list[] = "<tr><td>"._('OpenSSL').":</td><td>$openssl</td></tr>";
$list[] = "<tr><td>"._('Uptime').":</td><td><span class='uptime'></span></td></tr></table>";
write($style.implode($list),'_DONE_','');
echo $style,implode($list);
?>
+1 -17
View File
@@ -22,22 +22,6 @@ $_SERVER['REQUEST_URI'] = 'settings';
$login_locale = $display['locale'];
require_once "$docroot/webGui/include/Translations.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/changes?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
}
unset($argv[$argc-1]); // remove nchan parameter
$file = $argv[1];
$path = realpath('/etc/wireguard'.($argv[2]??''));
$root = '/boot/config/wireguard';
@@ -83,5 +67,5 @@ if (is_file("$path/$file.png")) {
$html[] = "<img src=\"/$file.png?v=".filemtime("$path/$file.png")."\">";
}
write(implode($style).implode($script).implode($html),'_DONE_','');
echo implode($style),implode($script),implode($html);
?>