Esempio n. 1
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;
 }
Esempio n. 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"));
                     $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">&nbsp;<!-- --></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;
 }
Esempio n. 3
0
 function makeActions()
 {
     global $parametersMod;
     global $site;
     $site->requireTemplate('standard/content_management/widgets/misc/contact_form/template.php');
     $sql = "select * from `" . DB_PREF . "mc_misc_contact_form_field` where `contact_form` = '" . mysql_real_escape_string($_REQUEST['spec_id']) . "' order by id";
     $rs = mysql_query($sql);
     $fields = array();
     if (!$rs) {
         trigger_error("Can't get form fields " . $sql);
     } else {
         while ($lock = mysql_fetch_assoc($rs)) {
             switch ($lock['type']) {
                 case 'text':
                     $field = new \Library\Php\Form\FieldText();
                     break;
                 case 'text_multiline':
                     $field = new \Library\Php\Form\FieldTextarea();
                     break;
                 case 'file':
                     $field = new \Library\Php\Form\FieldFile();
                     break;
                 case 'email':
                     $field = new \Library\Php\Form\FieldEmail();
                     break;
                 case 'select':
                     $field = new \Library\Php\Form\FieldSelect();
                     $field->values = $this->prepare_for_select($this->db_values_to_array($lock['values']));
                     break;
                 case 'checkbox':
                     $field = new \Library\Php\Form\FieldCheckbox();
                     break;
                 case 'radio':
                     $field = new \Library\Php\Form\FieldRadio();
                     $field->values = $this->prepare_for_select($this->db_values_to_array($lock['values']));
                     break;
             }
             $field->caption = $lock['name'];
             $field->name = 'field_' . (sizeof($fields) + 1);
             $field->required = $lock['required'];
             $fields[] = $field;
         }
     }
     $htmlForm = new \Library\Php\Form\Standard($fields);
     $errors = $htmlForm->getErrors();
     $answer = '';
     if (sizeof($errors) > 0 || $htmlForm->detectSpam()) {
         $answer = $htmlForm->generateErrorAnswer($errors);
     } else {
         $sql = "select * from `" . DB_PREF . "mc_misc_contact_form` where `id` = '" . mysql_real_escape_string($_REQUEST['spec_id']) . "' limit 1";
         $rs = mysql_query($sql);
         if (!$rs) {
             trigger_error("Can't get contact form " . $sql);
         } elseif ($lock = mysql_fetch_assoc($rs)) {
             $email = Template::generateEmail($fields);
             $files = array();
             $from = $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'email');
             foreach ($fields as $field) {
                 if (get_class($field) == 'Library\\Php\\Form\\FieldFile') {
                     if (!empty($_FILES[$field->name]) && $_FILES[$field->name]['error'] == 0) {
                         $file = array();
                         $file['real_name'] = $_FILES[$field->name]['tmp_name'];
                         $file['required_name'] = $_FILES[$field->name]['name'];
                         $files[] = $file;
                     }
                 }
                 if (get_class($field) == 'Library\\Php\\Form\\FieldEmail' && $field->postedValue() != '') {
                     $from = $field->postedValue();
                 }
             }
             $email_queue = new \Modules\administrator\email_queue\Module();
             $email_queue->addEmail($from, '', $lock['email_to'], '', $lock['email_subject'], $email, false, true, $files);
         } else {
             trigger_error("Unknown contact form id " . $sql);
         }
         $email_queue->send();
         $answer = '
         <html><head><meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '" /></head><body>
         <script type="text/javascript">
           var form = parent.window.document.getElementById(\'' . $_REQUEST['spec_rand_name'] . '\');
           form.style.display = \'none\';
           //var txtNode = document.createTextNode("' . htmlspecialchars($lock['thank_you']) . '"); 
           var note = parent.window.document.createElement(\'p\');
           //note.appendChild(txtNode); //ie7 bug sometimes dont allow to add a textnode. 
           note.innerHTML = "' . htmlspecialchars($lock['thank_you']) . '";
           form.parentNode.appendChild(note);
         </script>
         </body></html>
       ';
     }
     echo $answer;
 }
Esempio n. 4
0
 function makeActions()
 {
     global $site;
     global $parametersMod;
     global $session;
     global $log;
     $userZone = $site->getZoneByModule('community', 'user');
     if (!$userZone) {
         return;
     }
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'password_reset':
                 $standardForm = new \Library\Php\Form\Standard(\Modules\community\user\Config::getPasswordResetFields());
                 $errors = $standardForm->getErrors();
                 $tmpUser = Db::userByEmail($_POST['email']);
                 if (!$tmpUser) {
                     $errors['email'] = $parametersMod->getValue('community', 'user', 'errors', 'email_doesnt_exist');
                 }
                 if (!isset($_POST['password']) || $_POST['password'] == '' || $parametersMod->getValue('community', 'user', 'options', 'type_password_twice') && $_POST['password'] != $_POST['confirm_password']) {
                     $errors['password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                     $errors['confirm_password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                 }
                 if (sizeof($errors) > 0) {
                     $html = $standardForm->generateErrorAnswer($errors);
                 } else {
                     $tmp_code = md5(uniqid(rand(), true));
                     if ($parametersMod->getValue('community', 'user', 'options', 'encrypt_passwords')) {
                         $additionalFields['new_password'] = md5($_POST['password'] . \Modules\community\user\Config::$hashSalt);
                     } else {
                         $additionalFields['new_password'] = $_POST['password'];
                     }
                     $additionalFields['verification_code'] = $tmp_code;
                     $standardForm->updateDatabase(DB_PREF . 'm_community_user', 'id', $tmpUser['id'], $additionalFields);
                     $this->sendPasswordResetLink($_POST['email'], $tmp_code, $tmpUser['id']);
                     $html = "\n                <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . CHARSET . "\" /></head><body>\n                <script type=\"text/javascript\">\n                  parent.window.location = '" . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetSentText)) . "';\n                </script>\n                </body></html>            \n            ";
                 }
                 echo $html;
                 \Db::disconnect();
                 exit;
                 break;
             case 'password_reset_verification':
                 $current = Db::userById($_REQUEST['id']);
                 if ($current && $current['verified']) {
                     if ($current['verification_code'] == $_REQUEST['code']) {
                         if ($current['new_password'] != '') {
                             if (Db::verifyNewPassword($current['id'])) {
                                 $site->dispatchEvent('community', 'user', 'password_reset', array('user_id' => $current['id']));
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetVerified)));
                             } else {
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetVerificationError)));
                             }
                         } else {
                             header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetVerified)));
                         }
                     } else {
                         header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetVerificationError)));
                     }
                 } else {
                     header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlPasswordResetVerificationError)));
                 }
                 \Db::disconnect();
                 exit;
                 break;
             case 'register':
                 $html = '';
                 if (!$parametersMod->getValue('community', 'user', 'options', 'enable_registration')) {
                     \Db::disconnect();
                     exit;
                 }
                 $standardForm = new \Library\Php\Form\Standard(\Modules\community\user\Config::getRegistrationFields());
                 $errors = $standardForm->getErrors();
                 $sameEmailUser = Db::userByEmail($_POST['email']);
                 if ($_POST['email'] && $sameEmailUser) {
                     $errors['email'] = $parametersMod->getValue('community', 'user', 'errors', 'already_registered');
                 }
                 if ($parametersMod->getValue('community', 'user', 'options', 'login_type') == 'login') {
                     $sameLoginUser = Db::userByLogin($_POST['login']);
                     if ($sameLoginUser) {
                         $errors['login'] = $parametersMod->getValue('community', 'user', 'errors', 'already_registered');
                     }
                 }
                 if ($parametersMod->getValue('community', 'user', 'options', 'type_password_twice') && $_POST['password'] != $_POST['confirm_password']) {
                     $errors['password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                     $errors['confirm_password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                 }
                 if (sizeof($errors) > 0) {
                     $html = $standardForm->generateErrorAnswer($errors);
                 } else {
                     $tmp_code = md5(uniqid(rand(), true));
                     if ($parametersMod->getValue('community', 'user', 'options', 'encrypt_passwords')) {
                         $password = md5($_POST['password'] . \Modules\community\user\Config::$hashSalt);
                     } else {
                         $password = $_POST['password'];
                     }
                     if ($parametersMod->getValue('community', 'user', 'options', 'require_email_confirmation')) {
                         $verified = '0';
                     } else {
                         $verified = '1';
                     }
                     $insert_id = $standardForm->writeToDatabase(DB_PREF . 'm_community_user', array('verified' => $verified, 'verification_code' => $tmp_code, 'password' => $password, 'last_login' => date("Y-m-d"), 'language_id' => $site->currentLanguage['id']));
                     if ($insert_id !== false) {
                         $site->dispatchEvent('community', 'user', 'register', array('user_id' => $insert_id));
                         if ($parametersMod->getValue('community', 'user', 'options', 'require_email_confirmation')) {
                             $this->sendVerificationLink($_POST['email'], $tmp_code, $insert_id);
                             $html = "\n                    <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . CHARSET . "\" /></head><body>\n                    <script type=\"text/javascript\">\n                      parent.window.location = '" . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerificationRequired)) . "';\n                    </script>\n                    </body></html>\n                  ";
                         } else {
                             if ($parametersMod->getValue('community', 'user', 'options', 'autologin_after_registration')) {
                                 $tmpUser = Db::userById($insert_id);
                                 if ($tmpUser) {
                                     $this->login($tmpUser);
                                     $html = $this->redirectAfterLogin();
                                 }
                             } else {
                                 $html = "\n                      <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . CHARSET . "\" /></head><body>\n                      <script type=\"text/javascript\">\n                        parent.window.location.href = '" . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerified)) . "';\n                      </script>\n                      </body></html>\n                  ";
                             }
                         }
                     } else {
                         trigger_error("Cannot register new user");
                     }
                 }
                 echo $html;
                 \Db::disconnect();
                 exit;
                 break;
             case 'update_profile':
                 if ($session->loggedIn()) {
                     $standardForm = new \Library\Php\Form\Standard(\Modules\community\user\Config::getProfileFields());
                     $errors = $standardForm->getErrors();
                     $tmpUser = Db::userById($session->userId());
                     if (isset($_POST['email']) && $_POST['email'] != $tmpUser['email']) {
                         $user_by_new_email = Db::userByEmail($_POST['email']);
                         if ($user_by_new_email && $user_by_new_email['verified']) {
                             $errors['email'] = $parametersMod->getValue('community', 'user', 'errors', 'already_registered');
                         }
                     }
                     if ($parametersMod->getValue('community', 'user', 'options', 'type_password_twice') && $_POST['password'] != $_POST['confirm_password']) {
                         $errors['password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                         $errors['confirm_password'] = $parametersMod->getValue('community', 'user', 'errors', 'passwords_dont_match');
                     }
                     if (sizeof($errors) > 0) {
                         $html = $standardForm->generateErrorAnswer($errors);
                     } else {
                         if ($tmpUser) {
                             $additionalFields = array();
                             if (isset($_POST['email']) && $_POST['email'] != $tmpUser['email']) {
                                 $tmp_code = md5(uniqid(rand(), true));
                                 $additionalFields['new_email'] = $_POST['email'];
                                 $additionalFields['verification_code'] = $tmp_code;
                             }
                             if (isset($_POST['password']) && $_POST['password'] != '') {
                                 if ($parametersMod->getValue('community', 'user', 'options', 'encrypt_passwords')) {
                                     $additionalFields['password'] = md5($_POST['password'] . \Modules\community\user\Config::$hashSalt);
                                 } else {
                                     $additionalFields['password'] = $_POST['password'];
                                 }
                             }
                             $standardForm->updateDatabase(DB_PREF . 'm_community_user', 'id', $tmpUser['id'], $additionalFields);
                             $site->dispatchEvent('community', 'user', 'update_profile', array('user_id' => $tmpUser['id']));
                             if (isset($_POST['email']) && $_POST['email'] != $tmpUser['email']) {
                                 $this->sendUpdateVerificationLink($_POST['email'], $tmp_code, $tmpUser['id']);
                                 $html = "\n                    <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . CHARSET . "\" /></head><body>\n                    <script type=\"text/javascript\">\n                      parent.window.location = '" . $site->generateUrl(null, $userZone->getName(), array(Config::$urlEmailVerificationRequired)) . "';\n                    </script>\n                    </body></html>\n                  ";
                             } else {
                                 $html = "\n                    <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . CHARSET . "\" /></head><body>\n                    <script type=\"text/javascript\">\n                      parent.window.location = '" . $site->generateUrl(null, $userZone->getName(), array(Config::$urlProfile), array("message" => "updated")) . "';\n                    </script>\n                    </body></html>\n                  ";
                             }
                         } else {
                             trigger_error("Something goes wrong. " . $session->userId() . " " . $_POST['email']);
                         }
                     }
                     echo $html;
                     \Db::disconnect();
                     exit;
                 }
                 break;
             case 'login':
                 if ($parametersMod->getValue('community', 'user', 'options', 'login_type') == 'login') {
                     $tmpUser = Db::userByLogin($_POST['login']);
                 } else {
                     $tmpUser = Db::userByEmail($_POST['email']);
                 }
                 if ($parametersMod->getValue('community', 'user', 'options', 'encrypt_passwords')) {
                     $tmp_password = md5($_POST['password'] . \Modules\community\user\Config::$hashSalt);
                 } else {
                     $tmp_password = $_POST['password'];
                 }
                 if ($tmpUser && isset($_POST['password']) && $tmp_password == $tmpUser['password']) {
                     $this->login($tmpUser);
                     if ($parametersMod->getValue('community', 'user', 'options', 'enable_autologin') && isset($_POST['autologin']) && $_POST['autologin']) {
                         setCookie(Config::$autologinCookieName, json_encode(array('id' => $tmpUser['id'], 'pass' => md5($tmpUser['password'] . $tmpUser['created_on']))), time() + $parametersMod->getValue('community', 'user', 'options', 'autologin_time') * 60 * 60 * 24, Config::$autologinCookiePath, Config::getCookieDomain());
                     }
                     $html = $this->redirectAfterLogin();
                 } else {
                     $standardForm = new \Library\Php\Form\Standard(\Modules\community\user\Config::getRegistrationFields());
                     $errors = array();
                     $globalError = null;
                     $site->dispatchEvent('community', 'user', 'incorrect_login', array('post' => $_POST));
                     if ($parametersMod->getValue('community', 'user', 'options', 'login_type') == 'login') {
                         $globalError = $parametersMod->getValue('community', 'user', 'errors', 'incorrect_login_data');
                         $errors['login'] = '';
                     } else {
                         $globalError = $parametersMod->getValue('community', 'user', 'errors', 'incorrect_email_data');
                         $errors['email'] = '';
                     }
                     $errors['password'] = '';
                     $log->log('community/user', 'incorrect frontend login', $_SERVER['REMOTE_ADDR']);
                     $html = $standardForm->generateErrorAnswer($errors, $globalError);
                 }
                 echo $html;
                 \Db::disconnect();
                 exit;
                 break;
             case 'registration_verification':
                 $current = Db::userById($_REQUEST['id']);
                 if ($current) {
                     $sameEmailUser = Db::userByEmail($current['email']);
                     $sameLoginUser = Db::userByLogin($current['login']);
                     if ($current['verification_code'] == $_REQUEST['code']) {
                         if ($sameEmailUser && $sameEmailUser['id'] != $current['id']) {
                             header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlVerificationErrorEmailExist)));
                         } elseif ($parametersMod->getValue('community', 'user', 'options', 'login_type') == 'login' && $sameLoginUser && $sameLoginUser != $current['id']) {
                             header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlVerificationErrorUserExist)));
                         } else {
                             Db::verify($current['id']);
                             $site->dispatchEvent('community', 'user', 'registration_verification', array('user_id' => $current['id']));
                             if ($parametersMod->getValue('community', 'user', 'options', 'autologin_after_registration')) {
                                 $this->login($current);
                                 $this->redirectAfterLoginHeader();
                             } else {
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerified)));
                             }
                         }
                     } else {
                         header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerificationError)));
                     }
                 } else {
                     header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerificationError)));
                 }
                 \Db::disconnect();
                 exit;
                 break;
             case 'new_email_verification':
                 $sameEmailUser = Db::userById($_REQUEST['id']);
                 if ($sameEmailUser) {
                     if ($sameEmailUser['verification_code'] == $_REQUEST['code']) {
                         $user_with_new_email = Db::userByEmail($sameEmailUser['new_email']);
                         if ($user_with_new_email) {
                             if ($user_with_new_email['id'] == $sameEmailUser['id']) {
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerified)));
                             } else {
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlNewEmailVerificationError)));
                             }
                         } else {
                             if ($sameEmailUser['new_email'] == '') {
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRegistrationVerified)));
                             } else {
                                 Db::verifyNewEmail($sameEmailUser['id']);
                                 $site->dispatchEvent('community', 'user', 'new_email_verification', array('user_id' => $sameEmailUser['id']));
                                 header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlNewEmailVerified)));
                             }
                         }
                     } else {
                         header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlNewEmailVerificationError)));
                     }
                 } else {
                     header("location: " . $site->generateUrl(null, $userZone->getName(), array(Config::$urlNewEmailVerificationError)));
                 }
                 \Db::disconnect();
                 exit;
                 break;
             case 'logout':
                 if ($session->loggedIn()) {
                     $site->dispatchEvent('community', 'user', 'logout', array('user_id' => $session->userId()));
                 }
                 $session->logout();
                 if ($parametersMod->getValue('community', 'user', 'options', 'enable_autologin')) {
                     setCookie(Config::$autologinCookieName, '', time() - 60, Config::$autologinCookiePath, Config::getCookieDomain());
                 }
                 header('location: ' . BASE_URL);
                 \Db::disconnect();
                 exit;
                 break;
             case 'renew_registration':
                 if (isset($_GET['id'])) {
                     if (Db::renewRegistration($_GET['id']) == 1) {
                         $site->dispatchEvent('community', 'user', 'renew_registration', array('user_id' => $_GET['id']));
                         header('location: ' . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRenewedRegistration)));
                     } else {
                         header('location: ' . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRenewRegistrationError)));
                     }
                 } else {
                     header('location: ' . $site->generateUrl(null, $userZone->getName(), array(Config::$urlRenewRegistrationError)));
                 }
                 \Db::disconnect();
                 exit;
                 break;
         }
     }
 }