xinhuAction.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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, 'reimrecidsystem', $rs['num']);
  29. $this->sevessee($base, 'reimchehuisystem');
  30. $this->sevessee($base, 'reimservertype');
  31. $this->sevessee($base, 'reimappwxsystem');
  32. }
  33. return '同步成功';
  34. }
  35. private function sevessee($base, $key, $bh='')
  36. {
  37. $val = $this->option->getval($key);
  38. if($key=='reimrecidsystem')$val.='_'.$bh.'';
  39. $sql = "update ".$base.".`[Q]option` set `value`='$val',`optdt`='{$this->now}' where `num`='$key'";
  40. $this->db->query($sql, false);
  41. }
  42. public function getsetAjax()
  43. {
  44. $arr= array();
  45. $arr['reimhost']= $this->option->getval('reimhostsystem');
  46. $arr['reimrecid']= $this->option->getval('reimrecidsystem');
  47. $arr['reimpushurl']= $this->option->getval('reimpushurlsystem');
  48. $arr['reimchehui']= $this->option->getval('reimchehuisystem');
  49. $arr['servertype']= $this->rock->repempt($this->option->getval('reimservertype'),'1');
  50. if(isempt($arr['reimhost']))$arr['servertype']='1';
  51. $arr['reimappwx']= $this->rock->repempt($this->option->getval('reimappwxsystem'),'0');
  52. echo json_encode($arr);
  53. }
  54. //测试地址
  55. public function yibutestAjax()
  56. {
  57. $rand = time();
  58. $arr['krand'] = $rand;
  59. $runurl = m('base')->getasynurl('asynrun','asyntest', $arr);
  60. m('reim')->asynurl('asynrun','asyntest', $arr);
  61. $msg = '<font color="green">测试成功可以使用</font>';
  62. sleep(10);
  63. $mkey = $this->option->getval('asyntest');
  64. if($mkey!=$rand)$msg = '<font color="red">测试失败不能使用,说明你服务端上是不能访问这地址的</font>';
  65. echo '异步地址【'.$runurl.'】'.$msg.'';
  66. }
  67. //测试队列
  68. public function testqueueAjax()
  69. {
  70. $rand = 'queue'.time();
  71. $barr = c('rockqueue')->push('cli,test', array(
  72. 'rand' => $rand
  73. ));
  74. if(!$barr['success'])return '队列测试失败:<font color="red">'.$barr['msg'].'</font>';
  75. sleep(3);
  76. $mkey = $this->option->getval('asyntest');
  77. $msg = '<font color="green">队列测试成功,可以使用</font>';
  78. if($mkey!=$rand)$msg = '<font color="red">无法运行“'.$barr['cmdurl'].'”测试失败不能使用,去<a href="'.URLY.'view_rockservice.html" target="_blank">看看帮助</a>。</font>';
  79. echo $msg;
  80. }
  81. public function testsendAjax()
  82. {
  83. $barr = m('reim')->sendpush($this->adminid, $this->adminid,array(
  84. 'cont' => $this->jm->base64encode('测试内容:'.$this->now.''),
  85. 'type' => 'user',
  86. 'optdt' => $this->now,
  87. 'messid' => 0
  88. ));
  89. $msg = '';
  90. if($barr['success']){
  91. $msg='服务端推送地址可以使用';
  92. }else{
  93. $msg='<font color=red>服务端推送地址不能使用:'.$barr['msg'].'</font>';
  94. }
  95. echo $msg;
  96. }
  97. /**
  98. * 获取列表
  99. */
  100. public function getoainfoAjax()
  101. {
  102. $barr = $this->xinhuobj->getdata('dengji','getdata');
  103. $rows = array();
  104. if($barr['success']){
  105. $rows = $barr['data'];
  106. }
  107. return array(
  108. 'rows' => $rows
  109. );
  110. }
  111. public function deldengjiAjax()
  112. {
  113. $id = (int)$this->post('id');
  114. $barr = $this->xinhuobj->getdata('dengji','deldengji', array('id'=>$id));
  115. return $barr;
  116. }
  117. public function savedengjiAjax()
  118. {
  119. $id = (int)$this->post('id');
  120. $name = str_replace(' ','',$this->post('name'));
  121. $url = str_replace(' ','',$this->post('url'));
  122. if(substr($url,0,4)!='http')return returnerror('地址必须http开头');
  123. if(contain($url,'127.0.0.1') || contain($url,'localhost'))return returnerror('本地地址是不能登记到官网的');
  124. if(substr($url,-1)!='/')$url.='/';
  125. $carr = m('task')->pdlocal($url);
  126. if(!$carr['success'])return returnerror('系统地址无法打开');
  127. $barr = $this->xinhuobj->postdata('dengji','savedata', array(
  128. 'id' => $id,
  129. 'name' => $name,
  130. 'url' => urlencode($url),
  131. ));
  132. return $barr;
  133. }
  134. }
粤ICP备19079148号