use getConfiguredScriptServers()

This commit is contained in:
Roland Gruber 2019-10-13 20:12:55 +02:00
parent cc3e8057d8
commit de988316a5
1 changed files with 18 additions and 19 deletions

View File

@ -15,7 +15,7 @@ use \htmlResponsiveRow;
/* /*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2006 - 2018 Roland Gruber Copyright (C) 2006 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -51,7 +51,9 @@ startSecureSession();
enforceUserIsLoggedIn(); enforceUserIsLoggedIn();
// die if no write access // die if no write access
if (!checkIfWriteAccessIsAllowed()) die(); if (!checkIfWriteAccessIsAllowed()) {
die();
}
checkIfToolIsActive('toolTests'); checkIfToolIsActive('toolTests');
@ -64,33 +66,31 @@ echo "<form action=\"lamdaemonTest.php\" method=\"post\">\n";
$container = new htmlResponsiveRow(); $container = new htmlResponsiveRow();
$container->add(new htmlTitle(_("Lamdaemon test")), 12); $container->add(new htmlTitle(_("Lamdaemon test")), 12);
$servers = explode(";", $_SESSION['config']->get_scriptServers()); $servers = $_SESSION['config']->getConfiguredScriptServers();
$serverIDs = array(); $serverIDs = array();
$serverTitles = array(); $serverTitles = array();
for ($i = 0; $i < sizeof($servers); $i++) { foreach ($servers as $server) {
$serverParts = explode(":", $servers[$i]); $serverName = $server->getServer();
$serverName = $serverParts[0]; $label = $server->getLabel();
$title = $serverName; if ($label !== $serverName) {
if (isset($serverParts[1])) { $label = $label . " (" . $serverName . ")";
$title = $serverParts[1] . " (" . $serverName . ")";
} }
$serverIDs[] = $serverName; $serverIDs[] = $serverName;
$serverTitles[$serverName] = $title; $serverTitles[$serverName] = $label;
} }
if (isset($_POST['runTest'])) { if (isset($_POST['runTest'])) {
lamRunTestSuite($_POST['server'], $serverTitles[$_POST['server']] , isset($_POST['checkQuotas']), $container); lamRunTestSuite($_POST['server'], $serverTitles[$_POST['server']] , isset($_POST['checkQuotas']), $container);
} }
else if ((sizeof($servers) > 0) && isset($servers[0]) && ($servers[0] != '')) { elseif (!empty($servers)) {
$serverOptions = array(); $serverOptions = array();
for ($i = 0; $i < sizeof($servers); $i++) { foreach ($servers as $server) {
$servers[$i] = explode(":", $servers[$i]); $serverName = $server->getServer();
$serverName = $servers[$i][0]; $label = $server->getLabel();
$title = $serverName; if ($label !== $serverName) {
if (isset($servers[$i][1])) { $label = $label . " (" . $serverName . ")";
$title = $servers[$i][1] . " (" . $serverName . ")";
} }
$serverOptions[$title] = $serverName; $serverOptions[$label] = $serverName;
} }
$serverSelect = new htmlResponsiveSelect('server', $serverOptions, array(), _("Server")); $serverSelect = new htmlResponsiveSelect('server', $serverOptions, array(), _("Server"));
$serverSelect->setHasDescriptiveElements(true); $serverSelect->setHasDescriptiveElements(true);
@ -245,7 +245,6 @@ function lamRunTestSuite($serverName, $serverTitle, $testQuota, $container) {
if (!$stopTest) { if (!$stopTest) {
$container->add(new htmlOutputText(_("SSH connection")), 10, 4); $container->add(new htmlOutputText(_("SSH connection")), 10, 4);
flush(); flush();
$sshOk = false;
try { try {
$remote->connect($serverName); $remote->connect($serverName);
$container->add(new htmlImage($okImage), 2); $container->add(new htmlImage($okImage), 2);