JPushChajian.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * 最新系统推送1.9.7后
  4. * 软件:信呼OA
  5. * 最后更新:2021-10-09
  6. */
  7. class JPushChajian extends Chajian{
  8. //-------------最新原生app推送app是1.2.3版本 和 最新app+---------------
  9. public function push($title, $desc, $cont, $palias)
  10. {
  11. $uids = $palias['uids'];
  12. $alias2019 = $palias['alias2019'];
  13. $pushuids = $palias['pushuids']; //可以推送的用户ID
  14. $xmpush = c('xmpush');
  15. $hwpush = c('hwpush');
  16. $getui = c('getui');
  17. //可推送判断
  18. $ketualia = array();
  19. foreach($alias2019 as $ali1){
  20. $ali1aa = explode('|', $ali1);
  21. $_uid = $ali1aa[2];
  22. if(in_array($_uid, $pushuids))$ketualia[] = $ali1;
  23. }
  24. $alias2019 = $ketualia;
  25. //$this->rock->debugs($palias,'pushalias');//判断能不能推送,打印这个
  26. $xharr = array(
  27. 'uids' => $uids,
  28. 'title' => $this->rock->jm->base64encode($title),
  29. //'cont' => $this->rock->jm->base64encode($cont),
  30. 'desc' => $desc,
  31. 'systype'=> getconfig('systype')
  32. );
  33. if(!$alias2019)return;
  34. $getuiand = $getuiios = $mybyarr = $xmarr = $hwarr = $iosar = $puarr = array();
  35. foreach($alias2019 as $k=>$ali1){
  36. $ali1aa = explode('|', $ali1);
  37. $regid = $ali1aa[0];
  38. $_web = $ali1aa[1];
  39. if(contain($_web,'custpile')){
  40. $mybyarr[] = $k; //3
  41. }else if(contain($_web,'getui')){
  42. if(contain($_web,'iphone')){
  43. $getuiios[] = $k; //3
  44. }else{
  45. $getuiand[] = $k; //3
  46. }
  47. }else if(contain($_web,'mi')){
  48. $xmarr[] = $k; //0
  49. }else if(contain($_web,'huawei')){
  50. $hwarr[] = $k; //3
  51. }else if(contain($_web,'iphone')){
  52. $iosar[] = $k; //0
  53. }else{
  54. $puarr[] = $ali1;
  55. }
  56. }
  57. $mymsg = '';
  58. $desc = $this->rock->jm->base64decode($desc);
  59. if($xmarr){
  60. if($xmpush->sendbool()){
  61. $vstr = $this->getVal($alias2019, $xmarr, 0);
  62. $msg = $xmpush->androidsend($vstr, $title, $desc);
  63. if($msg)$mymsg.=chr(10).$msg;
  64. }else{
  65. $vsta = $this->getVala($alias2019, $xmarr);
  66. foreach($vsta as $v)$puarr[] = $v;
  67. }
  68. }
  69. if($hwarr){
  70. if($hwpush->sendbool()){
  71. $vstr = $this->getVal($alias2019, $hwarr, 3);
  72. $msg = $hwpush->androidsend($vstr, $title, $desc);
  73. if($msg)$mymsg.=chr(10).$msg;
  74. }else{
  75. $vsta = $this->getVala($alias2019, $hwarr);
  76. foreach($vsta as $v)$puarr[] = $v;
  77. }
  78. }
  79. if($iosar){
  80. if($xmpush->jpushiosbool()){
  81. $vstr = $this->getVal($alias2019, $iosar, 0);
  82. $msg = $xmpush->jpushiossend($vstr, $title, $desc);
  83. if($msg)$mymsg.=chr(10).$msg;
  84. }else{
  85. $vsta = $this->getVala($alias2019, $iosar);
  86. foreach($vsta as $v)$puarr[] = $v;
  87. }
  88. }
  89. if($getuiand){
  90. if($getui->isandroid()){
  91. $vstr = $this->getVal($alias2019, $getuiand, 3);
  92. $msg = $getui->push($vstr, $title, $desc);
  93. if($msg)$mymsg.=chr(10).$msg;
  94. }else{
  95. $vsta = $this->getVala($alias2019, $getuiand);
  96. foreach($vsta as $v)$puarr[] = $v;
  97. }
  98. }
  99. if($getuiios){
  100. if($getui->isios()){
  101. $vstr = $this->getVal($alias2019, $getuiios, 3);
  102. $msg = $getui->push($vstr, $title, $desc);
  103. if($msg)$mymsg.=chr(10).$msg;
  104. }else{
  105. $vsta = $this->getVala($alias2019, $getuiios);
  106. foreach($vsta as $v)$puarr[] = $v;
  107. }
  108. }
  109. if($mybyarr){
  110. if($getui->sendbool()){
  111. $vstr = $this->getVal($alias2019, $mybyarr, 3);
  112. $msg = $getui->push($vstr, $title, $desc);
  113. if($msg)$mymsg.=chr(10).$msg;
  114. }else{
  115. $msg = '自己编译未配置推送';
  116. $mymsg.=chr(10).$msg;
  117. }
  118. }
  119. if($mymsg)$this->rock->debugs($mymsg, 'mypush');
  120. //需要官网隧道
  121. if($puarr){
  122. $xharr['alias2019'] = join(',', $puarr);
  123. $runurl = c('xinhu')->geturlstr('jpushplat', $xharr);
  124. c('curl')->getcurl($runurl);
  125. }
  126. }
  127. private function getVal($alias2019, $new, $oi)
  128. {
  129. $stv = array();
  130. foreach($new as $j){
  131. $stra = explode('|', $alias2019[$j]);
  132. if(isset($stra[$oi]))$stv[]= $stra[$oi];
  133. }
  134. return $stv;
  135. }
  136. private function getVala($alias2019, $new)
  137. {
  138. $stv = array();
  139. foreach($new as $j){
  140. $stv[] = $alias2019[$j];
  141. }
  142. return $stv;
  143. }
  144. }
粤ICP备19079148号