コード例 #1
0
 /**
  * 返回
  */
 public static function get($key)
 {
     if (isset($_COOKIE[$key])) {
         return CEncrypt::decode($_COOKIE[$key]);
     }
     return null;
 }
コード例 #2
0
 /**
  * 设置基础数据
  */
 public static function setInitData($viewObject)
 {
     $prefix = CConfig::getInstance()->load('ACTION_PREFIX');
     $viewObject->assign('thisUrl', urlencode(CRequest::getUrl()));
     $viewObject->assign('base64Url', CEncrypt::safe_b64encode(CRequest::getUrl()));
     $viewObject->assign('controller', CRequest::getController());
     $viewObject->assign('action', CRequest::getAction());
     $viewObject->assign('actionPre', $prefix);
     $viewObject->assign('ip', CRequest::getIp());
     $viewObject->assign('module', CRequest::getModule());
     $viewObject->assign('time', time());
     $viewObject->assign('sessionID', session_id());
     $viewObject->assign('path', CRequest::getPath());
     $viewObject->assign('staticUrl', CConfig::getInstance('site')->load('staticUrl'));
     $viewObject->assign('uploadStaticUrl', CConfig::getInstance('site')->load('uploadStaticUrl'));
     $viewObject->assign('siteName', CConfig::getInstance('site')->load('siteName'));
 }
コード例 #3
0
 private static function _XXTEA($str, $action, $key)
 {
     if (empty($str)) {
         return '';
     }
     $key = empty($key) ? self::KEYSTRING : $key;
     $str = $action == 'DECRYPT' ? CEncrypt::safe_b64decode($str) : $str;
     $v = self::_xxtea_str2long($str, $action == 'DECRYPT' ? false : true);
     $k = self::_xxtea_str2long($key, false);
     if (empty($v) || empty($k)) {
         return '';
     }
     $len = count($k);
     if ($len < 4) {
         for ($i = $len; $i < 4; $i++) {
             $k[$i] = 0;
         }
     }
     $n = count($v) - 1;
     $z = $v[$n];
     $y = $v[0];
     $delta = 0x9e3779b9;
     $q = floor(6 + 52 / ($n + 1));
     if ($action == 'DECRYPT') {
         $sum = self::_xxtea_int32($q * $delta);
         while ($sum != 0) {
             $e = $sum >> 2 & 3;
             for ($p = $n; $p > 0; $p--) {
                 $z = $v[$p - 1];
                 $mx = self::_xxtea_int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::_xxtea_int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
                 $y = $v[$p] = self::_xxtea_int32($v[$p] - $mx);
             }
             $z = $v[$n];
             $mx = self::_xxtea_int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::_xxtea_int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
             $y = $v[0] = self::_xxtea_int32($v[0] - $mx);
             $sum = self::_xxtea_int32($sum - $delta);
         }
         return self::_xxtea_long2str($v, true);
     } else {
         $sum = 0;
         while (0 < $q--) {
             $sum = self::_xxtea_int32($sum + $delta);
             $e = $sum >> 2 & 3;
             for ($p = 0; $p < $n; $p++) {
                 $y = $v[$p + 1];
                 $mx = self::_xxtea_int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::_xxtea_int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
                 $z = $v[$p] = self::_xxtea_int32($v[$p] + $mx);
             }
             $y = $v[0];
             $mx = self::_xxtea_int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::_xxtea_int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
             $z = $v[$n] = self::_xxtea_int32($v[$n] + $mx);
         }
         return CEncrypt::safe_b64encode(self::_xxtea_long2str($v, false));
     }
 }