redirect.ctrl.php 2.4 KB

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