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;
 }
Example #2
0
 public function getDBData($newFolder = null)
 {
     if ($newFolder == null) {
         $newFolder = Util::getRootPath() . "system/DBData/";
     }
     if (!isset($_SERVER["HTTP_HOST"])) {
         $_SERVER["HTTP_HOST"] = "*";
     }
     $data = new mInstallation();
     if ($newFolder != "") {
         $data->changeFolder($newFolder);
     }
     $data->setAssocV3("httpHost", "=", $_SERVER["HTTP_HOST"]);
     #$data->loadCollectionV2();
     $n = $data->getNextEntry();
     if ($n == null) {
         #$data = new mInstallation();
         #if($newFolder != "") $data->changeFolder($newFolder);
         $data = new mInstallation();
         if ($newFolder != "") {
             $data->changeFolder($newFolder);
         }
         $data->setAssocV3("httpHost", "=", "*");
         $n = $data->getNextEntry();
     }
     if ($n != null) {
         $n->changeFolder($newFolder);
         $d = $n->getA();
     } else {
         $I = new Installation(-1);
         $I->changeFolder($newFolder);
         $I->makeNewInstallation();
         $d = $I->getA();
     }
     $I2 = new Installation(-1);
     $s = PMReflector::getAttributesArray($I2->newAttributes());
     $t = array();
     foreach ($s as $key => $value) {
         $t[$value] = $d->{$value};
     }
     $rt = Environment::getS("databaseData", $t);
     return $rt;
 }
 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;
 }
 public static function installUninstallPlugins($data, &$fail, &$errno, &$error)
 {
     $res = array();
     if (!$fail) {
         $mainPath = dirname(__FILE__) . '/../..';
         foreach ($data['PLUG'] as $plugs) {
             $file = dirname(__FILE__) . '/../../Plugins/' . $plugs;
             if (substr($file, -5) == '.json' && file_exists($file) && is_readable($file)) {
                 $input = file_get_contents($file);
                 $input = json_decode($input, true);
                 if ($input == null) {
                     $fail = true;
                     break;
                 }
                 // Dateiliste zusammentragen
                 $fileList = array();
                 $fileListAddress = array();
                 $componentFiles = array();
                 Installation::gibPluginDateien($input, $fileList, $fileListAddress, $componentFiles);
                 $fileList[] = $mainPath . '/install/config/' . $data['SV']['name'] . '.ini';
                 $fileListAddress[] = 'install/config/' . $data['SV']['name'] . '.ini';
                 // Dateien entfernen
                 Zugang::EntferneDateien($fileList, $fileListAddress, $data);
             }
         }
     }
     return $res;
 }
 /**
  * AjaxRequest objects are automatically processed when they are created, based on the unique $action
  * value. The result of the call is stored in $response to be handled however you need (e.g. output
  * as JSON, XML etc) - or an Exception is thrown if something went wrong. Exceptions are used SOLELY for
  * program errors: not for user-entry errors.
  */
 public function __construct($action, $post = array())
 {
     if (empty($action)) {
         throw new Exception("no_action_specified");
         return;
     }
     $this->action = $action;
     $post = Utils::sanitize($post);
     switch ($this->action) {
         // ------------------------------------------------------------------------------------
         // INSTALLATION
         // ------------------------------------------------------------------------------------
         // a fresh install assumes it's a blank slate: no database tables, no settings file
         case "installationTestDbSettings":
             Core::init("installation");
             list($success, $content) = Database::testDbSettings($post["dbHostname"], $post["dbName"], $post["dbUsername"], $post["dbPassword"]);
             $this->response["success"] = $success;
             $this->response["content"] = $content;
             break;
         case "installationCreateSettingsFile":
             Core::init("installation");
             if (Core::checkSettingsFileExists()) {
                 $this->response["success"] = 0;
                 $this->response["content"] = "Your settings.php file already exists.";
                 return;
             } else {
                 list($success, $content) = Installation::createSettingsFile($post["dbHostname"], $post["dbName"], $post["dbUsername"], $post["dbPassword"], $post["dbTablePrefix"]);
                 $this->response["success"] = $success;
                 $this->response["content"] = $content;
             }
             break;
         case "installationCreateDatabase":
             Core::init("installation_db_ready");
             list($success, $content) = Installation::createDatabase();
             if (!$success) {
                 $this->response["success"] = 0;
                 $this->response["content"] = $content;
                 return;
             }
             // always create the administrator account. If the user chose the anonymous setup, all values
             // will be blank and all configurations will be associated with this (anonymous) user
             $adminAccount = array("accountType" => "admin", "firstName" => $post["firstName"], "lastName" => $post["lastName"], "email" => $post["email"], "password" => $post["password"]);
             Account::createAccount($adminAccount);
             // make note of the fact that we've passed this installation step
             Settings::setSetting("userAccountSetup", $post["userAccountSetup"]);
             Settings::setSetting("installationStepComplete_Core", "yes");
             $this->response["success"] = 1;
             $this->response["content"] = "";
             break;
         case "installationDataTypes":
             Core::init("installation_db_ready");
             $index = $post["index"];
             $groupedDataTypes = DataTypePluginHelper::getDataTypePlugins("installion_db_ready", false);
             $dataTypes = DataTypePluginHelper::getDataTypeList($groupedDataTypes);
             if ($index >= count($dataTypes)) {
                 $this->response["success"] = 1;
                 $this->response["content"] = "";
                 $this->response["isComplete"] = true;
             } else {
                 // attempt to install this data type
                 $currDataType = $dataTypes[$index];
                 $this->response["dataTypeName"] = $currDataType->getName();
                 $this->response["dataTypeFolder"] = $currDataType->folder;
                 $this->response["isComplete"] = false;
                 try {
                     list($success, $content) = $currDataType->install();
                     $this->response["success"] = $success;
                     $this->response["content"] = $content;
                 } catch (Exception $e) {
                     $this->response["success"] = false;
                     $this->response["content"] = "Unknown error.";
                 }
             }
             break;
         case "installationSaveDataTypes":
             Core::init("installation_db_ready");
             $folders = $post["folders"];
             $response = Settings::setSetting("installedDataTypes", $folders);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["errorMessage"];
             break;
         case "installationExportTypes":
             Core::init("installation_db_ready");
             $index = $post["index"];
             $exportTypes = ExportTypePluginHelper::getExportTypePlugins("installation_db_ready", false);
             if ($index >= count($exportTypes)) {
                 $this->response["success"] = 1;
                 $this->response["content"] = "";
                 $this->response["isComplete"] = true;
             } else {
                 // attempt to install this data type
                 $currExportType = $exportTypes[$index];
                 $this->response["exportTypeName"] = $currExportType->getName();
                 $this->response["exportTypeFolder"] = $currExportType->folder;
                 $this->response["isComplete"] = false;
                 try {
                     list($success, $content) = $currExportType->install();
                     $this->response["success"] = $success;
                     $this->response["content"] = $content;
                 } catch (Exception $e) {
                     $this->response["success"] = false;
                     $this->response["content"] = "Unknown error.";
                 }
             }
             break;
         case "installationSaveExportTypes":
             Core::init("installation_db_ready");
             $folders = $post["folders"];
             $response = Settings::setSetting("installedExportTypes", $folders);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["errorMessage"];
             break;
         case "installationCountries":
             Core::init("installation_db_ready");
             $index = $post["index"];
             $countryPlugins = CountryPluginHelper::getCountryPlugins(false);
             if ($index >= count($countryPlugins)) {
                 $this->response["success"] = 1;
                 $this->response["content"] = "";
                 $this->response["isComplete"] = true;
             } else {
                 // attempt to install this data type
                 $currCountryPlugin = $countryPlugins[$index];
                 $this->response["countryName"] = $currCountryPlugin->getName();
                 $this->response["countryFolder"] = $currCountryPlugin->folder;
                 $this->response["isComplete"] = false;
                 try {
                     // always run the uninstallation function first to ensure any old data is all cleared out
                     $currCountryPlugin->uninstall();
                     list($success, $content) = $currCountryPlugin->install();
                     $this->response["success"] = $success;
                     $this->response["content"] = $content;
                 } catch (Exception $e) {
                     $this->response["success"] = false;
                     $this->response["content"] = "Unknown error.";
                 }
             }
             break;
         case "installationSaveCountries":
             Core::init("installation_db_ready");
             $folders = $post["folders"];
             $response = Settings::setSetting("installedCountries", $folders);
             $response = Settings::setSetting("installationComplete", "yes");
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["errorMessage"];
             break;
         case "generateInPage":
             Core::init("generation");
             $gen = new Generator($_POST);
             $response = $gen->generate();
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["content"];
             $this->response["isComplete"] = $response["isComplete"];
             break;
             // ------------------------------------------------------------------------------------
             // USER ACCOUNTS
             // ------------------------------------------------------------------------------------
         // ------------------------------------------------------------------------------------
         // USER ACCOUNTS
         // ------------------------------------------------------------------------------------
         case "getAccount":
             Core::init();
             $response = Core::$user->getAccount();
             $this->response["success"] = true;
             $this->response["content"] = $response;
             break;
         case "getUsers":
             Core::init();
             $response = Core::$user->getUsers();
             $this->response["success"] = $response["success"];
             if (isset($response["accounts"])) {
                 $this->response["content"] = $response["accounts"];
             }
             break;
         case "createAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->getAccountType() != "admin") {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::NON_ADMIN;
                 } else {
                     $accountInfo = $post;
                     $accountInfo["accountType"] = "user";
                     $response = Account::createAccount($accountInfo);
                     $this->response["success"] = true;
                 }
             }
             break;
         case "deleteAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->getAccountType() != "admin") {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::NON_ADMIN;
                 } else {
                     $accountID = $post["accountID"];
                     $response = Core::$user->deleteAccount($accountID);
                     $this->response["success"] = true;
                 }
             }
             break;
             // updates the current logged in user's info
         // updates the current logged in user's info
         case "updateAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->isAnonymous()) {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::INVALID_REQUEST;
                 } else {
                     $accountID = $post["accountID"];
                     $this->response = Core::$user->updateAccount($accountID, $post);
                 }
             }
             break;
         case "saveConfiguration":
             Core::init();
             $response = Core::$user->saveConfiguration($post);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             if (isset($response["lastUpdated"])) {
                 $this->response["lastUpdated"] = $response["lastUpdated"];
             }
             break;
         case "deleteDataSets":
             Core::init();
             $configurationIDs = $post["configurationIDs"];
             $response = Core::$user->deleteConfigurations($configurationIDs);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "saveDataSetVisibilityStatus":
             Core::init();
             $configurationID = $post["configurationID"];
             $status = $post["status"];
             $time = $post["time"];
             $response = Core::$user->saveDataSetVisibilityStatus($configurationID, $status, $time);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             if (isset($response["newStatus"])) {
                 $this->response["newStatus"] = $response["newStatus"];
             }
             break;
         case "getPublicDataSet":
             Core::init();
             $configurationID = $post["dataSetID"];
             $response = Core::$user->getPublicDataSet($configurationID);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "login":
             Core::init();
             $email = $post["email"];
             $password = $post["password"];
             $response = Account::login($email, $password);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
             // for single
         // for single
         case "logout":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = true;
             } else {
                 if (!Core::$user->isAnonymous()) {
                     Core::$user->logout();
                     $this->response["success"] = true;
                 }
             }
             break;
         case "resetPassword":
             Core::init();
             $email = $post["email"];
             $response = Account::resetPassword($email);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
     }
 }
Example #6
0
 public static function CreateDatabase()
 {
     Installation::CreateUserbase();
     Installation::CreateCategorybase();
     Installation::CreateBoardbase();
 }
Example #7
0
        Installation::CreateConfigFile($configData);
        require "config.php";
        //Installation::CreateDatabase();
        $utc = new DateTimeZone('UTC');
        $dt = new DateTime('now', $utc);
        require "install/templates/community.php";
        $db->DestroyConnection();
        break;
    case 5:
        require "core/classes/main.class.php";
        require "install/install.class.php";
        $configData = array('forum_name' => GetPost('community_name'), 'forum_base_url' => GetPost('community_url'), 'forum_timezone' => GetPost('community_timezone'));
        Installation::EditConfigFile($configData);
        require "install/templates/admincreation.php";
        break;
    case 6:
        require "core/classes/main.class.php";
        require "install/install.class.php";
        require "config.php";
        $adminData = array('name' => $db->SafeString(GetPost('admin_username')), 'email' => $db->SafeString(GetPost('admin_email')), 'password' => $db->SafeString(GetPost('admin_password')), 'password2' => $db->SafeString(GetPost('admin_password2')));
        $creation = Installation::CreateAdminAccount($adminData);
        require "install/templates/status.php";
        $db->DestroyConnection();
        break;
    case 7:
        require "install/templates/finished.php";
        break;
    default:
        require "install/templates/home.php";
        break;
}
Example #8
0
 protected function action_installation()
 {
     if (!Permissions::has('sys_access') or !Permissions::has('sys_installations_view')) {
         return $this->redirectForbidden();
     }
     $lang = i18n::load('diamondmvc-backend');
     $this->title = $lang->get('TITLE', 'ControllerSystem.Installation');
     if (!isset($_REQUEST['id'])) {
         $this->result = array('success' => false, 'msg' => $lang->get('ERROR_MISSING_ARGUMENTS'));
         return;
     }
     $path = jailpath(DIAMONDMVC_ROOT . DS . 'registry', $_REQUEST['id'] . '.json');
     if (!file_exists($path)) {
         $this->result = array('success' => false, 'msg' => $lang->get('ERROR_NO_META', 'ControllerSystem.Installation'));
         return;
     }
     $json = json_decode(file_get_contents($path), true);
     $meta = Installation::getInstallation($json);
     $this->result = array('success' => true, 'meta' => $meta, 'id' => $_REQUEST['id']);
 }
 /**
  * Gets the update data from the update URL provided by the given {@link Installation}.
  * @param  Installation $inst
  * @return array        JSON decoded update data or an empty array if the data could not be successfully read.
  */
 protected static function getUpdateData($inst)
 {
     $url = $inst->getUpdateUrl();
     if (!is_url($url)) {
         return array();
     }
     $updateData = @file_get_contents($url);
     if ($updateData === false) {
         return array();
     }
     $updateData = @json_decode($updateData, true);
     if ($updateData === null) {
         return array();
     }
     return $updateData;
 }
 /**
  * AjaxRequest objects are automatically processed when they are created, based on the unique $action
  * value. The result of the call is stored in $response to be handled however you need (e.g. output
  * as JSON, XML etc) - or an Exception is thrown if something went wrong. Exceptions are used SOLELY for
  * program errors: not for user-entry errors.
  */
 public function __construct($action, $post = array())
 {
     $this->action = $action;
     $this->post = Utils::sanitize($post);
     switch ($this->action) {
         // ------------------------------------------------------------------------------------
         // INSTALLATION
         // ------------------------------------------------------------------------------------
         // a fresh install assumes it's a blank slate: no database tables, no settings file
         case "installationTestDbSettings":
             Core::init("installation");
             if (Core::checkIsInstalled()) {
                 return;
             }
             list($success, $content) = Database::testDbSettings($this->post["dbHostname"], $this->post["dbName"], $this->post["dbUsername"], $this->post["dbPassword"]);
             $this->response["success"] = $success;
             $this->response["content"] = $content;
             break;
         case "installationCreateSettingsFile":
             Core::init("installation");
             if (Core::checkIsInstalled()) {
                 return;
             }
             if (Core::checkSettingsFileExists()) {
                 $this->response["success"] = 0;
                 $this->response["content"] = "Your settings.php file already exists.";
                 return;
             } else {
                 list($success, $content) = Installation::createSettingsFile($this->post["dbHostname"], $this->post["dbName"], $this->post["dbUsername"], $this->post["dbPassword"], $this->post["dbTablePrefix"]);
                 $this->response["success"] = $success ? 1 : 0;
                 // bah!
                 $this->response["content"] = $content;
             }
             break;
         case "confirmSettingsFileExists":
             Core::init("installation");
             $settingsFileExists = Core::checkSettingsFileExists();
             $this->response["success"] = $settingsFileExists ? 1 : 0;
             break;
         case "installationCreateDatabase":
             Core::init("installationDatabaseReady");
             if (Core::checkIsInstalled()) {
                 $this->response["success"] = 0;
                 $this->response["content"] = "It appears that the script is already installed. If the database already existed, you may need to delete the tables manually before being able to continue.";
                 return;
             }
             list($success, $content) = Installation::createDatabase();
             if (!$success) {
                 $this->response["success"] = 0;
                 $this->response["content"] = $content;
                 return;
             }
             // always create the administrator account. If the user chose the anonymous setup, all values
             // will be blank and all configurations will be associated with this (anonymous) user
             $adminAccount = array("accountType" => "admin");
             if ($this->post["userAccountSetup"] != "anonymous") {
                 $adminAccount["firstName"] = $this->post["firstName"];
                 $adminAccount["lastName"] = $this->post["lastName"];
                 $adminAccount["email"] = $this->post["email"];
                 $adminAccount["password"] = $this->post["password"];
             }
             Account::createAccount($adminAccount, true);
             // make note of the fact that we've passed this step of the installation process
             Settings::setSetting("userAccountSetup", $this->post["userAccountSetup"]);
             Settings::setSetting("installationStepComplete_Core", "yes");
             Settings::setSetting("defaultLanguage", $this->post["defaultLanguage"]);
             Settings::setSetting("allowAnonymousAccess", $this->post["allowAnonymousAccess"] == "yes" ? "yes" : "no");
             Settings::setSetting("anonymousUserPermissionDeniedMsg", $this->post["anonymousUserPermissionDeniedMsg"]);
             $this->response["success"] = 1;
             $this->response["content"] = "";
             break;
             // ------------------------------------------------------------------------------------
             // PLUGINS (installation + reset)
             // ------------------------------------------------------------------------------------
         // ------------------------------------------------------------------------------------
         // PLUGINS (installation + reset)
         // ------------------------------------------------------------------------------------
         case "installationDataTypes":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $this->setDataTypes();
             }
             break;
         case "installationValidateSettingsFile":
             $response = Installation::validateSettingsFile();
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["errorMessage"];
             break;
         case "resetDataTypes":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $this->setDataTypes();
             }
             break;
         case "installationSaveDataTypes":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $folders = $this->post["folders"];
                 $response = Settings::setSetting("installedDataTypes", $folders);
                 $this->response["success"] = $response["success"];
                 $this->response["content"] = $response["errorMessage"];
             }
             break;
         case "resetSaveDataTypes":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $folders = $this->post["folders"];
                 $response = Settings::setSetting("installedDataTypes", $folders);
                 $this->response["success"] = $response["success"];
                 $this->response["content"] = $response["errorMessage"];
             }
             break;
         case "installationExportTypes":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $this->setExportTypes();
             }
             break;
         case "resetExportTypes":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $this->setExportTypes();
             }
             break;
         case "installationSaveExportTypes":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $folders = $this->post["folders"];
                 $response = Settings::setSetting("installedExportTypes", $folders);
                 $this->response["success"] = $response["success"];
                 $this->response["content"] = $response["errorMessage"];
             }
             break;
         case "resetSaveExportTypes":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $folders = $this->post["folders"];
                 $response = Settings::setSetting("installedExportTypes", $folders);
                 $this->response["success"] = $response["success"];
                 $this->response["content"] = $response["errorMessage"];
             }
             break;
         case "installationCountries":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $this->setCountries();
             }
             break;
         case "resetCountries":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $this->setCountries();
             }
             break;
         case "installationSaveCountries":
             Core::init("installationDatabaseReady");
             if (!Core::checkIsInstalled()) {
                 $folders = $this->post["folders"];
                 Settings::setSetting("installedCountries", $folders);
                 $response = Settings::setSetting("installationComplete", "yes");
                 $this->response["success"] = $response["success"];
                 $this->response["content"] = $response["errorMessage"];
             }
             break;
         case "resetSaveCountries":
             Core::init("resetPlugins");
             if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
                 $folders = $this->post["folders"];
                 Settings::setSetting("installedCountries", $folders);
                 $this->response["success"] = true;
                 // ...!
             }
             break;
             // called anytime the plugins were updated (either via the installation or core script). This
             // runs any post-processes that need to be done
         // called anytime the plugins were updated (either via the installation or core script). This
         // runs any post-processes that need to be done
         case "updatedPluginsPostProcess":
             Core::init();
             $this->response["success"] = Minification::createAppStartFile() ? 1 : 0;
             break;
             // ------------------------------------------------------------------------------------
             // USER ACCOUNTS
             // ------------------------------------------------------------------------------------
         // ------------------------------------------------------------------------------------
         // USER ACCOUNTS
         // ------------------------------------------------------------------------------------
         case "getAccount":
             Core::init();
             $response = Core::$user->getAccount();
             $this->response["success"] = true;
             $this->response["content"] = $response;
             break;
         case "getUsers":
             Core::init();
             $response = Core::$user->getUsers();
             $this->response["success"] = $response["success"];
             if (isset($response["accounts"])) {
                 $this->response["content"] = $response["accounts"];
             }
             break;
         case "createAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->getAccountType() != "admin") {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::NON_ADMIN;
                 } else {
                     if (Account::checkAccountExists($this->post["email"])) {
                         $this->response["success"] = false;
                         $this->response["errorCode"] = ErrorCodes::ACCOUNT_ALREADY_EXISTS;
                     } else {
                         $accountInfo = $this->post;
                         $accountInfo["accountType"] = "user";
                         Account::createAccount($accountInfo);
                         $this->response["success"] = true;
                     }
                 }
             }
             break;
         case "deleteAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->getAccountType() != "admin") {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::NON_ADMIN;
                 } else {
                     $accountID = $this->post["accountID"];
                     $response = Core::$user->deleteAccount($accountID);
                     $this->response["success"] = true;
                 }
             }
             break;
             // updates the current logged in user's info
         // updates the current logged in user's info
         case "updateAccount":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = false;
                 $this->response["errorCode"] = ErrorCodes::NOT_LOGGED_IN;
             } else {
                 if (Core::$user->isAnonymousAdmin()) {
                     $this->response["success"] = false;
                     $this->response["errorCode"] = ErrorCodes::INVALID_REQUEST;
                 } else {
                     $accountID = $this->post["accountID"];
                     $this->response = Core::$user->updateAccount($accountID, $this->post);
                 }
             }
             break;
         case "saveConfiguration":
             Core::init();
             $response = Core::$user->saveConfiguration($this->post);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             if (isset($response["lastUpdated"])) {
                 $this->response["lastUpdated"] = $response["lastUpdated"];
             }
             break;
         case "copyDataSet":
             Core::init();
             $response = Core::$user->copyConfiguration($this->post);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "deleteDataSets":
             Core::init();
             $configurationIDs = $this->post["configurationIDs"];
             $response = Core::$user->deleteConfigurations($configurationIDs);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "saveDataSetVisibilityStatus":
             Core::init();
             $configurationID = $this->post["configurationID"];
             $status = $this->post["status"];
             $time = $this->post["time"];
             $response = Core::$user->saveDataSetVisibilityStatus($configurationID, $status, $time);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             if (isset($response["newStatus"])) {
                 $this->response["newStatus"] = $response["newStatus"];
             }
             break;
         case "getPublicDataSet":
             Core::init();
             $configurationID = $this->post["dataSetID"];
             $response = Core::$user->getPublicDataSet($configurationID);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "getDataSetHistory":
             Core::init();
             $configurationID = $this->post["dataSetID"];
             $response = Core::$user->getDataSetHistory($configurationID);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "login":
             Core::init();
             $email = $this->post["email"];
             $password = $this->post["password"];
             $response = Account::login($email, $password);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
         case "logout":
             Core::init();
             if (!Core::checkIsLoggedIn()) {
                 $this->response["success"] = true;
             } else {
                 if (!Core::$user->isAnonymousAdmin()) {
                     Core::$user->logout();
                     $this->response["success"] = true;
                 }
             }
             break;
         case "resetPassword":
             Core::init();
             $email = $this->post["email"];
             $response = Account::resetPassword($email);
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["message"];
             break;
             // ------------------------------------------------------------------------------------
             // DATA GENERATION
             // ------------------------------------------------------------------------------------
         // ------------------------------------------------------------------------------------
         // DATA GENERATION
         // ------------------------------------------------------------------------------------
         case "generateInPage":
             Core::init("generation");
             $gen = new DataGenerator(Constants::GEN_ENVIRONMENT_POST, $this->post);
             $response = $gen->generate();
             $this->response["success"] = $response["success"];
             $this->response["content"] = $response["content"];
             $this->response["isComplete"] = $response["isComplete"];
             break;
     }
 }
Example #11
0
 /**
  * You may use this default version check to see if the version of the plugin matches the application's version
  * 
  * @param string $plugin
  */
 public function VersionCheck($plugin)
 {
     $l = $this->languageClass->getBrowserTexts();
     if (Util::versionCheck($_SESSION["applications"]->getRunningVersion(), $_SESSION["CurrentAppPlugins"]->getVersionOfPlugin($plugin), "!=")) {
         $t = new HTMLTable(1);
         $t->addRow(str_replace(array("%1", "%2"), array($_SESSION["CurrentAppPlugins"]->getVersionOfPlugin($plugin), $_SESSION["applications"]->getRunningVersion()), $l["versionError"]));
         $t->addRow(Installation::getReloadButton());
         die($t->getHTML());
     }
 }
Example #12
0
 public function getDBData($newFolder = null)
 {
     $external = false;
     if (file_exists(Util::getRootPath() . "../../phynxConfig")) {
         $newFolder = Util::getRootPath() . "../../phynxConfig/";
         $external = true;
     }
     if (file_exists(Util::getRootPath() . "../phynxConfig")) {
         $newFolder = Util::getRootPath() . "../phynxConfig/";
         $external = true;
     }
     if ($newFolder == null) {
         $newFolder = Util::getRootPath() . "system/DBData/";
     }
     $findFor = "*";
     if (isset($_SERVER["HTTP_HOST"])) {
         $findFor = $_SERVER["HTTP_HOST"];
     }
     $data = new mInstallation();
     if ($newFolder != "") {
         $data->changeFolder($newFolder);
     }
     $data->setAssocV3("httpHost", "=", $findFor);
     #$data->loadCollectionV2();
     $n = $data->getNextEntry();
     if ($n == null) {
         #$data = new mInstallation();
         #if($newFolder != "") $data->changeFolder($newFolder);
         $data = new mInstallation();
         if ($newFolder != "") {
             $data->changeFolder($newFolder);
         }
         $data->setAssocV3("httpHost", "=", "*");
         $n = $data->getNextEntry();
     }
     if ($n != null) {
         $n->changeFolder($newFolder);
         $d = $n->getA();
     } else {
         if (!isset($_SERVER["HTTP_CLOUD"])) {
             $I = new Installation(-1);
             $I->changeFolder($newFolder);
             $I->makeNewInstallation();
             $d = $I->getA();
         }
     }
     $I2 = new Installation(-1);
     $s = PMReflector::getAttributesArray($I2->newAttributes());
     $t = array();
     if (isset($d)) {
         foreach ($s as $key => $value) {
             $t[$value] = $d->{$value};
         }
     }
     $t["external"] = $external;
     $rt = Environment::getS("databaseData", $t);
     return $rt;
 }
 public static function install($data, &$fail, &$errno, &$error)
 {
     // Datenbank einrichten
     if (!isset($data['action']) || $data['action'] != 'update') {
         if (!$fail && (isset($data['DB']['db_override']) && $data['DB']['db_override'] === 'override')) {
             $sql = "DROP SCHEMA IF EXISTS `" . $data['DB']['db_name'] . "`;";
             $oldName = $data['DB']['db_name'];
             $data['DB']['db_name'] = null;
             $result = DBRequest::request($sql, false, $data);
             if ($result["errno"] !== 0) {
                 $fail = true;
                 $errno = $result["errno"];
                 $error = isset($result["error"]) ? $result["error"] : '';
             }
             $data['DB']['db_name'] = $oldName;
         }
     }
     if (!$fail) {
         $add = isset($data['DB']['db_ignore']) && $data['DB']['db_ignore'] === 'ignore' || isset($data['action']) && $data['action'] == 'update' ? 'IF NOT EXISTS ' : '';
         $sql = "CREATE SCHEMA {$add}`" . $data['DB']['db_name'] . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;";
         $oldName = $data['DB']['db_name'];
         $data['DB']['db_name'] = null;
         $result = DBRequest::request($sql, false, $data);
         if ($result["errno"] !== 0) {
             $fail = true;
             $errno = $result["errno"];
             $error = isset($result["error"]) ? $result["error"] : '';
         }
         $data['DB']['db_name'] = $oldName;
     }
     // CControl+DBQuery2 einrichten
     $res = array();
     if (!$fail) {
         $list = array('DB/CControl', 'DB/DBQuery2');
         $platform = Installation::PlattformZusammenstellen($data);
         for ($i = 0; $i < count($list); $i++) {
             $url = $list[$i];
             //$data['PL']['init'];
             // inits all components
             $result = Request::post($data['PL']['url'] . '/' . $url . '/platform', array(), Platform::encodePlatform($platform));
             $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'];
                 }
                 ///if (isset($result['content'])) echo $result['content'];
             }
         }
     }
     return $res;
 }
Example #14
0
 public static function install($data, &$fail, &$errno, &$error)
 {
     $fail = false;
     $url = $data['PL']['init'];
     $components = array();
     // inits all components
     $result = Request::get($data['PL']['url'] . '/' . $url . '/definition/send', array(), '');
     //echo $result['content'];
     if (isset($result['content']) && isset($result['status'])) {
         // component routers
         $router = array();
         $results = Component::decodeComponent($result['content']);
         $results = Installation::orderBy(json_decode(Component::encodeComponent($results), true), 'name', SORT_ASC);
         $results = Component::decodeComponent(json_encode($results));
         if (!is_array($results)) {
             $results = array($results);
         }
         if (count($results) == 0) {
             $fail = true;
             $error = Language::Get('components', 'noComponents');
         }
         foreach ($results as $res) {
             $components[$res->getName()] = array();
             $components[$res->getName()]['init'] = $res;
         }
         // get component definitions from database
         $result4 = Request::get($data['PL']['url'] . '/' . $url . '/definition', array(), '');
         if (isset($result4['content']) && isset($result4['status']) && $result4['status'] === 200) {
             $definitions = Component::decodeComponent($result4['content']);
             if (!is_array($definitions)) {
                 $definitions = array($definitions);
             }
             if (count($definitions) == 0) {
                 $fail = true;
                 $error = Language::Get('components', 'noDefinitions');
             }
             $result2 = new Request_MultiRequest();
             $result3 = new Request_MultiRequest();
             $tempDef = array();
             foreach ($definitions as $definition) {
                 if (strpos($definition->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
                     continue;
                 }
                 $components[$definition->getName()]['definition'] = $definition;
                 $tempDef[] = $definition;
                 $request = Request_CreateRequest::createGet($definition->getAddress() . '/info/commands', array(), '');
                 $result2->addRequest($request);
                 $request = Request_CreateRequest::createGet($definition->getAddress() . '/info/links', array(), '');
                 $result3->addRequest($request);
             }
             $definitions = $tempDef;
             $result2 = $result2->run();
             $result3 = $result3->run();
             foreach ($results as $res) {
                 if ($res === null) {
                     $fail = true;
                     continue;
                 }
                 $countLinks = 0;
                 $resultCounter = -1;
                 foreach ($definitions as $definition) {
                     //if (strpos($definition->getAddress().'/', $data['PL']['urlExtern'].'/')===false) continue;
                     $resultCounter++;
                     if ($definition->getId() === $res->getId()) {
                         $links = $definition->getLinks();
                         $links = Installation::orderBy(json_decode(Link::encodeLink($links), true), 'name', SORT_ASC);
                         $links = Link::decodeLink(json_encode($links));
                         if (!is_array($links)) {
                             $links = array($links);
                         }
                         $components[$definition->getName()]['links'] = $links;
                         if (isset($result2[$resultCounter]['content']) && isset($result2[$resultCounter]['status']) && $result2[$resultCounter]['status'] === 200) {
                             $commands = json_decode($result2[$resultCounter]['content'], true);
                             if ($commands !== null) {
                                 $components[$definition->getName()]['commands'] = $commands;
                             }
                         }
                         if (isset($result3[$resultCounter]['content']) && isset($result3[$resultCounter]['status']) && $result3[$resultCounter]['status'] === 200) {
                             $calls = json_decode($result3[$resultCounter]['content'], true);
                             $components[$definition->getName()]['call'] = $calls;
                         }
                         break;
                     }
                 }
                 if ($res->getStatus() !== 201) {
                     $fail = true;
                 }
             }
         } else {
             $fail = true;
             $error = Language::Get('components', 'noDefinitions');
         }
     } else {
         $fail = true;
         $error = Language::Get('components', 'operationFailed');
     }
     if (isset($result['status']) && $result['status'] !== 200) {
         $fail = true;
         $error = Language::Get('components', 'operationFailed');
         $errno = $result['status'];
     }
     return $components;
 }
 function getHTML($id)
 {
     $showHelp = true;
     if ($this->collector == null) {
         $this->lCV3($id);
     }
     $singularLanguageClass = $this->loadLanguageClass("Installation");
     $text = $singularLanguageClass != null ? $singularLanguageClass->getText() : "";
     $t = new HTMLTable(1);
     $g = "";
     $DBFilePath = Util::getRootPath() . "system/DBData/Installation.pfdb.php";
     $writable = new HTMLTable(1);
     $File = new File($DBFilePath);
     $File->loadMe();
     if (!$File->getA()->FileIsWritable) {
         $writable->addRow("<img src=\"./images/navi/restrictions.png\" style=\"float:left;margin-right:10px;\"/>Die Datei " . $DBFilePath . " ist nicht beschreibbar, Änderungen können nicht gespeichert werden.<br /><br />Machen Sie die Datei mit einem FTP-Programm beschreibbar. Klicken Sie dazu mit der rechten Maustaste auf die Datei auf dem Server, wählen Sie \"Eigenschaften\", und geben Sie den Modus 666 an, damit sie durch den Besitzer, die Gruppe und alle Anderen les- und schreibbar ist.");
         $g .= $writable->getHTML();
     }
     $gui = new HTMLGUI();
     $gui->setName("Datenbank-Zugangsdaten");
     if ($this->collector != null) {
         $gui->setAttributes($this->collector);
     }
     $gui->setCollectionOf($this->collectionOf, "Datenbank-Zugangsdaten");
     $gui->hideAttribute("password");
     $gui->hideAttribute("httpHost");
     $gui->hideAttribute("InstallationID");
     if (strstr($_SERVER["SCRIPT_FILENAME"], "demo")) {
         $UA = $_SESSION["S"]->getCurrentUser()->getA();
         if ($UA->name != "Installations-Benutzer") {
             $g = "In der Demo können keine Datenbank-Zugangsdaten geändert werden!";
             $gui->setIsDisplayMode(true);
         }
     }
     if (!Session::isPluginLoaded("multiInstall")) {
         $gui->setIsDisplayMode(true);
         $gui->setEditInDisplayMode(true, "contentLeft");
     }
     #try {
     $g .= $gui->getBrowserHTML($id);
     #} catch (Exception $e){
     #	$t->addRow(array("Etwas stimmt nicht, eine ".get_class($e)." wurde abgefangen!"));
     #	$t->addRow(array("<span style=\"font-size:8px;\">".nl2br(str_replace("#","\n#", $e->getTraceAsString()))."</span>"));
     #}
     $help = "\n\t<script type=\"text/javascript\">\n\t\tcontentManager.rmePCR('mInstallation','','getHelp','true','if(checkResponse(transport)) { Popup.create(\\'123\\', \\'Installation\\', \\'Hilfe\\'); Popup.update(transport, \\'123\\', \\'Installation\\'); }');\n\t</script>";
     try {
         $user = new User(1);
         $user->loadMe();
     } catch (DatabaseNotSelectedException $e) {
         $t->addRow(isset($text["noDatabase"]) ? $text["noDatabase"] : "Es wurde kein korrekter Datenbankname angegeben.<br /><br />Bitte geben Sie eine existierende Datenbank an, sie wird nicht automatisch erzeugt.");
         return $g . $t->getHTML() . $help;
     } catch (NoDBUserDataException $e) {
         $t->addRow(isset($text["wrongData"]) ? $text["wrongData"] : "Mit den angegebenen Datenbank-Zugangsdaten kann keine Verbindung aufgebaut werden.<br /><br />Wenn sie korrekt sind, wird hier eine Liste der Plugins angezeigt.");
         if (PHYNX_MAIN_STORAGE == "MySQL") {
             try {
                 $DB1 = new DBStorageU();
                 $B = new Button("Hinweis", "notice", "icon");
                 $B->style("float:left;margin-right:10px;");
                 $File = new File(Util::getRootPath() . "system/connect.php");
                 $BR = new Button("DB-Verbindung\numstellen", "lieferschein");
                 $BR->style("float:right;margin-left:10px;");
                 $BR->rmePCR("mInstallation", "-1", "switchDBToMySQLo", "", "Installation.reloadApp();");
                 $BR = "Verwenden Sie den nebenstehenden Knopf, um die Verbindungsart auf die ältere Version umzustellen.<br />{$BR} Sie müssen sich anschließend erneut anmelden.";
                 $BReload = new Button("Ansicht\naktualisieren", "refresh");
                 $BReload->onclick("contentManager.emptyFrame('contentLeft'); contentManager.loadFrame('contentRight', 'mInstallation', -1, 0, 'mInstallationGUI;-');Popup.closeNonPersistent();");
                 $BReload->style("float:right;margin:10px;");
                 if (!$File->A("FileIsWritable")) {
                     $BR = "Bitte machen Sie die Datei /system/connect.php für den Webserver beschreibbar, damit phynx auf die ältere Verbindungsart umstellen kann.<br /><br />Verwenden Sie dazu Ihr FTP-Programm. Klicken Sie mit der rechten Maustaste auf die Datei auf dem Server, wählen Sie \"Eigenschaften\", und geben Sie den Modus 666 an, damit sie durch den Besitzer, die Gruppe und alle Anderen les- und schreibbar ist.{$BReload}";
                 }
                 $t->addRow(array("{$B} <b>Möglicherweise ist die MySQLi-Erweiterung auf Ihrem Server nicht korrekt konfiguriert.</b><br /><br />{$BR}"));
                 $t->addRowClass("backgroundColor0");
             } catch (Exception $e) {
                 #echo "MySQL geht auch nicht!";
             }
         }
         return $g . $t->getHTML() . $help;
     } catch (DatabaseNotFoundException $e) {
         $t->addRow(isset($text["noDatabase"]) ? $text["noDatabase"] : "Es wurde kein korrekter Datenbankname angegeben.<br /><br />Bitte geben Sie eine existierende Datenbank an, sie wird nicht automatisch erzeugt.");
         return $g . $t->getHTML() . $help;
     } catch (TableDoesNotExistException $e) {
     } catch (StorageException $e) {
     }
     $help = "\n\t<script type=\"text/javascript\">\n\t\trme('mInstallation','','getHelp','false','if(checkResponse(transport)) { Popup.create(\\'123\\', \\'Installation\\', \\'Hilfe\\'); Popup.update(transport, \\'123\\', \\'Installation\\'); }');\n\t</script>";
     if ($id == -1) {
         $BackupTab = new HTMLTable(1);
         $BackupButton = new Button("Backup-\nManager", "disk");
         $BackupButton->style("float:right;");
         $BackupButton->onclick("contentManager.loadFrame('contentLeft','BackupManager');");
         $BackupTab->addRow($BackupButton);
         $BUT = new Button(isset($text["alle Tabellen aktualisieren"]) ? $text["alle Tabellen aktualisieren"] : "alle Tabellen\naktualisieren", "update");
         $BUT->rmePCR("mInstallation", "", "updateAllTables", "", "\$('contentLeft').update(transport.responseText);");
         $g .= "\n\t<div style=\"height:30px;\"></div>\n\t{$BackupTab}\n\t<div class=\"Tab backgroundColor1\"><p>Plugins</p></div>\n\t<table>\n\t\t<colgroup>\n\t\t\t<col style=\"width:100px;\" class=\"backgroundColor2\" />\n\t\t\t<col class=\"backgroundColor3\" />\n\t\t</colgroup>\n\t\t<tr>\n\t\t\t<td colspan=\"3\">\n\t\t\t\t<span style=\"float:right;\">" . Installation::getReloadButton() . "</span>\n\t\t\t\t{$BUT}\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"background-color:white;\"></td>\n\t\t</tr>";
         $p = array_flip($_SESSION["CurrentAppPlugins"]->getAllPlugins());
         foreach ($p as $key => $value) {
             try {
                 if (method_exists($_SESSION["CurrentAppPlugins"], "isPluginGeneric") and $_SESSION["CurrentAppPlugins"]->isPluginGeneric($key)) {
                     $c = new mGenericGUI('', $key);
                 } else {
                     $c = new $key();
                 }
             } catch (ClassNotFoundException $e) {
                 $key2 = $key . "GUI";
                 try {
                     $c = new $key2();
                 } catch (ClassNotFoundException $e2) {
                     continue;
                 }
             }
             if ($key == "CIs") {
                 continue;
             }
             /*$e = explode(", ",$_SESSION["CurrentAppPlugins"]->getDepsOfPlugin($key));
             		for($i=0;$i<count($e);$i++) 
             			if($e[$i] != "none") 
             				$e[$i] = (($p[$e[$i]] != -1) ? $p[$e[$i]] : $e[$i]);*/
             if ($c->checkIfMyTableExists() and $c->checkIfMyDBFileExists()) {
                 $showHelp = false;
             }
             if (!$c->checkIfMyDBFileExists()) {
                 continue;
             }
             $g .= "\n\t\t<tr>\n\t\t\t<td style=\"font-weight:bold;text-align:right;\">" . ($value != -1 ? $value : $key) . "</td>\n\t\t\t<td>" . (!$c->checkIfMyTableExists() ? $c->checkIfMyDBFileExists() ? "<input type=\"button\" value=\"" . (isset($text["Tabelle anlegen"]) ? $text["Tabelle anlegen"] : "Tabelle anlegen") . "\" onclick=\"installTable('{$key}');\" />" : "keine DB-Info-Datei" : ($c->checkIfMyDBFileExists() ? "<input type=\"button\" onclick=\"checkFields('{$key}');\" value=\"Tabellenupdate\" style=\"float:right;width:140px;\" />" . (isset($text["Tabelle existiert"]) ? $text["Tabelle existiert"] : "Tabelle existiert") : (isset($text["keine DB-Info-Datei"]) ? $text["keine DB-Info-Datei"] : "keine DB-Info-Datei")) . "") . "</td>\n\t\t</tr>";
         }
         $g .= "\n\t</table>";
     }
     $showHelp = false;
     if (!$showHelp) {
         $help = "";
     }
     $ST = new HTMLSideTable("left");
     try {
         $BTestMail = $ST->addButton("Mailversand\ntesten", "mail");
         $BTestMail->popup("mailTest", "Mailversand testen", "mInstallation", "-1", "testMailGUI");
         $MailServer = LoginData::get("MailServerUserPass");
         $MailServerID = $MailServer == null ? -1 : $MailServer->getID();
         $BMail = $ST->addButton("Mail-Server\neintragen", "./plugins/Installation/serverMail.png");
         $BMail->popup("edit", "Mail-Server", "LoginData", $MailServerID, "getPopup", "", "LoginDataGUI;preset:mailServer");
     } catch (Exception $e) {
     }
     return (!$showHelp ? $ST : "") . $g . $help;
 }
Example #16
0
 /**
  * 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);
     }
 }
Example #17
0
    if (file_exists("../lang/lang_{$external_lang}.php")) {
        $language = $external_lang;
    }
}
// if there is no language use english ;-)
if ($language == '') {
    $language == 'en';
}
// Set the cookie (for the next 93(= 3x31) days)
setcookie('ComaCMS_user_lang', $language, time() + 8035200);
// Set the translation class
$translation = new Language($language);
$translation->AddSources('../lang/');
$output->Language = $language;
// Initialize the install class
$installation = new Installation($translation, $output);
// Define menuentries
$menuArray = array();
// Generate and replace PATH
switch ($extern_page) {
    case 1:
        $pagename = $translation->GetTranslation('language');
        $menuArray[] = array($translation->GetTranslation('language'), '1');
        break;
    case 2:
        $pagename = $translation->GetTranslation('sitestyle');
        $menuArray[] = array($translation->GetTranslation('language'), '1');
        $menuArray[] = array($translation->GetTranslation('sitestyle'), '2');
        break;
    case 3:
        $pagename = $translation->GetTranslation('requirements');
 /**
  * Perform this action
  *
  * @param   string[] args
  */
 public function perform(array $args)
 {
     $installation = new Installation();
     $installation->setBase(new Folder(isset($args[0]) ? $args[0] : dirname(Runtime::getInstance()->bootstrapScript()) . '/..'));
     $force = in_array('-f', $args);
     with($version = $installation->getVersion());
     Console::writeLine('===> Local version ', $version, ' @ ', $installation->getBase());
     if (strstr($version, '-dev')) {
         Console::writeLine('*** Cannot update development checkouts');
         return 2;
     }
     // Query releases website for newer versions
     $c = new HttpConnection(self::UPGRADE_URL);
     $r = $c->get(new RequestData($version));
     switch ($r->getStatusCode()) {
         case HttpConstants::STATUS_OK:
         case HttpConstants::STATUS_NOT_EXTENDED:
             Console::writeLine('*** ', $this->readLine($r->getInputStream()));
             return 2;
         case HttpConstants::STATUS_SEE_OTHER:
             $upgrade = $r->getHeader('X-Upgrade-To');
             $base = $r->getHeader('Location');
             Console::writeLine('---> Upgrading to ', $upgrade, ' (', $base, ')');
             $target = new Folder($installation->getBase(), $upgrade);
             $target->exists() || $target->create();
             // Verify dependencies
             $this->extract($base, 'depend', $target);
             with($p = new Properties($target->getURI() . 'depend.ini'));
             $verify = 1;
             $rtversion = phpversion();
             $extensions = array_flip(array_map('strtolower', get_loaded_extensions()));
             foreach ($p->readSection('php') as $op => $compare) {
                 if (!version_compare(phpversion(), $compare, $op)) {
                     $verify &= $this->error('PHP version ' . $op . ' ' . $compare . ' required, have ' . $rtversion);
                 }
             }
             foreach ($p->readSection('ext.required') as $ext => $usage) {
                 if (!isset($extensions[$ext])) {
                     $verify &= $this->error('PHP Extension ' . $ext . ' required for ' . $usage);
                 }
             }
             foreach ($p->readSection('ext.conflict') as $ext => $usage) {
                 if (isset($extensions[$ext])) {
                     $verify &= $this->error('PHP Extension ' . $ext . ' conflicts (' . $usage . ')');
                 }
             }
             foreach ($p->readSection('ext.optional') as $ext => $usage) {
                 if (!isset($extensions[$ext])) {
                     $verify &= $this->error('PHP Extension ' . $ext . ' not found, needed for ' . $usage . ' (ignoring)');
                 }
             }
             foreach ($p->readSection('ini') as $setting => $match) {
                 $value = ini_get($setting);
                 if (!preg_match($match, $value)) {
                     $verify &= $this->error('PHP .ini setting ' . $setting . ' needs to match ' . $match . ' (but is ' . $value . ')');
                 }
             }
             // Remove depend.ini, finally check if we should continue
             create(new File($p->getFilename()))->unlink();
             if (!$verify) {
                 if (!$force) {
                     return 3;
                 }
                 Console::writeLine('!!! Ignoring errors because -f was passed');
             }
             // Download base, tools, libraries and meta information
             $this->extract($base, 'base', $target);
             $this->extract($base, 'tools', $target);
             $this->extract($base, 'lib', $target);
             $this->extract($base, 'meta-inf', $target);
             // Verify it works by running the XP Framework core unittests
             $tests = array('net.xp_framework.unittest.core.**');
             Console::writeLine('---> Running tests with [USE_XP=', $upgrade, ']:');
             $rt = Runtime::getInstance();
             set_include_path(implode(PATH_SEPARATOR, array(rtrim($target->getURI(), DIRECTORY_SEPARATOR), '', $target->getURI() . 'lib' . DIRECTORY_SEPARATOR . 'xp-net.xp_framework-' . $upgrade . '.xar')));
             with($p = $rt->newInstance($rt->startupOptions(), 'class', 'xp.unittest.Runner', $tests));
             $p->in->close();
             while (!$p->out->eof()) {
                 Console::writeLine($p->out->readLine());
             }
             while (!$p->err->eof()) {
                 Console::writeLine($p->err->readLine());
             }
             $exit = $p->close();
             // Nonzero exit means failure
             if (0 !== $exit) {
                 Console::writeLine('*** Test run failed, please consult above error messsages');
                 Console::writeLine($p->getCommandLine());
                 return 2;
             }
             Console::writeLine('===> Done, installed @ ', $target);
             return 0;
         default:
             throw new IllegalStateException('Unexpected response ' . xp::stringOf($r));
     }
 }
Example #19
0
if (!empty($_POST['function']) || !empty($_GET['function'])) {
    session_start();
    date_default_timezone_set('UTC');
    # Load required files
    require __DIR__ . '/define.php';
    require __DIR__ . '/autoload.php';
    require __DIR__ . '/modules/misc.php';
    if (file_exists(LYCHEE_CONFIG_FILE)) {
        require LYCHEE_CONFIG_FILE;
    } else {
        ###
        # Installation Access
        # Limited access to configure Lychee. Only available when the config.php file is missing.
        ###
        define('LYCHEE_ACCESS_INSTALLATION', true);
        $installation = new Installation(null, null, null);
        $installation->check($_POST['function']);
        exit;
    }
    # Define the table prefix
    if (!isset($dbTablePrefix)) {
        $dbTablePrefix = '';
    }
    defineTablePrefix($dbTablePrefix);
    # Connect to database
    $database = Database::connect($dbHost, $dbUser, $dbPassword, $dbName);
    # Load settings
    $settings = new Settings($database);
    $settings = $settings->get();
    # Init plugins
    $plugins = explode(';', $settings['plugins']);
Example #20
0
loadSchema('acl');
// Add the administrative account
printHeader("Add an administrative account");
print "\nPlease enter an username for your administrative account [root] : ";
$username = getInput('%s');
if ($username == "") {
    $username = "******";
}
print "\nPlease enter a password for your administrative account : ";
$password = getInput('%s');
if ($nimode) {
    $username = '******';
    $password = '******';
}
LoadObjectDependency("org.freemedsoftware.public.Installation");
Installation::CreateAdministrationAccount($username, $password);
print "\n\n";
printHeader("Form ACL rules for users");
include_once dirname(__FILE__) . '/../lib/acl.php';
include_once dirname(__FILE__) . '/../lib/org/freemedsoftware/module/ACL.class.php';
$a = new ACL();
$q = "SELECT username, id FROM user WHERE id > 0";
$r = $GLOBALS['sql']->queryAll($q);
foreach ($r as $user) {
    print " - Adding ACL record for user " . $user['username'] . " (" . $user['id'] . ") \n";
    $a->UserAdd($r['id']);
}
printHeader("Create 'healthy system' status");
`touch ./data/cache/healthy`;
printHeader("Force module definition upgrades");
$modules = CreateObject('org.freemedsoftware.core.ModuleIndex', true, false);
Example #21
0
					<div class="input-field col s12">
						<input id="community_name" name="community_name" type="text" class="validate">
						<label for="community_name">Community name</label>
					</div>
				</div>
				
				<div class="row">
					<div class="input-field col s12">
						<input id="community_url" name="community_url" type="text" class="validate" value="', getURL(), '">
						<label for="community_url">Community url</label>
					</div>
				</div>
				
				<div class="input-field col s12 m6">
					<select name="community_timezone" id="db_type">';
foreach (DateTimeZone::listIdentifiers() as $tz) {
    $current_tz = new DateTimeZone($tz);
    $offset = $current_tz->getOffset($dt);
    $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
    $abbr = $transition[0]['abbr'];
    echo '<option value="' . $tz . '">' . $tz . ' [' . $abbr . ' ' . Installation::formatOffset($offset) . ']</option>';
}
echo '</select>
					<label>Database type</label>
				</div>
				
				<input type="submit" class="btn-flat waves-effect waves-greyBlue waves-light right" value="Next">
			</form>
		</div>
	</div>
</div>';
Example #22
0
 public static function quickUpgrade($table)
 {
     $oldTable = $GLOBALS['db']->GetAll("describe {$table}");
     $newTable = $GLOBALS['db']->GetAll("describe install_{$table}");
     $changed = false;
     if (sizeof($newTable) != sizeof($oldTable)) {
         $changed = true;
     }
     foreach ($oldTable as $key => $value) {
         if (array_diff($oldTable[$key], $newTable[$key]) || array_diff($newTable[$key], $oldTable[$key])) {
             $changed = true;
         }
     }
     $oldTableIndexes = $GLOBALS['db']->GetAll("show indexes from {$table}");
     $newTableIndexes = $GLOBALS['db']->GetAll("show indexes from install_{$table}");
     if (sizeof($newTableIndexes) != sizeof($oldTableIndexes)) {
         $changed = true;
     }
     if ($changed) {
         Installation::updateDBTable($table, "install_" . $table);
     }
     return $changed;
 }