예제 #1
0
 public function _store_handler($res)
 {
     foreach ($res as &$store) {
         $crypt3des = new Crypt3Des();
         $store['verify_code'] = $crypt3des->decrypt($store['verify_code']);
         $store['store_id'] = $store['id'];
         unset($store['id']);
         $store['store_name'] = $store['name'];
         unset($store['name']);
         $store['store_photo'] = json_decode($store['store_photo']);
         $store = array_merge($store, $this->get_mall_floor_where(array('id' => $store['mall_floor_id']))[0]);
         //商铺经营的品类
         global $CATEGORY;
         $category_id = json_decode($store['cate_id_str']);
         unset($store['cate_id_str']);
         foreach ($category_id as $value) {
             $store['store_category'][$value] = $CATEGORY[$value];
         }
         //商铺所属的品牌
         $brand_id = $store['brand_id'];
         $brand = $this->ci_get(T_BRAND, array('id' => $brand_id))[0];
         //商铺的品牌名字
         $store['brand_name'] = $brand['name'];
         $store['brand_logo'] = json_decode($brand['logo'])[0];
         $brand_style_id = json_decode($brand['style_id']);
         //商铺的品牌的 风格
         $brand_style = [];
         global $STYLE;
         if ($brand_style_id) {
             foreach ($brand_style_id as $value) {
                 $brand_style[$value] = $STYLE[$value];
             }
         }
         $store['brand_style'] = $brand_style;
         ksort($store);
     }
     return $res;
 }
예제 #2
0
 public static function up_decode($str)
 {
     if (!$str) {
         return $str;
     }
     $str = urldecode($str);
     $str = trim($str);
     $cr = new Crypt3Des(Crypt3DesKey, Crypt3DesIV);
     $str = str_replace('-', '+', $str);
     $str = str_replace('.', '/', $str);
     $str = str_replace('!', '=', $str);
     $str = $cr->decrypt($str);
     $couldbeA = json_decode($str, true);
     if (is_array($couldbeA)) {
         return $couldbeA;
     }
     return false;
 }
예제 #3
0
function GetUserinfoJson($token)
{
    if (empty($token)) {
        die(ErrorCode::CODE("1007"));
    }
    $userinfo = json_decode(Crypt3Des::decrypt(urldecode($token), $GLOBALS['keys']), true);
    if (empty($userinfo)) {
        die(ErrorCode::CODE("1008"));
    }
    return $userinfo;
}
 public static function decode($string)
 {
     $crypt = new Crypt3Des(Encrypt::$key);
     $decryptStr = $crypt->decrypt($string);
     return $decryptStr;
 }
예제 #5
0
 /**
  * 验证TOKEN
  */
 public function validate($token, $method)
 {
     $check = 1;
     // 0不检查 1检查
     if ($check && !$this->_isIgnoreValidate($method)) {
         require_once './application/libraries/Crypt3des.php';
         $Crypt3Des = new Crypt3Des(array('PIN' => 'lanxiaopin'));
         if (!$token) {
             header('HTTP/1.1 403 Forbidden');
             throw new Exception('Forbidden 无权限访问此服务 无法获取TOKEN', 403);
         }
         $res = $Crypt3Des->decrypt($token);
         if (!$res) {
             header('HTTP/1.1 403 Forbidden');
             throw new Exception('Forbidden 无权限访问此服务TOKEN验证失败', 403);
         }
     }
 }
예제 #6
0
/**
 * 3DES解密php程式
 * 
 * @param string $data
 *            需要加密字符串
 * @param string $key
 *            运营商应用密钥
 * @return string $res 解密后的字符串
 */
function do_decrypt($data, $key)
{
    if ($data === '' || !extension_loaded('mcrypt')) {
        return $data;
    }
    if (!defined('_3DES_')) {
        define('_3DES_', 1);
        include_once APPPATH . '/libraries/3des.php';
    }
    $des = new Crypt3Des($key);
    return $des->decrypt($data);
}