public static function install($data, &$fail, &$errno, &$error) { $res = array(); if (!$fail) { // die /platform Befehle auslösen $list = Einstellungen::getLinks('postPlatform'); $platform = Installation::PlattformZusammenstellen($data); $multiRequestHandle = new Request_MultiRequest(); for ($i = 0; $i < count($list); $i++) { // inits all components $handler = Request_CreateRequest::createPost($list[$i]->getAddress() . '/platform', array(), Platform::encodePlatform($platform)); $multiRequestHandle->addRequest($handler); } $answer = $multiRequestHandle->run(); for ($i = 0; $i < count($list); $i++) { $url = $list[$i]->getTargetName(); $result = $answer[$i]; $res[$url] = array(); if (isset($result['content']) && isset($result['status']) && $result['status'] === 201) { $res[$url]['status'] = 201; } else { $res[$url]['status'] = 409; $fail = true; if (isset($result['status'])) { $errno = $result['status']; $res[$url]['status'] = $result['status']; } } } } return $res; }
public static function show($console, $result, $data) { $text = ''; $failure = false; Einstellungen::$path = dirname(__FILE__) . '/../config'; if (!is_dir(Einstellungen::$path) || !is_writable(__FILE__)) { $text .= Design::erstelleZeile($console, Language::Get('mainInfo', 'notWritable'), 'error'); $failure = true; } if ($failure) { echo Design::erstelleBlock($console, Language::Get('mainInfo', 'title'), $text); } }
/** * Ermittelt alle vorhandenen Serverkonfigurationsdateien * aus dem config Ordners * * @return string[] Die Dateipfade */ public static function GibServerDateien() { $serverFiles = array(); Einstellungen::$path = dirname(__FILE__) . '/../config'; Einstellungen::generatepath(Einstellungen::$path); if (is_dir(Einstellungen::$path)) { if ($handle = opendir(Einstellungen::$path)) { while (false !== ($file = readdir($handle))) { if ($file == '.' || $file == '..') { continue; } $serverFiles[] = $file; } closedir($handle); } } else { return array(); } return $serverFiles; }
public static function cleanCourses($data, &$fail, &$errno, &$error) { $res = array(); if (!$fail) { $cleanLinks = Einstellungen::getLinks('deleteClean'); // alle Veranstaltungen abrufen $multiRequestHandle = new Request_MultiRequest(); $handler = Request_CreateRequest::createGet($data['PL']['url'] . '/DB/DBCourse/course', array(), ''); $multiRequestHandle->addRequest($handler); $result = $multiRequestHandle->run(); if (isset($result[0]['content']) && isset($result[0]['status']) && $result[0]['status'] === 200) { // /course ausloesen $courses = Course::decodeCourse($result[0]['content']); if (!is_array($courses)) { $courses = array($courses); } $offset = count($courses) - 50; // nur die letzten 50 Veranstaltungen werden bereinigt $offset = $offset < 0 ? 0 : $offset; $courses = array_slice($courses, $offset); foreach ($courses as $course) { $multiRequestHandle = new Request_MultiRequest(); $answer = array(); for ($i = 0; $i < count($cleanLinks); $i++) { // inits all components $handler = Request_CreateRequest::createDelete($cleanLinks[$i]->getAddress() . '/clean/clean/course/' . $course->getId(), array(), ''); $multiRequestHandle->addRequest($handler); } $answer = $multiRequestHandle->run(); } $res['status'] = 201; } else { $fail = true; $error = "GET /DB/DBCourse/course " . Language::Get('courses', 'operationFailed'); if (isset($result[0]['status'])) { $errno = $result[0]['status']; } } } return $res; }
public static function install($data, &$fail, &$errno, &$error) { $serverFiles = Installation::GibServerDateien(); $installComponentDefsResult['components'] = array(); foreach ($serverFiles as $sf) { $sf = pathinfo($sf)['filename']; $tempData = Einstellungen::ladeEinstellungenDirekt($sf, $data); if ($tempData === null) { $fail = true; $error = Language::Get('generateComponents', 'noAccess'); return; } $componentList = Zugang::Ermitteln('actionInstallComponentDefs', 'KomponentenErstellen::installiereKomponentenDefinitionen', $tempData, $fail, $errno, $error); if (isset($componentList['components'])) { $installComponentDefsResult['components'] = array_merge($installComponentDefsResult['components'], $componentList['components']); } } // Komponenten erzeugen $comList = array(); $setDBNames = array(); $ComponentList = array(); // zunächst die Komponentenliste nach Namen sortieren $ComponentListInput = array(); foreach ($installComponentDefsResult['components'] as $key => $input) { if (!isset($input['name'])) { continue; } if (!isset($ComponentListInput[$input['name']])) { $ComponentListInput[$input['name']] = array(); } $ComponentListInput[$input['name']][$key] = $input; } for ($zz = 0; $zz < 2; $zz++) { $tempList = array(); foreach ($ComponentListInput as $key2 => $ComNames) { foreach ($ComNames as $key => $input) { if (!isset($input['name'])) { continue; } if (!isset($input['type']) || $input['type'] == 'normal') { // normale Komponente if (!isset($input['registered'])) { $comList[] = "('{$input['name']}', '{$input['urlExtern']}/{$input['path']}', '" . (isset($input['option']) ? $input['option'] : '') . "', '" . implode(';', isset($input['def']) ? $input['def'] : array()) . "')"; // Verknüpfungen erstellen $setDBNames[] = " SET @{$key}_{$input['name']} = (select CO_id from Component where CO_address='{$input['urlExtern']}/{$input['path']}' limit 1); "; $input['dbName'] = $key . '_' . $input['name']; $input['registered'] = '1'; } if (!isset($tempList[$key2])) { $tempList[$key2] = array(); } $tempList[$key2][] = $input; } elseif (isset($input['type']) && $input['type'] == 'clone') { // Komponente basiert auf einer bestehenden if (!isset($input['base'])) { continue; } if (!isset($input['baseURI'])) { $input['baseURI'] = ''; } if (isset($ComponentListInput[$input['base']])) { foreach ($ComponentListInput[$input['base']] as $key3 => $input2) { if (!isset($input2['name'])) { continue; } // pruefe, dass die Eintraege nicht doppelt erstellt werden $found = false; if (isset($ComponentListInput[$input['name']])) { foreach ($ComponentListInput[$input['name']] as $input3) { if ((!isset($input3['type']) || $input3['type'] == 'normal') && $input['name'] == $input3['name'] && "{$input3['urlExtern']}/{$input3['path']}" == "{$input2['urlExtern']}/{$input2['path']}{$input['baseURI']}") { $found = true; break; } } } if ($found) { continue; } if (isset($tempList[$input['name']])) { foreach ($tempList[$input['name']] as $input3) { if ($input['name'] == $input3['name'] && "{$input3['urlExtern']}/{$input3['path']}" == "{$input2['urlExtern']}/{$input2['path']}{$input['baseURI']}") { $found = true; break; } } } if ($found) { continue; } $input2['path'] = "{$input2['path']}{$input['baseURI']}"; $input2['def'] = array_merge($input2['def'], $input['def']); $input2['links'] = array_merge(isset($input2['links']) ? $input2['links'] : array(), isset($input['links']) ? $input['links'] : array()); $input2['connector'] = array_merge(isset($input2['connector']) ? $input2['connector'] : array(), isset($input['connector']) ? $input['connector'] : array()); if (isset($input['option'])) { $input2['option'] = $input['option']; } $input2['name'] = $input['name']; $input2['registered'] = null; if (!isset($tempList[$key2])) { $tempList[$key2] = array(); } $tempList[$key2][] = $input2; } } } } } $ComponentListInput = $tempList; } $sql = "START TRANSACTION;SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;TRUNCATE TABLE `ComponentLinkage`;SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;COMMIT;"; //TRUNCATE TABLE `Component`; DBRequest::request2($sql, false, $data, true); $sql = "UPDATE `Component` SET `CO_status` = '0';"; DBRequest::request2($sql, false, $data, true); $sql = "START TRANSACTION;SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;INSERT INTO `Component` (`CO_name`, `CO_address`, `CO_option`, `CO_def`) VALUES "; $installComponentDefsResult['componentsCount'] = count($comList); $sql .= implode(',', $comList); unset($comList); $sql .= " ON DUPLICATE KEY UPDATE CO_status='1', CO_address=VALUES(CO_address), CO_option=VALUES(CO_option), CO_def=VALUES(CO_def);SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;COMMIT;"; //echo $sql; DBRequest::request2($sql, false, $data, true); //echo $sql; $sql = "START TRANSACTION;SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;"; $sql .= implode('', $setDBNames); unset($setDBNames); $links = array(); foreach ($ComponentListInput as $key2 => $ComNames) { foreach ($ComNames as $key => $input) { if (isset($input['type']) && $input['type'] != 'normal') { continue; } if (isset($input['dbName'])) { // prüfe nun alle Verknüpfungen dieser Komponente und erstelle diese if (isset($input['links'])) { foreach ($input['links'] as $link) { if (!isset($link['target'])) { $link['target'] = ''; } if (!is_array($link['target'])) { $link['target'] = array($link['target']); } foreach ($link['target'] as $tar) { // $tar -> der Name der Zielkomponente if (!isset($ComponentListInput[$tar])) { continue; } foreach ($ComponentListInput[$tar] as $target) { // $target -> das Objekt der Zielkomponente if (!isset($target['dbName'])) { continue; } if (!isset($input['link_type']) || $input['link_type'] == 'local' || $input['link_type'] == '') { if ($input['urlExtern'] == $target['urlExtern']) { $priority = isset($input['priority']) ? ", CL_priority = {$input['priority']}" : ''; $relevanz = isset($input['relevanz']) ? $input['relevanz'] : ''; $sql .= " INSERT INTO `ComponentLinkage` SET CO_id_owner = @{$input['dbName']}, CL_name = '{$link['name']}', CL_relevanz = '{$relevanz}', CO_id_target = @{$target['dbName']} {$priority};"; $links[] = 1; } } elseif ($input['link_type'] == 'full') { if ($input['urlExtern'] == $target['urlExtern'] || isset($target['link_availability']) && $target['link_availability'] == 'full') { $priority = isset($input['priority']) ? ", CL_priority = {$input['priority']}" : ''; $relevanz = isset($input['relevanz']) ? $input['relevanz'] : ''; $sql .= " INSERT INTO `ComponentLinkage` SET CO_id_owner = @{$input['dbName']}, CL_name = '{$link['name']}', CL_relevanz = '{$relevanz}', CO_id_target = @{$target['dbName']} {$priority};"; $links[] = 1; } } } } } } if (isset($input['connector'])) { foreach ($input['connector'] as $link) { if (!isset($link['target'])) { $link['target'] = ''; } if (!is_array($link['target'])) { $link['target'] = array($link['target']); } if (!isset($link['links'])) { $link['links'] = array('a' => null); } foreach ($link['links'] as $callKey => $call) { foreach ($link['target'] as $tar) { // $tar -> der Name der Zielkomponente if (!isset($ComponentListInput[$tar])) { continue; } foreach ($ComponentListInput[$tar] as $target) { // $target -> das Objekt der Zielkomponente if (!isset($target['dbName'])) { continue; } if (!isset($input['link_type']) || $input['link_type'] == 'local' || $input['link_type'] == '') { if ($input['urlExtern'] == $target['urlExtern']) { $priority = isset($link['priority']) ? ", CL_priority = {$link['priority']}" : ''; $method = isset($call['method']) ? $call['method'] : 'GET'; $path = isset($call['path']) ? ", CL_path = '{$method} {$call['path']}'" : ''; $relevanz = isset($link['relevanz']) ? $link['relevanz'] : ''; $sql .= " INSERT INTO `ComponentLinkage` SET CO_id_owner = @{$target['dbName']}, CL_name = '{$link['name']}', CL_relevanz = '{$relevanz}', CO_id_target = @{$input['dbName']} {$priority} {$path};"; $links[] = 1; } } elseif ($input['link_type'] == 'full') { if ($input['urlExtern'] == $target['urlExtern'] || isset($input['link_availability']) && $input['link_availability'] == 'full') { $priority = isset($link['priority']) ? ", CL_priority = {$link['priority']}" : ''; $method = isset($call['method']) ? $call['method'] : 'GET'; $path = isset($call['path']) ? ", CL_path = '{$method} {$call['path']}'" : ''; $relevanz = isset($link['relevanz']) ? $link['relevanz'] : ''; $sql .= " INSERT INTO `ComponentLinkage` SET CO_id_owner = @{$target['dbName']}, CL_name = '{$link['name']}', CL_relevanz = '{$relevanz}', CO_id_target = @{$input['dbName']} {$priority} {$path};"; $links[] = 1; } } } } } } } } } } $installComponentDefsResult['linksCount'] = count($links); $sql .= " SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;COMMIT;"; DBRequest::request2($sql, false, $data, true); $installComponentDefsResult['components'] = $ComponentListInput; return $installComponentDefsResult; }
/** * Setzt die globalen Konfigurationsdaten auf den Ursprungszustand zurück */ public static function resetConf() { Einstellungen::$konfiguration = array(); }
/** * ??? * * @param ??? * @param ??? * @param string[][] $data Die Serverdaten * @return ??? */ public static function SendeDateien($files, $filesAddresses, $data) { $mainPath = dirname(__FILE__) . '/../..'; if ($data['ZV']['zv_type'] == 'local' || $data['ZV']['zv_type'] == '') { // leer } elseif ($data['ZV']['zv_type'] == 'ssh') { // Dateien senden if (!is_array($files)) { $files = array($files); } $allPaths = array(); foreach ($filesAddresses as $addresses) { $allPaths[] = dirname($addresses); } $allPaths = array_unique($allPaths); $allPaths = array_values($allPaths); for ($i = 0; $i < count($allPaths) - 1; $i++) { if (strpos($allPaths[$i + 1] . '/', $allPaths[$i] . '/') === 0) { $allPaths[$i] = null; } } $ssh = Zugang::Verbinden($data); foreach ($allPaths as $path) { if ($path != null) { $command = '$path="' . $path . '"; $e=explode("/", ltrim($path,"/")); $c=count($e); $cp=$e[0]; for($i=1;$i<$c;$i++){if(!is_dir($cp) && !@mkdir($cp,0775)){return false;} chmod($cp,0775);$cp.="/".$e[$i];} @mkdir($path,0775);chmod($path,0775);return true;'; $command = Zugang::checkServerType($ssh, $command); if (count($ssh->channel_status) > 0 && $ssh->channel_status[0] != 97) { $ssh = Zugang::Verbinden($data); } $ssh->exec('php -r ' . $command); } } $zip = new ZipArchive(); Einstellungen::generatepath(dirname(__FILE__) . '/../temp'); if ($zip->open(dirname(__FILE__) . '/../temp/data.zip', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) === TRUE) { for ($i = 0; $i < count($files); $i++) { if (file_exists($files[$i]) && is_readable($files[$i])) { $zip->addFromString($filesAddresses[$i], file_get_contents($files[$i])); } } $zip->close(); } if (count($ssh->channel_status) > 0 && $ssh->channel_status[0] != 97) { $ssh = Zugang::Verbinden($data); } $scp = new Net_SCP($ssh); if (count($ssh->channel_status) > 0 && $ssh->channel_status[0] != 97) { $ssh = Zugang::Verbinden($data); $scp = new Net_SCP($ssh); } $scp->put('data.zip', dirname(__FILE__) . '/../temp/data.zip', NET_SCP_LOCAL_FILE); $command = '$zip = new ZipArchive;$zip->open("data.zip");$zip->extractTo(".");$zip->close();unlink("data.zip");'; if (count($ssh->channel_status) > 0 && $ssh->channel_status[0] != 97) { $ssh = Zugang::Verbinden($data); $scp = new Net_SCP($ssh); } $command = Zugang::checkServerType($ssh, $command); $ssh->exec('php -r ' . $command); $ssh->disconnect(); if (isset($result['fail'])) { $fail = $result['fail']; unset($result['fail']); } if (isset($result['errno'])) { $errno = $result['errno']; unset($result['errno']); } if (isset($result['error'])) { $error = $result['error']; unset($result['error']); } } else { return array(); } }
/** * Die Hauptfunktion des Installationsassistenten * * @param bool $console true = Konsolendarstellung, false = HTML */ public function CallInstall($console = false) { $output = array(); $installFail = false; $simple = false; $data = array(); $tmp = array(); if (isset($_POST['data'])) { $data = $_POST['data']; } if (isset($_POST['tmp'])) { $tmp = $_POST['tmp']; } if (isset($_POST['simple'])) { $simple = true; } if (isset($_POST['update'])) { $_POST['action'] = 'update'; } if (isset($_POST['actionInstall'])) { $_POST['action'] = 'install'; } if (isset($_POST['actionUpdate'])) { $_POST['action'] = 'update'; } if (!isset($data['PL']['language'])) { $data['PL']['language'] = 'de'; } if (!isset($data['PL']['init'])) { $data['PL']['init'] = 'DB/CControl'; } // URLs und Pfade sollen keinen / am Ende haben (damit es einheitlich ist) if (isset($data['PL']['url'])) { $data['PL']['url'] = rtrim($data['PL']['url'], '/'); } if (isset($data['PL']['urlExtern'])) { $data['PL']['urlExtern'] = rtrim($data['PL']['urlExtern'], '/'); } if (isset($data['PL']['temp'])) { $data['PL']['temp'] = rtrim($data['PL']['temp'], '/'); } if (isset($data['PL']['files'])) { $data['PL']['files'] = rtrim($data['PL']['files'], '/'); } if (isset($data['PL']['init'])) { $data['PL']['init'] = rtrim($data['PL']['init'], '/'); } // check which server is selected $server = isset($_POST['server']) ? $_POST['server'] : null; Einstellungen::$selected_server = isset($_POST['selected_server']) ? $_POST['selected_server'] : null; // behandle das MasterPasswort $serverHash = md5(Einstellungen::$selected_server); $tmp[$serverHash]['newMasterPassword'] = isset($tmp[$serverHash]['masterPassword']) ? $tmp[$serverHash]['masterPassword'] : null; if (isset($_POST['changeMasterPassword'])) { Einstellungen::$masterPassword[$serverHash] = isset($tmp[$serverHash]['oldMasterPassword']) ? $tmp[$serverHash]['oldMasterPassword'] : null; $tmp[$serverHash]['masterPassword'] = Einstellungen::$masterPassword[$serverHash]; } else { Einstellungen::$masterPassword[$serverHash] = $tmp[$serverHash]['newMasterPassword']; $tmp[$serverHash]['masterPassword'] = Einstellungen::$masterPassword[$serverHash]; } foreach ($tmp as $key => $tm) { if (!isset($tm['masterPassword']) && isset($tm['oldMasterPassword']) && trim($tm['oldMasterPassword']) != '') { $tmp[$key]['masterPassword'] = $tm['oldMasterPassword']; $tmp[$key]['newMasterPassword'] = isset($tmp[$key]['oldMasterPassword']) ? $tmp[$key]['oldMasterPassword'] : null; Einstellungen::$masterPassword[$key] = $tm['oldMasterPassword']; } if (!isset(Einstellungen::$masterPassword[$key]) && isset($tmp[$key]['masterPassword']) && trim($tmp[$key]['masterPassword']) != '') { $tmp[$key]['newMasterPassword'] = isset($tmp[$key]['masterPassword']) ? $tmp[$key]['masterPassword'] : null; Einstellungen::$masterPassword[$key] = $tm['masterPassword']; } } // prüfe ob der Servername geändert wurde if (isset($data['SV']['name']) && $data['SV']['name'] !== null && Einstellungen::$selected_server !== null) { if ($data['SV']['name'] != Einstellungen::$selected_server) { $oldServerHash = md5($data['SV']['name']); $newServerHash = md5(Einstellungen::$selected_server); if (isset(Einstellungen::$masterPassword[$oldServerHash])) { Einstellungen::$masterPassword[$newServerHash] = Einstellungen::$masterPassword[$oldServerHash]; unset(Einstellungen::$masterPassword[$oldServerHash]); } Einstellungen::umbenennenEinstellungen(Einstellungen::$selected_server, $data['SV']['name']); } } // check which menu is selected $selected_menu = intval(isset($_POST['selected_menu']) ? $_POST['selected_menu'] : self::$menuItems[0]); if (isset($_POST['action']) && $_POST['action'] == 'update') { $selected_menu = -1; } // check server configs Einstellungen::$serverFiles = Installation::GibServerDateien(); // add Server $addServer = false; $addServerResult = array(); if ((isset($_POST['action']) && $_POST['action'] === 'install' || isset($_POST['actionAddServer']) || count(Einstellungen::$serverFiles) == 0) && !$installFail) { $addServer = true; $server = Einstellungen::NeuenServerAnlegen(); Einstellungen::$serverFiles[] = $server; $server = pathinfo($server)['filename']; Einstellungen::ladeEinstellungen($server, $data); ///$data['SV']['name'] = $server; Einstellungen::speichereEinstellungen($server, $data); } // save data on switching between server-confs if (Einstellungen::$selected_server !== null && $server != null) { if ($server != Einstellungen::$selected_server) { Einstellungen::ladeEinstellungen(Einstellungen::$selected_server, $data); //Einstellungen::speichereEinstellungen(Einstellungen::$selected_server,$data); Einstellungen::resetConf(); } } // select first if no server is selected if (Einstellungen::$selected_server == null && $server == null) { Einstellungen::$selected_server = pathinfo(Einstellungen::$serverFiles[0])['filename']; $server = Einstellungen::$selected_server; } if ($server != null) { Einstellungen::$selected_server = $server; } $server = Einstellungen::$selected_server; $data['SV']['name'] = Einstellungen::$selected_server; $serverHash = md5(Einstellungen::$selected_server); if (!isset($tmp[$serverHash]['masterPassword'])) { $tmp[$serverHash]['masterPassword'] = null; } // nun kann die Konfiguration des gewählten Servers geladen werden (selected_server) Einstellungen::ladeEinstellungen(Einstellungen::$selected_server, $data); Einstellungen::$masterPassword[$serverHash] = isset($tmp[$serverHash]['newMasterPassword']) ? $tmp[$serverHash]['newMasterPassword'] : ''; if (isset(Einstellungen::$masterPassword[$serverHash])) { $tmp[$serverHash]['masterPassword'] = Einstellungen::$masterPassword[$serverHash]; } // load language Language::loadLanguage($data['PL']['language'], 'default', 'ini'); // ermittle alle Segmente $this->loadSegments(); if (Einstellungen::$accessAllowed) { if ($console) { $data['ZV']['zv_type'] = 'local'; } if ($simple) { $data['ZV']['zv_type'] = 'local'; } if (isset($_POST['action'])) { $data['action'] = $_POST['action']; } $fail = false; $errno = null; $error = null; if ($simple) { $selected_menu = -1; } } if (!$console && !$simple) { // select language - german if (isset($_POST['actionSelectGerman']) || isset($_POST['actionSelectGerman_x'])) { $data['PL']['language'] = 'de'; } // select language - english if (isset($_POST['actionSelectEnglish']) || isset($_POST['actionSelectEnglish_x'])) { $data['PL']['language'] = 'en'; } echo "<html><head>"; echo "<link rel='stylesheet' type='text/css' href='css/format.css'>"; $titleText = Language::Get('main', 'title' . $selected_menu); if ($selected_menu == -1) { if (isset($_POST['action'])) { $titleText = Language::Get('main', 'title' . $_POST['action']); } } echo "</head><body><div class='center'>"; if (Einstellungen::$accessAllowed && $titleText !== '???') { echo "<h1>" . $titleText . "</h1></br>"; } echo "<form action='' method='post' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false'>"; } if (Einstellungen::$accessAllowed) { // führe die Initialisierungsfunktionen der Segmente aus foreach (Einstellungen::$segments as $segs) { if (!is_callable("{$segs}::init")) { continue; } ///if (!isset($segs::$initialized)) continue; ///if ($segs::$initialized) continue; $segs::init($console, $data, $fail, $errno, $error); } $segmentResults = array(); // installiere die Segmente foreach (Einstellungen::$segments as $segs) { if (!isset($segs::$onEvents)) { continue; } foreach ($segs::$onEvents as $event) { if (isset($event['enabledInstall']) && !$event['enabledInstall']) { continue; } $isSetEvent = false; if (isset($_POST['action']) && in_array($_POST['action'], $event['event'])) { $isSetEvent = true; } foreach ($event['event'] as $ev) { if (isset($_POST[$ev])) { $isSetEvent = true; break; } } if (!$installFail && ($segs::$page === $selected_menu && in_array('page', $event['event']) || $isSetEvent)) { $result = array(); $procedure = 'install'; if (isset($event['procedure'])) { $procedure = $event['procedure']; } $result['content'] = Zugang::Ermitteln($event['name'], $segs . '::' . $procedure, $data, $fail, $errno, $error); $segs::$installed = true; $installFail = $fail; $result['fail'] = $fail; $result['errno'] = $errno; $result['error'] = $error; if ($console && !$simple) { $output[$segs::$name] = $result; } $fail = false; $errno = null; $error = null; if (!isset($segmentResults[$segs::$name])) { $segmentResults[$segs::$name] = array(); } $segmentResults[$segs::$name][$event['name']] = $result; } } } } if (!$console && !$simple) { echo "<table border='0'><tr>"; echo "<th valign='top'>"; echo "<div style='width:150px;word-break: break-all;'>"; echo "<table border='0'>"; // ab hier wird die linke Infoleiste erzeugt foreach (Einstellungen::$segments as $segs) { if (isset($segs::$enabledShow) && !$segs::$enabledShow) { continue; } if (!is_callable("{$segs}::showInfoBar")) { continue; } $segs::showInfoBar($data); echo "<tr><th height='10'></th></tr>"; } echo "</table>"; echo "</div"; echo "</th>"; echo "<th width='2'></th>"; echo "</th>"; echo "<th width='600'><hr />"; if (Einstellungen::$accessAllowed) { echo "<table border='0' cellpadding='4' width='600'>"; echo "<input type='hidden' name='selected_menu' value='{$selected_menu}'>"; echo "<tr>"; $text = ''; for ($i = 0; $i < count(self::$menuItems); $i++) { if ($i % 5 == 0 && $i > 0) { $text .= "<tr>"; } $item = self::$menuItems[$i]; $type = self::$menuTypes[$i]; echo "<td class='" . ($type == 0 ? 'h' : 'k') . "'><div align='center'>" . Design::erstelleSubmitButtonFlach('selected_menu', $item, $selected_menu == $item ? '<font color="maroon">' . Language::Get('main', 'title' . $item) . '</font>' : Language::Get('main', 'title' . $item)) . "</div></td>"; } echo "</tr>"; echo "</table>"; } else { $text = ''; $text .= Design::erstelleBeschreibung($console, Language::Get('main', 'insertMasterPassword')); echo Design::erstelleBlock($console, '', $text); } echo "<hr />"; } #region Sprachwahl if (!$console && !$simple) { echo "<input type='hidden' name='data[PL][language]' value='{$data['PL']['language']}'>"; echo "<div align='center'>" . Design::erstelleSubmitButtonGrafisch('actionSelectGerman', './images/de.gif', 32, 22) . Design::erstelleSubmitButtonGrafisch('actionSelectEnglish', './images/en.gif', 32, 22) . "</div>"; } #endregion Sprachwahl if (Einstellungen::$accessAllowed) { // show segments foreach (Einstellungen::$segments as $segs) { if (isset($segs::$enabledShow) && !$segs::$enabledShow) { continue; } if (!isset($segs::$page) || $segs::$page === $selected_menu || isset($segs::$installed) && $segs::$installed) { if (!is_callable("{$segs}::show")) { continue; } $result = isset($segmentResults[$segs::$name]) ? $segmentResults[$segs::$name] : array(); $segs::show($console, $result, $data); } } if ($simple) { if ($installFail) { echo "0"; } else { echo "1"; } } if (!$console && !$simple) { if (($selected_menu === 2 || $selected_menu === 3 || $selected_menu === 4) && false) { echo "<table border='0' cellpadding='3' width='600'>"; echo "<tr><td class='h'><div align='center'><input type='submit' name='actionInstall' value=' " . Language::Get('main', 'installAll') . " '></div></td></tr>"; echo "</table><br />"; } #region zurück_weiter_buttons $a = ''; $b = ''; if (array_search($selected_menu, self::$menuItems) > 0) { $item = self::$menuItems[array_search($selected_menu, self::$menuItems) - 1]; $a = Design::erstelleSubmitButtonFlach('selected_menu', $item, Language::Get('main', 'back')) . '<br><font size=1>(' . Language::Get('main', 'title' . $item) . ')</font>'; } if ($selected_menu >= 0 && array_search($selected_menu, self::$menuItems) < count(self::$menuItems) - 1) { $item = self::$menuItems[array_search($selected_menu, self::$menuItems) + 1]; $b = Design::erstelleSubmitButtonFlach('selected_menu', $item, Language::Get('main', 'next')) . '<br><font size=1>(' . Language::Get('main', 'title' . $item) . ')</font>'; } echo "<table border='0' cellpadding='3' width='600'>"; echo "<thead><tr><th align='left' width='50%'>{$a}</th><th align='right' width='50%'>{$b}</th></tr></thead>"; if ($selected_menu == 0) { if (!isset($_POST['actionShowPhpInfo'])) { echo "<tr><th colspan='2'>" . Design::erstelleSubmitButton("actionShowPhpInfo", 'PHPInfo') . "</th></tr>"; } } echo "</table>"; #endregion zurück_weiter_buttons echo "<div>"; echo "</div>"; echo "</th>"; echo "<th width='2'></th>"; echo "<th valign='top'>"; // ab hier wird die Infoleiste mit der aktuellen Konfiguration erstellt // (die Leiste rechts am Rand) echo "<div style='width:150px;word-break: break-all;'>"; echo "<table border='0'>"; foreach (Einstellungen::$segments as $segs) { if (!is_callable("{$segs}::getSettingsBar")) { continue; } $settings = $segs::getSettingsBar($data); if (count($settings) > 0) { foreach ($settings as $key => $values) { if (!isset($values[0]) || !isset($values[1])) { continue; } echo "<tr><td class='e'>" . $values[0] . "</td></tr>"; echo "<tr><td>" . $values[1] . "</td></tr>"; echo "<tr><th></th></tr>"; } } } echo "</table>"; echo "</div"; echo "</th></tr></form></table>"; echo "</div></body></html>"; } if (isset($_POST['actionShowPhpInfo'])) { ob_start(); phpinfo(); $phpinfo = array('phpinfo' => array()); if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if (strlen($match[1])) { $phpinfo[$match[1]] = array(); } elseif (isset($match[3])) { $arr = array_keys($phpinfo); $phpinfo[end($arr)][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; } else { $arr = array_keys($phpinfo); $phpinfo[end($arr)][] = $match[2]; } } } echo "<br><br><br><br><div align='center'>"; foreach ($phpinfo as $name => $section) { echo "<h3>{$name}</h3>\n<table>\n"; foreach ($section as $key => $val) { if (is_array($val)) { echo "<tr><td>{$key}</td><td>{$val['0']}</td><td>{$val['1']}</td></tr>\n"; } elseif (is_string($key)) { echo "<tr><td>{$key}</td><td>{$val}</td></tr>\n"; } else { echo "<tr><td>{$val}</td></tr>\n"; } } echo "</table>\n"; } echo "</div>"; } } if ($console && !$simple) { echo json_encode($output); } if (!$console && !$simple) { Einstellungen::speichereEinstellungen($server, $data); } }
/** * Erzeugt eine Auswahlbox * * @param bool $console true = Konsolendarstellung, false = HTML * @param mixed $variable Der aktuelle Wert des Feldes (null = nicht zugewiesen) * @param string $variablenName Der Name des Feldes * @param mixed $default Der Standartwert (wenn $variable = null) * @param bool $save true = speichere $variable in den Server Einstellungen, false = sonst * @return string Der Text der Auswahl */ public static function erstelleAuswahl($console, &$variable, $variablenName, $value, $default, $save = false) { if ($save == true && $variable == null) { $variable = Einstellungen::Get($variablenName, $default); } if ($save == true && $variable != null) { Einstellungen::Set($variablenName, $variable); } if ($variable == null) { $variable = $default; } $empty = '_'; $result = Design::erstelleVersteckteEingabezeile($console, $empty, $variablenName, $default, $save); $result .= "<input style='width:100%' type='checkbox' name='{$variablenName}' value='" . $value . "'" . ($variable == $value && $variable != null ? "checked" : ($default === null ? '' : ($default === $value ? "checked" : ''))) . ">"; return $result; }
<?php include "../libs/libraries.php"; $ok = 0; $meldung = ""; $err = new ErrorQueue(); $conn = new Connection(); if ($conn->connect($DB_SERVER, $DB_NAME, $DB_USERNAME, $DB_PASSWORD)) { if (isset($_POST['update'])) { $update = intval($_POST['update']); } else { $update = 0; } $einstellungen = new Einstellungen($conn); //$err->addError($einstellungen->getLastError()); if ($update == 1) { if ($einstellungen->writeEinstellungen($_POST['adminmail'])) { $einstellungen->loadEinstellungen(); $meldung = "Die Einstellungen wurden erfolgreich übernommen."; } else { //echo $einstellungen->getLastError(); $err->addError($einstellungen->getLastError()); } } $adminmail = $einstellungen->getAdminsEmail(); } else { $err->addError($conn->getLastError()); } ?>