Example #1
0
 public function get($name, $dec = true, $encKey = '')
 {
     $enValue = isset($_COOKIE[$name]) ? $_COOKIE[$name] : false;
     if (!$enValue) {
         return false;
     }
     if ($dec) {
         $encKey = $encKey ?: $this->encCode;
         $deValue = Encrypt::auth($enValue, $encKey, 'DECODE');
     } else {
         $deValue = $value;
     }
     return $deValue ?: false;
 }
Example #2
0
 public function _getUser()
 {
     // 解密cas server传来的原始数据
     $encKey = $this->cfg['encKey'];
     if ($encVal = Encrypt::auth(phpCAS::getUser(), $encKey, 'DECODE')) {
         $encVal = json_decode($encVal, true);
         if ($this->isAdmin) {
             // 获取redis权限
             $redis = new \Redis();
             $redis->connect($this->cfg['redis']['host'], $this->cfg['redis']['port']);
             $redis->select($this->cfg['redis']['dbname']);
             $res = unserialize($redis->get('group' . $encVal['ugroup'] . '_' . $this->cfg['siteid']));
             $encVal['permMenu'] = unserialize($redis->get('group' . $encVal['ugroup'] . '_' . $this->cfg['siteid']));
         }
     }
     return $encVal ?: false;
 }
Example #3
0
 public function encrypt($siteId, $value)
 {
     $siteCfg = (include 'siteConfig.php');
     $encKey = isset($siteCfg['site'][$siteId]['encKey']) ? $siteCfg['site'][$siteId]['encKey'] : false;
     return $encKey ? \Encrypt::auth($value, $encKey, 'ENCODE') : $value;
 }