mail.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. define('CURSCRIPT', 'mail');
  4. require_once dirname(__FILE__) . '/global.php';
  5. require_once MYMPS_INC . '/db.class.php';
  6. require_once MYMPS_INC . '/email.fun.php';
  7. (!in_array($part, array('setting', 'template', 'sendlist')) || !$part) && ($part = 'setting');
  8. if (!submit_check(CURSCRIPT . '_submit')) {
  9. switch ($part) {
  10. case 'setting':
  11. chk_admin_purview('purview_邮件服务器');
  12. $here = '邮件服务器设置';
  13. $res = $db->query('SELECT description,value FROM ' . $db_mymps . 'config WHERE type=\'mail\'');
  14. while ($row = $db->fetchRow($res)) {
  15. $mail_config[$row['description']] = $row['value'];
  16. }
  17. break;
  18. case 'sendlist':
  19. chk_admin_purview('purview_邮件发送记录');
  20. $here = 'My_mps邮件发送记录';
  21. $sql = 'SELECT * FROM `' . $db_mymps . 'mail_sendlist` ORDER BY id DESC';
  22. $rows_num = mymps_count('mail_sendlist');
  23. $param = setParam(array('part'));
  24. $list = page1($sql);
  25. break;
  26. default:
  27. chk_admin_purview('purview_邮件模板');
  28. $here = '邮件模板管理';
  29. $tpl = mail_template_list();
  30. $template_id && ($edit = $db->getRow('SELECT * FROM `' . $db_mymps . 'mail_template` WHERE template_id = \'' . $template_id . '\''));
  31. break;
  32. }
  33. include mymps_tpl(CURSCRIPT . '_' . $part);
  34. } else {
  35. if (!empty($test_mail)) {
  36. $test_mail = trim($test_mail);
  37. if (!send_email($test_mail, '来自' . $mymps_global[SiteName] . '的测试邮件', '如果你收到了这封邮件,则表明你已经成功配置了邮箱服务器,发送时间:' . GetTime(time()))) {
  38. write_msg('测试邮件发出失败!请仔细配置好邮箱服务信息', '?part=setting');
  39. } else {
  40. write_msg('恭喜,您已经成功发出测试邮件', '?part=setting', 'write_record');
  41. }
  42. }
  43. if ($part == 'setting') {
  44. $des = array('mail_service', 'smtp_server', 'smtp_serverport', 'smtp_mail', 'mail_user', 'mail_pass');
  45. mymps_delete('config', 'WHERE type = \'mail\'');
  46. foreach ($des as $key) {
  47. $db->query('INSERT ' . $db_mymps . 'config (description,value,type) VALUES (\'' . $key . '\',\'' . trim(${$key}) . '\',\'mail\')');
  48. }
  49. clear_cache_files('mail_config');
  50. write_msg('邮件服务器配置设置成功!', '?part=' . $part, 'WriteRecord');
  51. } else {
  52. if ($part == 'template') {
  53. $return_url = '?part=template';
  54. if (is_array($delids)) {
  55. foreach ($delids as $kids => $vids) {
  56. mymps_delete('mail_template', 'WHERE template_id = ' . $vids);
  57. }
  58. }
  59. if (is_array($add) && $add[template_subject] && $add[template_code]) {
  60. if ($db->getOne('SELECT template_id FROM `' . $db_mymps . 'mail_template` WHERE template_code = \'' . $add['template_code'] . '\'')) {
  61. write_msg('您填写的模板标识码重复了!');
  62. } else {
  63. $db->query('INSERT `' . $db_mymps . 'mail_template` (template_subject,template_code,is_html,is_sys,last_modify)VALUES(\'' . $add['template_subject'] . '\',\'' . $add['template_code'] . '\',\'' . $add['is_html'] . '\',\'' . $add['is_sys'] . '\',\'' . time() . '\')');
  64. }
  65. }
  66. if (is_array($edit) && $edit[template_id] && $edit[template_subject] && $edit[template_code] && $edit[template_content]) {
  67. $db->query('UPDATE `' . $db_mymps . 'mail_template` SET template_subject = \'' . $edit['template_subject'] . '\', template_code = \'' . $edit['template_code'] . '\' , is_html = \'' . $edit['is_html'] . '\' , template_content = \'' . $edit['template_content'] . '\' , last_modify = \'' . time() . '\' WHERE template_id = \'' . $edit['template_id'] . '\'');
  68. $return_url = '?part=template&template_id=' . $edit[template_id];
  69. }
  70. clear_cache_files('mail_template');
  71. write_msg('邮件模板增加或更新成功!', $return_url, 'write_record');
  72. } else {
  73. if ($part == 'sendlist') {
  74. $return_url = '?part=sendlist';
  75. if (is_array($delids)) {
  76. foreach ($delids as $kids => $vids) {
  77. mymps_delete('mail_sendlist', 'WHERE id = ' . $vids);
  78. }
  79. }
  80. write_msg('成功删除邮件发送记录!', $return_url, 'write_record');
  81. }
  82. }
  83. }
  84. }
  85. is_object($db) && $db->Close();
  86. $mymps_global = $db = $db_mymps = $part = NULL;