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


PHP SessionCache::unsetKey方法代码示例

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


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

示例1: userLogoutUpdate

 public function userLogoutUpdate($reason = 1)
 {
     $user_id = SessionCache::get('user_id');
     $cookie = SessionCache::get('cookie');
     $q = "UPDATE #prefix#user_logon_info SET logout=NOW(), working_time = (logout-login)/60, logout_reason=:logout_reason ";
     $q .= "WHERE user_id=:user_id AND cookie=:cookie";
     $vars = array(':user_id' => $user_id, ':cookie' => $cookie, ':logout_reason' => $reason);
     $ps = $this->execute($q, $vars);
     $loginTime = explode(":", SessionCache::get('login_time'));
     $logoutTime = explode(":", date('H:i'));
     $totalTime = 60 * $logoutTime[0] + $logoutTime[1] - (60 * $loginTime[0] + $loginTime[1]);
     $this->updateWorkingHour($user_id, $totalTime);
     SessionCache::unsetKey('login_time');
     SessionCache::unsetKey('cookie');
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:15,代码来源:class.UserLogonMySQLDAO.php

示例2: testPutGetIsset

 public function testPutGetIsset()
 {
     $config = Config::getInstance();
     //nothing is set
     $this->assertNull(SessionCache::get('my_key'));
     $this->assertFalse(SessionCache::isKeySet('my_key'));
     //set a key
     SessionCache::put('my_key', 'my_value');
     $this->assertTrue(isset($_SESSION[$config->getValue('source_root_path')]));
     $this->assertEqual($_SESSION[$config->getValue('source_root_path')]['my_key'], 'my_value');
     $this->assertEqual(SessionCache::get('my_key'), 'my_value');
     //overwrite existing key
     SessionCache::put('my_key', 'my_value2');
     $this->assertTrue($_SESSION[$config->getValue('source_root_path')]['my_key'] != 'my_value');
     $this->assertEqual($_SESSION[$config->getValue('source_root_path')]['my_key'], 'my_value2');
     //set another key
     SessionCache::put('my_key2', 'my_other_value');
     $this->assertEqual($_SESSION[$config->getValue('source_root_path')]['my_key2'], 'my_other_value');
     //unset first key
     SessionCache::unsetKey('my_key');
     $this->assertNull(SessionCache::get('my_key'));
     $this->assertFalse(SessionCache::isKeySet('my_key'));
 }
开发者ID:randi2kewl,项目名称:ThinkUp,代码行数:23,代码来源:TestOfSessionCache.php

示例3: control

 public function control()
 {
     if ($this->isLoggedIn()) {
         $controller = new DashboardController(true);
         return $controller->go();
     } else {
         // register form validation
         $this->addHeaderCSS('assets/css/validate_password.css');
         $this->addHeaderJavaScript('assets/js/jquery.validate.min.js');
         $this->addHeaderJavaScript('assets/js/jquery.validate.password.js');
         $this->addHeaderJavaScript('assets/js/validate_password.js');
         $config = Config::getInstance();
         $is_registration_open = $config->getValue('is_registration_open');
         $this->disableCaching();
         $invite_dao = DAOFactory::getDAO('InviteDAO');
         if (isset($_GET['code'])) {
             $invite_code = $_GET['code'];
         } else {
             $invite_code = null;
         }
         $this->addToView('invite_code', $invite_code);
         $is_invite_code_valid = $invite_dao->isInviteValid($invite_code);
         if ($invite_code != null && $is_invite_code_valid) {
             $this->addSuccessMessage("Welcome, VIP! You've been invited to register on " . $config->getValue('app_title_prefix') . "ThinkUp.");
         }
         $has_been_registered = false;
         if (!$is_registration_open && !$is_invite_code_valid) {
             $this->addToView('closed', true);
             $disable_xss = true;
             $this->addErrorMessage('<p>Sorry, registration is closed on this installation of ' . $config->getValue('app_title_prefix') . "ThinkUp.</p>" . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>', null, $disable_xss);
         } else {
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $this->addToView('closed', false);
             $captcha = new Captcha();
             if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
                 foreach ($this->REQUIRED_PARAMS as $param) {
                     if (!isset($_POST[$param]) || $_POST[$param] == '') {
                         $this->addErrorMessage('Please fill out all required fields.');
                         $this->is_missing_param = true;
                     }
                 }
                 if (!$this->is_missing_param) {
                     $valid_input = true;
                     if (!Utils::validateEmail($_POST['email'])) {
                         $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email');
                         $valid_input = false;
                     }
                     if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
                         $this->addErrorMessage("Passwords do not match.", 'password');
                         $valid_input = false;
                     } else {
                         if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $_POST['pass1'])) {
                             $this->addErrorMessage("Password must be at least 8 characters and contain both numbers " . "and letters.", 'password');
                             $valid_input = false;
                         }
                     }
                     if (!$captcha->doesTextMatchImage()) {
                         $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha');
                         $valid_input = false;
                     }
                     if ($valid_input) {
                         if ($owner_dao->doesOwnerExist($_POST['email'])) {
                             $this->addErrorMessage("User account already exists.", 'email');
                         } else {
                             // Insert the details into the database
                             $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']);
                             if ($activation_code != false) {
                                 $es = new ViewManager();
                                 $es->caching = false;
                                 $es->assign('application_url', Utils::getApplicationURL(false));
                                 $es->assign('email', urlencode($_POST['email']));
                                 $es->assign('activ_code', $activation_code);
                                 $message = $es->fetch('_email.registration.tpl');
                                 Mailer::mail($_POST['email'], "Activate Your Account on " . $config->getValue('app_title_prefix') . "ThinkUp", $message);
                                 SessionCache::unsetKey('ckey');
                                 $this->addSuccessMessage("Success! Check your email for an activation link.");
                                 //delete invite code
                                 if ($is_invite_code_valid) {
                                     $invite_dao->deleteInviteCode($invite_code);
                                 }
                                 $has_been_registered = true;
                             } else {
                                 $this->addErrorMessage("Unable to register a new user. Please try again.");
                             }
                         }
                     }
                 }
                 if (isset($_POST["full_name"])) {
                     $this->addToView('name', $_POST["full_name"]);
                 }
                 if (isset($_POST["email"])) {
                     $this->addToView('mail', $_POST["email"]);
                 }
                 $this->addToView('has_been_registered', $has_been_registered);
             }
             $challenge = $captcha->generate();
             $this->addToView('captcha', $challenge);
         }
         $this->view_mgr->addHelp('register', 'userguide/accounts/index');
         return $this->generateView();
//.........这里部分代码省略.........
开发者ID:randomecho,项目名称:ThinkUp,代码行数:101,代码来源:class.RegisterController.php

示例4: setSnowflakeSession

 /**
  * Sets/deletes in the session to let us know we needed to run the Snowflake migration.
  * @param bool $delete Delete the session if true
  * @param mixed $value Session value, defaults to false
  * @return mixed Boolean true if successful, else contents of session key
  */
 public function setSnowflakeSession($value = false, $delete = false)
 {
     $key = 'runnig_snowflake_uprade';
     if ($delete) {
         if (SessionCache::isKeySet($key)) {
             SessionCache::unsetKey($key);
             return true;
         }
     } else {
         if ($value) {
             SessionCache::put($key, $value);
             return true;
         } else {
             if (SessionCache::isKeySet($key)) {
                 return SessionCache::get($key);
             } else {
                 return false;
             }
         }
     }
     return false;
 }
开发者ID:randomecho,项目名称:ThinkUp,代码行数:28,代码来源:class.UpgradeDatabaseController.php

示例5: adminControl

 public function adminControl()
 {
     $this->disableCaching();
     $option_dao = DAOFactory::getDAO("OptionDAO");
     if (isset($_POST['save'])) {
         // verify CSRF token
         $this->validateCSRFToken();
         $required = array();
         $config_values = array();
         $parent_config_values = array();
         $app_config = AppConfig::getConfigData();
         $values = 0;
         foreach ($app_config as $key => $value) {
             $app_config[$key]['title'] = isset($app_config[$key]['title']) ? $app_config[$key]['title'] : $key;
             if (isset($_POST[$key]) && $_POST[$key] != '' || $app_config[$key]['required'] && ((!isset($app_config[$key]['value']) || $app_config[$key]['value'] == '') && !isset($required[$key]))) {
                 $config_values[$key] = $app_config[$key];
                 if (isset($_POST[$key])) {
                     $config_values[$key]['value'] = $_POST[$key];
                     $values++;
                 }
                 $config_values[$key]['value'] = isset($_POST[$key]) ? $_POST[$key] : '';
                 if (isset($app_config[$key]['match']) && !preg_match($app_config[$key]['match'], $config_values[$key]['value'])) {
                     $required[$key] = $app_config[$key]['title'] . ' should ' . $app_config[$key]['match_message'];
                 }
                 if (isset($app_config[$key]['dependencies'])) {
                     foreach ($config_values[$key]['dependencies'] as $dep_key) {
                         $config_values[$dep_key]['value'] = isset($_POST[$dep_key]) ? $_POST[$dep_key] : '';
                         $value = $config_values[$dep_key]['value'];
                         if (isset($app_config[$dep_key]['match']) && !preg_match($app_config[$dep_key]['match'], $value)) {
                             $required[$dep_key] = $app_config[$dep_key]['title'] . ' is required if ' . $app_config[$key]['title'] . ' is set ' . $app_config[$dep_key]['match_message'];
                         }
                     }
                 }
             }
             // strip magic quotes if enabled...
             if (get_magic_quotes_gpc() && isset($config_values[$key]['value'])) {
                 $config_values[$key]['value'] = stripslashes($config_values[$key]['value']);
             }
         }
         if (count($required) > 0) {
             $this->setJsonData(array('status' => 'failed', 'required' => $required));
         } else {
             // save our data
             $saved = 0;
             $deleted = 0;
             foreach ($config_values as $key => $config_value) {
                 $config = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, $key);
                 if ($config_value['value'] != '') {
                     if ($config) {
                         $option_dao->updateOption($config->option_id, $config_value['value']);
                     } else {
                         $option_dao->insertOption(OptionDAO::APP_OPTIONS, $key, $config_value['value']);
                     }
                     $saved++;
                 }
             }
             foreach ($app_config as $key => $value) {
                 // delete the record if it exists and is empty in the post request
                 if (!isset($config_values[$key]['value']) || $config_values[$key]['value'] == '') {
                     $config = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, $key);
                     if ($config) {
                         $option_dao->deleteOption($config->option_id);
                         $deleted++;
                     }
                 }
             }
             $this->setJsonData(array('status' => 'success', 'saved' => $saved, 'deleted' => $deleted));
             SessionCache::unsetKey('selected_instance_network');
             SessionCache::unsetKey('selected_instance_username');
         }
     } else {
         $config_values = $option_dao->getOptions(OptionDAO::APP_OPTIONS);
         $app_config = AppConfig::getConfigData();
         $filtered_config_values = array();
         foreach ($app_config as $key => $value) {
             if (isset($config_values[$key])) {
                 $filtered_config_values[$key] = $config_values[$key];
             }
         }
         $this->setJsonData(array('values' => $filtered_config_values, 'app_config_settings' => $app_config));
     }
     return $this->generateView();
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:83,代码来源:class.AppConfigController.php

示例6: logout

 /**
  * Log out and kill long-term cookie.
  * @return void
  */
 public static function logout()
 {
     SessionCache::unsetKey('user');
     SessionCache::unsetKey('user_is_admin');
     if (!empty($_COOKIE[self::COOKIE_NAME])) {
         if (!headers_sent()) {
             setcookie(self::COOKIE_NAME, '', time() - 60 * 60 * 24, '/', self::getCookieDomain());
         }
         $cookie_dao = DAOFactory::getDAO('CookieDAO');
         $cookie_dao->deleteByCookie($_COOKIE[self::COOKIE_NAME]);
     }
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:16,代码来源:class.Session.php

示例7: logout

 /**
  * Log out
  */
 public static function logout()
 {
     SessionCache::unsetKey('user');
     SessionCache::unsetKey('user_is_admin');
 }
开发者ID:rgroves,项目名称:ThinkUp,代码行数:8,代码来源:class.Session.php

示例8: logout

 /**
  * Log out and kill long-term cookie.
  * @return void
  */
 public static function logout()
 {
     SessionCache::unsetKey('user_id');
     SessionCache::unsetKey('first_name');
     SessionCache::unsetKey('last_name');
     SessionCache::unsetKey('user_email');
     SessionCache::unsetKey('user_set');
     if (!empty($_COOKIE[self::COOKIE_NAME])) {
         if (!headers_sent()) {
             setcookie(self::COOKIE_NAME, '', time() - 60 * 60, '/', self::getCookieDomain());
         }
         $cookie_dao = DAOFactory::getDAO('CookieDAO');
         $cookie_dao->deleteByCookie($_COOKIE[self::COOKIE_NAME]);
     }
     //var_dump($_SESSION);
     //SessionCache::unsetPermission();
     //var_dump($_SESSION);
     //session_destroy();
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:23,代码来源:class.Session.php

示例9: clearSessionData

 /**
  * Clears session data by namespace
  * @param $namespace
  */
 public function clearSessionData($namespace)
 {
     $key = 'options_data:' . $namespace;
     if (SessionCache::isKeySet($key)) {
         SessionCache::unsetKey($key);
     }
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:11,代码来源:class.OptionMySQLDAO.php

示例10: control

 public function control()
 {
     if ($this->isLoggedIn()) {
         $controller = new DashboardController(true);
         return $controller->go();
     } else {
         $config = Config::getInstance();
         $is_registration_open = $config->getValue('is_registration_open');
         $this->disableCaching();
         $invite_dao = DAOFactory::getDAO('InviteDAO');
         if (isset($_GET['code'])) {
             $invite_code = $_GET['code'];
         } else {
             $invite_code = null;
         }
         $this->addToView('invite_code', $invite_code);
         $is_invite_code_valid = $invite_dao->isInviteValid($invite_code);
         if (!$is_registration_open && !$is_invite_code_valid) {
             $this->addToView('closed', true);
             $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>');
         } else {
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $this->addToView('closed', false);
             $captcha = new Captcha();
             if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
                 foreach ($this->REQUIRED_PARAMS as $param) {
                     if (!isset($_POST[$param]) || $_POST[$param] == '') {
                         $this->addErrorMessage('Please fill out all required fields.');
                         $this->is_missing_param = true;
                     }
                 }
                 if (!$this->is_missing_param) {
                     $valid_input = true;
                     if (!Utils::validateEmail($_POST['email'])) {
                         $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email');
                         $valid_input = false;
                     }
                     if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
                         $this->addErrorMessage("Passwords do not match.", 'password');
                         $valid_input = false;
                     } else {
                         if (strlen($_POST['pass1']) < 5) {
                             $this->addErrorMessage("Password must be at least 5 characters.", 'password');
                             $valid_input = false;
                         }
                     }
                     if (!$captcha->doesTextMatchImage()) {
                         $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha');
                         $valid_input = false;
                     }
                     if ($valid_input) {
                         if ($owner_dao->doesOwnerExist($_POST['email'])) {
                             $this->addErrorMessage("User account already exists.", 'email');
                         } else {
                             // Insert the details into the database
                             $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']);
                             if ($activation_code != false) {
                                 $es = new SmartyThinkUp();
                                 $es->caching = false;
                                 $server = $_SERVER['HTTP_HOST'];
                                 $es->assign('server', $server);
                                 $es->assign('email', urlencode($_POST['email']));
                                 $es->assign('activ_code', $activation_code);
                                 $message = $es->fetch('_email.registration.tpl');
                                 Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message);
                                 SessionCache::unsetKey('ckey');
                                 $this->addSuccessMessage("Success! Check your email for an activation link.");
                                 //delete invite code
                                 if ($is_invite_code_valid) {
                                     $invite_dao->deleteInviteCode($invite_code);
                                 }
                             } else {
                                 $this->addErrorMessage("Unable to register a new user. Please try again.");
                             }
                         }
                     }
                 }
                 if (isset($_POST["full_name"])) {
                     $this->addToView('name', $_POST["full_name"]);
                 }
                 if (isset($_POST["email"])) {
                     $this->addToView('mail', $_POST["email"]);
                 }
             }
             $challenge = $captcha->generate();
             $this->addToView('captcha', $challenge);
         }
         $this->view_mgr->addHelp('register', 'userguide/accounts/index');
         return $this->generateView();
     }
 }
开发者ID:rgroves,项目名称:ThinkUp,代码行数:91,代码来源:class.RegisterController.php

示例11: control

 public function control()
 {
     if ($this->isLoggedIn()) {
         $controller = new DashboardController(true);
         return $controller->go();
     } else {
         $this->disableCaching();
         $config = Config::getInstance();
         if (!$config->getValue('is_registration_open')) {
             $this->addToView('closed', true);
             $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://github.com/ginatrapani/thinkup/tree/master">Install ThinkUp on your own ' . 'server.</a></p>');
         } else {
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $this->addToView('closed', false);
             $captcha = new Captcha();
             if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
                 foreach ($this->REQUIRED_PARAMS as $param) {
                     if (!isset($_POST[$param]) || $_POST[$param] == '') {
                         $this->addErrorMessage('Please fill out all required fields.');
                         $this->is_missing_param = true;
                     }
                 }
                 if (!$this->is_missing_param) {
                     if (!Utils::validateEmail($_POST['email'])) {
                         $this->addErrorMessage("Incorrect email. Please enter valid email address.");
                     } elseif (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
                         $this->addErrorMessage("Passwords do not match.");
                     } elseif (!$captcha->check()) {
                         // Captcha not valid, captcha handles message...
                     } else {
                         if ($owner_dao->doesOwnerExist($_POST['email'])) {
                             $this->addErrorMessage("User account already exists.");
                         } else {
                             $es = new SmartyThinkUp();
                             $es->caching = false;
                             $session = new Session();
                             $activ_code = rand(1000, 9999);
                             $cryptpass = $session->pwdcrypt($_POST['pass2']);
                             $server = $_SERVER['HTTP_HOST'];
                             $owner_dao->create($_POST['email'], $cryptpass, $activ_code, $_POST['full_name']);
                             $es->assign('server', $server);
                             $es->assign('email', urlencode($_POST['email']));
                             $es->assign('activ_code', $activ_code);
                             $message = $es->fetch('_email.registration.tpl');
                             Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message);
                             SessionCache::unsetKey('ckey');
                             $this->addSuccessMessage("Success! Check your email for an activation link.");
                         }
                     }
                 }
                 if (isset($_POST["full_name"])) {
                     $this->addToView('name', $_POST["full_name"]);
                 }
                 if (isset($_POST["email"])) {
                     $this->addToView('mail', $_POST["email"]);
                 }
             }
             $challenge = $captcha->generate();
             $this->addToView('captcha', $challenge);
         }
         return $this->generateView();
     }
 }
开发者ID:hendrasaputra,项目名称:ThinkUp,代码行数:63,代码来源:class.RegisterController.php


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