diff --git a/plugins/dynamix.docker.manager/include/CreateDocker.php b/plugins/dynamix.docker.manager/include/CreateDocker.php
index 0a69d9f43..e88c05c91 100644
--- a/plugins/dynamix.docker.manager/include/CreateDocker.php
+++ b/plugins/dynamix.docker.manager/include/CreateDocker.php
@@ -13,8 +13,12 @@
*/
?>
+$docroot = @$docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
+
ignore_user_abort(true);
-require_once '/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php';
+
+require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
+
$DockerClient = new DockerClient();
$DockerUpdate = new DockerUpdate();
$DockerTemplates = new DockerTemplates();
@@ -473,7 +477,7 @@ if (isset($_POST['contName'])) {
// Get the command line
list($cmd, $Name, $Repository) = xmlToCommand($postXML, $create_paths);
- readfile("/usr/local/emhttp/plugins/dynamix.docker.manager/log.htm");
+ readfile("$docroot/plugins/dynamix.docker.manager/log.htm");
@flush();
// Saving the generated configuration file.
@@ -492,8 +496,8 @@ if (isset($_POST['contName'])) {
echo "
".htmlentities($postXML)."
";
echo "COMMAND:
";
echo "".htmlentities($cmd)."
";
- echo "";
- echo "
";
+ echo "";
+ echo "
";
goto END;
}
@@ -501,7 +505,7 @@ if (isset($_POST['contName'])) {
if (!$DockerClient->doesImageExist($Repository)) {
// Pull image
if (!pullImage($Name, $Repository)) {
- echo '
';
+ echo '
';
goto END;
}
}
@@ -546,7 +550,7 @@ if (isset($_POST['contName'])) {
$_GET['cmd'] = $cmd;
include($dockerManPaths['plugin'] . "/include/Exec.php");
- echo '
';
+ echo '
';
goto END;
}
@@ -554,7 +558,7 @@ if (isset($_POST['contName'])) {
## UPDATE CONTAINER
##
if ($_GET['updateContainer']){
- readfile("/usr/local/emhttp/plugins/dynamix.docker.manager/log.htm");
+ readfile("$docroot/plugins/dynamix.docker.manager/log.htm");
@flush();
foreach ($_GET['ct'] as $value) {
@@ -602,7 +606,7 @@ if ($_GET['updateContainer']){
}
}
- echo '
';
+ echo '
';
goto END;
}
diff --git a/plugins/dynamix.docker.manager/include/UpdateConfig.php b/plugins/dynamix.docker.manager/include/UpdateConfig.php
index 95ebb2092..5a6b63fa3 100644
--- a/plugins/dynamix.docker.manager/include/UpdateConfig.php
+++ b/plugins/dynamix.docker.manager/include/UpdateConfig.php
@@ -11,7 +11,8 @@
*/
?>
-require_once("/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php");
+$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
+require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
// Autostart file
global $dockerManPaths;
@@ -22,27 +23,27 @@ $template_repos = $dockerManPaths['template-repos'];
if ($_POST['action'] == "autostart" ){
$json = ($_POST['response'] == 'json') ? true : false;
- if (! $json) readfile("/usr/local/emhttp/update.htm");
+ if (!$json) readfile("$docroot/update.htm");
$container = urldecode(($_POST['container']));
unset($_POST['container']);
$allAutoStart = @file($autostart_file, FILE_IGNORE_NEW_LINES);
- if ($allAutoStart===FALSE) $allAutoStart = array();
+ if ($allAutoStart===FALSE) $allAutoStart = [];
$key = array_search($container, $allAutoStart);
if ($key===FALSE) {
array_push($allAutoStart, $container);
- if ($json) echo json_encode(array( 'autostart' => true ));
+ if ($json) echo json_encode(['autostart' => true]);
}
else {
unset($allAutoStart[$key]);
- if ($json) echo json_encode(array( 'autostart' => false ));
+ if ($json) echo json_encode(['autostart' => false]);
}
file_put_contents($autostart_file, implode(PHP_EOL, $allAutoStart).(count($allAutoStart)? PHP_EOL : ""));
}
if ($_POST['#action'] == "templates" ){
- readfile("/usr/local/emhttp/update.htm");
+ readfile("$docroot/update.htm");
$repos = $_POST['template_repos'];
file_put_contents($template_repos, $repos);
$DockerTemplates = new DockerTemplates();
@@ -50,6 +51,6 @@ if ($_POST['#action'] == "templates" ){
}
if ( isset($_GET['is_dir'] )) {
- echo json_encode( array( 'is_dir' => is_dir( $_GET['is_dir'] )));
+ echo json_encode(['is_dir' => is_dir($_GET['is_dir'])]);
}
?>
diff --git a/plugins/dynamix.docker.manager/scripts/dockerupdate.php b/plugins/dynamix.docker.manager/scripts/dockerupdate.php
index c259b4970..37688a913 100755
--- a/plugins/dynamix.docker.manager/scripts/dockerupdate.php
+++ b/plugins/dynamix.docker.manager/scripts/dockerupdate.php
@@ -12,10 +12,13 @@
*/
?>
+$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
+
exec("pgrep docker", $pid);
if (count($pid) == 1) exit(0);
-require_once '/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php';
+require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
+
$DockerClient = new DockerClient();
$DockerTemplates = new DockerTemplates();
@@ -32,8 +35,8 @@ if (!isset($check)) {
$DockerTemplates->getAllInfo(true);
echo " Done.";
} else {
- require_once '/usr/local/emhttp/webGui/include/Wrappers.php';
- $notify = "/usr/local/emhttp/webGui/scripts/notify";
+ require_once "$docroot/webGui/include/Wrappers.php";
+ $notify = "$docroot/webGui/scripts/notify";
$unraid = parse_plugin_cfg("dynamix",true);
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['docker_notify'];
@@ -43,7 +46,7 @@ if (!isset($check)) {
$name = $ct['Name'];
$image = $ct['Image'];
if ($info[$name]['updated'] == "false") {
- $updateStatus = (is_file($dockerManPaths['update-status'])) ? json_decode(file_get_contents($dockerManPaths['update-status']), TRUE) : array();
+ $updateStatus = (is_file($dockerManPaths['update-status'])) ? json_decode(file_get_contents($dockerManPaths['update-status']), TRUE) : [];
$new = str_replace('sha256:', '', $updateStatus[$image]['remote']);
$new = substr($new, 0, 4).'..'.substr($new, -4, 4);