mirror of
https://github.com/unraid/webgui.git
synced 2026-03-09 04:21:27 -05:00
Merge pull request #76 from bergware/master
Incorporate all enhancements of "bleeding edge"
This commit is contained in:
@@ -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 "<pre>".htmlentities($postXML)."</pre>";
|
||||
echo "<h2>COMMAND:</h2>";
|
||||
echo "<pre>".htmlentities($cmd)."</pre>";
|
||||
echo "<center><input type='button' value='Back' onclick='window.location=window.location.pathname+window.location.hash+\"?xmlTemplate=edit:${filename}\"'>";
|
||||
echo "<input type='button' value='Done' onclick='done()'></center><br>";
|
||||
echo "<div style='text-align:center'><input type='button' value='Back' onclick='window.location=window.location.pathname+window.location.hash+\"?xmlTemplate=edit:${filename}\"'>";
|
||||
echo "<input type='button' value='Done' onclick='done()'></div><br>";
|
||||
goto END;
|
||||
}
|
||||
|
||||
@@ -501,7 +505,7 @@ if (isset($_POST['contName'])) {
|
||||
if (!$DockerClient->doesImageExist($Repository)) {
|
||||
// Pull image
|
||||
if (!pullImage($Name, $Repository)) {
|
||||
echo '<center><input type="button" value="Done" onclick="done()"></center><br>';
|
||||
echo '<div style="text-align:center"><input type="button" value="Done" onclick="done()"></div><br>';
|
||||
goto END;
|
||||
}
|
||||
}
|
||||
@@ -546,7 +550,7 @@ if (isset($_POST['contName'])) {
|
||||
$_GET['cmd'] = $cmd;
|
||||
include($dockerManPaths['plugin'] . "/include/Exec.php");
|
||||
|
||||
echo '<center><input type="button" value="Done" onclick="done()"></center><br>';
|
||||
echo '<div style="text-align:center"><input type="button" value="Done" onclick="done()"></div><br>';
|
||||
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 '<center><input type="button" value="Done" onclick="window.parent.jQuery(\'#iframe-popup\').dialog(\'close\');"></center><br>';
|
||||
echo '<div style="text-align:center"><input type="button" value="Done" onclick="window.parent.jQuery(\'#iframe-popup\').dialog(\'close\');"></div><br>';
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
$dockerManPaths = [
|
||||
'plugin' => '/usr/local/emhttp/plugins/dynamix.docker.manager',
|
||||
@@ -26,11 +27,11 @@ $dockerManPaths = [
|
||||
|
||||
#load emhttp variables if needed.
|
||||
if (!isset($var)) {
|
||||
if (!is_file("/usr/local/emhttp/state/var.ini")) shell_exec("wget -qO /dev/null localhost:$(lsof -nPc emhttp | grep -Po 'TCP[^\d]*\K\d+')");
|
||||
$var = @parse_ini_file("/usr/local/emhttp/state/var.ini");
|
||||
if (!is_file("$docroot/state/var.ini")) shell_exec("wget -qO /dev/null localhost:$(lsof -nPc emhttp | grep -Po 'TCP[^\d]*\K\d+')");
|
||||
$var = @parse_ini_file("$docroot/state/var.ini");
|
||||
}
|
||||
if (!isset($eth0) && is_file("/usr/local/emhttp/state/network.ini")) {
|
||||
extract(parse_ini_file('/usr/local/emhttp/state/network.ini',true));
|
||||
if (!isset($eth0) && is_file("$docroot/state/network.ini")) {
|
||||
extract(parse_ini_file("$docroot/state/network.ini",true));
|
||||
}
|
||||
|
||||
// Docker configuration file - guaranteed to exist
|
||||
@@ -354,7 +355,7 @@ class DockerTemplates {
|
||||
|
||||
|
||||
public function getIcon($Repository) {
|
||||
global $dockerManPaths;
|
||||
global $docroot, $dockerManPaths;
|
||||
|
||||
$imgUrl = $this->getTemplateValue($Repository, "Icon");
|
||||
|
||||
@@ -369,8 +370,7 @@ class DockerTemplates {
|
||||
}
|
||||
@copy($storagePath, $tempPath);
|
||||
}
|
||||
|
||||
return (is_file($tempPath)) ? str_replace('/usr/local/emhttp', '', $tempPath) : "";
|
||||
return (is_file($tempPath)) ? str_replace($docroot, '', $tempPath) : "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,12 +778,12 @@ class DockerClient {
|
||||
|
||||
|
||||
public function removeContainer($id) {
|
||||
global $dockerManPaths;
|
||||
global $docroot, $dockerManPaths;
|
||||
// Purge cached container information
|
||||
$info = DockerUtil::loadJSON($dockerManPaths['webui-info']);
|
||||
if (isset($info[$id])) {
|
||||
if (isset($info[$id]['icon'])) {
|
||||
$iconRam = '/usr/local/emhttp'.$info[$id]['icon'];
|
||||
$iconRam = $docroot.$info[$id]['icon'];
|
||||
$iconFlash = str_replace($dockerManPaths['images-ram'], $dockerManPaths['images-storage'], $iconRam);
|
||||
if (is_file($iconRam)) {
|
||||
unlink($iconRam);
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
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";
|
||||
|
||||
$DockerClient = new DockerClient();
|
||||
|
||||
$_REQUEST = array_merge($_GET, $_POST);
|
||||
@@ -62,9 +65,9 @@ switch ($action) {
|
||||
if ($container) {
|
||||
$since = array_key_exists('since', $_REQUEST) ? $_REQUEST['since'] : '';
|
||||
$title = array_key_exists('title', $_REQUEST) ? $_REQUEST['title'] : '';
|
||||
require_once '/usr/local/emhttp/webGui/include/ColorCoding.php';
|
||||
require_once "$docroot/webGui/include/ColorCoding.php";
|
||||
if (!$since) {
|
||||
readfile("/usr/local/emhttp/plugins/dynamix.docker.manager/log.htm");
|
||||
readfile("$docroot/plugins/dynamix.docker.manager/log.htm");
|
||||
echo "<script>document.title = '$title';</script>";
|
||||
echo "<script>addLog('".addslashes("<p style='text-align:center'><span class='error label'>Error</span><span class='warn label'>Warning</span><span class='system label'>System</span><span class='array label'>Array</span><span class='login label'>Login</span></p>")."');</script>";
|
||||
$tail = 350;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
if ( isset( $_GET['cmd'] )) {
|
||||
$command = urldecode(($_GET['cmd']));
|
||||
$descriptorspec = [
|
||||
@@ -20,7 +22,7 @@ if ( isset( $_GET['cmd'] )) {
|
||||
];
|
||||
|
||||
$parts = explode(" ", $command);
|
||||
$command = escapeshellcmd(realpath($_SERVER['DOCUMENT_ROOT'].array_shift($parts)));
|
||||
$command = escapeshellcmd(realpath($docroot.array_shift($parts)));
|
||||
if (!$command) return;
|
||||
$command .= " ".implode(" ", $parts); // should add 'escapeshellarg' here, but this requires changes in all the original arguments
|
||||
$id = mt_rand();
|
||||
@@ -31,7 +33,7 @@ if ( isset( $_GET['cmd'] )) {
|
||||
echo "<p class=\"logLine\" id=\"logBody\"></p></fieldset>');</script>";
|
||||
echo "<script>show_Wait({$id});</script>";
|
||||
@flush();
|
||||
$proc = proc_open($command." 2>&1", $descriptorspec, $pipes, '/', array());
|
||||
$proc = proc_open($command." 2>&1", $descriptorspec, $pipes, '/', []);
|
||||
while ($out = fgets( $pipes[1] )) {
|
||||
$out = preg_replace("%[\t\n\x0B\f\r]+%", '', $out );
|
||||
@flush();
|
||||
|
||||
@@ -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'])]);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user