oauth.ctrl.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. load()->model('setting');
  8. load()->model('user');
  9. $dos = array('display', 'save_oauth');
  10. $do = in_array($_GPC['do'], $dos)? $do : 'display';
  11. $oauth = setting_load('global_oauth');
  12. $oauth = !empty($oauth['global_oauth']) ? $oauth['global_oauth'] : array();
  13. if ($do == 'display') {
  14. $user_have_accounts = user_borrow_oauth_account_list();
  15. $oauth_accounts = $user_have_accounts['oauth_accounts'];
  16. }
  17. if ($do == 'save_oauth') {
  18. if (!$_W['isajax'] || !$_W['ispost']) {
  19. iajax(-1, '添加失败');
  20. }
  21. $oauth['oauth']['account'] = intval($_GPC['account']);
  22. $oauth['oauth']['host'] = safe_gpc_url(rtrim($_GPC['host'],'/'), false);
  23. if (!empty($_GPC['host']) && empty($oauth['oauth']['host'])) {
  24. iajax(-1, '域名不合法');
  25. }
  26. $result = setting_save($oauth, 'global_oauth');
  27. if (is_error($result)) {
  28. iajax(-1, '添加失败');
  29. }
  30. iajax(0, '添加成功', url('system/oauth'));
  31. }
  32. template('system/oauth');