redirect.ctrl.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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('cloud');
  8. load()->func('communication');
  9. $dos = array('profile', 'callback', 'appstore', 'buybranch', 'sms', 'vsx');
  10. $do = in_array($do, $dos) ? $do : 'profile';
  11. if($do == 'profile') {
  12. define('ACTIVE_FRAME_URL', url('cloud/profile'));
  13. $iframe = cloud_auth_url('profile');
  14. $title = '注册站点';
  15. }
  16. if($do == 'sms') {
  17. define('ACTIVE_FRAME_URL', url('cloud/sms'));
  18. permission_check_account_user('system_cloud_sms');
  19. $iframe = cloud_auth_url('sms');
  20. $title = '云短信';
  21. }
  22. if ($do == 'vsx') {
  23. $url = safe_gpc_string($_GPC['url']);
  24. cloud_v_to_xs($url);
  25. exit;
  26. }
  27. if($do == 'appstore') {
  28. $iframe = cloud_auth_url('appstore');
  29. $title = '应用商城';
  30. header("Location: $iframe");
  31. exit;
  32. }
  33. if($do == 'promotion') {
  34. if(empty($_W['setting']['site']['key']) || empty($_W['setting']['site']['token'])) {
  35. itoast("你的程序需要在微擎云服务平台注册你的站点资料, 来接入云平台服务后才能使用推广功能.", url('cloud/profile'), 'error');
  36. }
  37. $iframe = cloud_auth_url('promotion');
  38. $title = '我要推广';
  39. }
  40. if ($do == 'buybranch') {
  41. $auth = array();
  42. $auth['name'] = $_GPC['m'];
  43. $auth['branch'] = intval($_GPC['branch']);
  44. $url = cloud_auth_url('buybranch', $auth);
  45. $response = ihttp_request($url);
  46. $response = json_decode($response['content'], true);
  47. if (is_error($response['message'])) {
  48. itoast($response['message']['message'], url('module/manage-system'), 'error');
  49. }
  50. $params = array(
  51. 'is_upgrade' => 1,
  52. 'is_buy' => 1,
  53. );
  54. if (trim($_GPC['type']) == 'theme') {
  55. $params['t'] = $auth['name'];
  56. } else {
  57. $params['m'] = $auth['name'];
  58. }
  59. itoast($response['message']['message'], url('cloud/process', $params), 'success');
  60. }
  61. if($do == 'callback') {
  62. $secret = $_GPC['token'];
  63. if(strlen($secret) == 32) {
  64. $cache = cache_read(cache_system_key('cloud_auth_transfer'));
  65. if (empty($cache) || empty($cache['secret'])) {
  66. $cache = cache_read('cloud:auth:transfer');
  67. }
  68. cache_delete(cache_system_key('cloud_auth_transfer'));
  69. if(!empty($cache) && $cache['secret'] == $secret) {
  70. $site = $cache;
  71. unset($site['secret']);
  72. setting_save($site, 'site');
  73. $auth = array();
  74. $auth['key'] = $site['key'];
  75. $auth['password'] = md5($site['key'] . $site['token']);
  76. $url = cloud_auth_url('profile', $auth);
  77. header('Location: ' . $url);
  78. exit();
  79. }
  80. }
  81. itoast('访问错误.', '', '');
  82. }
  83. template('cloud/frame');