diff --git a/config/version.php b/config/version.php index b16e647..a8833f7 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ $desc, 'systype'=> getconfig('systype') ); - $isuguanw = false; - - //没有设置推送(走的信呼官网渠道) - if(!$xmpush->sendbool() && !$hwpush->sendbool()){ - if($xmalias || $newalias || $oldalias || $alias2019){ - if($xmalias)$xharr['xmalias'] = join(',', $xmalias); - if($newalias)$xharr['newalias'] = join(',', $newalias); - if($oldalias)$xharr['oldalias'] = join(',', $oldalias); - if($alias2019)$xharr['alias2019'] = join(',', $alias2019); - $isuguanw = true; - } - }else{ - $desc = $this->rock->jm->base64decode($desc); - $xmarr = array();//小米的人员 - $othar = array();//其他人用 - $iosar = array(); //IOS - $hwarr = array(); //华为 - $iospas= array(); - if($alias2019)foreach($alias2019 as $ali1){ - $ali1aa = explode('|', $ali1); - $regid = $ali1aa[0]; - $sjlxx = $ali1aa[1]; - if(contain($sjlxx,'xiaomi')){ - $xmarr[] = $regid; - }else if(contain($sjlxx,'huawei')){ - if(isset($ali1aa[3]) && $ali1aa[3])$hwarr[] = $ali1aa[3]; - }else if(contain($sjlxx,'iphone')){ - $iosar[] = $regid; - $iospas[]= $ali1; + if(!$alias2019)return; + + $getuiand = $getuiios = $mybyarr = $xmarr = $hwarr = $iosar = $puarr = array(); + foreach($alias2019 as $k=>$ali1){ + $ali1aa = explode('|', $ali1); + $regid = $ali1aa[0]; + $_web = $ali1aa[1]; + if(contain($_web,'custpile')){ + $mybyarr[] = $k; //3 + }else if(contain($_web,'getui')){ + if(contain($_web,'iphone')){ + $getuiios[] = $k; //3 }else{ - $othar[] = $regid; + $getuiand[] = $k; //3 } + }else if(contain($_web,'mi')){ + $xmarr[] = $k; //0 + }else if(contain($_web,'huawei')){ + $hwarr[] = $k; //3 + }else if(contain($_web,'iphone')){ + $iosar[] = $k; //0 + }else{ + $puarr[] = $ali1; } - $msg = $msg1 = $msg2 = ''; - if($oldalias)$msg = $xmpush->androidsend($oldalias, $title, $desc, $cont); - if($xmarr)$msg = $xmpush->androidsend($xmarr, $title, $desc); - if($iosar){ - if(!$xmpush->jpushiosbool()){ - $xharr['alias2019'] = join(',', $iospas); - $isuguanw = true; - }else{ - $msg1= $xmpush->jpushiossend($iosar, $title, $desc); - } - } - if($hwarr)$msg2= $hwpush->androidsend($hwarr, $title, $desc); - $msg5 = $msg.$msg1.$msg2; - if($msg5)$this->rock->debugs($msg5,'mypush'); } - if($isuguanw){ + $mymsg = ''; + $desc = $this->rock->jm->base64decode($desc); + if($xmarr){ + if($xmpush->sendbool()){ + $vstr = $this->getVal($alias2019, $xmarr, 0); + $msg = $xmpush->androidsend($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $vsta = $this->getVala($alias2019, $xmarr); + foreach($vsta as $v)$puarr[] = $v; + } + } + + if($hwarr){ + if($hwpush->sendbool()){ + $vstr = $this->getVal($alias2019, $hwarr, 3); + $msg = $hwpush->androidsend($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $vsta = $this->getVala($alias2019, $hwarr); + foreach($vsta as $v)$puarr[] = $v; + } + } + + if($iosar){ + if($xmpush->jpushiosbool()){ + $vstr = $this->getVal($alias2019, $iosar, 0); + $msg = $xmpush->jpushiossend($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $vsta = $this->getVala($alias2019, $iosar); + foreach($vsta as $v)$puarr[] = $v; + } + } + + if($getuiand){ + if($getui->isandroid()){ + $vstr = $this->getVal($alias2019, $getuiand, 3); + $msg = $getui->push($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $vsta = $this->getVala($alias2019, $getuiand); + foreach($vsta as $v)$puarr[] = $v; + } + } + + if($getuiios){ + if($getui->isios()){ + $vstr = $this->getVal($alias2019, $getuiios, 3); + $msg = $getui->push($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $vsta = $this->getVala($alias2019, $getuiios); + foreach($vsta as $v)$puarr[] = $v; + } + } + + if($mybyarr){ + if($getui->sendbool()){ + $vstr = $this->getVal($alias2019, $mybyarr, 3); + $msg = $getui->push($vstr, $title, $desc); + if($msg)$mymsg.=chr(10).$msg; + }else{ + $msg = '自己编译未配置推送'; + $mymsg.=chr(10).$msg; + } + } + + if($mymsg)$this->rock->debugs($mymsg, 'mypush'); + + + //需要官网隧道 + if($puarr){ + $xharr['alias2019'] = join(',', $puarr); $runurl = c('xinhu')->geturlstr('jpushplat', $xharr); c('curl')->getcurl($runurl); } } + + + private function getVal($alias2019, $new, $oi) + { + $stv = array(); + foreach($new as $j){ + $stra = explode('|', $alias2019[$j]); + if(isset($stra[$oi]))$stv[]= $stra[$oi]; + } + return $stv; + } + + private function getVala($alias2019, $new) + { + $stv = array(); + foreach($new as $j){ + $stv[] = $alias2019[$j]; + } + return $stv; + } } \ No newline at end of file diff --git a/include/chajian/curlChajian.php b/include/chajian/curlChajian.php index ce2edd8..342d7ec 100644 --- a/include/chajian/curlChajian.php +++ b/include/chajian/curlChajian.php @@ -75,6 +75,8 @@ class curlChajian extends Chajian{ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); + if($this->rock->HTTPweb)curl_setopt($ch, CURLOPT_USERAGENT, $this->rock->HTTPweb); + if($this->rock->ip)$headarr['X-FORWARDED-FOR'] = $this->rock->ip; if($ishttps==1){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } @@ -105,12 +107,14 @@ class curlChajian extends Chajian{ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_HEADER, 0); //不返回header + if($this->rock->HTTPweb)curl_setopt($ch, CURLOPT_USERAGENT, $this->rock->HTTPweb); curl_setopt($ch, CURLOPT_POST, 1); @curl_setopt($ch, CURLOPT_POSTFIELDS, $cont); if($ishttps==1){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } + if($this->rock->ip)$headarr['X-FORWARDED-FOR'] = $this->rock->ip; //设置head if($headarr){ $heads = array(); diff --git a/include/chajian/getuiChajian.php b/include/chajian/getuiChajian.php new file mode 100644 index 0000000..2cdd58d --- /dev/null +++ b/include/chajian/getuiChajian.php @@ -0,0 +1,141 @@ +appid = getconfig('getui_appid'); + $this->appkey = getconfig('getui_appkey'); + $this->mastersecret = getconfig('getui_mastersecret'); + $this->apptype = getconfig('getui_apptype','0'); + } + + /** + * 获取token + */ + public function gettoken(){ + $url = str_replace('{appid}',$this->appid, $this->pushurl).'/auth'; + $token = c('cache')->get('getui'.$this->appid.''); + if(isempt($token)){ + $timestamp = ''.time().'000'; + $sign = hash("sha256", $this->appkey.$timestamp.$this->mastersecret); + $result = c('curl')->postcurl($url, json_encode(array( + "sign" => $sign, + "timestamp" => $timestamp, + "appkey" => $this->appkey, + )),0, array( + 'content-type' => 'application/json;charset=utf-8' + )); + if($result){ + $barr = json_decode($result, true); + if($barr['code']==0){ + $token = $barr['data']['token']; + $expire_time = $barr['data']['expire_time']; + c('cache')->set('getui'.$this->appid.'',$token, $expire_time * 0.001 - time()); + }else{ + echo $result; + } + } + } + return $token; + } + + /** + * 判断是否可以发送 + */ + public function sendbool() + { + if(!$this->appid || !$this->appkey || !$this->mastersecret)return false; + return true; + } + + /** + * 是否安卓的 + */ + public function isandroid() + { + if(!$this->sendbool())return false; + if($this->apptype=='2')return false; + return true; + } + + /** + * 是否安卓的 + */ + public function isios() + { + if(!$this->sendbool())return false; + if($this->apptype=='1')return false; + return true; + } + + /** + * 推送 + */ + public function push($cid, $title, $cont) + { + if(!$this->sendbool())return 'params empty'; + $url = str_replace('{appid}',$this->appid, $this->pushurl).'/push/single/batch/cid'; + $token = $this->gettoken(); + if(is_string($cid))$cid = explode(',', $cid); + + $msg_list = array(); + + foreach($cid as $_cid){ + $parr = array(); + $parr['request_id'] = 'a'.time().rand(1000,9999).''; + //$parr['settings'] = array('ttl' => '-1'); + $parr['audience']['cid'] = array($_cid); + $parr['push_message']['notification'] = array( + 'title' => $title, + 'body' => $cont, + 'click_type' => 'startapp', + ); + //离线厂商推送的 + $parr['push_channel']['ios'] = array( + 'type' => 'notify', + 'payload' => 'notify', + 'aps' => array( + 'alert' => array( + 'title' => $title, + 'body' => $cont, + ), + 'sound'=>'default', + ), + 'auto_badge' => '1' + ); + + $parr['push_channel']['android'] = array( + 'ups' => array( + 'notification' => array( + 'title' => $title, + 'body' => $cont, + 'click_type' => 'startapp', + 'notify_id' => rand(100,99999), + ) + ) + ); + $msg_list[] = $parr; + } + $toboay = array( + 'is_async' => false, + 'msg_list' => $msg_list + ); + $result = c('curl')->postcurl($url, json_encode($toboay),0, array( + 'content-type' => 'application/json;charset=utf-8', + 'token' => $token, + )); + return $result; + } + +} \ No newline at end of file diff --git a/include/chajian/xmpushChajian.php b/include/chajian/xmpushChajian.php index 9597d68..9c94253 100644 --- a/include/chajian/xmpushChajian.php +++ b/include/chajian/xmpushChajian.php @@ -37,6 +37,12 @@ class xmpushChajian extends Chajian{ if($this->android_secret=='')return false; return true; } + + public function setsecret($secret, $package) + { + $this->android_secret = $secret; + $this->android_package = $package; + } /** * 安卓推送通知 diff --git a/js/dingwei.js b/js/dingwei.js index ad96b28..5f37496 100644 --- a/js/dingwei.js +++ b/js/dingwei.js @@ -72,7 +72,7 @@ js.dw = { this.wait('原生app定位中...'); return; } - if(api.startLocation){ + if(window['api'] && api.startLocation){ js.msg(); if(api.systemType=='ios'){ this.wait(''+api.systemType+'APP定位中...'); @@ -103,7 +103,9 @@ js.dw = { dtes.latitude = ret.location.latitude; } js.dw.baiduLocationSuc(dtes,err); + js.dw.bmLocation.stopLocation(); }); + } } return; diff --git a/js/js.js b/js/js.js index 79bb51c..62c3c47 100644 --- a/js/js.js +++ b/js/js.js @@ -1178,8 +1178,13 @@ js.appwin=function(na,dz){ if(dz.substr(0,4)!='http')dz=NOWURL+dz; var jg = (dz.indexOf('?')==-1)?'?':'&'; if(!na)na=' '; - var bstr=jm.base64encode('{"name":"'+na+'","url":"openurl","dizhi":"'+dz+''+jg+'hideheader=true"}'); - var url = ''+ourl+'?bstr='+bstr+''; + var dizhi = ''+dz+''+jg+'hideheader=true'; + if(apicloud && api.openWindcloud){ + api.openWindcloud({name:na,url:dz}) + return true; + } + var bstr =jm.base64encode('{"name":"'+na+'","url":"openurl","dizhi":"'+dizhi+'"}'); + var url = ''+ourl+'?bstr='+bstr+''; return this.apiopenWin(url); } js.sendevent=function(typ,na,d){ diff --git a/js/jswx.js b/js/jswx.js index 6147238..7f5d0cb 100644 --- a/js/jswx.js +++ b/js/jswx.js @@ -179,11 +179,13 @@ js.showmenu=function(d){ if(!a)return; var h1=$(window).height(),h2=document.body.scrollHeight,s1; if(h2>h1)h1=h2; - var col=''; - var s='