getDockerContainers(); $images = $DockerClient->getDockerImages(); $user_prefs = $dockerManPaths['user-prefs']; $autostart_file = $dockerManPaths['autostart-file']; if (!$containers && !$images) { echo ""._('No Docker containers installed').""; return; } if (file_exists($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); unset($sort); } // Read container info $allInfo = $DockerTemplates->getAllInfo(); $docker = []; $null = '0.0.0.0'; $autostart = (array)@file($autostart_file,FILE_IGNORE_NEW_LINES); $names = array_map('var_split',$autostart); function my_lang_time($text) { [$number, $text] = my_explode(' ',$text,2); return sprintf(_("%s $text"),$number); } function my_lang_log($text) { global $language; if (isset($language['healthy'])) $text = str_replace('healthy',$language['healthy'],$text); if (isset($language['Exited'])) $text = str_replace('Exited',$language['Exited'],$text); if (strpos($text,'ago')!==false) { [$t1,$t2] = my_explode(') ',$text); return $t1.'): '.my_lang_time($t2); } return _(_($text),2); } foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; $info = &$allInfo[$name]; $running = $info['running'] ? 1 : 0; $paused = $info['paused'] ? 1 : 0; $is_autostart = $info['autostart'] ? 'true':'false'; $updateStatus = substr($ct['NetworkMode'],-4)==':???' ? 2 : ($info['updated']=='true' ? 0 : ($info['updated']=='false' ? 1 : 3)); $template = $info['template']??''; $shell = $info['shell']??''; $webGui = html_entity_decode($info['url']??''); $support = html_entity_decode($info['Support']??''); $project = html_entity_decode($info['Project']??''); $registry = html_entity_decode($info['registry']??''); $donateLink = html_entity_decode($info['DonateLink']??''); $readme = html_entity_decode($info['ReadMe']??''); $menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s', '%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project),addslashes($registry),addslashes($donateLink),addslashes($readme)); $docker[] = "docker.push({name:'$name',id:'$id',state:$running,pause:$paused,update:$updateStatus});"; $shape = $running ? ($paused ? 'pause' : 'play') : 'square'; $status = $running ? ($paused ? 'paused' : 'started') : 'stopped'; $color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text'); $update = $updateStatus==1 ? 'blue-text' : ''; $icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png'; $image = substr($icon,-4)=='.png' ? "" : (substr($icon,0,5)=='icon-' ? "" : ""); $wait = var_split($autostart[array_search($name,$names)]??'',1); $networks = []; foreach($ct['Networks'] as $netName => $netVals) { $networks[] = "{$netName}{$netVals['IPAddress']}"; } $ports = []; foreach ($ct['Ports'] as $port) { $ports[] = sprintf('%s:%s%s', _var($port,'PrivatePort'), strtoupper(_var($port,'Type')), _var($port,'PublicPort')); } $paths = []; $ct['Volumes'] = is_array($ct['Volumes']) ? $ct['Volumes'] : []; foreach ($ct['Volumes'] as $mount) { [$host_path,$container_path,$access_mode] = my_explode(':',$mount,3); $paths[] = sprintf('%s%s', htmlspecialchars($container_path), $access_mode=='ro'?'long-arrow-left':'arrows-h', htmlspecialchars($host_path)); } echo ""; if ($template) { $appname = "".htmlspecialchars($name).""; } else { $appname = htmlspecialchars($name); } echo "$image$appname
"._($status)."
"; echo "
"._('Container ID').": $id
"; if ($ct['BaseImage']) echo "".htmlspecialchars($ct['BaseImage'])."
"; echo _('By').": "; $registry = $info['registry']; ['strRepo' => $author, 'strTag' => $version] = DockerUtil::parseImageTag($ct['Image']); if ($registry) { echo "".htmlspecialchars(compress($author,24)).""; } else { echo htmlspecialchars(compress($author,24)); } echo "
"; switch ($updateStatus) { case 0: echo " "._('up-to-date').""; echo "
"._('force update')."
"; break; case 1: echo "
"._('update ready')."
"; echo " "._('apply update').""; break; case 2: echo "
"._('rebuild ready')."
"; echo " "._('rebuilding').""; break; default: echo " "._('not available').""; echo "
"._('force update')."
"; break; } echo "
".compress(_($version),12,0)."
"; echo " ".implode(' ',$networks).""; echo "".implode('
',$ports)."
"; echo "".implode('
',$paths)."
"; echo "0%
"; echo "
0 / 0"; echo ""; echo ""; echo "
".htmlspecialchars(str_replace('Up',_('Uptime').':',my_lang_log($ct['Status'])))."
"._('Created').": ".htmlspecialchars(my_lang_time($ct['Created']))."
"; } foreach ($images as $image) { if (count($image['usedBy'])) continue; $id = $image['Id']; $menu = sprintf("onclick=\"addDockerImageContext('%s','%s')\"", $id, implode(',',$image['Tags'])); echo ""; echo "("._('orphan image').")
"._('stopped')."
"; echo ""._('Image ID').": $id
"; echo implode(', ',$image['Tags']); echo ""._('Created')." ".htmlspecialchars(_($image['Created'],0)).""; } echo "\0".implode($docker)."\0".(pgrep('rc.docker')!==false ? 1:0); ?>