function manage() { global $cms; global $parametersMod; global $log; $answer = ''; if (isset($_GET['action'])) { switch ($_GET['action']) { case "cache_clear": $log->log('administrator/system', 'Cache was cleared'); $module = new Module(); $module->clearCache(); $answer .= ' <div class="note"> ' . $parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_cleared') . ' </div> '; break; } } $answer .= HtmlOutput::header(); $answer .= '<div class="content">'; $answer .= '<h1>ImpressPages CMS ' . htmlspecialchars(\DbSystem::getSystemVariable('version')) . '</h1>'; $answer .= '</div>'; $answer .= '<div class="content">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache')) . '</h1>'; $answer .= $parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_comments'); $answer .= '<a href="' . $cms->generateUrl($cms->curModId, 'action=cache_clear') . '" class="button">' . htmlspecialchars($parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_clear')) . '</a><br /><br /><br />'; $answer .= '</div>'; $answer .= '<div id="systemInfo" class="content" style="display: none;">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('standard', 'configuration', 'system_translations', 'system_message')) . '</h1>'; $answer .= ' <script type="text/javascript" src="' . BASE_URL . MODULE_DIR . 'administrator/system/script.js"></script>'; $answer .= '</div>'; $answer .= HtmlOutput::footer(); return $answer; }
function manage() { global $cms; global $parametersMod; $answer = ''; if (isset($_GET['action'])) { switch ($_GET['action']) { case 'import': $standardForm = new \Library\Php\Form\Standard($this->importFields); $errors = $standardForm->getErrors(); if (sizeof($errors) > 0) { $answer = $standardForm->generateErrorAnswer($errors); } else { $fileUpload = new \Library\Php\File\UploadFile(); $fileUpload->allowOnly(array("php", "conf", "txt")); $file = $fileUpload->upload('config', TMP_FILE_DIR); if ($file == UPLOAD_ERR_OK) { $_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file'] = BASE_DIR . TMP_FILE_DIR . $fileUpload->fileName; $answer .= HtmlOutput::header(); $answer .= ' <script type="text/javascript"> //<![CDATA[ parent.document.location = \'' . $cms->generateUrl($cms->curModId, 'action=import_uploaded') . '\'; //]] </script>'; $answer .= HtmlOutput::footer(); } else { $errors['config'] = 'impossible to upload'; $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); } } break; case 'import_uploaded': $info = pathinfo($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file']); if ($info['extension'] == 'conf') { $answer .= HtmlOutput::header(); $config = unserialize(file_get_contents($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file'])); $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_title_preview')) . '</h1>'; $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_button_preview')) . '</a><br /><br /><br />'; $answer .= $config->previewParameters(); $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_button_preview')) . '</a><br /><br />'; $answer .= HtmlOutput::footer(); } else { $answer .= HtmlOutput::header(); $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_title_preview')) . '</h1>'; $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_button_preview')) . '</a><br /><br /><br />'; $answer .= \Modules\developer\localization\Manager::previewParameters($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file']); $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_button_preview')) . '</a><br /><br />'; $answer .= HtmlOutput::footer(); $answer .= HtmlOutput::header(); } break; case 'import_confirmed': if (isset($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file'])) { $info = pathinfo($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file']); if ($info['extension'] == 'conf') { $config = unserialize(file_get_contents($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file'])); $answer .= HtmlOutput::header(); //$config_import = new mod_developer_config_exp_imp_parameters(); //$config_import->save_parameters(); $config->saveParameters(); $answer .= ' <div class="content"> <h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'parameters_imported')) . '</h1> <a href="' . $cms->generateUrl($cms->curModId) . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'continue')) . '</a> <div class="clear"><!-- --></div> </div> '; $answer .= HtmlOutput::footer(); } else { $answer .= HtmlOutput::header(); //$config_import = new mod_developer_config_exp_imp_parameters(); //$config_import->save_parameters(); \Modules\developer\localization\Manager::saveParameters($_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file']); $answer .= ' <div class="content"> <h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'parameters_imported')) . '</h1> <a href="' . $cms->generateUrl($cms->curModId) . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'continue')) . '</a> <div class="clear"> <!-- --></div> </div> '; $answer .= HtmlOutput::footer(); } } break; case 'export': $standardForm = new \Library\Php\Form\Standard($this->exportFields); $errors = $standardForm->getErrors(); if (sizeof($errors) > 0) { $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); } else { $file = $this->writeParametersToFile(); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . $file . "\""); $answer = file_get_contents(TMP_FILE_DIR . $file); } break; } } else { $answer .= HtmlOutput::header(); $answer .= '<div class="content">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'import_title')) . '</h1>'; $answer .= $this->importForm(); $answer .= '</div><div class="content">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'export_title')) . '</h1>'; $answer .= $this->exportForm(); $answer .= '</div>'; $answer .= HtmlOutput::footer(); } return $answer; }
function manage() { global $cms; global $parametersMod; $answer = ''; if (isset($_GET['action'])) { switch ($_GET['action']) { case 'import': $standardForm = new \Library\Php\Form\Standard($this->importFields); $errors = $standardForm->getErrors(); if (sizeof($errors) > 0) { $answer = $standardForm->generateErrorAnswer($errors); } else { $fileUpload = new \Library\Php\File\UploadFile(); $fileUpload->allowOnly(array("php")); $file = $fileUpload->upload('config', TMP_FILE_DIR); //security check if ($file == UPLOAD_ERR_OK && function_exists('token_get_all')) { $error = false; $content = file_get_contents(BASE_DIR . TMP_FILE_DIR . $fileUpload->fileName); $tokens = token_get_all($content); foreach ($tokens as $key => $token) { if (is_array($token)) { if ($token[0] == 307) { $error = true; } } } if ($error) { unlink(BASE_DIR . TMP_FILE_DIR . $fileUpload->fileName); $errors['config'] = 'Incorrect language file'; $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); break; } } //end security check if ($file == UPLOAD_ERR_OK) { $_SESSION['backend_modules']['developer']['localization']['uploaded_file'] = BASE_DIR . TMP_FILE_DIR . $fileUpload->fileName; $answer .= HtmlOutput::header(); $answer .= ' <script type="text/javascript"> //<![CDATA[ parent.document.location = \'' . $cms->generateUrl($cms->curModId, 'action=import_uploaded') . '\'; //]] </script>'; $answer .= HtmlOutput::footer(); } else { $errors['config'] = 'impossible to upload'; $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); } } break; case 'import_uploaded': $answer .= HtmlOutput::header(); $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'localization', 'admin_translations', 'preview')) . '</h1>'; $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'localization', 'admin_translations', 'import_language_file')) . '</a><br /><br /><br />'; $answer .= $this->previewParameters($_SESSION['backend_modules']['developer']['localization']['uploaded_file']); $answer .= '<br /><a href="' . $cms->generateUrl($cms->curModId, 'action=import_confirmed') . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'localization', 'admin_translations', 'import_language_file')) . '</a><br /><br />'; $answer .= HtmlOutput::footer(); break; case 'import_confirmed': if (isset($_SESSION['backend_modules']['developer']['localization']['uploaded_file'])) { //$config = unserialize(file_get_contents(TMP_FILE_DIR.$_SESSION['backend_modules']['developer']['config_exp_imp']['uploaded_file'])); $answer .= HtmlOutput::header(); //$config_import = new mod_developer_config_exp_imp_parameters(); //$config_import->save_parameters(); $this->saveParameters($_SESSION['backend_modules']['developer']['localization']['uploaded_file']); $answer .= ' <div class="content"> <h1>' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'parameters_imported')) . '</h1> <a href="' . $cms->generateUrl($cms->curModId) . '" class="button">' . htmlspecialchars($parametersMod->getValue('developer', 'config_exp_imp', 'admin_translations', 'continue')) . '</a> <div class="clear"> <!-- --></div> </div> '; $answer .= HtmlOutput::footer(); } break; case 'export': if ($_REQUEST['language'] == 'backend') { $standardForm = new \Library\Php\Form\Standard($this->exportFields); $errors = $standardForm->getErrors(); if (sizeof($errors) > 0) { $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); } else { header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"administrator_interface_" . $parametersMod->getValue('standard', 'configuration', 'advanced_options', 'administrator_interface_language') . ".php\""); $answer = $this->generateAdministratorInterfaceLanguageFile(); } } else { $standardForm = new \Library\Php\Form\Standard($this->exportFields); $errors = $standardForm->getErrors(); if (sizeof($errors) > 0) { $answer .= HtmlOutput::header(); $answer .= $standardForm->generateErrorAnswer($errors); $answer .= HtmlOutput::footer(); } else { header("Content-type: application/octet-stream"); $language = Db::getLanguage($_REQUEST['language']); header("Content-Disposition: attachment; filename=\"public_interface_" . $language['code'] . ".php\""); $answer = $this->generatePublicInterfaceLanguageFile($_REQUEST['language']); } } break; } } else { $answer .= HtmlOutput::header(); $answer .= '<div class="content">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'localization', 'admin_translations', 'import_language_file')) . '</h1>'; $answer .= $this->importForm(); $answer .= '</div><div class="content">'; $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('developer', 'localization', 'admin_translations', 'export_language_file')) . '</h1>'; $answer .= $this->exportForm(); $answer .= '</div>'; $answer .= HtmlOutput::footer(); } return $answer; }