passport.ctrl.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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('oauth', 'save_oauth', 'uc_setting', 'upload_file');
  8. $do = in_array($do, $dos) ? $do : 'oauth';
  9. $_W['page']['title'] = '公众平台oAuth选项 - 会员中心';
  10. load()->model('user');
  11. if ($do == 'save_oauth') {
  12. $type = $_GPC['type'];
  13. $account = trim($_GPC['account']);
  14. if ($type == 'oauth') {
  15. $host = safe_gpc_url(rtrim($_GPC['host'],'/'), false);
  16. if (!empty($_GPC['host']) && empty($host)) {
  17. iajax(-1, '域名不合法');
  18. }
  19. $data = array(
  20. 'host' => $host,
  21. 'account' => $account,
  22. );
  23. pdo_update('uni_settings', array('oauth' => iserializer($data)), array('uniacid' => $_W['uniacid']));
  24. cache_delete("unisetting:{$_W['uniacid']}");
  25. }
  26. if ($type == 'jsoauth') {
  27. pdo_update('uni_settings', array('jsauth_acid' => $account), array('uniacid' => $_W['uniacid']));
  28. cache_delete("unisetting:{$_W['uniacid']}");
  29. }
  30. iajax(0, '');
  31. }
  32. if ($do == 'oauth') {
  33. $user_have_accounts = user_borrow_oauth_account_list();
  34. $oauth_accounts = $user_have_accounts['oauth_accounts'];
  35. $jsoauth_accounts = $user_have_accounts['jsoauth_accounts'];
  36. $oauth = pdo_fetchcolumn('SELECT `oauth` FROM '.tablename('uni_settings').' WHERE `uniacid` = :uniacid LIMIT 1',array(':uniacid' => $_W['uniacid']));
  37. $oauth = iunserializer($oauth) ? iunserializer($oauth) : array();
  38. $jsoauth = pdo_getcolumn('uni_settings', array('uniacid' => $_W['uniacid']), 'jsauth_acid');
  39. }
  40. template('profile/passport');