xinhuAction.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. //服务端设置
  3. class xinhuClassAction extends Action
  4. {
  5. public $xinhuobj;
  6. public function initAction()
  7. {
  8. $this->xinhuobj = c('xinhuapi');
  9. }
  10. public function setsaveAjax()
  11. {
  12. if(!COMPANYNUM){
  13. $this->option->setval('reimhostsystem@-8', $this->post('host'));
  14. $this->option->setval('reimpushurlsystem@-8', $this->post('push'));
  15. $this->option->setval('reimservertype@-8', $this->post('servertype'));
  16. $this->option->setval('reimappwxsystem@-8', $this->post('reimappwx'));
  17. }
  18. $this->option->setval('reimrecidsystem@-8', $this->post('receid'));
  19. $this->option->setval('reimchehuisystem@-8', $this->post('chehui'));
  20. $this->backmsg();
  21. }
  22. public function tongbudwAjax()
  23. {
  24. $rows = m('company')->getall('iscreate=1');
  25. foreach($rows as $k=>$rs){
  26. $base = ''.DB_BASE.'_company_'.$rs['num'].'';
  27. $this->sevessee($base, 'reimhostsystem');
  28. $this->sevessee($base, 'reimpushurlsystem');
  29. $this->sevessee($base, 'reimrecidsystem', $rs['num']);
  30. $this->sevessee($base, 'reimchehuisystem');
  31. $this->sevessee($base, 'reimservertype');
  32. $this->sevessee($base, 'reimappwxsystem');
  33. }
  34. return '同步成功';
  35. }
  36. private function sevessee($base, $key, $bh='')
  37. {
  38. $val = $this->option->getval($key);
  39. if($key=='reimrecidsystem')$val.='_'.$bh.'';
  40. $table = "".$base.".`[Q]option`";
  41. $where = "`num`='$key'";
  42. $ors = $this->db->getone($table, $where);
  43. if($ors){
  44. $sql = "update $table set `value`='$val',`optdt`='{$this->now}' where $where";
  45. }else{
  46. $sql = "insert into $table set `value`='$val',`optdt`='{$this->now}',`num`='$key'";
  47. }
  48. $this->db->query($sql, false);
  49. }
  50. public function getsetAjax()
  51. {
  52. $arr= array();
  53. $arr['reimhost']= $this->option->getval('reimhostsystem');
  54. $arr['reimrecid']= $this->option->getval('reimrecidsystem');
  55. $arr['reimpushurl']= $this->option->getval('reimpushurlsystem');
  56. $arr['reimchehui']= $this->option->getval('reimchehuisystem');
  57. $arr['servertype']= $this->rock->repempt($this->option->getval('reimservertype'),'1');
  58. if(isempt($arr['reimhost']))$arr['servertype']='1';
  59. $arr['reimappwx']= $this->rock->repempt($this->option->getval('reimappwxsystem'),'0');
  60. echo json_encode($arr);
  61. }
  62. //测试地址
  63. public function yibutestAjax()
  64. {
  65. $rand = time();
  66. $arr['krand'] = $rand;
  67. $runurl = m('base')->getasynurl('asynrun','asyntest', $arr);
  68. m('reim')->asynurl('asynrun','asyntest', $arr);
  69. $msg = '<font color="green">测试成功可以使用</font>';
  70. sleep(10);
  71. $mkey = $this->option->getval('asyntest');
  72. if($mkey!=$rand)$msg = '<font color="red">测试失败不能使用,说明你服务端上是不能访问这地址的</font>';
  73. echo '异步地址【'.$runurl.'】'.$msg.'';
  74. }
  75. //测试队列
  76. public function testqueueAjax()
  77. {
  78. $rand = 'queue'.time();
  79. $barr = c('rockqueue')->push('cli,test', array(
  80. 'rand' => $rand
  81. ));
  82. if(!$barr['success'])return '队列测试失败:<font color="red">'.$barr['msg'].'</font>';
  83. sleep(3);
  84. $mkey = $this->option->getval('asyntest');
  85. $msg = '<font color="green">队列测试成功,可以使用</font>';
  86. if($mkey!=$rand)$msg = '<font color="red">无法运行“'.$barr['cmdurl'].'”测试失败不能使用,去<a href="'.URLY.'view_rockservice.html" target="_blank">看看帮助</a>。</font>';
  87. echo $msg;
  88. }
  89. public function testsendAjax()
  90. {
  91. $barr = m('reim')->sendpush($this->adminid, $this->adminid,array(
  92. 'cont' => $this->jm->base64encode('测试内容:'.$this->now.''),
  93. 'type' => 'user',
  94. 'optdt' => $this->now,
  95. 'messid' => 0
  96. ));
  97. $msg = '';
  98. if($barr['success']){
  99. $msg='服务端推送地址可以使用';
  100. }else{
  101. $msg='<font color=red>服务端推送地址不能使用:'.$barr['msg'].'</font>';
  102. }
  103. echo $msg;
  104. }
  105. /**
  106. * 获取列表
  107. */
  108. public function getoainfoAjax()
  109. {
  110. $barr = $this->xinhuobj->getdata('dengji','getdata');
  111. $rows = array();
  112. if($barr['success']){
  113. $rows = $barr['data'];
  114. }
  115. return array(
  116. 'rows' => $rows
  117. );
  118. }
  119. public function deldengjiAjax()
  120. {
  121. $id = (int)$this->post('id');
  122. $barr = $this->xinhuobj->getdata('dengji','deldengji', array('id'=>$id));
  123. return $barr;
  124. }
  125. public function savedengjiAjax()
  126. {
  127. $id = (int)$this->post('id');
  128. $name = str_replace(' ','',$this->post('name'));
  129. $url = str_replace(' ','',$this->post('url'));
  130. if(substr($url,0,4)!='http')return returnerror('地址必须http开头');
  131. if(contain($url,'127.0.0.1') || contain($url,'localhost'))return returnerror('本地地址是不能登记到官网的');
  132. if(substr($url,-1)!='/')$url.='/';
  133. $carr = m('task')->pdlocal($url);
  134. if(!$carr['success'])return returnerror('系统地址无法打开');
  135. $barr = $this->xinhuobj->postdata('dengji','savedata', array(
  136. 'id' => $id,
  137. 'name' => $name,
  138. 'url' => urlencode($url),
  139. ));
  140. return $barr;
  141. }
  142. public function getonlineAjax()
  143. {
  144. $barr = m('reim')->pushserver('getonline');
  145. if(!$barr['success'])return $barr;
  146. $data = $barr['data'];
  147. if(!$data)return returnerror('无人员在线');
  148. $ondats = json_decode($data, true);
  149. $pc = $ondats['pc'];
  150. $app = $ondats['app'];
  151. $uar1= explode(',', $pc);
  152. $uar2= explode(',', $app);
  153. $str = $pc;
  154. $on1 = count($uar1);
  155. $on2 = count($uar2);
  156. if($app){
  157. if($str)$str.=',';
  158. $str.=$app;
  159. }
  160. if(!$str)return returnerror('无人员在线');
  161. if(!$app)$on2 = 0;
  162. if(!$pc)$on1 = 0;
  163. $rows = m('admin')->getall('id in('.$str.') and `status`=1','id,name,face','sort asc');
  164. foreach($rows as $k=>$rs){
  165. $rows[$k]['pconline'] = in_array($rs['id'], $uar1);
  166. $rows[$k]['apponline'] = in_array($rs['id'], $uar2);
  167. }
  168. return returnsuccess(array(
  169. 'rows' => $rows,
  170. 'msg' => 'PC在线'.$on1.'人,APP在线'.$on2.'人',
  171. ));
  172. }
  173. }
粤ICP备19079148号