当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsUser::sessionSet方法代码示例

本文整理汇总了PHP中cmsUser::sessionSet方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::sessionSet方法的具体用法?PHP cmsUser::sessionSet怎么用?PHP cmsUser::sessionSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsUser的用法示例。


在下文中一共展示了cmsUser::sessionSet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     if (!$this->getPackageContentsDir()) {
         $this->redirectToAction('install/finish');
     }
     $form = $this->getForm('ftp');
     $is_submitted = $this->request->has('submit');
     $account = cmsUser::isSessionSet('ftp_account') ? cmsUser::sessionGet('ftp_account') : array();
     if ($is_submitted) {
         $account = array_merge($account, $form->parse($this->request, $is_submitted, $account));
         cmsUser::sessionSet('ftp_account', $account);
         $errors = $form->validate($this, $account);
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
         if (!$errors) {
             $account['host'] = trim(str_replace('ftp://', '', $account['host']), '/');
             if ($account['path'] != '/') {
                 $account['path'] = '/' . trim($account['path'], '/') . '/';
             }
             $this->uploadPackageToFTP($account);
         }
     }
     return cmsTemplate::getInstance()->render('install_ftp', array('account' => $account, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:25,代码来源:install_ftp.php

示例2: run

 public function run($pass_token)
 {
     if (!$pass_token) {
         cmsCore::error404();
     }
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $users_model = cmsCore::getModel('users');
     $user = $users_model->getUserByPassToken($pass_token);
     if (!$user) {
         cmsCore::error404();
     }
     $users_model->unlockUser($user['id']);
     $users_model->clearUserPassToken($user['id']);
     cmsEventsManager::hook('user_registered', $user);
     cmsUser::addSessionMessage($this->options['reg_auto_auth'] ? LANG_REG_SUCCESS_VERIFIED_AND_AUTH : LANG_REG_SUCCESS_VERIFIED, 'success');
     // авторизуем пользователя автоматически
     if ($this->options['reg_auto_auth']) {
         $user = cmsEventsManager::hook('user_login', $user);
         cmsUser::sessionSet('user', array('id' => $user['id'], 'groups' => $user['groups'], 'time_zone' => $user['time_zone'], 'perms' => cmsUser::getPermissions($user['groups']), 'is_admin' => $user['is_admin']));
         $update_data = array('ip' => cmsUser::getIp());
         $this->model->update('{users}', $user['id'], $update_data, true);
         cmsEventsManager::hook('auth_login', $user['id']);
     }
     $this->redirect($this->getAuthRedirectUrl($this->options['first_auth_redirect']));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:27,代码来源:verify.php

示例3: run

 public function run()
 {
     if (!$this->getPackageContentsDir()) {
         $this->redirectToAction('install/finish');
     }
     $form = $this->getForm('ftp');
     $account = cmsUser::isSessionSet('ftp_account') ? cmsUser::sessionGet('ftp_account') : array();
     if ($this->request->has('submit')) {
         $account = array_merge($account, $form->parse($this->request, true, $account));
         if ($account['save_to_session']) {
             cmsUser::sessionSet('ftp_account', $account);
         } else {
             cmsUser::sessionSet('ftp_account', array('host' => $account['host'], 'path' => $account['path'], 'is_pasv' => $account['is_pasv']));
         }
         $errors = $form->validate($this, $account);
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
         if (!$errors) {
             $account['host'] = trim(str_replace('ftp://', '', $account['host']), '/');
             if ($account['path'] != '/') {
                 $account['path'] = '/' . trim($account['path'], '/') . '/';
             }
             $this->uploadPackageToFTP($account);
         }
     }
     return $this->cms_template->render('install_ftp', array('manifest' => $this->parsePackageManifest(), 'account' => $account, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:28,代码来源:install_ftp.php

示例4: run

 public function run()
 {
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $email = $this->request->get('login_email');
     $password = $this->request->get('login_password');
     $remember = (bool) $this->request->get('remember');
     $back_url = $this->request->has('back') ? $this->request->get('back') : false;
     $is_site_offline = !cmsConfig::get('is_site_on');
     if ($this->request->has('submit')) {
         $is_captcha_valid = true;
         if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
         }
         if ($is_captcha_valid) {
             cmsUser::sessionUnset('is_auth_captcha');
             $logged_id = cmsUser::login($email, $password, $remember);
             if ($logged_id) {
                 if ($is_site_offline) {
                     $userSession = cmsUser::sessionGet('user');
                     if (!$userSession['is_admin']) {
                         cmsUser::addSessionMessage(LANG_LOGIN_ADMIN_ONLY, 'error');
                         cmsUser::logout();
                         $this->redirectBack();
                     }
                 }
                 cmsEventsManager::hook('auth_login', $logged_id);
                 $is_back = $this->request->get('is_back');
                 if ($is_back) {
                     $this->redirectBack();
                 }
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirectToHome();
                 }
             }
         }
         if ($this->options['auth_captcha'] && !$is_site_offline) {
             cmsUser::sessionSet('is_auth_captcha', true);
         }
         if ($is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
             if ($is_site_offline) {
                 $this->redirectBack();
             }
         } else {
             cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
         }
     }
     if ($back_url) {
         cmsUser::addSessionMessage(LANG_LOGIN_REQUIRED, 'error');
     }
     if (cmsUser::sessionGet('is_auth_captcha')) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     return cmsTemplate::getInstance()->render('login', array('back_url' => $back_url, 'captcha_html' => isset($captcha_html) ? $captcha_html : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:59,代码来源:login.php

示例5: run

 public function run()
 {
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $email = $this->request->get('login_email', '');
     $password = $this->request->get('login_password', '');
     $remember = (bool) $this->request->get('remember');
     $back_url = $this->request->get('back', '');
     $is_site_offline = !cmsConfig::get('is_site_on');
     $is_submit = $this->request->has('submit');
     if ($is_submit) {
         $is_captcha_valid = true;
         if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
         }
         if ($is_captcha_valid) {
             cmsUser::sessionUnset('is_auth_captcha');
             $logged_id = cmsUser::login($email, $password, $remember);
             if ($logged_id) {
                 if ($is_site_offline) {
                     $userSession = cmsUser::sessionGet('user');
                     if (!$userSession['is_admin']) {
                         cmsUser::addSessionMessage(LANG_LOGIN_ADMIN_ONLY, 'error');
                         cmsUser::logout();
                         $this->redirectBack();
                     }
                 }
                 cmsEventsManager::hook('auth_login', $logged_id);
                 $auth_redirect = $this->options['auth_redirect'];
                 $is_first_auth = cmsUser::getUPS('first_auth', $logged_id);
                 if ($is_first_auth) {
                     $auth_redirect = $this->options['first_auth_redirect'];
                     cmsUser::deleteUPS('first_auth', $logged_id);
                 }
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirect($this->getAuthRedirectUrl($auth_redirect));
                 }
             }
         }
         if ($this->options['auth_captcha'] && !$is_site_offline) {
             cmsUser::sessionSet('is_auth_captcha', true);
         }
         if ($is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
             if ($is_site_offline) {
                 $this->redirectBack();
             }
         } else {
             cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
         }
         if ($this->options['auth_redirect'] == 'none' || !empty($is_first_auth) && $this->options['first_auth_redirect'] == 'none') {
             if (!$back_url) {
                 $back_url = $this->getBackURL();
             }
         }
     }
     if ($back_url && !$is_submit) {
         cmsUser::addSessionMessage(LANG_LOGIN_REQUIRED, 'error');
     }
     if (cmsUser::sessionGet('is_auth_captcha')) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     return $this->cms_template->render('login', array('back_url' => $back_url, 'captcha_html' => isset($captcha_html) ? $captcha_html : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:67,代码来源:login.php

示例6: run


//.........这里部分代码省略.........
                     unset($user[$field['name']]);
                 }
             }
         }
         $errors = $form->validate($this, $user);
         if (!$errors) {
             //
             // проверяем код приглашения
             //
             if ($this->options['is_reg_invites']) {
                 $invite = $this->model->getInviteByCode($user['inv']);
                 if (!$invite) {
                     $errors['inv'] = LANG_REG_WRONG_INVITE_CODE;
                 } else {
                     if ($this->options['is_invites_strict'] && $invite['email'] != $user['email']) {
                         $errors['inv'] = LANG_REG_WRONG_INVITE_CODE_EMAIL;
                     } else {
                         $user['inviter_id'] = $invite['user_id'];
                     }
                 }
             }
             //
             // проверяем допустимость e-mail, имени и IP
             //
             if (!$this->isEmailAllowed($user['email'])) {
                 $errors['email'] = sprintf(LANG_AUTH_RESTRICTED_EMAIL, $user['email']);
             }
             if (!$this->isNameAllowed($user['nickname'])) {
                 $errors['nickname'] = sprintf(LANG_AUTH_RESTRICTED_NAME, $user['nickname']);
             }
             if (!$this->isIPAllowed(cmsUser::get('ip'))) {
                 cmsUser::addSessionMessage(sprintf(LANG_AUTH_RESTRICTED_IP, cmsUser::get('ip')), 'error');
                 $errors = true;
             }
         }
         //
         // Проверяем капчу
         //
         if (!$errors && $this->options['reg_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
             if (!$is_captcha_valid) {
                 $errors = true;
                 cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
             }
         }
         if (!$errors) {
             unset($user['inv']);
             //
             // Блокируем пользователя, если включена верификация e-mail
             //
             if ($this->options['verify_email']) {
                 $user = array_merge($user, array('is_locked' => true, 'lock_reason' => LANG_REG_CFG_VERIFY_LOCK_REASON, 'pass_token' => string_random(32, $user['email']), 'date_token' => ''));
             }
             $result = $users_model->addUser($user);
             if ($result['success']) {
                 $user['id'] = $result['id'];
                 cmsUser::addSessionMessage(LANG_REG_SUCCESS, 'success');
                 cmsUser::setUPS('first_auth', 1, $user['id']);
                 // отправляем письмо верификации e-mail
                 if ($this->options['verify_email']) {
                     $this->options['verify_exp'] = empty($this->options['verify_exp']) ? 48 : $this->options['verify_exp'];
                     $messenger = cmsCore::getController('messages');
                     $to = array('email' => $user['email'], 'name' => $user['nickname']);
                     $letter = array('name' => 'reg_verify');
                     $messenger->sendEmail($to, $letter, array('nickname' => $user['nickname'], 'page_url' => href_to_abs('auth', 'verify', $user['pass_token']), 'pass_token' => $user['pass_token'], 'valid_until' => html_date(date('d.m.Y H:i', time() + $this->options['verify_exp'] * 3600), true)));
                     cmsUser::addSessionMessage(sprintf(LANG_REG_SUCCESS_NEED_VERIFY, $user['email']), 'info');
                 } else {
                     cmsEventsManager::hook('user_registered', $user);
                     // авторизуем пользователя автоматически
                     if ($this->options['reg_auto_auth']) {
                         $logged_id = cmsUser::login($user['email'], $user['password1']);
                         if ($logged_id) {
                             cmsEventsManager::hook('auth_login', $logged_id);
                         }
                     }
                 }
                 $back_url = cmsUser::sessionGet('auth_back_url') ? cmsUser::sessionGet('auth_back_url', true) : false;
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirect($this->getAuthRedirectUrl($this->options['first_auth_redirect']));
                 }
             } else {
                 $errors = $result['errors'];
             }
         }
         if ($errors && $is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     // Капча
     if ($this->options['reg_captcha']) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     // запоминаем откуда пришли на регистрацию
     if (empty($errors) && $this->options['first_auth_redirect'] == 'none') {
         cmsUser::sessionSet('auth_back_url', $this->getBackURL());
     }
     return $this->cms_template->render('registration', array('user' => $user, 'form' => $form, 'captcha_html' => isset($captcha_html) ? $captcha_html : false, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:101,代码来源:register.php

示例7: generateCSRFToken

 /**
  * Создает, сохраняет в сессии и возвращает CSRF-token
  * @return string
  */
 public static function generateCSRFToken()
 {
     $hash = implode('::', array(session_id(), rand(0, 9999), microtime(true)));
     $token = md5($hash);
     cmsUser::sessionSet('csrf_token', $token);
     return $token;
 }
开发者ID:asphix,项目名称:icms2,代码行数:11,代码来源:form.php

示例8: run

 public function run($profile, $do = false)
 {
     if (!cmsUser::isLogged()) {
         cmsCore::error404();
     }
     $user = cmsUser::getInstance();
     // если нужно, передаем управление другому экшену
     if ($do) {
         $this->runAction('profile_edit_' . $do, array($profile) + array_slice($this->params, 2));
         return;
     }
     // проверяем наличие доступа
     if ($profile['id'] != $user->id && !$user->is_admin) {
         cmsCore::error404();
     }
     // Получаем поля
     $content_model = cmsCore::getModel('content');
     $content_model->setTablePrefix('');
     $content_model->orderBy('ordering');
     $fields = $content_model->getContentFields('{users}');
     // Строим форму
     $form = new cmsForm();
     // Разбиваем поля по группам
     $fieldsets = cmsForm::mapFieldsToFieldsets($fields, function ($field, $user) {
         // проверяем что группа пользователя имеет доступ к редактированию этого поля
         if ($field['groups_edit'] && !$user->isInGroups($field['groups_edit'])) {
             return false;
         }
         return true;
     });
     // Добавляем поля в форму
     foreach ($fieldsets as $fieldset) {
         $fieldset_id = $form->addFieldset($fieldset['title']);
         foreach ($fieldset['fields'] as $field) {
             // добавляем поле в форму
             $form->addField($fieldset_id, $field['handler']);
         }
     }
     // Добавляем поле выбора часового пояса
     $config = cmsConfig::getInstance();
     $fieldset_id = $form->addFieldset(LANG_TIME_ZONE);
     $form->addField($fieldset_id, new fieldList('time_zone', array('default' => $config->time_zone, 'generator' => function ($item) {
         return cmsCore::getTimeZones();
     })));
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $new = $form->parse($this->request, $is_submitted, $profile);
         $old = $profile;
         $profile = array_merge($profile, $new);
         // Проверям правильность заполнения
         $errors = $form->validate($this, $profile);
         if (!$errors) {
             $is_allowed = cmsEventsManager::hookAll('user_profile_update', $profile, true);
             if ($is_allowed !== true && in_array(false, $is_allowed)) {
                 $errors = true;
             }
         }
         if (!$errors) {
             // Обновляем профиль и редиректим на его просмотр
             $this->model->updateUser($profile['id'], $profile);
             // Отдельно обновляем часовой пояс в сессии
             cmsUser::sessionSet('user_data:time_zone', $profile['time_zone']);
             // Постим уведомление о смене аватара в ленту
             if (!$this->model->isAvatarsEqual($new['avatar'], $old['avatar'])) {
                 $activity_controller = cmsCore::getController('activity');
                 $activity_controller->deleteEntry($this->name, "avatar", $profile['id']);
                 if (!empty($new['avatar'])) {
                     $activity_controller->addEntry($this->name, "avatar", array('user_id' => $profile['id'], 'subject_title' => $profile['nickname'], 'subject_id' => $profile['id'], 'subject_url' => href_to('users', $profile['id']), 'is_private' => 0, 'group_id' => null, 'images' => array(array('url' => href_to('users', $profile['id']), 'src' => html_image_src($new['avatar'], 'normal'))), 'images_count' => 1));
                 }
             }
             $this->redirectTo('users', $profile['id']);
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('profile_edit', array('do' => 'edit', 'id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:dgolovanev,项目名称:icms2,代码行数:80,代码来源:profile_edit.php

示例9: getGeoByIp

 public function getGeoByIp()
 {
     $cached_geo = cmsUser::sessionGet('geo_data');
     if ($cached_geo) {
         return $cached_geo;
     }
     $out = simplexml_load_string(file_get_contents_from_url('http://ipgeobase.ru:7020/geo?ip=' . cmsUser::getIp()));
     $data = array();
     if ($out && is_object($out) && !empty($out->ip[0])) {
         foreach ($out->ip[0] as $key => $value) {
             $data[$key] = (string) $value;
         }
     }
     $geo = array('city' => array('id' => null, 'name' => null), 'country' => array('id' => null, 'name' => null));
     if (isset($data['country'])) {
         $geo['country'] = $this->model->getItemByField('geo_countries', 'alpha2', $data['country']);
     }
     if (isset($data['city'])) {
         if (!empty($geo['country']['id'])) {
             $this->model->filterEqual('country_id', $geo['country']['id']);
         }
         $geo['city'] = $this->model->getItemByField('geo_cities', 'name', $data['city']);
     }
     cmsUser::sessionSet('geo_data', $geo);
     return $geo;
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:26,代码来源:frontend.php


注:本文中的cmsUser::sessionSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。