人人商城

subscribe.ctrl.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $dos = array('subscribe', 'check', 'ban');
  8. $do = in_array($do, $dos) ? $do : 'subscribe';
  9. load()->model('extension');
  10. load()->model('cache');
  11. if ($do == 'subscribe') {
  12. $_W['page']['title'] = '系统 - 订阅管理';
  13. $modules = pdo_fetchall("SELECT title, name, subscribes FROM ".tablename('modules')." WHERE subscribes <> ''", array(), 'name');
  14. if (!empty($modules)) {
  15. foreach ($modules as $module) {
  16. $module['subscribes'] = unserialize($module['subscribes']);
  17. if (!empty($module['subscribes'])) {
  18. foreach ($module['subscribes'] as $event) {
  19. if ($event == 'text' || $event == 'enter') {
  20. continue;
  21. }
  22. $module_subscribes[$module['name']]= $module['subscribes'];
  23. }
  24. }
  25. }
  26. }
  27. $mtypes = ext_module_msg_types();
  28. $module_ban = $_W['setting']['module_receive_ban'];
  29. if (!is_array($module_ban)) {
  30. $module_ban = array();
  31. }
  32. template('extension/subscribe');
  33. }
  34. if ($do == 'check') {
  35. $_W['uniacid'] = 1;
  36. load()->classs('account');
  37. $modulename = $_GPC['modulename'];
  38. $obj = WeUtility::createModuleReceiver($modulename);
  39. if (empty($obj)) {
  40. exit('error');
  41. }
  42. $obj->uniacid = $_W['uniacid'];
  43. $obj->acid = $_W['acid'];
  44. if(method_exists($obj, 'receive')) {
  45. @$obj->receive();
  46. exit('success');
  47. }
  48. }
  49. if ($do == 'ban') {
  50. $modulename = $_GPC['modulename'];
  51. $ban = $_GPC['ban'];
  52. if (empty($modulename)) {
  53. message('请设置模块名', referer(), 'error');
  54. }
  55. if (!is_array($_W['setting']['module_receive_ban'])) {
  56. $_W['setting']['module_receive_ban'] = array();
  57. }
  58. if (empty($ban)) {
  59. $_W['setting']['module_receive_ban'][$modulename] = $modulename;
  60. } else {
  61. unset($_W['setting']['module_receive_ban'][$modulename]);
  62. }
  63. setting_save($_W['setting']['module_receive_ban'], 'module_receive_ban');
  64. cache_build_module_subscribe_type();
  65. message($module_ban, '', 'ajax');
  66. }