Use "null coalescing assignment" operator for $docroot

This commit is contained in:
bergware
2023-10-26 14:00:15 +02:00
parent a671e237a0
commit ceeb125ba9
109 changed files with 726 additions and 743 deletions

View File

@@ -12,7 +12,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2014-2022, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2022, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$user_prefs = $dockerManPaths['user-prefs'];

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2020, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2015-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,10 +12,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
libxml_use_internal_errors(true);
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
@@ -398,6 +396,7 @@ function addConfigPopup() {
// Start Dialog section
popup.dialog({
title: title,
height: 'auto',
width: 900,
resizable: false,
modal: true,
@@ -466,6 +465,7 @@ function editConfigPopup(num,disabled) {
popup.find(".switch-button-background").css("margin-top", "6px");
popup.dialog({
title: title,
height: 'auto',
width: 900,
resizable: false,
modal: true,

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,10 +12,7 @@
*/
?>
<?
libxml_use_internal_errors(true); # Suppress any warnings from xml errors.
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/Helpers.php";
require_once "$docroot/webGui/include/Wrappers.php";
@@ -56,8 +53,8 @@ if (file_exists($docker_cfgfile) && exec("grep -Pom1 '_{$port}(_[0-9]+)?=' $dock
exec("sed -ri 's/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_{$port}\\2=/' $docker_cfgfile");
}
$defaults = @parse_ini_file("$docroot/plugins/dynamix.docker.manager/default.cfg") ?: [];
$dockercfg = array_replace_recursive($defaults, @parse_ini_file($docker_cfgfile) ?: []);
$defaults = (array)@parse_ini_file("$docroot/plugins/dynamix.docker.manager/default.cfg");
$dockercfg = array_replace_recursive($defaults, (array)@parse_ini_file($docker_cfgfile));
function var_split($item, $i=0) {
return array_pad(explode(' ',$item),$i+1,'')[$i];

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
@@ -34,7 +33,7 @@ if (!$containers && !$images) {
}
if (file_exists($user_prefs)) {
$prefs = @parse_ini_file($user_prefs) ?: [];
$prefs = (array)@parse_ini_file($user_prefs);
$sort = [];
foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs);
array_multisort($sort,SORT_NUMERIC,$containers);
@@ -46,7 +45,7 @@ $allInfo = $DockerTemplates->getAllInfo();
$docker = [];
$null = '0.0.0.0';
$autostart = @file($autostart_file,FILE_IGNORE_NEW_LINES) ?: [];
$autostart = (array)@file($autostart_file,FILE_IGNORE_NEW_LINES);
$names = array_map('var_split',$autostart);
function my_lang_time($text) {

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2014-2022, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2022, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$ncsi = exec("wget --spider --no-check-certificate -nv -T10 -t1 https://www.msftncsi.com/ncsi.txt 2>&1|grep -o 'OK'")=='OK';

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$autostart_file = $dockerManPaths['autostart-file'];
@@ -25,7 +25,7 @@ case 'autostart':
$container = urldecode(($_POST['container']));
$wait = $_POST['wait'];
$item = rtrim("$container $wait");
$autostart = @file($autostart_file, FILE_IGNORE_NEW_LINES) ?: [];
$autostart = (array)@file($autostart_file, FILE_IGNORE_NEW_LINES);
$key = array_search($item, $autostart);
if ($_POST['auto']=='true') {
if ($key===false) $autostart[] = $item;
@@ -48,7 +48,7 @@ case 'wait':
$container = urldecode(($_POST['container']));
$wait = $_POST['wait'];
$item = rtrim("$container $wait");
$autostart = file($autostart_file, FILE_IGNORE_NEW_LINES) ?: [];
$autostart = (array)@file($autostart_file, FILE_IGNORE_NEW_LINES);
$names = array_map('var_split', $autostart);
$autostart[array_search($container,$names)] = $item;
file_put_contents($autostart_file, implode("\n", $autostart)."\n");

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2015-2018, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2018, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$autostart_file = $dockerManPaths['autostart-file'];

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -1,8 +1,8 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -13,8 +13,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
extract(parse_plugin_cfg('dynamix', true));
@@ -45,7 +44,7 @@ if (!isset($check)) {
echo " Done.";
} else {
$notify = "$docroot/webGui/scripts/notify";
$var = @parse_ini_file("/var/local/emhttp/var.ini") ?: [];
$var = (array)@parse_ini_file("/var/local/emhttp/var.ini");
$server = strtoupper(_var($var,'NAME','tower'));
$output = _var($notify,'docker_notify');
$info = $DockerTemplates->getAllInfo(true);

View File

@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$DockerClient = new DockerClient();

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -1,5 +1,5 @@
<?php
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
<?PHP
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$var = (array)parse_ini_file('state/var.ini');
require_once "$docroot/webGui/include/Wrappers.php";

View File

@@ -1,5 +1,5 @@
<?php
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
<?PHP
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once("$docroot/plugins/dynamix.my.servers/include/state.php");
require_once("$docroot/plugins/dynamix.my.servers/include/translations.php");
?>

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/webGui/include/Secure.php";

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";

View File

@@ -10,12 +10,13 @@
* all copies or substantial portions of the Software.
*/
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
require_once "$docroot/plugins/dynamix/include/Secure.php";
//add translations
$_SERVER['REQUEST_URI'] = "plugins";
require_once "$docroot/plugins/dynamix/include/Translations.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
require_once "$docroot/plugins/dynamix/include/Secure.php";
function download_url($url, $path = "") {
$ch = curl_init();
@@ -39,21 +40,17 @@ switch ($_POST['action']) {
case 'checkPlugin':
$options = $_POST['options'] ?? '';
$plugin = $options['plugin'] ?? '';
$name = unbundle($options['name'] ?? $plugin);
$file = "/boot/config/plugins/$plugin";
$file = realpath($file)==$file ? $file : "";
if ( ! $plugin || ! file_exists($file) ) {
echo json_encode(["updateAvailable"=>false]);
break;
}
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");
$alerts = plugin("alert","/tmp/plugins/$plugin");
$version = plugin("version","/tmp/plugins/$plugin");
@@ -69,7 +66,6 @@ switch ($_POST['action']) {
} else {
@unlink('/tmp/plugins/my_alerts.txt');
}
$update = false;
if ( strcmp($version,$installedVersion) > 0 ) {
$unraid = parse_ini_file("/etc/unraid-version");
@@ -77,17 +73,14 @@ switch ($_POST['action']) {
}
$updateMessage = sprintf(_("%s: An update is available."),$name);
$linkMessage = sprintf(_("Click here to install version %s"),$version);
echo json_encode(["updateAvailable"=>$update, "version"=>$version, "min"=>$min, "alert"=>$alerts, "changes"=>$changes, "installedVersion"=>$installedVersion, "updateMessage"=>$updateMessage, "linkMessage"=>$linkMessage]);
break;
case 'addRebootNotice':
$message = htmlspecialchars(trim($_POST['message']));
if ( ! $message ) break;
$existing = @file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];
if (!$message) break;
$existing = (array)@file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$existing[] = $message;
file_put_contents("/tmp/reboot_notifications",implode("\n",array_unique($existing)));
break;

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
extract(parse_plugin_cfg('dynamix', true));
@@ -23,7 +22,7 @@ $_SERVER['REQUEST_URI'] = "scripts";
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
function apos($text) {
// So that "&apos;" doesn't show up in email

View File

@@ -12,11 +12,9 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
extract(parse_plugin_cfg('dynamix',true));
// Multi-language support
@@ -24,7 +22,7 @@ $_SERVER['REQUEST_URI'] = "scripts";
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
function apos($text) {
// So that "&apos;" doesn't show up in email

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -12,8 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
@@ -24,7 +23,7 @@ if (!function_exists('_')) {
extract(parse_plugin_cfg('dynamix', true));
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
$script = "$docroot/webGui/scripts/notify";
$server = strtoupper(_var($var,'NAME','server'));
$output = _var($notify,'plugin');

View File

@@ -6,8 +6,8 @@ Markdown="false"
---
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -18,7 +18,7 @@ Markdown="false"
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$cpus = cpu_list();
@@ -146,14 +146,10 @@ function getisoimageboth(uuid,dev,bus,file,dev2,bus2,file2){
var box = $("#dialogWindow");
box.html($("#templateISOboth").html());
box.find('#target').attr('value',file).fileTreeAttach(null,null,function(path){
var bits = path.substr(1).split('/');
var auto = bits.length>3 ? '' : share;
box.find('#target').val(path+auto).change();
box.find('#target').val(path).change();
});
box.find('#target2').attr('value',file2).fileTreeAttach(null,null,function(path){
var bits = path.substr(1).split('/');
var auto = bits.length>3 ? '' : share;
box.find('#target2').val(path+auto).change();
box.find('#target2').val(path).change();
});
box.dialog({
title: "_(Select ISOs for CDROMs)_",
@@ -183,9 +179,7 @@ function getisoimage(uuid,dev,bus,file){
var box = $("#dialogWindow");
box.html($("#templateISO").html());
box.find('#target').attr('value',file).fileTreeAttach(null,null,function(path){
var bits = path.substr(1).split('/');
var auto = bits.length>3 ? '' : share;
box.find('#target').val(path+auto).change();
box.find('#target').val(path).change();
});
box.dialog({
title: "_(Select ISO)_",
@@ -217,6 +211,7 @@ function VMClone(uuid, name){
document.getElementById("Overwrite").checked = true;
box.dialog({
title: "_(VM Clone)_",
height: 'auto',
width: 600,
resizable: false,
modal: true,
@@ -263,6 +258,7 @@ function selectsnapshot(uuid, name ,snaps, opt, getlist,state){
document.getElementById("targetsnapfspc").checked = true;
box.dialog({
title: optiontext,
height: 'auto',
width: 600,
resizable: false,
modal: true,
@@ -335,6 +331,7 @@ function selectblock(uuid, name, snaps, opt, getlist, state){
}
box.dialog({
title: optiontext,
height: 'auto',
width: 600,
resizable: false,
modal: true,

View File

@@ -5,7 +5,8 @@ Markdown="false"
---
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -16,7 +17,7 @@ Markdown="false"
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
foreach($arrAllTemplates as $strName => $arrTemplate):

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,14 +12,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// get Fedora download archive
$fedora = '/var/tmp/fedora-virtio-isos';
$archive = 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio';

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,13 +12,13 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
if (file_exists('/boot/config/plugins/dynamix.vm.manager/vmpreview')) $vmpreview = true ; else $vmpreview = false ;
@@ -28,7 +28,7 @@ if (empty($vms)) {
return;
}
if (file_exists($user_prefs)) {
$prefs = @parse_ini_file($user_prefs) ?: [];
$prefs = (array)@parse_ini_file($user_prefs);
$sort = [];
foreach ($vms as $vm) $sort[] = array_search($vm,$prefs);
array_multisort($sort,SORT_NUMERIC,$vms);
@@ -185,7 +185,7 @@ foreach ($vms as $vm) {
$changemedia = "getisoimageboth(\"{$uuid}\",\"hda\",\"{$cdbus}\",\"{$cdfile}\",\"hdb\",\"{$cdbus2}\",\"{$cdfile2}\")";
$title = _('Select ISO image');
$cdstr = $cdromcount." / 2<a class='hand' title='$title' href='#' onclick='$changemedia'><i class='fa fa-bullseye' ></i></a>";
$cdstr = $cdromcount." / 2<a class='hand' title='$title' href='#' onclick='$changemedia'><i class='fa fa-floppy-o'></i></a>";
echo "<tr parent-id='$i' class='sortable'><td class='vm-name' style='width:220px;padding:8px'><i class='fa fa-arrows-v mover orange-text'></i>";
echo "<span class='outer'><span id='vm-$uuid' $menu class='hand'>$image</span><span class='inner'><a href='#' onclick='return toggle_id(\"name-$i\")' title='click for more VM info'>$vm</a><br><i class='fa fa-$shape $status $color'></i><span class='state'>"._($status)." $snapshotstcount</span></span></span></td>";
echo "<td>$desc</td>";
@@ -248,7 +248,7 @@ foreach ($vms as $vm) {
$title = _('Insert CD');
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\",\"--select\")";
$disk = _("No CD image inserted in to drive");
echo "<tr><td>$disk<a title='$title' href='#' onclick='$changemedia'><i class='fa fa-bullseye'></i></a></td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
echo "<tr><td>$disk<a title='$title' href='#' onclick='$changemedia'><i class='fa fa-floppy-o'></i></a></td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
}
}
echo "</tbody>";

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2015-2020, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2020, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,7 +12,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,13 +12,13 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
function requireLibvirt() {
global $lv;

View File

@@ -1,6 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-2023, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -11,14 +12,15 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
}
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
switch ($display['theme']) {
case 'gray' : $bgcolor = '#121510'; $border = '#606e7f'; $top = -44; break;

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -42,7 +42,8 @@
* Usage:
* $xml = Array2XML::createXML('root_node_name', $php_array);
* echo $xml->saveXML();
*/
**/
class Array2XML {
private static $xml = null;
private static $encoding = 'UTF-8';
@@ -160,8 +161,7 @@ private static $encoding = 'UTF-8';
}
}
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt.php";
require_once "$docroot/webGui/include/Custom.php";
@@ -756,13 +756,13 @@ private static $encoding = 'UTF-8';
$arrWhitelistGPUClassIDregex = '/^(0001|03)/';
$arrWhitelistAudioClassIDregex = '/^(0403)/';
# "System peripheral [0880]" "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" -pff "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]"
# "System peripheral [0880]" "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" -pff "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]"
# typeid productid
# file is csv typeid:productid
#
if (is_file("/boot/config/VMPCIOverride.cfg")) {
$arrWhiteListOverride = str_getcsv(file_get_contents("/boot/config/VMPCIOverride.cfg")) ;
}
}
$arrWhiteListOverride[] = "0880:089a" ;
$arrValidPCIDevices = [];
@@ -1498,7 +1498,7 @@ private static $encoding = 'UTF-8';
*/
$uuid = $lv->domain_get_uuid($clone) ;
write("addLog\0".htmlspecialchars(_("Checking if clone exists")));
if ($uuid) { $arrResponse = ['error' => _("Clone VM name already inuse")]; return false ;}
if ($uuid) { $arrResponse = ['error' => _("Clone VM name already inuse")]; return false ;}
#VM must be shutdown.
$res = $lv->get_domain_by_name($vm);
$dom = $lv->domain_get_info($res);
@@ -1518,18 +1518,18 @@ private static $encoding = 'UTF-8';
$pathinfo = pathinfo($file) ;
$capacity = $capacity + $disk["capacity"] ;
}
#Check free space.
write("addLog\0".htmlspecialchars("Checking for free space"));
$dirfree = disk_free_space($pathinfo["dirname"]) ;
$sourcedir = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($pathinfo["dirname"])." 2>/dev/null"));
$sourcedir = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($pathinfo["dirname"])." 2>/dev/null"));
$repdir = str_replace('/mnt/user/', "/mnt/$sourcedir/", $pathinfo["dirname"]);
$repdirfree = disk_free_space($repdir) ;
$reflink = true ;
$capacity *= 1 ;
if ($free == "yes" && $repdirfree < $capacity) { $reflink = false ;}
if ($free == "yes" && $dirfree < $capacity) { write("addLog\0".htmlspecialchars(_("Insufficent storage for clone"))); return false ;}
if ($free == "yes" && $dirfree < $capacity) { write("addLog\0".htmlspecialchars(_("Insufficent storage for clone"))); return false ;}
#Clone XML
$uuid = $lv->domain_get_uuid($vm) ;
@@ -1567,17 +1567,17 @@ private static $encoding = 'UTF-8';
chgrp($clonedir, 'users');
}
write("addLog\0".htmlspecialchars("Checking for image files"));
if ($file_exists && $overwrite != "yes") { write("addLog\0".htmlspecialchars(_("New image file names exist and Overwrite is not allowed"))); return( false) ; }
if ($file_exists && $overwrite != "yes") { write("addLog\0".htmlspecialchars(_("New image file names exist and Overwrite is not allowed"))); return( false) ; }
#Create duplicate files.
foreach($file_clone as $diskid => $disk) {
$target = $disk['target'] ;
$source = $disk['source'] ;
if ($target == $source) { write("addLog\0".htmlspecialchars(_("New image file is same as old"))); return( false) ; }
$sourcerealdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($source)." 2>/dev/null"));
$source = $disk['source'] ;
if ($target == $source) { write("addLog\0".htmlspecialchars(_("New image file is same as old"))); return( false) ; }
$sourcerealdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($source)." 2>/dev/null"));
$reptgt = str_replace('/mnt/user/', "/mnt/$sourcerealdisk/", $target);
$repsrc = str_replace('/mnt/user/', "/mnt/$sourcerealdisk/", $source);
$cmdstr = "cp --reflink=always '$repsrc' '$reptgt'" ;
if ($reflink == true) { $refcmd = $cmdstr ; } else {$refcmd = false; }
$cmdstr = "rsync -ahPIXS --out-format=%f --info=flist0,misc0,stats0,name1,progress2 '$source' '$target'" ;
@@ -1592,23 +1592,23 @@ private static $encoding = 'UTF-8';
file_put_contents("/tmp/clonexml" ,$xml) ;
$rtn = $lv->domain_define($xml) ;
return($rtn) ;
}
function compare_creationtime($a, $b) {
return strnatcmp($a['creationtime'], $b['creationtime']);
}
}
function compare_creationtimelt($a, $b) {
return $a['creationtime'] < $b['creationtime'];
}
}
function getvmsnapshots($vm) {
$snaps=array() ;
$dbpath = "/etc/libvirt/qemu/snapshot/$vm" ;
$snaps_json = file_get_contents($dbpath."/snapshots.db") ;
$snaps = json_decode($snaps_json,true) ;
$snaps = json_decode($snaps_json,true) ;
if (is_array($snaps)) uasort($snaps,'compare_creationtime') ;
return $snaps ;
}
@@ -1618,7 +1618,7 @@ private static $encoding = 'UTF-8';
$dbpath = "/etc/libvirt/qemu/snapshot/$vm" ;
if (!is_dir($dbpath)) mkdir($dbpath) ;
$snaps_json = file_get_contents($dbpath."/snapshots.db") ;
$snaps = json_decode($snaps_json,true) ;
$snaps = json_decode($snaps_json,true) ;
$snapshot_res=$lv->domain_snapshot_lookup_by_name($vm,$name) ;
$snapshot_xml=$lv->domain_snapshot_get_xml($snapshot_res) ;
$a = simplexml_load_string($snapshot_xml) ;
@@ -1639,10 +1639,10 @@ private static $encoding = 'UTF-8';
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ;
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line) ;
$output[$key] = $line ;
$output[$key] = $line ;
}
$snaps[$vmsnap]['backing'][$disk["device"]] = $output ;
$snaps[$vmsnap]['backing'][$disk["device"]] = $output ;
$rev = "r".$disk["device"] ;
$reversed = array_reverse($output) ;
$snaps[$vmsnap]['backing'][$rev] = $reversed ;
@@ -1655,7 +1655,7 @@ private static $encoding = 'UTF-8';
if (array_key_exists(0 , $b["disks"]["disk"])) $snaps[$vmsnap]["disks"]= $b["disks"]["disk"]; else $snaps[$vmsnap]["disks"][0]= $b["disks"]["disk"];
$value = json_encode($snaps,JSON_PRETTY_PRINT) ;
file_put_contents($dbpath."/snapshots.db",$value) ;
}
@@ -1665,7 +1665,7 @@ private static $encoding = 'UTF-8';
$dbpath = "/etc/libvirt/qemu/snapshot/$vm" ;
if (!is_dir($dbpath)) mkdir($dbpath) ;
$snaps_json = file_get_contents($dbpath."/snapshots.db") ;
$snaps = json_decode($snaps_json,true) ;
$snaps = json_decode($snaps_json,true) ;
foreach($snaps as $vmsnap=>$snap)
$disks =$lv->get_disk_stats($vm) ;
@@ -1675,10 +1675,10 @@ private static $encoding = 'UTF-8';
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ;
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line) ;
$output[$key] = $line ;
$output[$key] = $line ;
}
$snaps[$vmsnap]['backing'][$disk["device"]] = $output ;
$snaps[$vmsnap]['backing'][$disk["device"]] = $output ;
$rev = "r".$disk["device"] ;
$reversed = array_reverse($output) ;
$snaps[$vmsnap]['backing'][$rev] = $reversed ;
@@ -1688,7 +1688,7 @@ private static $encoding = 'UTF-8';
$snaps[$vmsnap]["parent"]= $parendfileinfo["extension"];
$snaps[$vmsnap]["parent"] = str_replace("qcow2",'',$snaps[$vmsnap]["parent"]) ;
if (isset($parentfind[1]) && !isset($parentfind[2])) $snaps[$vmsnap]["parent"]="Base" ;
$value = json_encode($snaps,JSON_PRETTY_PRINT) ;
$res = $lv->get_domain_by_name($vm);
#if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_create_snapshot($lv->domain_get_uuid($vm),$name) ;
@@ -1697,12 +1697,12 @@ private static $encoding = 'UTF-8';
#Remove any NVRAMs that are no longer valid.
# Get uuid
$vmuuid = $lv->domain_get_uuid($vm) ;
#Get list of files
#$filepath = "/etc/libvirt/qemu/nvram/'.$uuid*" ; #$snapshotname"
$filepath = "/etc/libvirt/qemu/nvram/$vmuuid*" ; #$snapshotname"
#Get list of files
#$filepath = "/etc/libvirt/qemu/nvram/'.$uuid*" ; #$snapshotname"
$filepath = "/etc/libvirt/qemu/nvram/$vmuuid*" ; #$snapshotname"
$nvram_files=glob($filepath) ;
foreach($nvram_files as $key => $nvram_file) {
if ($nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi.fd" || $nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi-tpm.fd" ) unset($nvram_files[$key]) ;
if ($nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi.fd" || $nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi-tpm.fd" ) unset($nvram_files[$key]) ;
foreach ($snaps as $snapshotname => $snap) {
$tpmfilename = "/etc/libvirt/qemu/nvram/".$vmuuid.$snapshotname."_VARS-pure-efi-tpm.fd" ;
$nontpmfilename = "/etc/libvirt/qemu/nvram/".$vmuuid.$snapshotname."_VARS-pure-efi.fd" ;
@@ -1712,7 +1712,7 @@ private static $encoding = 'UTF-8';
}
foreach ($nvram_files as $nvram_file) unlink($nvram_file) ;
file_put_contents($dbpath."/snapshots.db",$value) ;
}
@@ -1720,7 +1720,7 @@ private static $encoding = 'UTF-8';
global $lv ;
$dbpath = "/etc/libvirt/qemu/snapshot/$vm" ;
$snaps_json = file_get_contents($dbpath."/snapshots.db") ;
$snaps = json_decode($snaps_json,true) ;
$snaps = json_decode($snaps_json,true) ;
unset($snaps[$name]) ;
$value = json_encode($snaps,JSON_PRETTY_PRINT) ;
file_put_contents($dbpath."/snapshots.db",$value) ;
@@ -1730,19 +1730,19 @@ private static $encoding = 'UTF-8';
function vm_snapshot($vm,$snapshotname, $snapshotdesc, $free = "yes", $memorysnap = "yes") {
global $lv ;
#Get State
$res = $lv->get_domain_by_name($vm);
$dom = $lv->domain_get_info($res);
$state = $lv->domain_state_translate($dom['state']);
#Get disks for --diskspec
#Get disks for --diskspec
$disks =$lv->get_disk_stats($vm) ;
$diskspec = "" ;
$capacity = 0 ;
if ($snapshotname == "--generate") $name= "S" . date("YmdHis") ; else $name=$snapshotname ;
if ($snapshotdesc != "") $snapshotdesc = " --description '$snapshotdesc'" ;
foreach($disks as $disk) {
$file = $disk["file"] ;
$pathinfo = pathinfo($file) ;
@@ -1754,38 +1754,38 @@ private static $encoding = 'UTF-8';
#get memory
$mem = $lv->domain_get_memory_stats($vm) ;
$memory = $mem[6] ;
if ($memorysnap = "yes") $memspec = ' --memspec "'.$pathinfo["dirname"].'/memory'.$name.'.mem",snapshot=external' ; else $memspec = "" ;
$cmdstr = "virsh snapshot-create-as '$vm' --name '$name' $snapshotdesc --atomic" ;
if ($state == "running") {
$cmdstr .= " --live ".$memspec.$diskspec ;
$capacity = $capacity + $memory ;
} else {
$cmdstr .= " --disk-only ".$diskspec ;
$cmdstr .= " --disk-only ".$diskspec ;
}
#Check free space.
$dirfree = disk_free_space($pathinfo["dirname"]) ;
$capacity *= 1 ;
if ($free == "yes" && $dirfree < $capacity) { $arrResponse = ['error' => _("Insufficent Storage for Snapshot")]; return $arrResponse ;}
if ($free == "yes" && $dirfree < $capacity) { $arrResponse = ['error' => _("Insufficent Storage for Snapshot")]; return $arrResponse ;}
#Copy nvram
if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_create_snapshot($lv->domain_get_uuid($vm),$name) ;
$xmlfile = $pathinfo["dirname"]."/".$name.".running" ;
file_put_contents("/tmp/xmltst", "$xmlfile" ) ;
if ($state == "running") exec("virsh dumpxml '$vm' > ".escapeshellarg($xmlfile),$outxml,$rtnxml) ;
$output= [] ;
$test = false ;
if ($test) exec($cmdstr." --print-xml 2>&1",$output,$return) ; else exec($cmdstr." 2>&1",$output,$return) ;
if (strpos(" ".$output[0],"error") ) {
if (strpos(" ".$output[0],"error") ) {
$arrResponse = ['error' => substr($output[0],6) ] ;
} else {
$arrResponse = ['success' => true] ;
@@ -1803,8 +1803,8 @@ private static $encoding = 'UTF-8';
$disks =$lv->get_disk_stats($vm) ;
switch ($snapslist[$snap]['state']) {
case "shutoff":
case "running":
case "shutoff":
case "running":
#VM must be shutdown.
$res = $lv->get_domain_by_name($vm);
$dom = $lv->domain_get_info($res);
@@ -1817,7 +1817,7 @@ private static $encoding = 'UTF-8';
$xmlobj = custom::createArray('domain',$strXML) ;
# Process disks and update path.
$disks=($snapslist[$snap]['disks']) ;
$disks=($snapslist[$snap]['disks']) ;
foreach ($disks as $disk) {
$diskname = $disk["@attributes"]["name"] ;
if ($diskname == "hda" || $diskname == "hdb") continue ;
@@ -1859,7 +1859,7 @@ private static $encoding = 'UTF-8';
$item++ ;
}
}
uasort($snapslist,'compare_creationtimelt') ;
foreach($snapslist as $s) {
$name = $s['name'] ;
@@ -1877,13 +1877,13 @@ private static $encoding = 'UTF-8';
# Restore Memory.
$makerun = true ;
if ($makerun == true) exec("virsh restore ".escapeshellarg($memoryfile)) ;
#exec("virsh restore $memoryfile") ;
}
if ($makerun == true) exec("virsh restore ".escapeshellarg($memoryfile)) ;
#exec("virsh restore $memoryfile") ;
}
#Delete Metadata only.
if ($actionmeta == "yes") {
if ($actionmeta == "yes") {
$ret = delete_snapshots_database("$vm","$name") ;
}
}
if (is_file($memoryfile) && $action == "yes") unlink($memoryfile) ;
if (is_file($xmlfile) && $action == "yes") unlink($xmlfile) ;
if ($s['name'] == $snap) break ;
@@ -1891,11 +1891,11 @@ private static $encoding = 'UTF-8';
#if VM was started restart.
if ($state == 'running' && $snapslist[$snap]['state'] != "running") {
$arrResponse = $lv->domain_start($vm) ;
}
}
if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_revert_snapshot($lv->domain_get_uuid($vm),$name) ;
break ;
}
$arrResponse = ['success' => true] ;
return($arrResponse) ;
@@ -1914,9 +1914,9 @@ private static $encoding = 'UTF-8';
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ;
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line) ;
$output[$key] = $line ;
$output[$key] = $line ;
}
$snaps[$vm][$disk["device"]] = $output ;
$snaps[$vm][$disk["device"]] = $output ;
$rev = "r".$disk["device"] ;
$reversed = array_reverse($output) ;
$snaps[$vm][$rev] = $reversed ;
@@ -1927,7 +1927,7 @@ private static $encoding = 'UTF-8';
}
$snapdisks= $snapslist[$snap]['disks'] ;
foreach ($snapdisks as $diskkey => $snapdisk) {
$diskname = $snapdisk["@attributes"]["name"] ;
if ($diskname == "hda" || $diskname == "hdb") continue ;
@@ -1940,7 +1940,7 @@ private static $encoding = 'UTF-8';
{
if (!isset($snaps[$vm]["r".$diskname][$item])) break ;
$newpath = $snaps[$vm]["r".$diskname][$item] ;
if (is_file($path)) $data .= "$newpath<br>" ;
if (is_file($path)) $data .= "$newpath<br>" ;
$item++ ;
}
@@ -1958,7 +1958,7 @@ private static $encoding = 'UTF-8';
}
return($data) ;
}
function vm_snapremove($vm, $snap) {
global $lv ;
@@ -1973,10 +1973,10 @@ private static $encoding = 'UTF-8';
exec("qemu-img info --backing-chain -U $file | grep image:",$output) ;
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line) ;
$output[$key] = $line ;
$output[$key] = $line ;
}
$snaps[$vm][$disk["device"]] = $output ;
$snaps[$vm][$disk["device"]] = $output ;
$rev = "r".$disk["device"] ;
$reversed = array_reverse($output) ;
$snaps[$vm][$rev] = $reversed ;
@@ -1988,7 +1988,7 @@ private static $encoding = 'UTF-8';
$xmlobj = custom::createArray('domain',$strXML) ;
# Process disks.
$disks=($snapslist[$snap]['disks']) ;
$disks=($snapslist[$snap]['disks']) ;
foreach ($disks as $disk) {
$diskname = $disk["@attributes"]["name"] ;
if ($diskname == "hda" || $diskname == "hdb") continue ;
@@ -1999,30 +1999,30 @@ private static $encoding = 'UTF-8';
return ($data) ;
}
}
$disks=($snapslist[$snap]['disks']) ;
foreach ($disks as $disk) {
$diskname = $disk["@attributes"]["name"] ;
if ($diskname == "hda" || $diskname == "hdb") continue ;
$path = $disk["source"]["@attributes"]["file"] ;
if (is_file($path)) {
if(!unlink("$path")) {
if(!unlink("$path")) {
$data = ["error" => "Unable to remove image file $path"] ;
return ($data) ;
}
}
}
}
# Delete NVRAM
# Delete NVRAM
if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_delete_snapshot($lv->domain_get_uuid($vm),$snap) ;
$ret = delete_snapshots_database("$vm","$snap") ;
if(!$ret)
$data = ["error" => "Unable to remove snap metadata $snap"] ;
else
$data = ["success => 'true"] ;
return($data) ;
}
@@ -2059,7 +2059,7 @@ OPTIONS
blockcommit Debian --path /mnt/user/domains/Debian/vdisk1.S20230513120410qcow2 --verbose --pivot --delete
*/
# Error if VM Not running.
$snapslist= getvmsnapshots($vm) ;
$disks =$lv->get_disk_stats($vm) ;
@@ -2069,7 +2069,7 @@ OPTIONS
if ($pivot == "yes") $cmdstr .= " --pivot " ;
if ($action == "yes") $cmdstr .= " --delete " ;
# Process disks and update path.
$snapdisks=($snapslist[$snap]['disks']) ;
$snapdisks=($snapslist[$snap]['disks']) ;
if ($base != "--base" && $base != "") {
#get file name from snapshot.
$snapdisks=($snapslist[$base]['disks']) ;
@@ -2094,15 +2094,15 @@ OPTIONS
}
$error = execCommand_nchan($cmdstr,$path) ;
if (!$error) {
if (!$error) {
$arrResponse = ['error' => "Process Failed"] ;
return($arrResponse) ;
} else {
$arrResponse = ['success' => true] ;
}
}
# Delete NVRAM
# Delete NVRAM
#if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_delete_snapshot($lv->domain_get_uuid($vm),$snap) ;
refresh_snapshots_database($vm) ;
@@ -2149,9 +2149,9 @@ OPTIONS
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ;
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line) ;
$output[$key] = $line ;
$output[$key] = $line ;
}
$snaps[$vm][$disk["device"]] = $output ;
$snaps[$vm][$disk["device"]] = $output ;
$rev = "r".$disk["device"] ;
$reversed = array_reverse($output) ;
$snaps[$vm][$rev] = $reversed ;
@@ -2166,7 +2166,7 @@ OPTIONS
$cmdstr = "virsh blockpull '$vm' --path '$path' --verbose --pivot --delete" ;
$cmdstr = "virsh blockpull '$vm' --path '$path' --verbose --wait " ;
# Process disks and update path.
$snapdisks=($snapslist[$snap]['disks']) ;
$snapdisks=($snapslist[$snap]['disks']) ;
if ($base != "--base" && $base != "") {
#get file name from snapshot.
$snapdisks=($snapslist[$base]['disks']) ;
@@ -2183,8 +2183,8 @@ OPTIONS
$error = execCommand_nchan($cmdstr,$path) ;
if (!$error) {
if (!$error) {
$arrResponse = ['error' => "Process Failed" ] ;
return($arrResponse) ;
} else {
@@ -2195,7 +2195,7 @@ OPTIONS
}
refresh_snapshots_database($vm) ;
$ret = $ret = delete_snapshots_database("$vm","$snap") ;
$ret = $ret = delete_snapshots_database("$vm","$snap") ;
if($ret)
$data = ["error" => "Unable to remove snap metadata $snap"] ;
else
@@ -2241,6 +2241,6 @@ OPTIONS
*/
}
?>

View File

@@ -1,6 +1,7 @@
#!/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,
@@ -11,47 +12,47 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
// add translations
$_SERVER['REQUEST_URI'] = '';
$login_locale = _var($display,'locale');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?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);
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?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 execCommand_nchan($command,$idx) {
$waitID = mt_rand();
[$cmd,$args] = explode(' ',$command,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
write("addLog\0<br>") ;
#write("addToID\0$idx\0 $action") ;
$proc = popen("$command 2>&1",'r');
while ($out = fgets($proc)) {
$out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out);
if (substr($out,0,1) == "B") { ;
write("progress\0$idx\0".htmlspecialchars(substr($out,strrpos($out,"Block Pull")))) ;
} else echo write("addToID\0$idx\0 ".htmlspecialchars($out));
}
$retval = pclose($proc);
$out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
return $retval===0;
$waitID = mt_rand();
[$cmd,$args] = explode(' ',$command,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
write("addLog\0<br>") ;
#write("addToID\0$idx\0 $action") ;
$proc = popen("$command 2>&1",'r');
while ($out = fgets($proc)) {
$out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out);
if (substr($out,0,1) == "B") { ;
write("progress\0$idx\0".htmlspecialchars(substr($out,strrpos($out,"Block Pull")))) ;
} else echo write("addToID\0$idx\0 ".htmlspecialchars($out));
}
$retval = pclose($proc);
$out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
return $retval===0;
}
#{action:"snap-", uuid:uuid , snapshotname:target , remove:remove, free:free ,removemeta:removemeta ,keep:keep, desc:desc}
@@ -65,10 +66,10 @@ $style[] = "legend{font-size:1.1rem!important;font-weight:bold}";
$style[] = "</style>";
foreach (explode('&', $url) as $chunk) {
$param = explode("=", $chunk);
if ($param) {
${urldecode($param[0])} = urldecode($param[1]) ;
}
$param = explode("=", $chunk);
if ($param) {
${urldecode($param[0])} = urldecode($param[1]) ;
}
}
$id = 1 ;
write(implode($style)."<p class='logLine'></p>");
@@ -78,24 +79,23 @@ write("addLog\0".htmlspecialchars("VMName $name "));
write("addLog\0".htmlspecialchars("SNAP $snapshotname "));
write("addLog\0".htmlspecialchars("Base $targetbase "));
if ($action == "commit") {
write("addLog\0".htmlspecialchars("Top $targettop "));
write("addLog\0".htmlspecialchars("Pivot $targetpivot "));
write("addLog\0".htmlspecialchars("Delete $targetdelete "));
write("addLog\0".htmlspecialchars("Top $targettop "));
write("addLog\0".htmlspecialchars("Pivot $targetpivot "));
write("addLog\0".htmlspecialchars("Delete $targetdelete "));
}
switch ($action) {
case "commit":
vm_blockcommit($name,$snapshotname,$path,$targetbase,$targettop,$targetpivot,$targetdelete) ;
break ;
case "copy":
vm_blockcopy($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ;
break;
case "pull":
vm_blockpull($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ;
break ;
}
case "commit":
vm_blockcommit($name,$snapshotname,$path,$targetbase,$targettop,$targetpivot,$targetdelete) ;
break ;
case "copy":
vm_blockcopy($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ;
break;
case "pull":
vm_blockpull($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ;
break ;
}
#execCommand_nchan("ls /") ;
write("stop_Wait\0$waitID") ;
write('_DONE_','');
?>
?>

View File

@@ -1,6 +1,7 @@
#!/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,
@@ -11,67 +12,65 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = '';
$login_locale = _var($display,'locale');
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
require_once "$docroot/webGui/include/Helpers.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?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 execCommand_nchan_clone($command,$idx,$refcmd=false) {
$waitID = mt_rand();
if ($refcmd) {
[$cmd,$args] = explode(' ',$refcmd,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
$rtn = exec("$refcmd 2>&1", $output,$return) ;
if ($return == 0) $reflinkok = true ; else {
$reflinkok = false ;
write("addLog\0<br><b>{$output[0]}</b>");
}
$out = $return ? _('The command failed revert to rsync')."." : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
}
if ($reflinkok) {
return true ;
} else {
$waitID = mt_rand();
[$cmd,$args] = explode(' ',$command,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
write("addToID\0$idx\0Cloning VM: ") ;
$proc = popen("$command 2>&1 &",'r');
while ($out = fread($proc,100)) {
$out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out);
$out = trim($out) ;
$values = explode(' ',$out) ;
$string = _("Data copied: ").$values[0].' '._(" Percentage: ").$values[1].' '._(" Transfer Rate: ").$values[2].' '._(" Time remaining: ").$values[4].$values[5] ;
write("progress\0$idx\0".htmlspecialchars($string)) ;
if ($out) $stringsave=$string ;
}
$retval = pclose($proc);
write("progress\0$idx\0".htmlspecialchars($stringsave)) ;
$out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
return $retval===0;
function write(...$messages) {
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?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 execCommand_nchan_clone($command,$idx,$refcmd=false) {
$waitID = mt_rand();
if ($refcmd) {
[$cmd,$args] = explode(' ',$refcmd,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
$rtn = exec("$refcmd 2>&1", $output,$return) ;
if ($return == 0) $reflinkok = true ; else {
$reflinkok = false ;
write("addLog\0<br><b>{$output[0]}</b>");
}
$out = $return ? _('The command failed revert to rsync')."." : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
}
if ($reflinkok) {
return true ;
} else {
$waitID = mt_rand();
[$cmd,$args] = explode(' ',$command,2);
write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._('Command execution')."</legend>".basename($cmd).' '.str_replace(" -","<br>&nbsp;&nbsp;-",htmlspecialchars($args))."<br><span id='wait-$waitID'>"._('Please wait')." </span><p class='logLine'></p></fieldset>","show_Wait\0$waitID");
write("addToID\0$idx\0Cloning VM: ") ;
$proc = popen("$command 2>&1 &",'r');
while ($out = fread($proc,100)) {
$out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out);
$out = trim($out);
$values = explode(' ',$out);
$string = _("Data copied: ").$values[0].' '._(" Percentage: ").$values[1].' '._(" Transfer Rate: ").$values[2].' '._(" Time remaining: ").$values[4].$values[5];
write("progress\0$idx\0".htmlspecialchars($string));
if ($out) $stringsave=$string;
}
$retval = pclose($proc);
write("progress\0$idx\0".htmlspecialchars($stringsave));
$out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!';
write("stop_Wait\0$waitID","addLog\0<br><b>$out</b>");
return $retval===0;
}
}
@@ -86,10 +85,10 @@ $style[] = "legend{font-size:1.1rem!important;font-weight:bold}";
$style[] = "</style>";
foreach (explode('&', $url) as $chunk) {
$param = explode("=", $chunk);
if ($param) {
${urldecode($param[0])} = urldecode($param[1]) ;
}
$param = explode("=", $chunk);
if ($param) {
${urldecode($param[0])} = urldecode($param[1]) ;
}
}
$id = 1 ;
write(implode($style)."<p class='logLine'></p>");
@@ -99,10 +98,10 @@ write("<p class='logLine'></p>","addLog\0<fieldset class='docker'><legend>"._("O
write("addLog\0".htmlspecialchars("Cloning $name to $clone"));
switch ($action) {
case "clone":
$rtn = vm_clone($name,$clone,$overwrite,$start,$edit,$free,$waitID) ;
break ;
}
case "clone":
$rtn = vm_clone($name,$clone,$overwrite,$start,$edit,$free,$waitID) ;
break ;
}
write("stop_Wait\0$waitID") ;
if ($rtn) write('_DONE_',''); else write('_ERROR_','');
?>
?>

View File

@@ -15,7 +15,7 @@ table.domdisk tbody tr:nth-child(even){background-color:transparent!important}
table.domdisk tbody tr:nth-child(4n-1){background-color:transparent!important}
table.snapshot{margin-top:0}
i.mover{margin-right:8px;display:none}
i.fa-bullseye{padding-left:12px}
i.fa-floppy-o{padding-left:12px}
#resetsort{margin-left:12px;display:inline-block;width:32px}
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset button[disabled]{cursor:default;color:#808080;background:-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 0 no-repeat,-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#404040),to(#404040)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#808080),to(#808080)) 100% 100% no-repeat;background:linear-gradient(90deg,#404040 0,#808080) 0 0 no-repeat,linear-gradient(90deg,#404040 0,#808080) 0 100% no-repeat,linear-gradient(0deg,#404040 0,#404040) 0 100% no-repeat,linear-gradient(0deg,#808080 0,#808080) 100% 100% no-repeat;background-size:100% 2px,100% 2px,2px 100%,2px 100%}
.dropdown-menu{z-index:10001}

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,15 +12,16 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
}
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$arrValidMachineTypes = getValidMachineTypes();
$arrValidGPUDevices = getValidGPUDevices();
@@ -449,13 +450,13 @@
}
?>
</select>
<?
<?
$usbboothidden = "hidden" ;
if ($arrConfig['domain']['ovmf'] != '0') $usbboothidden = "" ;
?>
<span id="USBBoottext" class="advanced" <?=$usbboothidden?>>_(Enable USB boot)_:</span>
<select name="domain[usbboot]" id="domain_usbboot" class="narrow" title="_(define OS boot options)_" <?=$usbboothidden?> onchange="USBBootChange(this)">
<?
echo mk_option($arrConfig['domain']['usbboot'], 'No', 'No');
@@ -607,8 +608,8 @@
$boolShowAllDisks = (strpos($domain_cfg['DOMAINDIR'], '/mnt/user/') === 0);
if (!empty($arrDisk['new'])) {
if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false ||
basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] ||
if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false ||
basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] ||
basename($arrDisk['new']) != 'vdisk'.($i+1).'.img') {
$default_option = 'manual';
}
@@ -736,12 +737,12 @@
<b>vDisk Bus</b><br>
Select virtio for best performance.
</p>
<p class="advanced">
<b>vDisk Boot Order</b><br>
Specify the order the devices are used for booting.
</p>
<p class="advanced">
<b>vDisk Serial</b><br>
Set the device serial number presented to the VM.
@@ -837,7 +838,7 @@
<select name="disk[{{INDEX}}][bus]" class="disk_bus narrow">
<?mk_dropdown_options($arrValidDiskBuses, '');?>
</select>
_(Boot Order)_:
<input type="number" size="5" maxlength="5" id="disk[{{INDEX}}][boot]" class="narrow bootorder" style="width: 50px;" name="disk[{{INDEX}}][boot]" title="_(Boot order)_" value="" >
</td>
@@ -868,7 +869,7 @@
</select>
_(Unraid Share)_:
<select name="shares[<?=$i?>][unraid]" class="disk_bus narrow" onchange="ShareChange(this)" >
<? $UnraidShareDisabled = ' disabled="disabled"' ;
<? $UnraidShareDisabled = ' disabled="disabled"' ;
$arrUnraidIndex = array_search("User:".$arrShare['target'],$arrUnraidShares) ;
if ($arrUnraidIndex != false && substr($arrShare['source'],0,10) != '/mnt/user/') $arrUnraidIndex = false ;
if ($arrUnraidIndex == false) $arrUnraidIndex = array_search("Disk:".$arrShare['target'],$arrUnraidShares) ;
@@ -876,11 +877,11 @@
mk_dropdown_options($arrUnraidShares, $arrUnraidIndex);?>
</select>
</td>
</tr>
</tr>
<tr class="advanced">
<td>
<text id="shares[<?=$i?>]sourcetext" > _(Unraid Source Path)_: </text>
<td>
<text id="shares[<?=$i?>]sourcetext" > _(Unraid Source Path)_: </text>
</td>
<td>
<input type="text" <?=$UnraidShareDisabled?> id="shares[<?=$i?>][source]" name="shares[<?=$i?>][source]" autocomplete="off" data-pickfolders="true" data-pickfilter="NO_FILES_FILTER" data-pickroot="/mnt/" value="<?=htmlspecialchars($arrShare['source'])?>" placeholder="_(e.g.)_ /mnt/user/..." title="_(path of Unraid share)_" />
@@ -903,7 +904,7 @@
Used to create a VirtFS mapping to a Linux-based guest. Specify the mode you want to use either 9p or Virtiofs.
</p>
<p>
<b>Unraid Share</b><br>
Set tag and path to match the selected Unraid share.
@@ -918,8 +919,8 @@
<b>Unraid Mount tag</b><br>
Specify the mount tag that you will use for mounting the VirtFS share inside the VM. See this page for how to do this on a Linux-based guest: <a href="http://wiki.qemu.org/Documentation/9psetup" target="_blank">http://wiki.qemu.org/Documentation/9psetup</a>
</p>
<p>
For Windows additional software needs to be installed: <a href="https://virtio-fs.gitlab.io/howto-windows.html" target="_blank">https://virtio-fs.gitlab.io/howto-windows.html</a>
<p>
For Windows additional software needs to be installed: <a href="https://virtio-fs.gitlab.io/howto-windows.html" target="_blank">https://virtio-fs.gitlab.io/howto-windows.html</a>
</p>
<p>Additional devices can be added/removed by clicking the symbols to the left.</p>
@@ -939,12 +940,12 @@
</select>
_(Unraid Share)_:
<select name="shares[{{INDEX}}][unraid]" class="disk_bus narrow" onchange="ShareChange(this)" >
<?mk_dropdown_options($arrUnraidShares, '');?>
</select>
</td>
</tr>
</tr>
<tr class="advanced">
<td>_(Unraid Source Path)_:</td>
@@ -975,7 +976,7 @@
if ($i == 0) {
// Only the first video card can be VNC or SPICE
echo mk_option($arrGPU['id'], 'virtual', _('Virtual'));
} else {
echo mk_option($arrGPU['id'], '', _('None'));
}
@@ -985,11 +986,11 @@
}
?>
</select>
<?
<?
if ($arrGPU['id'] != 'virtual') $multifunction = "" ; else $multifunction = " disabled " ;
?>
<span id="GPUMulti<?=$i?>" name="gpu[<?=$i?>][multi]" class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced gpumultiline<?=$i?>" >_(Multifunction)_:</span>
<select id="GPUMultiSel<?=$i?>" name="gpu[<?=$i?>][multi]" class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced narrow gpumultiselect<?=$i?>" title="_(define Multifunctiion Support)_" <?=$multifunction?> >
<?
echo mk_option($arrGPU['guest']['multi'], 'off', 'Off');
@@ -999,7 +1000,7 @@
</td>
</tr>
<?if ($i == 0) {
<?if ($i == 0) {
$hiddenport = $hiddenwsport = "hidden" ;
if ($arrGPU['autoport'] == "no"){
if ($arrGPU['protocol'] == "vnc") $hiddenport = $hiddenwsport = "" ;
@@ -1033,13 +1034,13 @@
echo mk_option($arrGPU['autoport'], 'no', _('No'));
?>
</select>
<span id="Porttext" <?=$hiddenport?>>_(VM Console Port)_:</span>
<input type="number" size="5" maxlength="5" id="port" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][port]" title="_(port for virtual console)_" value="<?=$arrGPU['port']?>" <?=$hiddenport?> >
<span id="WSPorttext" <?=$hiddenwsport?>>_(VM Console WS Port)_:</span>
<input type="number" size="5" maxlength="5" id="wsport" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][wsport]" title="_(wsport for virtual console)_" value="<?=$arrGPU['wsport']?>" <?=$hiddenwsport?> >
</td>
</tr>
@@ -1082,7 +1083,7 @@
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>Virtual video protocol VNC/SPICE</b><br>
If you wish to assign a protocol type, specify one here.
If you wish to assign a protocol type, specify one here.
</p>
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
@@ -1092,7 +1093,7 @@
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>Virtual auto port</b><br>
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
</p>
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vncmodel">
@@ -1196,13 +1197,13 @@
</script>
<? if ( $arrConfig['nic'] == false) {
$arrConfig['nic']['0'] =
$arrConfig['nic']['0'] =
[
'network' => $domain_bridge,
'mac' => "",
'model' => 'virtio-net'
] ;
}
}
foreach ($arrConfig['nic'] as $i => $arrNic) {
$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
@@ -1326,7 +1327,7 @@
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<td>_(USB Devices)_:</td>
<td>
@@ -1336,7 +1337,7 @@
foreach($arrVMUSBs as $i => $arrDev) {
?>
<label for="usb<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"';?>
/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name="usbopt[<?=htmlspecialchars($arrDev['id'])?>]" id="usbopt<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if ($arrDev["startupPolicy"] =="optional") echo 'checked="checked"';?>/>&nbsp&nbsp&nbsp&nbsp&nbsp
/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name="usbopt[<?=htmlspecialchars($arrDev['id'])?>]" id="usbopt<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if ($arrDev["startupPolicy"] =="optional") echo 'checked="checked"';?>/>&nbsp&nbsp&nbsp&nbsp&nbsp
<input type="number" size="5" maxlength="5" id="usbboot<?=$i?>" class="narrow bootorder" <?=$bootdisable?> style="width: 50px;" name="usbboot[<?=htmlspecialchars($arrDev['id'])?>]" title="_(Boot order)_" value="<?=$arrDev['usbboot']?>" >
<?=htmlspecialchars($arrDev['name'])?> (<?=htmlspecialchars($arrDev['id'])?>)</label><br/>
<?
@@ -1357,7 +1358,7 @@
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<tr>
<td>_(Other PCI Devices)_:</td>
@@ -1373,14 +1374,14 @@
if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) {
$extra .= ' checked="checked"';
foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ;
} elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) {
//$extra .= ' disabled="disabled"';
continue;
}
$intAvailableOtherPCIDevices++;
?>
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<input type="number" size="5" maxlength="5" id="pciboot<?=$i?>" class="narrow pcibootorder" <?=$bootdisable?> style="width: 50px;" name="pciboot[<?=htmlspecialchars($arrDev['id'])?>]" title="_(Boot order)_" value="<?=$pciboot?>" >
<?=htmlspecialchars($arrDev['name'])?> | <?=htmlspecialchars($arrDev['type'])?> (<?=htmlspecialchars($arrDev['id'])?>)</label><br/>
<?
@@ -1471,8 +1472,8 @@ function ShareChange(share) {
var path = "/mnt/" + strArray[1] ;
}
if (strArray[0] != "Manual") {
document.getElementById(name+"[target]").value = strArray[1] ;
document.getElementById(name+"[source]").value = path ;
document.getElementById(name+"[target]").value = strArray[1] ;
document.getElementById(name+"[source]").value = path ;
document.getElementById(name+"[target]").setAttribute("disabled","disabled");
document.getElementById(name+"[source]").setAttribute("disabled","disabled");
} else {
@@ -1503,18 +1504,18 @@ function SetBootorderfields(usbbootvalue) {
} else bootelements[i].removeAttribute("disabled");
}
var bootelements = document.getElementsByClassName("pcibootorder");
const bootpcidevs = <?
const bootpcidevs = <?
$devlist = [] ;
foreach($arrValidOtherDevices as $i => $arrDev) {
if ($arrDev["typeid"] != "0108" && substr($arrDev["typeid"],0,2) != "02") $devlist[$arrDev['id']] = "N" ; else $devlist[$arrDev['id']] = "Y" ;
}
echo json_encode($devlist) ;
?>
?>
for(var i = 0; i < bootelements.length; i++) {
let bootpciid = bootelements[i].name.split('[') ;
bootpciid= bootpciid[1].replace(']', '') ;
if (usbbootvalue == "Yes") {
bootelements[i].value = "";
bootelements[i].setAttribute("disabled","disabled");
@@ -1552,7 +1553,7 @@ function AutoportChange(autoport) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
function ProtocolChange(protocol) {
@@ -1576,10 +1577,10 @@ function ProtocolChange(protocol) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
@@ -1747,7 +1748,7 @@ $(function() {
var auto_serial = 'vdisk' + (index+1) ;
$disk_serial.val(auto_serial);
}
}
});
};

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,15 +12,16 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
}
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$arrValidMachineTypes = getValidMachineTypes();
$arrValidGPUDevices = getValidGPUDevices();
@@ -666,12 +667,12 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
}
?>
</select>
<?
<?
$usbboothidden = "hidden" ;
if ($arrConfig['domain']['ovmf'] != '0') $usbboothidden = "" ;
?>
<span id="USBBoottext" class="advanced" <?=$usbboothidden?>>_(Enable USB boot)_:</span>
<select name="domain[usbboot]" id="domain_usbboot" class="narrow" title="_(define OS boot options)_" <?=$usbboothidden?> onchange="USBBootChange(this)">
<?
echo mk_option($arrConfig['domain']['usbboot'], 'No', 'No');
@@ -748,7 +749,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
</select>
</td>
</tr>
<?if ($i == 0) {
<?if ($i == 0) {
$hiddenport = $hiddenwsport = "hidden" ;
if ($arrGPU['autoport'] == "no"){
if ($arrGPU['protocol'] == "vnc") $hiddenport = $hiddenwsport = "" ;
@@ -772,13 +773,13 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
echo mk_option($arrGPU['autoport'], 'no', _('No'));
?>
</select>
<span id="Porttext" <?=$hiddenport?>>_(VM Console Port)_:</span>
<input type="number" size="5" maxlength="5" id="port" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][port]" title="_(port for virtual console)_" value="<?=$arrGPU['port']?>" <?=$hiddenport?> >
<span id="WSPorttext" <?=$hiddenwsport?>>_(VM Console WS Port)_:</span>
<input type="number" size="5" maxlength="5" id="wsport" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][wsport]" title="_(wsport for virtual console)_" value="<?=$arrGPU['wsport']?>" <?=$hiddenwsport?> >
</td>
</tr>
@@ -800,19 +801,19 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<b>virtual video protocol VDA/SPICE</b><br>
If you wish to assign a protocol type, specify one here.
</p>
<b>Graphics Card</b><br>
If you wish to assign a graphics card to the VM, select it from this list, otherwise leave it set to virtual.
</p>
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>virtual video protocol VDC/SPICE</b><br>
If you wish to assign a protocol type, specify one here.
If you wish to assign a protocol type, specify one here.
</p>
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>virtual auto port</b><br>
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
</p>
@@ -898,15 +899,15 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
</table>
</script>
<?
<?
if ( $arrConfig['nic'] == false) {
$arrConfig['nic']['0'] =
$arrConfig['nic']['0'] =
[
'network' => $domain_bridge,
'mac' => "",
'model' => 'virtio-net'
] ;
}
}
foreach ($arrConfig['nic'] as $i => $arrNic) {
$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
@@ -951,7 +952,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<td>
<input type="number" size="5" maxlength="5" id="nic[<?=$i?>][boot]" class="narrow bootorder" <?=$bootdisable?> style="width: 50px;" name="nic[<?=$i?>][boot]" title="_(Boot order)_" value="<?=$arrNic['boot']?>" >
</td>
</tr>
</tr>
</table>
<?if ($i == 0) {?>
<div class="advanced">
@@ -1025,7 +1026,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<tr>
<td>_(USB Devices)_:</td>
@@ -1057,7 +1058,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<tr>
<td>_(Other PCI Devices)_:</td>
@@ -1073,14 +1074,14 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) {
$extra .= ' checked="checked"';
foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ;
} elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) {
//$extra .= ' disabled="disabled"';
continue;
}
$intAvailableOtherPCIDevices++;
?>
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<input type="number" size="5" maxlength="5" id="pciboot<?=$i?>" class="narrow pcibootorder" <?=$bootdisable?> style="width: 50px;" name="pciboot[<?=htmlspecialchars($arrDev['id'])?>]" title="_(Boot order)_" value="<?=$pciboot?>" >
<?=htmlspecialchars($arrDev['name'])?> | <?=htmlspecialchars($arrDev['type'])?> (<?=htmlspecialchars($arrDev['id'])?>)</label><br/>
<?
@@ -1159,7 +1160,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<script src="<?autov('/plugins/dynamix.vm.manager/scripts/codemirror/addon/hint/libvirt-schema.js')?>"></script>
<script src="<?autov('/plugins/dynamix.vm.manager/scripts/codemirror/mode/xml/xml.js')?>"></script>
<script type="text/javascript">
function BIOSChange(bios) {
var value = bios.value;
if (value == "0") {
@@ -1182,18 +1183,18 @@ function SetBootorderfields(usbbootvalue) {
} else bootelements[i].removeAttribute("disabled");
}
var bootelements = document.getElementsByClassName("pcibootorder");
const bootpcidevs = <?
const bootpcidevs = <?
$devlist = [] ;
foreach($arrValidOtherDevices as $i => $arrDev) {
if ($arrDev["typeid"] != "0108") $devlist[$arrDev['id']] = "N" ; else $devlist[$arrDev['id']] = "Y" ;
}
echo json_encode($devlist) ;
?>
?>
for(var i = 0; i < bootelements.length; i++) {
let bootpciid = bootelements[i].name.split('[') ;
bootpciid= bootpciid[1].replace(']', '') ;
if (usbbootvalue == "Yes") {
bootelements[i].value = "";
bootelements[i].setAttribute("disabled","disabled");
@@ -1231,7 +1232,7 @@ function AutoportChange(autoport) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
function ProtocolChange(protocol) {
@@ -1255,10 +1256,10 @@ function ProtocolChange(protocol) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
$(function() {
function completeAfter(cm, pred) {
var cur = cm.getCursor();

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,15 +12,16 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
}
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Custom.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$arrValidMachineTypes = getValidMachineTypes();
$arrValidGPUDevices = getValidGPUDevices();
@@ -665,12 +666,12 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
}
?>
</select>
<?
<?
$usbboothidden = "hidden" ;
if ($arrConfig['domain']['ovmf'] != '0') $usbboothidden = "" ;
?>
<span id="USBBoottext" class="advanced" <?=$usbboothidden?>>_(Enable USB boot)_:</span>
<select name="domain[usbboot]" id="domain_usbboot" class="narrow" title="_(define OS boot options)_" <?=$usbboothidden?> onchange="USBBootChange(this)">
<?
echo mk_option($arrConfig['domain']['usbboot'], 'No', 'No');
@@ -747,7 +748,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
</select>
</td>
</tr>
<?if ($i == 0) {
<?if ($i == 0) {
$hiddenport = $hiddenwsport = "hidden" ;
if ($arrGPU['autoport'] == "no"){
if ($arrGPU['protocol'] == "vnc") $hiddenport = $hiddenwsport = "" ;
@@ -771,13 +772,13 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
echo mk_option($arrGPU['autoport'], 'no', _('No'));
?>
</select>
<span id="Porttext" <?=$hiddenport?>>_(VM Console Port)_:</span>
<input type="number" size="5" maxlength="5" id="port" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][port]" title="_(port for virtual console)_" value="<?=$arrGPU['port']?>" <?=$hiddenport?> >
<span id="WSPorttext" <?=$hiddenwsport?>>_(VM Console WS Port)_:</span>
<input type="number" size="5" maxlength="5" id="wsport" class="narrow" style="width: 50px;" name="gpu[<?=$i?>][wsport]" title="_(wsport for virtual console)_" value="<?=$arrGPU['wsport']?>" <?=$hiddenwsport?> >
</td>
</tr>
@@ -802,12 +803,12 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>virtual video protocol VDC/SPICE</b><br>
If you wish to assign a protocol type, specify one here.
If you wish to assign a protocol type, specify one here.
</p>
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
<b>virtual auto port</b><br>
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
</p>
<p class="<?if ($arrGPU['id'] == 'virtual') echo 'was';?>advanced romfile">
@@ -893,7 +894,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
</script>
<?if ( $arrConfig['nic'] == false) {
$arrConfig['nic']['0'] =
$arrConfig['nic']['0'] =
[
'network' => $domain_bridge,
'mac' => "",
@@ -944,7 +945,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<td>
<input type="number" size="5" maxlength="5" id="nic[<?=$i?>][boot]" class="narrow bootorder" <?=$bootdisable?> style="width: 50px;" name="nic[<?=$i?>][boot]" title="_(Boot order)_" value="<?=$arrNic['boot']?>" >
</td>
</tr>
</tr>
</table>
<?if ($i == 0) {?>
<div class="advanced">
@@ -1018,7 +1019,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Optional)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<tr>
<td>_(USB Devices)_:</td>
@@ -1029,7 +1030,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
foreach($arrVMUSBs as $i => $arrDev) {
?>
<label for="usb<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"';?>
/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name="usbopt[<?=htmlspecialchars($arrDev['id'])?>]]" id="usbopt<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if ($arrDev["startupPolicy"] =="optional") echo 'checked="checked"';?>/>&nbsp&nbsp&nbsp&nbsp&nbsp
/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name="usbopt[<?=htmlspecialchars($arrDev['id'])?>]]" id="usbopt<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?if ($arrDev["startupPolicy"] =="optional") echo 'checked="checked"';?>/>&nbsp&nbsp&nbsp&nbsp&nbsp
<input type="number" size="5" maxlength="5" id="usbboot<?=$i?>" class="narrow bootorder" <?=$bootdisable?> style="width: 50px;" name="usbboot[<?=htmlspecialchars($arrDev['id'])?>]]" title="_(Boot order)_" value="<?=$arrDev['usbboot']?>" >
<?=htmlspecialchars($arrDev['name'])?> (<?=htmlspecialchars($arrDev['id'])?>)</label><br/>
<?
@@ -1050,7 +1051,7 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
<table>
<tr><td></td>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<td>_(Select)_&nbsp&nbsp_(Boot Order)_</td></tr></div>
<tr>
<tr>
<td>_(Other PCI Devices)_:</td>
@@ -1066,14 +1067,14 @@ $hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaratio
if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) {
$extra .= ' checked="checked"';
foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ;
} elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) {
//$extra .= ' disabled="disabled"';
continue;
}
$intAvailableOtherPCIDevices++;
?>
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<label for="pci<?=$i?>">&nbsp&nbsp&nbsp&nbsp<input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=htmlspecialchars($arrDev['id'])?>" <?=$extra?>/> &nbsp
<input type="number" size="5" maxlength="5" id="pciboot<?=$i?>" class="narrow pcibootorder" <?=$bootdisable?> style="width: 50px;" name="pciboot[<?=htmlspecialchars($arrDev['id'])?>]" title="_(Boot order)_" value="<?=$pciboot?>" >
<?=htmlspecialchars($arrDev['name'])?> | <?=htmlspecialchars($arrDev['type'])?> (<?=htmlspecialchars($arrDev['id'])?>)</label><br/>
<?
@@ -1175,18 +1176,18 @@ function SetBootorderfields(usbbootvalue) {
} else bootelements[i].removeAttribute("disabled");
}
var bootelements = document.getElementsByClassName("pcibootorder");
const bootpcidevs = <?
const bootpcidevs = <?
$devlist = [] ;
foreach($arrValidOtherDevices as $i => $arrDev) {
if ($arrDev["typeid"] != "0108") $devlist[$arrDev['id']] = "N" ; else $devlist[$arrDev['id']] = "Y" ;
}
echo json_encode($devlist) ;
?>
?>
for(var i = 0; i < bootelements.length; i++) {
let bootpciid = bootelements[i].name.split('[') ;
bootpciid= bootpciid[1].replace(']', '') ;
if (usbbootvalue == "Yes") {
bootelements[i].value = "";
bootelements[i].setAttribute("disabled","disabled");
@@ -1224,7 +1225,7 @@ function AutoportChange(autoport) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
function ProtocolChange(protocol) {
@@ -1248,7 +1249,7 @@ function ProtocolChange(protocol) {
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
}
}
}
}
$(function() {
function completeAfter(cm, pred) {
@@ -1292,7 +1293,7 @@ $(function() {
});
SetBootorderfields("<?=$arrConfig['domain']['usbboot']?>") ;
function resetForm() {
$("#vmform .domain_vcpu").change(); // restore the cpu checkbox disabled states
<?if ($boolRunning):?>

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2015-2021, Derek Macias, Eric Schultz, Jon Panozzo.
* Copyright 2012-2021, 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,
@@ -12,14 +12,15 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
}
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaration

View File

@@ -69,6 +69,7 @@ function addPoolPopup() {
// Start Dialog section
popup.dialog({
title: "_(Add Pool)_",
height: 'auto',
width: 600,
resizable: false,
modal: true,
@@ -115,6 +116,7 @@ function addSubpoolPopup(poolname,currentsubpools) {
// Start Dialog section
popup.dialog({
title: "_(Add ZFS Subpool)_",
height: 'auto',
width: 600,
resizable: false,
modal: true,

View File

@@ -1289,6 +1289,7 @@ function contentMgmt() {
box.html($("#templateContentMgmt").html().build());
box.dialog({
title: "_(Tile Management)_",
height: 'auto',
width: 900,
resizable: false,
modal: true,
@@ -1328,6 +1329,7 @@ function VMClone(uuid, name){
document.getElementById("Overwrite").checked = true;
box.dialog({
title: "_(VM Clone)_",
height: 'auto',
width: 600,
resizable: false,
modal: true,
@@ -1369,6 +1371,7 @@ function selectsnapshot(uuid, name ,snaps, opt, getlist){
document.getElementById("targetsnapfspc").checked = true;
box.dialog({
title: optiontext,
height: 'auto',
width: 600,
resizable: false,
modal: true,

View File

@@ -484,6 +484,7 @@ function renamePoolPopup() {
// Start Dialog section
popup.dialog({
title: "_(Rename Pool)_",
height: 'auto',
width: 600,
resizable: false,
modal: true,
@@ -1335,7 +1336,7 @@ $(function() {
<?if (fsType('btrfs')):?>
presetBTRFS(document.balance_schedule,'#balance-hour');
presetBTRFS(document.scrub_schedule,'#scrub-hour');
<?elseif (fsType('zfs')):?>
<?elseif (fsType('zfs') && !isSubpool($name)):?>
presetZFS(document.scrub_schedule,'#scrub-hour');
<?endif;?>
});

View File

@@ -52,7 +52,7 @@ function acceptableCert($certFile, $hostname, $expectedURL) {
return false;
}
$tasks = find_tasks();
$nginx = @parse_ini_file('/var/local/emhttp/nginx.ini') ?: [];
$nginx = (array)@parse_ini_file('/var/local/emhttp/nginx.ini');
$addr = _var($nginx,'NGINX_LANIP') ?: _var($nginx,'NGINX_LANIP6');
$keyfile = empty(_var($var,'regFILE')) ? false : @file_get_contents(_var($var,'regFILE'));
$cert2Issuer = '';

View File

@@ -16,7 +16,7 @@ Tag="file-text-o"
*/
?>
<?
$syslog = @parse_ini_file('/boot/config/rsyslog.cfg') ?: [];
$syslog = (array)@parse_ini_file('/boot/config/rsyslog.cfg');
function plain($ip) {
return str_replace(['[',']'],'',$ip);

View File

@@ -27,7 +27,7 @@ exec("ip -br -6 addr show scope global|awk '/^(br|bond|eth)[0-9]+(\\.[0-9]+)?/{s
exec("ls --indicator-style=none $etc/wg*.conf*|grep -Po wg[0-9]+",$vtuns);
exec("docker network ls --filter driver='macvlan' --filter driver='ipvlan' --format='{{.Name}}' 2>/dev/null",$filter);
$nginx = @parse_ini_file('state/nginx.ini') ?: [];
$nginx = (array)@parse_ini_file('state/nginx.ini');
// add subnets defined in Docker custom networks
if (count($filter)) {

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = '';

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
/* 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,
@@ -11,7 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";

View File

@@ -11,12 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
function age($number,$time) {
return sprintf(_('%s '.($number==1 ? $time : $time.'s').' ago'),$number);

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2012-2021, Bergware International.
/* 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,
@@ -11,14 +11,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
[$luks,$size,$hash,$rng] = my_explode(',',exec("/usr/sbin/cryptsetup --help|tail -1"),4);
$luks = str_replace('-plain64','',trim(explode(':',$luks)[1]));
$size = str_replace(' bits','',trim(explode(':',$size)[1]));

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2014-2023, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -12,13 +12,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'dashboard';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
require_once "$docroot/webGui/include/Helpers.php";
if (isset($_POST['sys'])) {
switch ($_POST['sys']) {

View File

@@ -11,9 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
extract(parse_plugin_cfg('dynamix',true));
$path = _var($notify,'path','/tmp/notifications');

View File

@@ -11,12 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'shares';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
$compute = rawurldecode(_var($_POST,'compute'));
$path = rawurldecode(_var($_POST,'path'));

View File

@@ -11,7 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$file = $_POST['file']??'';
function validpath($file) {

View File

@@ -1,5 +1,5 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
/* Copyright 2005-2023, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -10,7 +10,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
if (array_key_exists('getdiagnostics', $_GET)) {
$anonymize = empty($_GET['anonymize']) ? '-a' : '';

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$cmd = $_POST['cmd'];
$path = $_POST['path'];

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/webGui/include/Secure.php";

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
/* 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,
@@ -11,8 +11,9 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$charts = '/var/tmp/charts_data.tmp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$charts = '/var/tmp/charts_data.tmp';
switch ($_POST['cmd']) {
case 'get':

View File

@@ -10,8 +10,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
@@ -49,7 +48,7 @@ if ($host && in_array($host,['keys.lime-technology.com','lime-technology.com']))
$key_file = basename($url);
exec("/usr/bin/wget -q -O ".escapeshellarg("/boot/config/$key_file")." ".escapeshellarg($url), $output, $return_var);
if ($return_var === 0) {
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
if (_var($var,'mdState')=="STARTED") {
response_complete(200, array('status' => _('Please Stop array to complete key installation')), _('success').', '._('Please Stop array to complete key installation'));
} else {

View File

@@ -11,12 +11,13 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
$dynamix = parse_plugin_cfg('dynamix',true);
$filter = unscript($_GET['filter']??false);

View File

@@ -12,8 +12,9 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$notify = "$docroot/webGui/scripts/notify";
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$notify = "$docroot/webGui/scripts/notify";
switch ($_POST['cmd']??'') {
case 'init':

View File

@@ -11,13 +11,13 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
// Get the webGui configuration preferences
extract(parse_plugin_cfg('dynamix',true));

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
switch ($_POST['cmd']??'') {
case 'clear':

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2015-2021, Bergware International
/* Copyright 2005-2023, Lime Technology
* Copyright 2015-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,
@@ -11,7 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";

View File

@@ -11,14 +11,13 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
switch (_var($_GET,'protocol')) {
case 'smb': $data = @parse_ini_file('state/sec.ini',true) ?: []; break;
case 'nfs': $data = @parse_ini_file('state/sec_nfs.ini',true) ?: []; break;
case 'smb': $data = (array)@parse_ini_file('state/sec.ini',true); break;
case 'nfs': $data = (array)@parse_ini_file('state/sec_nfs.ini',true); break;
}
$name = unscript(_var($_GET,'name'));
echo json_encode(_var($data,$name));

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
/* 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,
@@ -11,13 +11,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$certPath = "/boot/config/ssl/certs/certificate_bundle.pem";
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Wrappers.php";
$certPath = "/boot/config/ssl/certs/certificate_bundle.pem";
$cli = php_sapi_name()=='cli';
function response_complete($httpcode, $result, $cli_success_msg='') {

View File

@@ -1,5 +1,5 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
/* Copyright 2005-2023, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -10,14 +10,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
$var = parse_ini_file('state/var.ini');
$keyfile = base64_encode(file_get_contents($var['regFILE']));
?>

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
@@ -42,7 +41,7 @@ case 'notice':
break;
case 'state':
$pools = explode(',',_var($_POST,'pools'));
$disks = @parse_ini_file('state/disks.ini',true) ?: [];
$disks = (array)@parse_ini_file('state/disks.ini',true);
$error = [];
foreach ($pools as $pool) if (stripos(_var($disks[$pool],'state'),'ERROR:')===0) $error[] = $pool.' - '.str_ireplace('ERROR:','',$disks[$pool]['state']);
echo implode('<br>',$error);

View File

@@ -11,9 +11,10 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$pid = '/var/run/nchan.pid';
$nchan = 'webGui/nchan/update_3';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$pid = '/var/run/nchan.pid';
$nchan = 'webGui/nchan/update_3';
if (is_file($pid) && exec("grep -Pom1 '^$nchan' $pid")) {
// restart update_3 script

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2012-2021, Bergware International.
/* 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,
@@ -11,7 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";

View File

@@ -11,12 +11,11 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
$shares = @parse_ini_file('state/shares.ini',true) ?: [];
$shares = (array)@parse_ini_file('state/shares.ini',true);
$name = unscript(_var($_GET,'name'));
echo json_encode(_var($shares,$name));
?>

View File

@@ -11,7 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'shares';
require_once "$docroot/webGui/include/Translations.php";
if (isset($_POST['scan'])) {
die((new FilesystemIterator("/mnt/user/{$_POST['scan']}"))->valid() ? '0' : '1');
@@ -31,11 +36,6 @@ if (isset($_POST['cleanup'])) {
die((string)$n);
}
// add translations
$_SERVER['REQUEST_URI'] = 'shares';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
$compute = rawurldecode(_var($_POST,'compute'));
$path = rawurldecode(_var($_POST,'path'));
$all = _var($_POST,'all');

View File

@@ -11,7 +11,9 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Preselect.php";
// add translations
$_SERVER['REQUEST_URI'] = 'main';
@@ -19,8 +21,6 @@ require_once "$docroot/webGui/include/Translations.php";
$disks = array_merge_recursive(@parse_ini_file('state/disks.ini',true)?:[], @parse_ini_file('state/devs.ini',true)?:[]);
require_once "$docroot/webGui/include/CustomMerge.php";
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Preselect.php";
function normalize($text, $glue='_') {
$words = explode($glue,$text);

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
function pgrep($proc) {

View File

@@ -11,26 +11,27 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
function usb_physical_port($usbbusdev) {
if (preg_match('/^Bus (?P<bus>\S+) Device (?P<dev>\S+): ID (?P<id>\S+)(?P<name>.*)$/', $usbbusdev, $usbMatch)) {
//udevadm info -a --name=/dev/bus/usb/003/002 | grep KERNEL==
$udevcmd = "udevadm info -a --name=/dev/bus/usb/".$usbMatch['bus']."/".$usbMatch['dev']." | grep KERNEL==" ;
$physical_busid = _("None") ;
$udevcmd = "udevadm info -a --name=/dev/bus/usb/".$usbMatch['bus']."/".$usbMatch['dev']." | grep KERNEL==";
$physical_busid = _("None");
exec($udevcmd , $udev);
if (isset($udev)) {
$physical_busid = trim(substr($udev[0], 13) , '"') ;
$physical_busid = trim(substr($udev[0], 13) , '"');
if (substr($physical_busid,0,3) =='usb') {
$physical_busid = substr($physical_busid,3).'-0' ;
$physical_busid = substr($physical_busid,3).'-0';
}
}
}
return($physical_busid) ;
return($physical_busid);
}
switch ($_POST['table']) {
@@ -103,7 +104,6 @@ case 't1':
}
}
$lines = array_values(array_unique($lines, SORT_STRING));
$iommuinuse = array ();
foreach ($lines as $pciinuse){
$string = exec("ls /sys/kernel/iommu_groups/*/devices/$pciinuse -1 -d");
@@ -152,7 +152,7 @@ case 't1':
exec('for usb_ctrl in $(find /sys/bus/usb/devices/usb* -maxdepth 0 -type l);do path="$(realpath "${usb_ctrl}")";if [[ $path == *'.$pciaddress.'* ]];then bus="$(cat "${usb_ctrl}/busnum")";lsusb -s $bus:|sort;fi;done',$getusb);
foreach($getusb as $usbdevice) {
[$bus,$id] = my_explode(':',$usbdevice);
$usbport = usb_physical_port($usbdevice) ;
$usbport = usb_physical_port($usbdevice);
if (strlen($usbport) > 7 ) {$usbport .= "\t"; } else { $usbport .= "\t\t"; }
echo "<tr><td></td><td></td><td></td><td></td><td style=\"padding-left: 50px;\">$bus Port $usbport".trim($id)."</td></tr>";
}
@@ -218,7 +218,7 @@ case 't3':
exec('lsusb|sort',$lsusb);
foreach ($lsusb as $line) {
[$bus,$id] = my_explode(':',$line);
$usbport = usb_physical_port($line) ;
$usbport = usb_physical_port($line);
echo "<tr><td>$bus Port $usbport</td><td> ".trim($id)."</td></tr>";
}
break;

View File

@@ -11,112 +11,106 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/SysDriversHelpers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/SysDriversHelpers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$kernel = shell_exec("uname -r") ;
$kernel = trim($kernel,"\n") ;
$lsmod = shell_exec("lsmod") ;
$kernel = shell_exec("uname -r");
$kernel = trim($kernel,"\n");
$lsmod = shell_exec("lsmod");
$supportpage = true;
$modtoplgfile = "/tmp/modulestoplg.json" ;
$sysdrvfile = "/tmp/sysdrivers.json" ;
$sysdrvinit = "/tmp/sysdrivers.init" ;
if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;}
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ;
$modtoplgfile = "/tmp/modulestoplg.json";
$sysdrvfile = "/tmp/sysdrivers.json";
$sysdrvinit = "/tmp/sysdrivers.init";
if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg(); createlist();}
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE);
switch ($_POST['table']) {
case 't1create':
if (is_file("/tmp/sysdrvbuild.running")) break ;
touch("/tmp/sysdrvbuild.running") ;
modtoplg() ;
createlist() ;
unlink("/tmp/sysdrvbuild.running") ;
break;
case 't1create':
if (is_file("/tmp/sysdrvbuild.running")) break;
touch("/tmp/sysdrvbuild.running");
modtoplg();
createlist();
unlink("/tmp/sysdrvbuild.running");
break;
case 't1load':
$list = file_get_contents($sysdrvfile) ;
$arrModules = json_decode($list,TRUE) ;
$init = false;
if (is_file($sysdrvinit)) $init = file_get_contents($sysdrvinit);
$html = "<thead><tr><th><b>"._("Driver")."</th><th><b>"._("Description")."</th><th data-value='System|Inuse|Custom|Disabled|\"Kernel - Inuse\"'><b>"._("State")."</th><th><b>"._("Type")."</th><th><b>"._("Modprobe.d config file")."</th></tr></thead>";
$html .= "<tbody>" ;
if (is_array($arrModules)) ksort($arrModules) ;
foreach($arrModules as $modname => $module) {
if ($modname == "") continue ;
case 't1load':
$list = file_get_contents($sysdrvfile);
$arrModules = json_decode($list,TRUE);
$init = false;
if (is_file($sysdrvinit)) $init = file_get_contents($sysdrvinit);
$html = "<thead><tr><th><b>"._("Driver")."</th><th><b>"._("Description")."</th><th data-value='System|Inuse|Custom|Disabled|\"Kernel - Inuse\"'><b>"._("State")."</th><th><b>"._("Type")."</th><th><b>"._("Modprobe.d config file")."</th></tr></thead>";
$html .= "<tbody>";
if (is_array($arrModules)) ksort($arrModules);
foreach($arrModules as $modname => $module) {
if ($modname == "") continue;
if (is_file("/boot/config/modprobe.d/$modname.conf")) {
$modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf");
$state = strpos($modprobe, "blacklist");
$modprobe = explode(PHP_EOL,$modprobe);
if($state !== false) {$state = "Disabled";} else $state="Custom";
$module['state'] = $state;
$module['modprobe'] = $modprobe;
} else {
if (is_file("/etc/modprobe.d/$modname.conf")) {
$modprobe = file_get_contents("/etc/modprobe.d/$modname.conf");
$state = strpos($modprobe, "blacklist");
$modprobe = explode(PHP_EOL,$modprobe);
if($state !== false) {$state = "Disabled";} else $state="System";
$module['state'] = $state;
$module['modprobe'] = $modprobe;
}
}
$html .= "<tr id='row$modname'>";
if ($supportpage) {
if ($module['support'] == false) {
$supporthtml = "";
} else {
$supporturl = $module['supporturl'];
$pluginname = $module['plugin'];
$supporthtml = "<span id='link$modname'><a href='$supporturl' target='_blank'><i title='"._("Support page $pluginname")."' class='fa fa-phone-square'></i></a></span>";
}
}
if (isset($module["version"])) $version = " (".$module["version"].")"; else $version = "";
$html .= "<td>$modname$version$supporthtml</td>";
$html .= "<td>{$module['description']}</td><td id=\"status$modname\">{$module['state']}</td><td>{$module['type']}</td>";
$text = "";
if (is_array($module["modprobe"])) {
$text = implode("\n",$module["modprobe"]);
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>";
$hidden = "";
if ($module['state'] == "System") $hidden = "hidden";
$html .= " <a class='info' href=\"#\" id=\"bin$modname\" $hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>";
$html .= "<span><textarea id=\"text".$modname."\" rows=3 disabled>$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
} else {
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>";
$html .= " <a class='info' href=\"#\" id=\"bin$modname\" hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>";
$html .= "<textarea id=\"text".$modname."\" rows=1 hidden disabled >$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
}
}
$html .= "</tbody>";
$rtn = array();
$rtn['html'] = $html;
if ($init !== false) {$init = true; unlink($sysdrvinit);}
$rtn['init'] = $init;
echo json_encode($rtn);
break;
if (is_file("/boot/config/modprobe.d/$modname.conf")) {
$modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ;
$state = strpos($modprobe, "blacklist");
$modprobe = explode(PHP_EOL,$modprobe) ;
if($state !== false) {$state = "Disabled" ;} else $state="Custom" ;
$module['state'] = $state ;
$module['modprobe'] = $modprobe ;
} else {
if (is_file("/etc/modprobe.d/$modname.conf")) {
$modprobe = file_get_contents("/etc/modprobe.d/$modname.conf") ;
$state = strpos($modprobe, "blacklist");
$modprobe = explode(PHP_EOL,$modprobe) ;
if($state !== false) {$state = "Disabled" ;} else $state="System" ;
$module['state'] = $state ;
$module['modprobe'] = $modprobe ;
}
}
$html .= "<tr id='row$modname'>" ;
if ($supportpage) {
if ($module['support'] == false) {
$supporthtml = "" ;
} else {
$supporturl = $module['supporturl'] ;
$pluginname = $module['plugin'] ;
$supporthtml = "<span id='link$modname'><a href='$supporturl' target='_blank'><i title='"._("Support page $pluginname")."' class='fa fa-phone-square'></i></a></span>" ;
}
}
if (isset($module["version"])) $version = " (".$module["version"].")" ; else $version = "" ;
$html .= "<td>$modname$version$supporthtml</td>" ;
$html .= "<td>{$module['description']}</td><td id=\"status$modname\">{$module['state']}</td><td>{$module['type']}</td>";
$text = "" ;
if (is_array($module["modprobe"])) {
$text = implode("\n",$module["modprobe"]) ;
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>" ;
$hidden = "" ;
if ($module['state'] == "System") $hidden = "hidden" ;
$html .= " <a class='info' href=\"#\" id=\"bin$modname\" $hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>" ;
$html .= "<span><textarea id=\"text".$modname."\" rows=3 disabled>$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
} else {
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>" ;
$html .= " <a class='info' href=\"#\" id=\"bin$modname\" hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>" ;
$html .= "<textarea id=\"text".$modname."\" rows=1 hidden disabled >$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
}
}
$html .= "</tbody>" ;
$rtn = array() ;
$rtn['html'] = $html ;
if ($init !== false) {$init = true ; unlink($sysdrvinit) ;}
$rtn['init'] = $init ;
echo json_encode($rtn) ;
break;
case "update":
$conf = $_POST['conf'] ;
$module = $_POST['module'] ;
if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ;
getmodules($module) ;
$return = $arrModules[$module] ;
$return['supportpage'] = $supportpage ;
if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]) ;
if ($error !== false) $return["error"] = false ; else $return["error"] = true ;
echo json_encode($return) ;
break ;
}
$conf = $_POST['conf'];
$module = $_POST['module'];
if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf"); else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf);
getmodules($module);
$return = $arrModules[$module];
$return['supportpage'] = $supportpage;
if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]);
if ($error !== false) $return["error"] = false; else $return["error"] = true;
echo json_encode($return);
break;
}
?>

View File

@@ -1,5 +1,5 @@
#!/usr/bin/php
<?php
<?PHP
function SysDriverslog($m, $type = "NOTICE") {
if ($type == "DEBUG") return NULL;
$m = print_r($m,true);
@@ -8,23 +8,25 @@ function SysDriverslog($m, $type = "NOTICE") {
exec("logger -t webGUI -- \"$m\"");
}
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
require_once "$docroot/webGui/include/Translations.php";
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/SysDriversHelpers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$kernel = shell_exec("uname -r") ;
$kernel = trim($kernel,"\n") ;
$lsmod = shell_exec("lsmod") ;
// add translations
require_once "$docroot/webGui/include/Translations.php";
$kernel = shell_exec("uname -r");
$kernel = trim($kernel,"\n");
$lsmod = shell_exec("lsmod");
$supportpage = true;
$modtoplgfile = "/tmp/modulestoplg.json" ;
$sysdrvfile = "/tmp/sysdrivers.json" ;
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ;
file_put_contents("/tmp/sysdrivers.init","1") ;
SysDriverslog("SysDrivers Build Starting") ;
modtoplg() ;
createlist() ;
SysDriverslog("SysDrivers Build Complete") ;
?>
$modtoplgfile = "/tmp/modulestoplg.json";
$sysdrvfile = "/tmp/sysdrivers.json";
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE);
file_put_contents("/tmp/sysdrivers.init","1");
SysDriverslog("SysDrivers Build Starting");
modtoplg();
createlist();
SysDriverslog("SysDrivers Build Complete");
?>

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
/* 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,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/ColorCoding.php";
array_multisort(array_map('filemtime',($logs = glob($_POST['log'].'*',GLOB_NOSORT))),SORT_ASC,$logs);

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
$device = $_POST['device']??'';
@@ -52,7 +51,7 @@ default:
break;
}
// spin up/down group of devices
$disks = @parse_ini_file('state/disks.ini',true) ?: [];
$disks = (array)@parse_ini_file('state/disks.ini',true);
// remove '*' from name
$name = substr($name,0,-1);
foreach ($disks as $disk) {

View File

@@ -1,5 +1,5 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
/* Copyright 2005-2023, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -10,14 +10,14 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
$var = parse_ini_file('state/var.ini');
if (!empty($_POST['trial'])) {

View File

@@ -11,12 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
function host_lookup_ip($host) {
$result = @dns_get_record($host, DNS_A);
@@ -180,8 +180,8 @@ if ($cli && ($argc > 1) && $argv[1] == "-v") {
if ($cli && ($argc > 1) && $argv[1] == "-vv") {
$verbose = true;
}
$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: [];
$nginx = @parse_ini_file('/var/local/emhttp/nginx.ini') ?: [];
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
$nginx = (array)@parse_ini_file('/var/local/emhttp/nginx.ini');
$is69 = version_compare(_var($var,'version'),"6.9.9","<");
$reloadNginx = false;
$dnserr = false;
@@ -189,7 +189,7 @@ $icon_warn = "⚠️ ";
$icon_ok = "✅ ";
$myservers_flash_cfg_path='/boot/config/plugins/dynamix.my.servers/myservers.cfg';
$myservers = file_exists($myservers_flash_cfg_path) ? @parse_ini_file($myservers_flash_cfg_path,true) : [];
$myservers = (array)@parse_ini_file($myservers_flash_cfg_path,true);
// ensure some vars are defined here so we don't have to test them later
if (empty($myservers['remote']['apikey'])) {
$myservers['remote']['apikey'] = "";

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2012-2021, Bergware International.
/* 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,
@@ -11,11 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
$map = $changes = [];

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
/* 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,
@@ -11,7 +11,8 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// Wrapper functions
function parse_plugin_cfg($plugin, $sections=false, $scanner=INI_SCANNER_NORMAL) {

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
/* 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,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
[$job, $cmd] = explode(';',$_POST['#job']);

View File

@@ -11,11 +11,12 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'settings';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Wrappers.php";
$save = false;
$disks = parse_ini_file('state/disks.ini',true);

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2021, Lime Technology
* Copyright 2012-2021, Bergware International.
/* 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,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
$memory = '/tmp/memory.tmp';

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
/* 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,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Encryption.php";
$_POST['AuthPass'] = base64_encrypt($_POST['AuthPass']);

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";

View File

@@ -11,8 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
// add translations

View File

@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
[$job, $cmd] = explode(';',$_POST['#job']);

View File

@@ -376,11 +376,11 @@ function update_translation($locale) {
}
}
while (true) {
$var = @parse_ini_file("$varroot/var.ini") ?: [];
$devs = @parse_ini_file("$varroot/devs.ini",true) ?: [];
$disks = @parse_ini_file("$varroot/disks.ini",true) ?: [];
$sec = @parse_ini_file("$varroot/sec.ini",true) ?: [];
$diskio = @parse_ini_file("$varroot/diskload.ini") ?: [];
$var = (array)@parse_ini_file("$varroot/var.ini");
$devs = (array)@parse_ini_file("$varroot/devs.ini",true);
$disks = (array)@parse_ini_file("$varroot/disks.ini",true);
$sec = (array)@parse_ini_file("$varroot/sec.ini",true);
$diskio = (array)@parse_ini_file("$varroot/diskload.ini");
$crypto = false;
$pools = pools_filter($disks);
$echo = [];

View File

@@ -69,7 +69,7 @@ function create_file($file,...$data) {
}
while (true) {
$var = @parse_ini_file("$varroot/var.ini") ?: [];
$var = (array)@parse_ini_file("$varroot/var.ini");
// check for language changes
extract(parse_plugin_cfg('dynamix',true));
if (_var($display,'locale') != $locale_init) {

View File

@@ -19,7 +19,7 @@ require_once "$docroot/webGui/include/publish.php";
require_once "$docroot/webGui/include/Wrappers.php";
while (true) {
$var = @parse_ini_file("$varroot/var.ini") ?: [];
$var = (array)@parse_ini_file("$varroot/var.ini");
publish('session',_var($var,'csrf_token'),0);
sleep(10);
}

View File

@@ -278,10 +278,10 @@ function print_error($error) {
}
while (true) {
$var = @parse_ini_file("$varroot/var.ini") ?: [];
$devs = @parse_ini_file("$varroot/devs.ini",true) ?: [];
$disks = @parse_ini_file("$varroot/disks.ini",true) ?: [];
$saved = @parse_ini_file("$varroot/monitor.ini",true) ?: [];
$var = (array)@parse_ini_file("$varroot/var.ini");
$devs = (array)@parse_ini_file("$varroot/devs.ini",true);
$disks = (array)@parse_ini_file("$varroot/disks.ini",true);
$saved = (array)@parse_ini_file("$varroot/monitor.ini",true);
$echo = [];
$size = _var($var,'mdResyncSize');
$spot = _var($var,'mdResyncPos');

View File

@@ -18,20 +18,21 @@
// if called from cli:
// anonymous: diagnostics
// all data: diagnostics -a
$opt = getopt('a',['all']);
$all = isset($opt['a']) || isset($opt['all']);
$zip = $all ? ($argv[2]??'') : ($argv[1]??'');
$cli = empty($zip);
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$folders = ['/boot','/boot/config','/boot/config/plugins','/boot/syslinux','/var/log','/var/log/plugins','/boot/extra','/var/log/packages','/var/lib/pkgtools/packages','/tmp'];
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
$folders = ['/boot','/boot/config','/boot/config/plugins','/boot/syslinux','/var/log','/var/log/plugins','/boot/extra','/var/log/packages','/var/lib/pkgtools/packages','/tmp'];
// global variables
$path = "/var/local/emhttp";
$var = @parse_ini_file("$path/var.ini") ?: [];
$disks = @parse_ini_file("$path/disks.ini",true) ?: [];
$var = (array)@parse_ini_file("$path/var.ini");
$disks = (array)@parse_ini_file("$path/disks.ini",true);
$pools = pools_filter($disks);
require_once "$docroot/webGui/include/CustomMerge.php";
@@ -354,8 +355,8 @@ if ($cli) {
}
// don't anonymize system share names
$vardomain = @parse_ini_file('/boot/config/domain.cfg') ?: [];
$vardocker = @parse_ini_file('/boot/config/docker.cfg') ?: [];
$vardomain = (array)@parse_ini_file('/boot/config/domain.cfg');
$vardocker = (array)@parse_ini_file('/boot/config/docker.cfg');
$showshares = [];
$customShares = '';
if (!empty($vardomain['IMAGE_FILE'])) $showshares[] = current(array_slice(explode('/',$vardomain['IMAGE_FILE']),3,1));
@@ -495,7 +496,7 @@ foreach ($files as $file) {
file_put_contents("/$diag/shares/shareDisks.txt",implode($shareDisk));
// create default user shares information
$shares = @parse_ini_file("$path/shares.ini", true) ?: [];
$shares = (array)@parse_ini_file("$path/shares.ini", true);
foreach ($shares as $share) {
$name = _var($share,'name');
if ($name && !in_array("/boot/config/shares/$name.cfg",$files)) {

View File

@@ -1,9 +1,10 @@
#!/usr/bin/php -q
<?PHP
require_once "/usr/local/emhttp/webGui/include/publish.php";
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/publish.php";
function emhttp_command($cmd) {
$var = @parse_ini_file("/var/local/emhttp/var.ini") ?: [];
$var = (array)@parse_ini_file("/var/local/emhttp/var.ini");
$cmd .= "&csrf_token=".($var['csrf_token']??'');
return curl_socket("/var/run/emhttpd.socket", "http://localhost/update", $cmd);
}

View File

@@ -11,8 +11,7 @@
* all copies or substantial portions of the Software.
*/
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix', true));

View File

@@ -12,8 +12,9 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$var = file_exists('/var/local/emhttp/var.ini') ? parse_ini_file('/var/local/emhttp/var.ini') : [];
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
$dir = ['system','appdata','isos','domains'];
$out = ['prev','previous'];

Some files were not shown because too many files have changed in this diff Show More