人人商城

redirect.ctrl.php 2.2KB

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