0,"return_msg"=>"操作数据或游戏ID不能为空")));exit(); } $md5Sign = $data['md5_sign']; unset($data['md5_sign']); #获取游戏key $game_data = M("game","tab_")->alias("g")->field("s.*") ->where(['g.apply_status'=>1,'g.id'=>$data['game_id']]) ->join("left join tab_game_set s on s.game_id = g.id") ->find(); if(empty($game_data)){ $this->set_message(0,"fail","游戏不存在或未通过审核"); } $md5_sign = $this->encrypt_md5($data,$game_data["access_key"]);//mengchuang DZQkkiz!@#9527 if($md5Sign !== $md5_sign){ $this->set_message(0,"fail","验签失败"); } define(PID,$data['promote_id']); define(UID,$data['user_id']); //} } public function set_message($status=0,$return_code="fail",$return_msg="操作失败"){ $msg = array( "status" => $status, "return_code" => $return_code, "return_msg" => $return_msg ); echo base64_encode(json_encode($msg)); exit(); } /** *验证签名 */ public function validation_sign($encrypt="",$md5_sign=""){ $signString = $this->arrSort($encrypt); $md5Str = $this->encrypt_md5($signString,$key=""); if($md5Str === $md5_sign){ return true; } else{ return false; } } /** *对数据进行排序 */ private function arrSort($para){ ksort($para); reset($para); return $para; } /** *MD5验签加密 */ public function encrypt_md5($param="",$key=""){ #对数组进行排序拼接 if(is_array($param)){ $md5Str = implode($this->arrSort($param)); } else{ $md5Str = $param; } $md5 = md5($md5Str . $key); return '' === $param ? 'false' : $md5; } }