xinhuAction.php 4.6 KB

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