DealMsgListAction.class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class DealMsgListAction extends CommonAction{
  10. public function index()
  11. {
  12. if(trim($_REQUEST['dest'])!='')
  13. $condition['dest'] = array('like','%'.trim($_REQUEST['dest']).'%');
  14. if(trim($_REQUEST['content'])!='')
  15. $condition['content'] = array('like','%'.trim($_REQUEST['content']).'%');
  16. $this->assign("default_map",$condition);
  17. parent::index();
  18. }
  19. public function show_content()
  20. {
  21. $id = intval($_REQUEST['id']);
  22. header("Content-Type:text/html; charset=utf-8");
  23. echo htmlspecialchars(M("DealMsgList")->where("id=".$id)->getField("content"));
  24. }
  25. public function send()
  26. {
  27. $id = intval($_REQUEST['id']);
  28. $msg_item = M("DealMsgList")->getById($id);
  29. if($msg_item)
  30. {
  31. if($msg_item['send_type']==0)
  32. {
  33. //短信
  34. require_once APP_ROOT_PATH."system/utils/es_sms.php";
  35. $sms = new sms_sender();
  36. $result = $sms->sendSms($msg_item['dest'],$msg_item['content']);
  37. $msg_item['result'] = $result['msg'];
  38. $msg_item['is_success'] = intval($result['status']);
  39. $msg_item['send_time'] = get_gmtime();
  40. M("DealMsgList")->save($msg_item);
  41. if($result['status'])
  42. {
  43. save_log(l("SEND_NOW").l("SUCCESS"),1);
  44. header("Content-Type:text/html; charset=utf-8");
  45. echo l("SEND_NOW").l("SUCCESS");
  46. }
  47. else
  48. {
  49. save_log(l("SEND_NOW").l("FAILED").$result['msg'],0);
  50. header("Content-Type:text/html; charset=utf-8");
  51. echo l("SEND_NOW").l("FAILED").$result['msg'];
  52. }
  53. }
  54. else
  55. {
  56. //邮件
  57. require_once APP_ROOT_PATH."system/utils/es_mail.php";
  58. $mail = new mail_sender();
  59. $mail->AddAddress($msg_item['dest']);
  60. $mail->IsHTML($msg_item['is_html']); // 设置邮件格式为 HTML
  61. $mail->Subject = $msg_item['title']; // 标题
  62. $mail->Body = $msg_item['content']; // 内容
  63. $result = $mail->Send();
  64. $msg_item['result'] = $mail->ErrorInfo;
  65. $msg_item['is_success'] = intval($result);
  66. $msg_item['send_time'] = get_gmtime();
  67. M("DealMsgList")->save($msg_item);
  68. if($result)
  69. {
  70. save_log(l("SEND_NOW").l("SUCCESS"),1);
  71. header("Content-Type:text/html; charset=utf-8");
  72. echo l("SEND_NOW").l("SUCCESS");
  73. }
  74. else
  75. {
  76. save_log(l("SEND_NOW").l("FAILED").$mail->ErrorInfo,0);
  77. header("Content-Type:text/html; charset=utf-8");
  78. echo l("SEND_NOW").l("FAILED").$mail->ErrorInfo;
  79. }
  80. }
  81. }
  82. else
  83. {
  84. header("Content-Type:text/html; charset=utf-8");
  85. echo l("SEND_NOW").l("FAILED");
  86. }
  87. }
  88. public function foreverdelete() {
  89. //彻底删除指定记录
  90. $ajax = intval($_REQUEST['ajax']);
  91. $id = $_REQUEST ['id'];
  92. if (isset ( $id )) {
  93. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  94. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  95. foreach($rel_data as $data)
  96. {
  97. $info[] = $data['id'];
  98. }
  99. if($info) $info = implode(",",$info);
  100. $list = M(MODULE_NAME)->where ( $condition )->delete();
  101. if ($list!==false) {
  102. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  103. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  104. } else {
  105. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  106. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  107. }
  108. } else {
  109. $this->error (l("INVALID_OPERATION"),$ajax);
  110. }
  111. }
  112. }
  113. ?>