white.ctrl.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. uni_user_permission_check('wechat_white_list');
  8. $dos = array('list');
  9. $do = in_array($do, $dos) ? $do : 'list';
  10. $acid = $_W['acid'];
  11. if($do == 'list') {
  12. $whitelist = pdo_fetchcolumn('SELECT whitelist FROM ' . tablename('coupon_setting') . ' WHERE uniacid = :aid AND acid = :acid', array(':aid' => $_W['uniacid'], ':acid' => $acid));
  13. if(!empty($whitelist)) {
  14. $whitelist = @iunserializer($whitelist);
  15. }
  16. if(checksubmit('submit')) {
  17. if(!empty($_GPC['username'])) {
  18. $data = array();
  19. foreach($_GPC['username'] as $da) {
  20. $da = trim($da);
  21. if(empty($da)) {
  22. continue;
  23. }
  24. $i++;
  25. $data[] = trim($da);
  26. if($i >= 10) {
  27. break;
  28. }
  29. }
  30. }
  31. load()->classs('coupon');
  32. $acc = new coupon($acid);
  33. $post['username'] = $data;
  34. $status = $acc->SetTestWhiteList($post);
  35. if(is_error($status)) {
  36. message($status['message'], '', 'error');
  37. } else {
  38. $data = iserializer($data);
  39. pdo_update('coupon_setting', array('whitelist' => $data), array('uniacid' => $_W['uniacid'], 'acid' => $acid));
  40. }
  41. message('设置测试白名单成功', referer(), 'success');
  42. }
  43. }
  44. template('wechat/white');