smsAction.php 5.0 KB

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