<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Crypt;use Illuminate\Support\Facades\Log;class AppHeader{public function handle(Request $req,Closure $next){$reqUrl=$req->fullUrl();$channel=$req->header("Channel","");$platform=$req->header("Source","");$identifier=$req->header("Device","");$system_version=$req->header("System","");$app_version=$req->header("Version","");$P2g0=(bool)empty($channel);if($P2g0)goto P2gBodyx9;goto P2gNextx9;P2gBodyx9:$P2g0=(bool)empty($platform);goto P2gx8;P2gNextx9:P2gx8:$P2g1=(bool)$P2g0;if($P2g1)goto P2gBodyx7;goto P2gNextx7;P2gBodyx7:$P2g1=(bool)empty($identifier);goto P2gx6;P2gNextx7:P2gx6:$P2g2=(bool)$P2g1;if($P2g2)goto P2gBodyx5;goto P2gNextx5;P2gBodyx5:$P2g2=(bool)empty($system_version);goto P2gx4;P2gNextx5:P2gx4:$P2g3=(bool)$P2g2;if($P2g3)goto P2gBodyx3;goto P2gNextx3;P2gBodyx3:$P2g3=(bool)empty($app_version);goto P2gx2;P2gNextx3:P2gx2:if($P2g3)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:$req=$this->userAgentParse($req);goto P2gx1;P2gNextxa:$req=$this->headerParse($req);P2gx1:return $next($req);}public function headerFormat($headers){$headers=array_map(function($item){return $item[0];},$headers);return $headers;}public function userAgentParse(Request $req){$userAgent=$req->header("user-agent","");$headers=json_decode($userAgent,true);$P2g0=null===$headers;if($P2g0)goto P2gBodyxc;goto P2gNextxc;P2gBodyxc:$appUserAgent=$req->header('App-User-Agent',"");$P2g0=!empty($appUserAgent);if($P2g0)goto P2gBodyxe;goto P2gNextxe;P2gBodyxe:$appUserAgent=Crypt::decrypt($appUserAgent);if(json_decode($appUserAgent,true))goto P2gBodyxg;goto P2gNextxg;P2gBodyxg:$P2g0=json_decode($appUserAgent,true);goto P2gxf;P2gNextxg:$P2gAC1=array();$P2g0=$P2gAC1;P2gxf:$headers=$P2g0;$headers["IDENTIFIER"]=$req->header("App-IDENTIFIER","");goto P2gxd;P2gNextxe:P2gxd:goto P2gxb;P2gNextxc:P2gxb:if($headers)goto P2gBodyxi;goto P2gNextxi;P2gBodyxi:$P2g0=$headers;goto P2gxh;P2gNextxi:$P2gAC0=array();$P2g0=$P2gAC0;P2gxh:$headers=$P2g0;foreach($headers as $key=>$val){$req->headers->set($key,$val,true);}$req=$this->headerParse($req);return $req;}public function headerParse(Request $req){$channel=$req->header("Channel","");$chaCode=$req->header("CHA-CODE","");$source=$req->header("Source","");$AA_A_A__="strtolower";$P2gAC0=$AA_A_A__($source);$source=$P2gAC0;if($channel)goto P2gBodyxk;goto P2gNextxk;P2gBodyxk:$P2g0=$channel;goto P2gxj;P2gNextxk:$P2g0=$chaCode;P2gxj:$realChannel=$P2g0;$template_id='';if(empty($realChannel))goto P2gBodyxm;goto P2gNextxm;P2gBodyxm:$realChannel=100001;if($req->url)goto P2gBodyxo;goto P2gNextxo;P2gBodyxo:$url=urldecode($req->url);$AA_A_A_A="substr";$P2gAC0=$AA_A_A_A($url,strpos($url,'?')+1);$param=$P2gAC0;$AA_A_AA_="strpos";$P2gAC0=$AA_A_AA_($param,'&');$P2g0=$P2gAC0!==false;if($P2g0)goto P2gBodyxq;goto P2gNextxq;P2gBodyxq:$AA_A_AAA="explode";$P2gAC0=$AA_A_AAA('&',$param);$paramArr=$P2gAC0;$param=$paramArr[0];$template=$paramArr[1];$AA_AA___="explode";$P2gAC0=$AA_AA___('=',$template);$templateArr=$P2gAC0;$template_id=$templateArr[1];goto P2gxp;P2gNextxq:P2gxp:$AA_AA__A="explode";$P2gAC0=$AA_AA__A('=',$param);$paramArrs=$P2gAC0;$realChannel=$paramArrs[1];goto P2gxn;P2gNextxo:P2gxn:if($req->template_id)goto P2gBodyxs;goto P2gNextxs;P2gBodyxs:$template_id=$req->template_id;goto P2gxr;P2gNextxs:P2gxr:goto P2gxl;P2gNextxm:P2gxl:$req->headers->set("Source",strtolower($source),true);$req->headers->set("Channel",$realChannel,true);$req->headers->set("CHA-CODE",$realChannel,true);$req->headers->set("template_id",$template_id,true);return $req;}}
?>