smsAction.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. class smsClassAction extends Action
  3. {
  4. public function initAction()
  5. {
  6. $this->smsobj = c('xinhuapi');
  7. }
  8. public function gettotalAjax()
  9. {
  10. $barr = $this->smsobj->getdata('sms','smstotal');
  11. $barr['sms_iscb'] = $this->option->getval('sms_iscb','0');
  12. $barr['sms_cbnum'] = $this->option->getval('sms_cbnum','defnum');
  13. $barr['sms_apikey'] = $this->option->getval('sms_apikey');
  14. $barr['sms_txnum'] = $this->option->getval('sms_txnum');
  15. $barr['sms_mknum'] = $this->option->getval('sms_mknum');
  16. $barr['sms_qmnum'] = $this->option->getval('sms_qmnum');
  17. $barr['sms_dirtype'] = $this->option->getval('sms_dirtype');
  18. $barr['sms_yanzm'] = $this->option->getval('sms_yanzm');
  19. $barr['pingtarr'] = $this->option->getdata('syssmsplat');
  20. return $barr;
  21. }
  22. //保存设置
  23. public function cogsaveAjax()
  24. {
  25. $sms_dirtype = $this->post('sms_dirtype');
  26. if(isempt($sms_dirtype) || $sms_dirtype=='null')$sms_dirtype = '';
  27. $this->option->setval('sms_iscb', $this->post('sms_iscb','0'));
  28. $this->option->setval('sms_cbnum', $this->post('sms_cbnum')); //催办编号
  29. $this->option->setval('sms_apikey', $this->post('sms_apikey'));
  30. $this->option->setval('sms_txnum', $this->post('sms_txnum')); //审批提醒模块编号
  31. $this->option->setval('sms_mknum', $this->post('sms_mknum')); //要提醒的模块编号
  32. $this->option->setval('sms_qmnum', $this->post('sms_qmnum')); //签名
  33. $this->option->setval('sms_dirtype', $sms_dirtype);
  34. $this->option->setval('sms_yanzm', $this->post('sms_yanzm'));//验证码的短信编号
  35. $this->option->delete("`num` like 'alisms\_%'");
  36. }
  37. //测试
  38. public function testsendAjax()
  39. {
  40. $mobile = $this->get('mobile');
  41. $dirtype = $this->get('dirtype');
  42. $lxss = $this->option->getval('sms_dirtype');
  43. if($dirtype!=$lxss)return returnerror('请先保存后在测试');
  44. $parasm = array(
  45. 'modename' => '模块测试',
  46. 'sericnum' => 'AB-'.date('Ymd').'-001',
  47. 'applyname' => $this->adminname,
  48. 'code' => rand(100000,999999),
  49. );
  50. $bh = $this->option->getval('sms_cbnum', 'defurls');
  51. $barr = $this->smsobj->send($mobile, '' ,$bh, $parasm, ''.URL.'?d=we', false);
  52. return $barr;
  53. }
  54. //获取签名
  55. public function getqianAjax()
  56. {
  57. $type = $this->option->getval('sms_dirtype');
  58. if(!isempt($type)){
  59. $rows[] = array(
  60. 'cont' => '非使用官网平台请到对应短信平台处理',
  61. 'isgk' => 0
  62. );
  63. return array(
  64. 'rows' => $rows,
  65. 'dirtype' => $type
  66. );
  67. }
  68. $barr = $this->smsobj->getdata('sms','getqian');
  69. $rows = array();
  70. if($barr['success']){
  71. $rows = $barr['data'];
  72. }
  73. return array(
  74. 'rows' => $rows
  75. );
  76. }
  77. //获取发送记录
  78. public function getrecordAjax()
  79. {
  80. $barr = $this->smsobj->getdata('sms','getrecord');
  81. $rows = array();
  82. if($barr['success']){
  83. $rows = $barr['data'];
  84. }
  85. return array(
  86. 'rows' => $rows
  87. );
  88. }
  89. //删除短信记录
  90. public function delrecordAjax()
  91. {
  92. $barr = $this->smsobj->getdata('sms','delrecord', array(
  93. 'id' => $this->post('id')
  94. ));
  95. return $barr;
  96. }
  97. //保存签名
  98. public function saveqianAjax()
  99. {
  100. if(getconfig('systype')=='demo')return returnerror('demo演示上禁止操作');
  101. $cont = trim($this->post('cont'));
  102. $num = $this->post('num');
  103. $explain = trim(htmlspecialchars($this->post('explain')));
  104. $isgk = (int)$this->post('isgk',1);
  105. $barr = $this->smsobj->postdata('sms','saveqian', array(
  106. 'cont' => $cont,
  107. 'num' => $num,
  108. 'isgk' => $isgk,
  109. 'explain' => $explain,
  110. ));
  111. return $barr;
  112. }
  113. //获取模版
  114. public function gettplAjax()
  115. {
  116. $type = $this->option->getval('sms_dirtype');
  117. if(!isempt($type)){
  118. $rows[] = array(
  119. 'cont' => '非使用官网平台请到对应短信平台处理',
  120. 'isgk' => 0
  121. );
  122. return array(
  123. 'rows' => $rows,
  124. 'dirtype' => $type
  125. );
  126. }
  127. $barr = $this->smsobj->getdata('sms','gettpl');
  128. $rows = array();
  129. if($barr['success']){
  130. $rows = $barr['data'];
  131. }
  132. return array(
  133. 'rows' => $rows
  134. );
  135. }
  136. //保存模版
  137. public function savetplAjax()
  138. {
  139. if(getconfig('systype')=='demo')return returnerror('demo演示上禁止操作');
  140. $cont = $this->post('cont');
  141. $num = $this->post('num');
  142. $isgk = 1;
  143. $barr = $this->smsobj->postdata('sms','savetpl', array(
  144. 'cont' => $cont,
  145. 'num' => $num,
  146. 'isgk' => 1,
  147. ));
  148. return $barr;
  149. }
  150. //删除模版
  151. public function deltplAjax()
  152. {
  153. if(getconfig('systype')=='demo')return returnerror('demo演示上禁止操作');
  154. $num = $this->post('num');
  155. $barr = $this->smsobj->getdata('sms','deltpl', array(
  156. 'num' => $num,
  157. ));
  158. return $barr;
  159. }
  160. //刷新模版状态
  161. public function relaodtplAjax()
  162. {
  163. $num = $this->post('num');
  164. $barr = $this->smsobj->getdata('sms','reloadtpl', array(
  165. 'num' => $num,
  166. ));
  167. return $barr;
  168. }
  169. //刷新状态
  170. public function reloadsignAjax()
  171. {
  172. $barr = $this->smsobj->getdata('sms','reloadsign');
  173. return $barr;
  174. }
  175. }
粤ICP备19079148号