mirror of
https://github.com/unraid/webgui.git
synced 2026-01-14 05:30:07 -06:00
Preserve reboot notices across pages
This commit is contained in:
@@ -30,36 +30,57 @@ function download_url($url, $path = "") {
|
||||
|
||||
return $out ?: false;
|
||||
}
|
||||
file_put_contents("/tmp/trace",$_POST['action']);
|
||||
switch ($_POST['action']) {
|
||||
case 'checkPlugin':
|
||||
$options = $_POST['options'];
|
||||
$plugin = $options['plugin'];
|
||||
|
||||
$options = $_POST['options'];
|
||||
$plugin = $options['plugin'];
|
||||
if ( ! $plugin || ! file_exists("/var/log/plugins/$plugin") ) {
|
||||
echo json_encode(array("updateAvailable"=>false));
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $plugin || ! file_exists("/var/log/plugins/$plugin") ) {
|
||||
echo json_encode(array("updateAvailable"=>false));
|
||||
return;
|
||||
}
|
||||
exec("mkdir -p /tmp/plugins");
|
||||
@unlink("/tmp/plugins/$plugin");
|
||||
$url = @plugin("pluginURL","/boot/config/plugins/$plugin");
|
||||
download_url($url,"/tmp/plugins/$plugin");
|
||||
|
||||
exec("mkdir -p /tmp/plugins");
|
||||
@unlink("/tmp/plugins/$plugin");
|
||||
$url = @plugin("pluginURL","/boot/config/plugins/$plugin");
|
||||
download_url($url,"/tmp/plugins/$plugin");
|
||||
$changes = @plugin("changes","/tmp/plugins/$plugin");
|
||||
$version = @plugin("version","/tmp/plugins/$plugin");
|
||||
$installedVersion = @plugin("version","/boot/config/plugins/$plugin");
|
||||
$min = @plugin("min","/tmp/plugins/$plugin") ?: "6.4.0";
|
||||
if ( $changes ) {
|
||||
file_put_contents("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt",$changes);
|
||||
} else {
|
||||
@unlink("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt");
|
||||
}
|
||||
|
||||
$changes = @plugin("changes","/tmp/plugins/$plugin");
|
||||
$version = @plugin("version","/tmp/plugins/$plugin");
|
||||
$installedVersion = @plugin("version","/boot/config/plugins/$plugin");
|
||||
$min = @plugin("min","/tmp/plugins/$plugin") ?: "6.4.0";
|
||||
if ( $changes ) {
|
||||
file_put_contents("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt",$changes);
|
||||
} else {
|
||||
@unlink("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt");
|
||||
}
|
||||
|
||||
$update = false;
|
||||
if ( strcmp($version,$installedVersion) > 0 ) {
|
||||
$unraid = parse_ini_file("/etc/unraid-version");
|
||||
$update = (version_compare($min,$unraid['version'],">")) ? false : true;
|
||||
}
|
||||
|
||||
echo json_encode(array("updateAvailable" => $update,"version" => $version,"min"=>$min,"changes"=>$changes,"installedVersion"=>$installedVersion));
|
||||
$update = false;
|
||||
if ( strcmp($version,$installedVersion) > 0 ) {
|
||||
$unraid = parse_ini_file("/etc/unraid-version");
|
||||
$update = (version_compare($min,$unraid['version'],">")) ? false : true;
|
||||
}
|
||||
|
||||
echo json_encode(array("updateAvailable" => $update,"version" => $version,"min"=>$min,"changes"=>$changes,"installedVersion"=>$installedVersion));
|
||||
break;
|
||||
|
||||
case 'addRebootNotice':
|
||||
$message = htmlspecialchars(trim($_POST['message']));
|
||||
if (!$message) break;
|
||||
|
||||
$existing = @file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: array();
|
||||
$existing[] = $message;
|
||||
|
||||
file_put_contents("/tmp/reboot_notifications",implode("\n",array_unique($existing)));
|
||||
break;
|
||||
|
||||
case 'removeRebootNotice':
|
||||
$message = htmlspecialchars(trim($_POST['message']));
|
||||
$existing = file_get_contents("/tmp/reboot_notifications");
|
||||
$newReboots = str_replace($message,"",$existing);
|
||||
file_put_contents("/tmp/reboot_notifications",$newReboots);
|
||||
file_put_contents("/tmp/blah","here");
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user