/** * 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; }
/** * Lädt die Konfiguration von $serverName und gibt sie direkt zurück * Achtung: wird nicht der globalen Konfiguration zugewiesen * * @param string $serverName Der Name der Konfiguration * @param string[][] $data Die Serverdaten * @return string[][] Die Konfiguration, null im Fehlerfall */ public static function ladeEinstellungenDirekt($serverName, $data) { $serverHash = md5($serverName); $path = dirname(__FILE__) . '/../config'; Einstellungen::generatepath($path); // erzeuge die Liste der Passwörter anhand des masterPasswort für die Verschlüsselung $keys = array(); if (isset(self::$masterPassword[$serverHash]) && trim(self::$masterPassword[$serverHash]) != '') { $keys = self::makeKeys(self::$masterPassword[$serverHash]); $keys = array_reverse($keys, false); } $default = self::getAllDefaults(); $konfiguration = array(); $data = array(); if (file_exists($path . '/' . $serverName . ".ini") && is_readable($path . '/' . $serverName . ".ini")) { $temp = file_get_contents($path . '/' . $serverName . ".ini"); if (isset(self::$masterPassword[$serverHash]) && trim(self::$masterPassword[$serverHash]) != '') { foreach ($keys as $key) { if ($key === '_BASE64') { $element2 = @base64_decode($temp, true); if ($element2 === false) { // die base64 dekodierung ist fehlgeschlagen return null; } $temp = $element2; } else { $temp = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $temp, MCRYPT_MODE_ECB); } } } $temp = explode("\n", $temp); foreach ($temp as $element) { if (trim($element) == '') { continue; } $pos = strpos($element, '='); if ($pos === false || $pos === 0) { return null; } $dat = @parse_ini_string('a=' . substr($element, $pos + 1)); if ($dat === false) { return null; } $dat = $dat['a']; $dat = trim($dat); $konfiguration[substr($element, 0, $pos)] = $dat; } } if (count($konfiguration) === 0) { // leer } elseif (!isset($konfiguration['data[SV][hash]']) && count($konfiguration) > 0) { return null; } else { $existingHash = $konfiguration['data[SV][hash]']; unset($konfiguration['data[SV][hash]']); $hash = self::makeHash($konfiguration); if ($existingHash == $hash) { // leer } else { return null; } } $konfiguration = self::extractData($konfiguration, 'data'); $default = self::extractData($default, 'data'); /////////////////////////// if (isset($_POST['update'])) { $_POST['action'] = 'update'; } if (isset($_POST['actionInstall'])) { $_POST['action'] = 'install'; } if (isset($_POST['actionUpdate'])) { $_POST['action'] = 'update'; } if (!isset($konfiguration['PL']['language'])) { $konfiguration['PL']['language'] = 'de'; } if (!isset($konfiguration['PL']['init'])) { $konfiguration['PL']['init'] = 'DB/CControl'; } if (isset($konfiguration['PL']['url'])) { $konfiguration['PL']['url'] = rtrim($konfiguration['PL']['url'], '/'); } if (isset($konfiguration['PL']['urlExtern'])) { $konfiguration['PL']['urlExtern'] = rtrim($konfiguration['PL']['urlExtern'], '/'); } if (isset($konfiguration['PL']['temp'])) { $konfiguration['PL']['temp'] = rtrim($konfiguration['PL']['temp'], '/'); } if (isset($konfiguration['PL']['files'])) { $konfiguration['PL']['files'] = rtrim($konfiguration['PL']['files'], '/'); } if (isset($konfiguration['PL']['init'])) { $konfiguration['PL']['init'] = rtrim($konfiguration['PL']['init'], '/'); } /////////////////////////// $konfiguration = array_merge($default, $konfiguration); return $konfiguration; }
/** * ??? * * @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(); } }
/** * Sucht die vorhandenen Segmentdateien * * @return string[] Die Pfade der Segmente */ public function loadSegments() { $p = dirname(__FILE__) . '/segments'; Einstellungen::generatepath($p); if ($handle = opendir($p)) { $segs = array(); while (false !== ($file = @readdir($handle))) { if ($file == '.' || $file == '..') { continue; } $segs[] = $file; } foreach ($segs as $seg) { include_once dirname(__FILE__) . '/segments/' . $seg; Einstellungen::$segments[] = substr($seg, 0, count($seg) - 5); } @closedir($handle); } // sort segments by page and rank function cmp($a, $b) { $posA = 0; $posB = 0; if (isset($a::$page)) { $posA = array_search($a::$page, Installer::$menuItems); } if (isset($b::$page)) { $posB = array_search($b::$page, Installer::$menuItems); } $rankA = 100; $rankB = 100; if (isset($a::$rank)) { $rankA = $a::$rank; } if (isset($b::$rank)) { $rankB = $b::$rank; } if ($posA === false) { return -1; } if ($posB === false) { return 1; } if ($posA == $posB) { if ($rankA == $rankB) { return 0; } return $rankA < $rankB ? -1 : 1; } return $posA < $posB ? -1 : 1; } usort(Einstellungen::$segments, "cmp"); }