示例#1
0
 public function updateDatabase()
 {
     global $navigation;
     global $htmlOutput;
     require_once 'db/db100.php';
     require_once __DIR__ . '/parameter_manager.php';
     require_once __DIR__ . '/parameter_db.php';
     $answer = '';
     if (\Db_100::getSystemVariable('version') != '1.0.5') {
         $module = \Modules\developer\localization\Db::getModule('community', 'newsletter');
         //community/user module
         $sql = "select max(`row_number`) as 'max_row_number' from `" . DB_PREF . "module` where `group_id` = '" . (int) $module['group_id'] . "' ";
         $rs = mysql_query($sql);
         if ($rs) {
             if ($lock = mysql_fetch_assoc($rs)) {
                 $maxRowNumber = $lock['max_row_number'];
             } else {
                 trigger_error('Can\'t get max row number ' . $sql);
             }
             $sqlUser = "******" . DB_PREF . "module` (`group_id`, `row_number`, `name`, `admin`, `translation`, `managed`, `version`, `core`) \n          VALUES (" . (int) $module['group_id'] . ", " . ($maxRowNumber + 1) . ", 'user', 1, 'User', 1, '1.00', 1);\n        ";
             $rs = mysql_query($sqlUser);
             if ($rs) {
                 $userModuleId = mysql_insert_id();
                 $users = $this->getUsers();
                 foreach ($users as $user) {
                     $this->addPermissions($userModuleId, $user['id']);
                 }
             } else {
                 trigger_error($sqlUser . ' ' . mysql_error());
             }
         } else {
             trigger_error($sql . ' ' . mysql_error());
         }
         $sql = "\n      CREATE TABLE IF NOT EXISTS `" . DB_PREF . "m_community_user` (\n        `id` int(11) NOT NULL AUTO_INCREMENT,\n        `login` varchar(255) NULL,\n        `language_id` int(11) NOT NULL,\n        `email` varchar(255) NOT NULL,\n        `password` varchar(32) NOT NULL,\n        `verified` tinyint(1) NOT NULL DEFAULT '0',\n        `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n        `last_login` timestamp NULL DEFAULT NULL,\n        `verification_code` varchar(32) NOT NULL,\n        `new_email` varchar(255) DEFAULT NULL,\n        `new_password` varchar(32) DEFAULT NULL,\n        `warned_on` timestamp NULL DEFAULT NULL,\n        `valid_until` timestamp NULL DEFAULT NULL COMMENT 'required for maintenance. Real date should be calculated in real time by last_login field.',\n        PRIMARY KEY (`id`)\n      ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;\n      ";
         $rs = mysql_query($sql);
         if (!$rs) {
             trigger_error($sql . ' ' . mysql_error());
         }
         \Modules\developer\localization\Manager::saveParameters(__DIR__ . '/community_user_parameters.php');
         \Modules\developer\localization\Manager::saveParameters(__DIR__ . '/standard_languages_parameters.php');
         //end community/user module
         //drop additional field in widget tables
         $tablesWithBaseUrl = array();
         $tablesWithBaseUrl[] = DB_PREF . 'mc_text_photos_text_title';
         $tablesWithBaseUrl[] = DB_PREF . 'mc_text_photos_text_photo';
         $tablesWithBaseUrl[] = DB_PREF . 'mc_text_photos_text';
         $tablesWithBaseUrl[] = DB_PREF . 'mc_text_photos_faq';
         $tablesWithBaseUrl[] = DB_PREF . 'mc_misc_rich_text';
         foreach ($tablesWithBaseUrl as $table) {
             $sqlColumns = "show columns from `" . $table . "`";
             $rsColumns = mysql_query($sqlColumns);
             if ($rsColumns) {
                 $columns = array();
                 while ($lockColumn = mysql_fetch_assoc($rsColumns)) {
                     $columns[$lockColumn['Field']] = 1;
                 }
                 if (isset($columns['base_url'])) {
                     $sql = " alter table `" . $table . "` drop `base_url` ";
                     $rs = mysql_query($sql);
                     if (!$rs) {
                         trigger_error($sql . ' ' . mysql_error());
                     }
                 }
             } else {
                 trigger_error($sql . ' ' . mysql_error());
             }
         }
         $replaceParameters = array();
         $replaceParameters[] = array('from' => 'show_unsubscribtion_button', 'to' => 'show_unsubscribe_button');
         $replaceParameters[] = array('from' => 'man_aditional_add_rss', 'to' => 'man_additional_add_rss');
         $replaceParameters[] = array('from' => 'man_aditional_button_title', 'to' => 'man_additional_button_title');
         $replaceParameters[] = array('from' => 'man_aditional_created_on', 'to' => 'man_additional_created_on');
         $replaceParameters[] = array('from' => 'man_aditional_description', 'to' => 'man_additional_description');
         $replaceParameters[] = array('from' => 'man_aditional_error_date_format', 'to' => 'man_additional_error_date_format');
         $replaceParameters[] = array('from' => 'man_aditional_inactive', 'to' => 'man_additional_inactive');
         $replaceParameters[] = array('from' => 'man_aditional_info', 'to' => 'man_additional_info');
         $replaceParameters[] = array('from' => 'man_aditional_keywords', 'to' => 'man_additional_keywords');
         $replaceParameters[] = array('from' => 'man_aditional_no_redirect', 'to' => 'man_additional_no_redirect');
         $replaceParameters[] = array('from' => 'man_aditional_page_properties', 'to' => 'man_additional_page_properties');
         $replaceParameters[] = array('from' => 'man_aditional_page_title', 'to' => 'man_additional_page_title');
         $replaceParameters[] = array('from' => 'man_aditional_redirect', 'to' => 'man_additional_redirect');
         $replaceParameters[] = array('from' => 'man_aditional_subpage', 'to' => 'man_additional_subpage');
         $replaceParameters[] = array('from' => 'man_aditional_type', 'to' => 'man_additional_type');
         $replaceParameters[] = array('from' => 'man_aditional_url', 'to' => 'man_additional_url');
         $replaceParameters[] = array('from' => 'man_aditional_visible', 'to' => 'man_additional_visible');
         foreach ($replaceParameters as $parameter) {
             $sql = " update `" . DB_PREF . "parameter` set `name` = '" . mysql_real_escape_string($parameter['to']) . "' where `name` = '" . mysql_real_escape_string($parameter['from']) . "' ";
             $rs = mysql_query($sql);
             if (!$rs) {
                 trigger_error($sql . ' ' . mysql_error());
             }
         }
         $replaceParameters = array();
         $replaceParameters[] = array('from' => 'Log zise in days', 'to' => 'Log size in days');
         $replaceParameters[] = array('from' => 'Field fonfiguration file', 'to' => 'Field configuration file');
         $replaceParameters[] = array('from' => 'Unpossible to delete the record', 'to' => 'Impossible to delete the record');
         $replaceParameters[] = array('from' => 'Aditional info', 'to' => 'Additional info');
         foreach ($replaceParameters as $parameter) {
             $sql = " update `" . DB_PREF . "parameter` set `translation` = '" . mysql_real_escape_string($parameter['to']) . "' where `translation` = '" . mysql_real_escape_string($parameter['from']) . "' ";
             $rs = mysql_query($sql);
             if (!$rs) {
                 trigger_error($sql . ' ' . mysql_error());
             }
         }
         if ($this->curStep == $this->stepCount) {
             \Db_100::setSystemVariable('version', '1.0.5');
         }
     }
     if ($this->curStep == $this->stepCount) {
         header("location: " . $navigation->generateLink($navigation->curStep() + 1));
     } else {
         header("location: " . $navigation->generateLink($navigation->curStep(), $navigation->curScript() + 1));
     }
     return $answer;
 }
示例#2
0
 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">&nbsp;<!-- --></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;
 }
示例#3
0
 private function importConfig($groupName, $moduleName)
 {
     require_once BASE_DIR . MODULE_DIR . 'developer/localization/manager.php';
     global $log;
     global $parametersMod;
     $siteLanguages = \Modules\standard\languages\Db::getLanguages();
     $installDir = BASE_DIR . PLUGIN_DIR . $groupName . '/' . $moduleName . '/install/';
     //install default config
     if (is_file($installDir . 'config.php')) {
         \Modules\developer\localization\Manager::saveParameters($installDir . 'config.php', true);
     }
     //get public area translation files
     $configFiles = $this->getFiles($installDir, 'translations.public.');
     foreach ($siteLanguages as $key => $language) {
         $siteLanguages[$key]['code'] = strtolower($siteLanguages[$key]['code']);
     }
     //install configuration files that match site languages
     foreach ($siteLanguages as $languageKey => $language) {
         if (isset($configFiles[$language['code']])) {
             \Modules\developer\localization\Manager::saveParameters($installDir . $configFiles[$language['code']]);
             $siteLanguages[$languageKey] == null;
             //mark language as installed
         }
     }
     //install configuration files that are similar to site languages. Eg. en-gb and en
     foreach ($configFiles as $configKey => $file) {
         if ($configKey !== 'default') {
             //default is already installed
             $fileCode = $configKey;
             $fileCode = substr($fileCode, 0, strpos($fileCode, '-'));
             foreach ($siteLanguages as $languageKey => $language) {
                 if ($language !== null) {
                     //null - already installed
                     $languageCode = substr($language['code'], 0, strpos($language['code'], '-'));
                     if ($languageCode = $fileCode) {
                         \Modules\developer\localization\Manager::saveParameters($installDir . $configFiles[$configKey]);
                         $siteLanguages[$languageKey] == null;
                         //mark language as installed
                     }
                 }
             }
         }
     }
     //get administration area translation files
     $configFiles = $this->getFiles($installDir, 'translations.administrator.');
     $administrationAreaLanguageCode = $parametersMod->getValue('standard', 'configuration', 'advanced_options', 'administrator_interface_language');
     if (isset($configFiles[$administrationAreaLanguageCode])) {
         \Modules\developer\localization\Manager::saveParameters($installDir . $configFiles[$administrationAreaLanguageCode], true);
     } else {
         if (strpos($administrationAreaLanguageCode, '-') !== false) {
             $administrationAreaLanguageCode = substr($administrationAreaLanguageCode, 0, strpos($administrationAreaLanguageCode, '-'));
         }
         foreach ($configFiles as $configKey => $file) {
             $fileCode = $configKey;
             $fileCode = substr($fileCode, 0, strpos($fileCode, '-'));
             if ($fileCode == $administrationAreaLanguageCode) {
                 \Modules\developer\localization\Manager::saveParameters($installDir . $configFiles[$configKey], true);
             }
         }
     }
 }