cloud_siteinfo.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: cloud_siteinfo.php 33808 2013-08-15 11:22:45Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. if(submitcheck('syncsubmit')) {
  12. if($cloudstatus != 'cloud') {
  13. cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'", 3000);</script>');
  14. }
  15. try {
  16. $cloudClient = & Cloud::loadClass('Service_Client_Cloud', array(true));
  17. if ($_G['setting']['my_app_status']) {
  18. $manyouClient = Cloud::loadClass('Service_Client_Manyou');
  19. $manyouClient->sync();
  20. }
  21. $res = $cloudClient->sync();
  22. } catch (Cloud_Service_Client_RestfulException $e) {
  23. cpmsg('cloud_sync_failure', '', 'error', array('errorCode' => $e->getCode(), 'errorMessage' => $e->getMessage()));
  24. }
  25. cpmsg('cloud_sync_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'", 3000);</script>');
  26. } elseif(submitcheck('resetsubmit')) {
  27. if (!isfounder()) {
  28. cpmsg('action_noaccess', '', 'error');
  29. }
  30. if($cloudstatus != 'cloud') {
  31. cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'", 3000);</script>');
  32. }
  33. try {
  34. $cloudClient = Cloud::loadClass('Service_Client_Cloud');
  35. $res = $cloudClient->resetKey();
  36. } catch (Cloud_Service_Client_RestfulException $e) {
  37. cpmsg($e->getMessage(), '', 'error');
  38. }
  39. $sId = intval($res['sId']);
  40. $sKey = trim($res['sKey']);
  41. C::t('common_setting')->update_batch(array('my_siteid' => $sId, 'my_sitekey' => $sKey));
  42. updatecache('setting');
  43. cpmsg('cloud_reset_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'", 3000);</script>');
  44. } elseif(submitcheck('ipsubmit')) {
  45. $_POST['cloud_api_ip'] = trim($_POST['cloud_api_ip']);
  46. $_POST['my_ip'] = trim($_POST['my_ip']);
  47. $_POST['connect_api_ip'] = trim($_POST['connect_api_ip']);
  48. if($_G['setting']['cloud_api_ip'] != $_POST['cloud_api_ip'] || $_G['setting']['my_ip'] != $_POST['my_ip'] || $_G['setting']['connect_api_ip'] != $_POST['connect_api_ip']) {
  49. C::t('common_setting')->update_batch(array('cloud_api_ip' => $_POST['cloud_api_ip'], 'my_ip' => $_POST['my_ip'], 'connect_api_ip' => $_POST['connect_api_ip']));
  50. updatecache('setting');
  51. }
  52. $locationUrl = ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor';
  53. cpmsg('cloud_ipsetting_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.$locationUrl.'\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.$locationUrl.'\'", 3000);</script>');
  54. } elseif ($_GET['anchor'] == 'cloud_ip') {
  55. ajaxshowheader();
  56. echo '
  57. <h3 class="flb" id="fctrl_showblock" style="cursor: move;">
  58. <em id="return_showblock" fwin="showblock">'.$lang['cloud_api_ip_btn'].'</em>
  59. <span><a title="'.$lang['close'].'" onclick="hideWindow(\'cloudApiIpWin\');return false;" class="flbc" href="javascript:;">'.$lang['close'].'</a></span>
  60. </h3>
  61. ';
  62. echo '<div style="margin: 0 10px; width: 700px;">';
  63. showformheader('cloud');
  64. showhiddenfields(array('operation' => $operation));
  65. if($_GET['callback']) {
  66. showhiddenfields(array('callback' => $_GET['callback']));
  67. }
  68. showtableheader();
  69. showsetting('cloud_api_ip', 'cloud_api_ip', $_G['setting']['cloud_api_ip'], 'text');
  70. showsetting('cloud_manyou_ip', 'my_ip', $_G['setting']['my_ip'], 'text');
  71. showsetting('cloud_connect_api_ip', 'connect_api_ip', $_G['setting']['connect_api_ip'], 'text');
  72. showsubmit('ipsubmit');
  73. showtablefooter();
  74. showformfooter();
  75. echo '</div>';
  76. ajaxshowfooter();
  77. } else {
  78. shownav('navcloud', 'menu_cloud_siteinfo');
  79. showsubmenu('menu_cloud_siteinfo');
  80. showtips('cloud_siteinfo_tips');
  81. echo '<script type="text/javascript">var disallowfloat = "";</script>';
  82. showformheader('cloud');
  83. showhiddenfields(array('operation' => $operation));
  84. showtableheader();
  85. showtitle('menu_cloud_siteinfo');
  86. showtablerow('', array('class="td24"'), array(
  87. '<strong>'.cplang('cloud_site_name').'</strong>',
  88. $_G['setting']['bbname']
  89. ));
  90. showtablerow('', array('class="td24"'), array(
  91. '<strong>'.cplang('cloud_site_url').'</strong>',
  92. $_G['siteurl']
  93. ));
  94. showtablerow('', array('class="td24"'), array(
  95. '<strong>'.cplang('cloud_site_id').'</strong>',
  96. $_G['setting']['my_siteid']
  97. ));
  98. $resetSubmitButton = isfounder() ? '<input type="submit" class="btn" id="submit_resetsubmit" name="resetsubmit" value="'.$lang['cloud_resetkey'].'" />&nbsp; ' : '';
  99. showsubmit('syncsubmit', 'cloud_sync', '',$resetSubmitButton.'<input type="button" class="btn" onClick="showWindow(\'cloudApiIpWin\', \''.ADMINSCRIPT.'?action=cloud&operation=siteinfo&anchor=cloud_ip\'); return false;" value="'.$lang['cloud_api_ip_btn'].'" />');
  100. showtablefooter();
  101. showformfooter();
  102. }