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


PHP rcube_utils::setcookie方法代码示例

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


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

示例1: setcookie

 public static function setcookie($name, $value, $exp = 0)
 {
     rcube_utils::setcookie($name, $value, $exp);
 }
开发者ID:peknur,项目名称:roundcubemail,代码行数:4,代码来源:rcmail.php

示例2: set_auth_cookie

 /**
  * Set session authentication cookie
  */
 public function set_auth_cookie()
 {
     $this->cookie = $this->_mkcookie($this->now);
     rcube_utils::setcookie($this->cookiename, $this->cookie, 0);
     $_COOKIE[$this->cookiename] = $this->cookie;
 }
开发者ID:Enclavet,项目名称:roundcubemail,代码行数:9,代码来源:rcube_session.php

示例3: remove_cookie

 /**
  * removes/unsets a cookie.
  *
  * @param $name the name of the cookie.
  * @return bool
  */
 function remove_cookie($name)
 {
     if (headers_sent()) {
         return false;
     }
     if (class_exists('rcube_utils')) {
         rcube_utils::setcookie($name, "", time() - 60);
     } else {
         rcmail::get_instance()->setcookie($name, "", time() - 60);
     }
     return true;
 }
开发者ID:shr3k,项目名称:Roundcube-Persistent-Login-Plugin,代码行数:18,代码来源:persistent_login.php

示例4: remove_cookie

 /**
  * removes/unsets a cookie.
  *
  * @param $name the name of the cookie.
  * @return bool
  */
 function remove_cookie($name)
 {
     if (headers_sent()) {
         return false;
     }
     rcube_utils::setcookie($name, "", time() - 60);
     return true;
 }
开发者ID:jkischel,项目名称:Roundcube-Persistent-Login-Plugin,代码行数:14,代码来源:persistent_login.php

示例5: __cookie

 private function __cookie($set = TRUE)
 {
     $rcmail = rcmail::get_instance();
     $user_agent = hash_hmac('md5', filter_input(INPUT_SERVER, 'USER_AGENT') ?: "", $rcmail->config->get('des_key'));
     $key = hash_hmac('sha256', implode("", array($rcmail->user->data['username'], $this->__getSecret())), $rcmail->config->get('des_key'), TRUE);
     $iv = hash_hmac('md5', implode("", array($rcmail->user->data['username'], $this->__getSecret())), $rcmail->config->get('des_key'), TRUE);
     $name = hash_hmac('md5', $rcmail->user->data['username'], $rcmail->config->get('des_key'));
     if ($set) {
         $expires = time() + 2592000;
         // 30 days from now
         $rand = mt_rand();
         $signature = hash_hmac('sha512', implode("", array($rcmail->user->data['username'], $this->__getSecret(), $user_agent, $rand, $expires)), $rcmail->config->get('des_key'), TRUE);
         $plain_content = sprintf("%d:%d:%s", $expires, $rand, $signature);
         $encrypted_content = openssl_encrypt($plain_content, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
         if ($encrypted_content !== false) {
             $b64_encrypted_content = strtr(base64_encode($encrypted_content), '+/=', '-_,');
             rcube_utils::setcookie($name, $b64_encrypted_content, $expires);
             return TRUE;
         }
         return false;
     } else {
         $b64_encrypted_content = filter_input(INPUT_COOKIE, $name, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/[a-zA-Z0-9_-]+,{0,3}/')));
         if (is_string($b64_encrypted_content) && !empty($b64_encrypted_content) && strlen($b64_encrypted_content) % 4 === 0) {
             $encrypted_content = base64_decode(strtr($b64_encrypted_content, '-_,', '+/='), TRUE);
             if ($encrypted_content !== false) {
                 $plain_content = openssl_decrypt($encrypted_content, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
                 if ($plain_content !== false) {
                     $now = time();
                     list($expires, $rand, $signature) = explode(':', $plain_content, 3);
                     if ($expires > $now && $expires - $now <= 2592000) {
                         $signature_verification = hash_hmac('sha512', implode("", array($rcmail->user->data['username'], $this->__getSecret(), $user_agent, $rand, $expires)), $rcmail->config->get('des_key'), TRUE);
                         // constant time
                         $cmp = strlen($signature) ^ strlen($signature_verification);
                         $signature = $signature ^ $signature_verification;
                         for ($i = 0; $i < strlen($signature); $i++) {
                             $cmp += ord($signature[$i]);
                         }
                         return $cmp === 0;
                     }
                 }
             }
         }
         return false;
     }
 }
开发者ID:alexandregz,项目名称:twofactor_gauthenticator,代码行数:45,代码来源:twofactor_gauthenticator.php


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