人人商城

jsauth.ctrl.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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('profile_jsauth');
  8. $_W['page']['title'] = '功能选项 - 公众号选项 - 借用js分享权限';
  9. $where = '';
  10. $params = array();
  11. if(empty($_W['isfounder'])) {
  12. $where = " WHERE `uniacid` IN (SELECT `uniacid` FROM " . tablename('uni_account_users') . " WHERE `uid`=:uid)";
  13. $params[':uid'] = $_W['uid'];
  14. }
  15. $sql = "SELECT * FROM " . tablename('uni_account') . $where;
  16. $uniaccounts = pdo_fetchall($sql, $params);
  17. $accounts = array();
  18. if(!empty($uniaccounts)) {
  19. foreach($uniaccounts as $uniaccount) {
  20. $accountlist = uni_accounts($uniaccount['uniacid']);
  21. if(!empty($accountlist)) {
  22. foreach($accountlist as $account) {
  23. if(!empty($account['key'])
  24. && !empty($account['secret'])
  25. && in_array($account['level'], array(3, 4))) {
  26. $accounts[$account['acid']] = $account['name'];
  27. }
  28. }
  29. }
  30. }
  31. }
  32. if(checksubmit('submit')) {
  33. $jsauth_acid = intval($_GPC['jsauth_acid']);
  34. if ($jsauth_acid == 0) {
  35. } elseif(!array_key_exists($jsauth_acid, $accounts)){
  36. message('指定的公众号不存在或没有权限借用指定的公众号.');
  37. }
  38. pdo_update('uni_settings', array('jsauth_acid' => $jsauth_acid), array('uniacid' => $_W['uniacid']));
  39. cache_delete("unisetting:{$_W['uniacid']}");
  40. message('设置借用 js 分享权限成功', referer() ,'success');
  41. }
  42. $jsauth_acid = pdo_fetchcolumn('SELECT `jsauth_acid` FROM '.tablename('uni_settings').' WHERE `uniacid` = :uniacid LIMIT 1',array(':uniacid' => $_W['uniacid']));
  43. template('profile/jsauth');