admincp_domain.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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: admincp_domain.php 32699 2013-03-01 02:54:05Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. $operation = in_array($operation, array('global', 'app', 'root')) ? $operation : 'global';
  13. $current = array($operation => 1);
  14. shownav('global', 'setting_domain');
  15. showsubmenu('setting_domain', array(
  16. array('setting_domain_base', 'domain', $current['global']),
  17. array('setting_domain_app', 'domain&operation=app', $current['app']),
  18. array('setting_domain_root', 'domain&operation=root', $current['root']),
  19. ));
  20. $navs = $_G['setting']['navs'];
  21. if($operation == 'app') {
  22. if(!submitcheck('submit')) {
  23. $appkeyarr = array(
  24. 'portal' => $navs[1]['navname'],
  25. 'forum' => $navs[2]['navname'],
  26. 'group' => $navs[3]['navname'],
  27. 'home' => $lang['nav_home'],
  28. 'mobile' => $lang['mobile'],
  29. 'default' => $lang['default']
  30. );
  31. showtips('setting_domain_app_tips');
  32. showformheader('domain&operation=app');
  33. showtableheader();
  34. showsubtitle(array('name', 'setting_domain_app_domain'));
  35. $app = array();
  36. $hiddenarr = array();
  37. foreach($appkeyarr as $key => $desc) {
  38. if(in_array($key, array('portal', 'group')) && !helper_access::check_module($key) || ($key == 'home' && !helper_access::check_module('feed'))) {
  39. $hiddenarr["appnew[$key]"] = '';
  40. } else {
  41. showtablerow('', array('class="td25"', ''), array(
  42. $desc,
  43. "<input type=\"text\" class=\"txt\" style=\"width:50%;\" name=\"appnew[$key]\" value=\"".$_G['setting']['domain']['app'][$key]."\">".($key == 'mobile' ? cplang('setting_domain_app_mobile_tips') : '')
  44. ));
  45. }
  46. }
  47. showsubmit('submit');
  48. showtablefooter();
  49. showhiddenfields($hiddenarr);
  50. showformfooter();
  51. } else {
  52. $olddomain = $_G['setting']['domain']['app'];
  53. $_G['setting']['domain']['app'] = array();
  54. $appset = false;
  55. foreach($_GET['appnew'] as $appkey => $domain) {
  56. if(preg_match('/^((http|https|ftp):\/\/|\.)|(\/|\.)$/i', $domain)) {
  57. cpmsg('setting_domain_http_error', '', 'error');
  58. }
  59. if(!empty($domain) && in_array($domain, $_G['setting']['domain']['app'])) {
  60. cpmsg('setting_domain_repeat_error', '', 'error');
  61. }
  62. if($appkey != 'default' && $domain) {
  63. $appset = true;
  64. }
  65. $_G['setting']['domain']['app'][$appkey] = $domain;
  66. }
  67. if($appset && !$_G['setting']['domain']['app']['default']) {
  68. cpmsg('setting_domain_need_default_error', '', 'error');
  69. }
  70. if($_GET['appnew']['mobile'] != $olddomain['mobile']) {
  71. C::t('common_nav')->update_by_identifier('mobile', array('url' => (!$_GET['appnew']['mobile'] ? 'forum.php?mobile=yes' : 'http://'.$_GET['appnew']['mobile'])));
  72. }
  73. C::t('common_setting')->update('domain',$_G['setting']['domain']);
  74. updatecache('setting');
  75. cpmsg('setting_update_succeed', 'action=domain&operation=app', 'succeed');
  76. }
  77. } elseif($operation == 'root') {
  78. $roottype = array(
  79. 'home' => $lang['domain_home'],
  80. 'group' => $navs[3]['navname'],
  81. 'forum' => $lang['domain_forum'],
  82. 'topic' => $lang['domain_topic'],
  83. 'channel' => $lang['channel'],
  84. );
  85. if(!submitcheck('submit')) {
  86. showtips('setting_domain_root_tips');
  87. showformheader('domain&operation=root');
  88. showtableheader();
  89. showsubtitle(array('name', 'setting_domain_app_domain'));
  90. $hiddenarr = array();
  91. foreach($roottype as $type => $desc) {
  92. if(in_array($type, array('topic', 'channel')) && !helper_access::check_module('portal') || ($type == 'home' && !$_G['setting']['homepagestyle']) || ($type == 'group' && !helper_access::check_module('group'))) {
  93. $hiddenarr["domainnew[$type]"] = '';
  94. } else {
  95. $domainroot = $_G['setting']['domain']['root'][$type];
  96. showtablerow('', array('class="td25"', ''), array(
  97. $desc,
  98. "<input type=\"text\" class=\"txt\" style=\"width:50%;\" name=\"domainnew[$type]\" value=\"$domainroot\">"
  99. ));
  100. }
  101. }
  102. showsubmit('submit');
  103. showtablefooter();
  104. showhiddenfields($hiddenarr);
  105. showformfooter();
  106. } else {
  107. $oldroot = $_G['setting']['domain']['root'];
  108. $_G['setting']['domain']['root'] = array();
  109. foreach($_GET['domainnew'] as $idtype => $domain) {
  110. if(preg_match('/^((http|https|ftp):\/\/|\.)|(\/|\.)$/i', $domain)) {
  111. cpmsg('setting_domain_http_error', '', 'error');
  112. }
  113. if($_G['setting']['domain']['root'][$idtype] != $domain) {
  114. $updatetype = $idtype == 'forum' ? array('forum', 'channel') : $idtype;
  115. C::t('common_domain')->update_by_idtype($updatetype, array('domainroot' => $domain));
  116. }
  117. $_G['setting']['domain']['root'][$idtype] = $domain;
  118. }
  119. C::t('common_setting')->update('domain', $_G['setting']['domain']);
  120. updatecache('setting');
  121. cpmsg('setting_update_succeed', 'action=domain&operation=root', 'succeed');
  122. }
  123. } else {
  124. if(!submitcheck('domainsubmit')) {
  125. showtips('setting_domain_base_tips');
  126. showformheader("domain");
  127. showtableheader();
  128. if($_G['setting']['homepagestyle']) {
  129. showsetting('setting_domain_allow_space', 'settingnew[allowspacedomain]', $_G['setting']['allowspacedomain'], 'radio');
  130. } else {
  131. showhiddenfields(array('settingnew[allowspacedomain]' => 0));
  132. }
  133. if(helper_access::check_module('group')) {
  134. showsetting('setting_domain_allow_group', 'settingnew[allowgroupdomain]', $_G['setting']['allowgroupdomain'], 'radio');
  135. } else {
  136. showhiddenfields(array('settingnew[allowgroupdomain]' => 0));
  137. }
  138. showsetting('setting_domain_hold_domain', 'settingnew[holddomain]', $_G['setting']['holddomain'], 'text');
  139. showsubmit('domainsubmit');
  140. showtablefooter();
  141. showformfooter();
  142. } else {
  143. $settings = $_GET['settingnew'];
  144. $settings['allowspacedomain'] = (float)$settings['allowspacedomain'];
  145. $settings['allowgroupdomain'] = (float)$settings['allowgroupdomain'];
  146. if($settings) {
  147. C::t('common_setting')->update_batch($settings);
  148. updatecache('setting');
  149. }
  150. cpmsg('setting_update_succeed', 'action=domain', 'succeed');
  151. }
  152. }
  153. ?>