人人商城

passport.ctrl.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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('passport', 'oauth', 'sync');
  8. $do = in_array($do, $dos) ? $do : 'passport';
  9. if($do == 'passport') {
  10. uni_user_permission_check('mc_passport_passport');
  11. $_W['page']['title'] = '会员中心参数 - 会员中心选项 - 会员中心';
  12. $uc = pdo_fetch("SELECT `uc`,`passport` FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  13. $passport = @iunserializer($uc['passport']);
  14. if(!is_array($passport)) {
  15. $passport = array();
  16. }
  17. if(checksubmit('submit')) {
  18. $rec = array();
  19. $passport = array();
  20. $passport['focusreg'] = intval($_GPC['passport']['focusreg']);
  21. $passport['item'] = trim($_GPC['passport']['item']);
  22. $passport['type'] = $_GPC['passport']['type'];
  23. $passport['audit'] = intval($_GPC['passport']['audit']);
  24. $passport['type'] = in_array($passport['type'], array('code', 'password', 'hybird')) ? $passport['type'] : 'password';
  25. $rec['passport'] = iserializer($passport);
  26. $row = pdo_fetch("SELECT uniacid FROM ".tablename('uni_settings') . " WHERE uniacid = :wid LIMIT 1", array(':wid' => intval($_W['uniacid'])));
  27. if(!empty($row)) {
  28. pdo_update('uni_settings', $rec, array('uniacid' => intval($_W['uniacid'])));
  29. }else {
  30. pdo_insert('uni_settings', $rec);
  31. }
  32. cache_delete("unisetting:{$_W['uniacid']}");
  33. message('设置成功!', referer(), 'success');
  34. }
  35. }
  36. if($do == 'oauth') {
  37. uni_user_permission_check('mc_passport_oauth');
  38. $_W['page']['title'] = '公众平台oAuth选项 - 会员中心';
  39. $where = '';
  40. $params = array();
  41. if(empty($_W['isfounder'])) {
  42. $where = " WHERE `uniacid` IN (SELECT `uniacid` FROM " . tablename('uni_account_users') . " WHERE `uid`=:uid)";
  43. $params[':uid'] = $_W['uid'];
  44. }
  45. $sql = "SELECT * FROM " . tablename('uni_account') . $where;
  46. $uniaccounts = pdo_fetchall($sql, $params);
  47. $accounts = array();
  48. if(!empty($uniaccounts)) {
  49. foreach($uniaccounts as $uniaccount) {
  50. $accountlist = uni_accounts($uniaccount['uniacid']);
  51. if(!empty($accountlist)) {
  52. foreach($accountlist as $account) {
  53. if(!empty($account['key'])
  54. && !empty($account['secret'])
  55. && in_array($account['level'], array(4))) {
  56. $accounts[$account['acid']] = $account['name'];
  57. }
  58. }
  59. }
  60. }
  61. }
  62. $oauth = pdo_fetchcolumn('SELECT `oauth` FROM '.tablename('uni_settings').' WHERE `uniacid` = :uniacid LIMIT 1',array(':uniacid' => $_W['uniacid']));
  63. $oauth = iunserializer($oauth) ? iunserializer($oauth) : array();
  64. if(checksubmit('submit')) {
  65. $host = rtrim($_GPC['host'],'/');
  66. if(!empty($host) && !preg_match('/^http(s)?:\/\//', $host)) {
  67. $host = $_W['sitescheme'].$host;
  68. }
  69. $data = array(
  70. 'host' => $host,
  71. 'account' => intval($_GPC['oauth']),
  72. );
  73. pdo_update('uni_settings', array('oauth' => iserializer($data)), array('uniacid' => $_W['uniacid']));
  74. cache_delete("unisetting:{$_W['uniacid']}");
  75. message('设置公众平台oAuth成功', referer() ,'success');
  76. }
  77. }
  78. if($do == 'sync') {
  79. uni_user_permission_check('mc_passport_sync');
  80. $_W['page']['title'] = '更新粉丝信息 - 公众号选项';
  81. $setting = uni_setting($_W['uniacid'], array('sync'));
  82. $sync = $setting['sync'];
  83. if(checksubmit('submit')) {
  84. pdo_update('uni_settings', array('sync' => intval($_GPC['sync'])), array('uniacid' => $_W['uniacid']));
  85. cache_delete("unisetting:{$_W['uniacid']}");
  86. message('更新设置成功', referer(), 'success');
  87. }
  88. }
  89. template('mc/passport');