PromoteMsgListAction.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 PromoteMsgListAction 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 M("PromoteMsgList")->where("id=".$id)->getField("content");
  24. }
  25. public function send()
  26. {
  27. $id = intval($_REQUEST['id']);
  28. $msg_item = M("PromoteMsgList")->getById($id);
  29. $log_info = $msg_item['title'];
  30. if($msg_item)
  31. {
  32. if($msg_item['send_type']==0)
  33. {
  34. //短信
  35. require_once APP_ROOT_PATH."system/utils/es_sms.php";
  36. $sms = new sms_sender();
  37. $result = $sms->sendSms($msg_item['dest'],$msg_item['content'],get_gmtime(),1);
  38. $msg_item['result'] = $result['msg'];
  39. $msg_item['is_success'] = intval($result['status']);
  40. $msg_item['send_time'] = NOW_TIME;
  41. M("PromoteMsgList")->save($msg_item);
  42. if($result['status'])
  43. {
  44. save_log($log_info.l("SEND_NOW").l("SUCCESS"),1);
  45. header("Content-Type:text/html; charset=utf-8");
  46. echo l("SEND_NOW").l("SUCCESS");
  47. }
  48. else
  49. {
  50. save_log($log_info.l("SEND_NOW").l("FAILED").$result['msg'],0);
  51. header("Content-Type:text/html; charset=utf-8");
  52. echo l("SEND_NOW").l("FAILED").$result['msg'];
  53. }
  54. }
  55. else
  56. {
  57. //邮件
  58. require_once APP_ROOT_PATH."system/utils/es_mail.php";
  59. $mail = new mail_sender();
  60. $mail->AddAddress($msg_item['dest']);
  61. $mail->IsHTML($msg_item['is_html']); // 设置邮件格式为 HTML
  62. $mail->Subject = $msg_item['title']; // 标题
  63. $mail->Body = $mail_content; // 内容
  64. $result = $mail->Send();
  65. $msg_item['result'] = $mail->ErrorInfo;
  66. $msg_item['is_success'] = intval($result);
  67. $msg_item['send_time'] = NOW_TIME;
  68. M("PromoteMsgList")->save($msg_item);
  69. if($result)
  70. {
  71. save_log($log_info.l("SEND_NOW").l("SUCCESS"),1);
  72. header("Content-Type:text/html; charset=utf-8");
  73. echo l("SEND_NOW").l("SUCCESS");
  74. }
  75. else
  76. {
  77. save_log($log_info.l("SEND_NOW").l("FAILED").$mail->ErrorInfo,0);
  78. header("Content-Type:text/html; charset=utf-8");
  79. echo l("SEND_NOW").l("FAILED").$mail->ErrorInfo;
  80. }
  81. }
  82. }
  83. else
  84. {
  85. header("Content-Type:text/html; charset=utf-8");
  86. echo l("SEND_NOW").l("FAILED");
  87. }
  88. }
  89. public function foreverdelete() {
  90. //彻底删除指定记录
  91. $ajax = intval($_REQUEST['ajax']);
  92. $id = $_REQUEST ['id'];
  93. if (isset ( $id )) {
  94. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  95. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  96. foreach($rel_data as $data)
  97. {
  98. $info[] = $data['id'];
  99. }
  100. if($info) $info = implode(",",$info);
  101. $list = M(MODULE_NAME)->where ( $condition )->delete();
  102. if ($list!==false) {
  103. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  104. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  105. } else {
  106. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  107. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  108. }
  109. } else {
  110. $this->error (l("INVALID_OPERATION"),$ajax);
  111. }
  112. }
  113. }
  114. ?>