protected function processForm(sfWebRequest $request, sfForm $form, $new) { $req_param = $request->getParameter($form->getName()); $req_param['birthdate'] = $req_param['birthdate']['year'] . "-" . $req_param['birthdate']['month'] . "-" . $req_param['birthdate']['day']; if ($new) { $req_param['created_at'] = date("Y-m-j H:i:s"); } if (!isset($req_param['login']['locked']) || is_null($req_param['login']['locked'])) { $req_param['login']['locked'] = 0; } $form->bind($req_param); if ($form->isValid()) { if (!$form->getObject()->isNew() || ModeratorManagement::checkForDoubloon($req_param['login']['login'])) { $user = $form->save(); $country = Doctrine::getTable('AddressCountry')->findOneById($req_param['address']['address_country_id']); if ($country) { $countryName = $country->getName(); } else { $countryName = null; } $userSeg = Doctrine::getTable('UserSeg')->findOneById($req_param['user_seg_id']); if ($userSeg) { $userSegDesignation = $userSeg->getDesignation(); } else { $userSegDesignation = null; } $userAwareness = Doctrine::getTable('UserAwareness')->findOneById($req_param['user_awareness_id']); if ($userAwareness) { $userAwarenessDesignation = $userAwareness->getDesignation(); } else { $userAwarenessDesignation = null; } $userGender = Doctrine::getTable('UserGender')->findOneById($req_param['user_gender_id']); if ($userGender) { $userGenderDesignation = $userGender->getDesignation(); } else { $userGenderDesignation = null; } $category = Doctrine::getTable('ActPublicCategory')->findOneById($req_param['act_public_category_id']); if ($category) { $categoryDesignation = $category->getDesignation(); } else { $categoryDesignation = null; } $cityName = $req_param['address']['name']; if ($new) { /*Duplication of certain data in the table user_archive, in a new entry*/ $this->values = array('age' => UserLib::getAge($req_param['birthdate']), 'created_at' => $req_param['created_at'], 'city_name' => $cityName, 'country' => $countryName, 'seg' => $userSegDesignation, 'awareness' => $userAwarenessDesignation, 'gender' => $userGenderDesignation, 'category' => $categoryDesignation, 'user_id' => $user->id); $this->archiveForm = new UserArchiveForm(); $this->archiveForm->bind($this->values); if ($this->archiveForm->isValid()) { $this->archiveForm->save(); } $this->getUser()->setFlash('notice', 'The user has been added.'); } else { /*Duplication of certain data in the table user_archive, in the existing entry*/ $updatedUserArchive = Doctrine::getTable('UserArchive')->findOneByUserId($user->id); $updatedUserArchive->setCountry($countryName); $updatedUserArchive->setCityName($cityName); $updatedUserArchive->setSeg($userSegDesignation); $updatedUserArchive->setAwareness($userAwarenessDesignation); $updatedUserArchive->setGender($userGenderDesignation); $updatedUserArchive->setCategory($categoryDesignation); $updatedUserArchive->save(); $this->getUser()->setFlash('notice', 'The user has been updated.'); } if ($req_param['direct_imputation']) { $this->getRequest()->setParameter('user_id', $user->id); $this->forward('use', 'index'); } else { $this->redirect('user/index'); } } else { $this->getUser()->setFlash('error', 'This login already exists, please choose another.'); } } else { $this->getUser()->setFlash('error', 'Required field(s) are missing or some field(s) are incorrect.', false); } }
<?php /** * Created by PhpStorm. * User: Alexey Osipov * Date: 20.11.2015 * Time: 14:34 UTC (+03:00) * Проверка лолгина и электронной почты при регистрации */ define("SITE_EXEC", 1); require_once "classes/user.php"; $us = new UserLib(); $us->checkField($_POST['type'], $_POST['value']);
<?php require dirname(__FILE__) . '/../lib/auto_load.php'; $written_language_tag = UserLib::getWrittenLanguageTag(); $uri = $_SERVER['SCRIPT_NAME']; function encodeFilterUri($uri_data, $where = array()) { $map = ConfigParserLib::get('category', 'category_map'); $uri_position = ConfigParserLib::get('product/' . $uri_data['category_name'], 'uri_position'); $where_uri = implode('-', array_values($where)); if (empty($where) || 0 < preg_match('/^1-1-(00\\-)+00$/', $where_uri)) { $where_uri = ''; } return '/' . $uri_data['group_name'] . '/' . array_search($uri_data['category_name'], $map) . '/' . $where_uri; } //首页 if (0 < preg_match('/^\\/$/', $uri)) { require dirname(__FILE__) . '/../module/all_groups.php'; require FdHelperLib::getViewFilePath('index'); exit; } //某个类别的筛选 /phone/cell_phones/0-0 if (0 < preg_match('/^\\/\\w+\\/\\w+\\/[0-9\\.-]+$/', $uri) || 0 < preg_match('/^\\/\\w+\\/\\w+\\/$/', $uri)) { $page_tmp_dir = ConfigParserLib::get('tmp', 'tmp_dir') . md5($_SERVER['REQUEST_URI']) . '/'; $ttl = ConfigParserLib::get('tmp', 'page_tmp_ttl'); //header('Cache-Control: max-age=' . $ttl * 60); header('Cache-Control: max-age=180'); $now = time(); //$filename = strtotime(date('Y-m-d H', $now) . ':00:00') + intval(date('i', $now) / $ttl) * $ttl * 60; $filename = strtotime(date('Y-m-d H', $now) . ':00:00'); $tmp_file_path = $page_tmp_dir . $filename;
<?php /** * Created by PhpStorm. * User: Alexey Osipov * Date: 20.11.2015 * Time: 00:19 UTC (+03:00) * Авторизация пользователя */ define("SITE_EXEC", 1); session_start(); require_once "classes/user.php"; $us = new UserLib(); $us->loginUser($_POST['user-login'], $_POST['user-password']);
<?php /** * Created by PhpStorm. * User: Alexey Osipov * Date: 21.11.2015 * Time: 12:14 UTC (+03:00) * Выход авторизованного пользователя из системы */ session_start(); require_once "classes/user.php"; $us = new UserLib(); $us->logoutUser();
* Регистрация нового пользователя */ define("SITE_EXEC", 1); session_start(); require_once "classes/user.php"; //Загрузка файла на сервер if (isset($_FILES['avatar']['tmp_name'])) { $uploaddir = __DIR__ . '/img/avatars/'; $avatar_file = date("h.m.s-d.m.y") . basename($_FILES['avatar']['name']); $uploadfile = $uploaddir . $avatar_file; if (!move_uploaded_file($_FILES['avatar']['tmp_name'], $uploadfile)) { echo "Ошибка загрузки фала\n"; } else { echo "Изображение загружено.\n"; } } //Регистрация пользователя $us = new UserLib(); $res = $us->registerUser($_POST["name"], $_POST["pass"], $_POST["email"], $_POST["birthday"], "", "", "", "", $_POST["firstName"], $avatar_file, $_SESSION["Lang"]); //Если регистрация успешна, редирект в личный кабинет if ($res[0] == true) { $_SESSION["id"] = $res[1]; $_SESSION["Name"] = $_POST["name"]; $_SESSION["FisrtName"] = $_POST["firstName"]; $_SESSION["Email"] = $_POST["email"]; $_SESSION["Avatar"] = $_POST["avatar"]; header("Location: personal.php"); } else { $_SESSION["error"] = "Ошибка регистрации. Повторите попытку."; header("Location: registration.php"); }