PageRenderTime 34ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/admincp/modules/settings/system.php

http://creative-portal.googlecode.com/
PHP | 268 lines | 232 code | 30 blank | 6 comment | 39 complexity | 9cb3d9a299a4da232c6f39b40d4f19bd MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-2-2010 12:55
  7. */
  8. if ( ! defined( 'NV_IS_FILE_SETTINGS' ) ) die( 'Stop!!!' );
  9. $page_title = $lang_module['global_config'];
  10. if ( defined( 'NV_EDITOR' ) ) require_once ( NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php' );
  11. $submit = $nv_Request->get_string( 'submit', 'post' );
  12. $errormess = "";
  13. $array_config_global = $global_config;
  14. $themeadmin_array = nv_scandir( NV_ROOTDIR . "/themes", $global_config['check_theme_admin'] );
  15. $allow_sitelangs = array();
  16. foreach ( $global_config['allow_sitelangs'] as $lang_i )
  17. {
  18. if ( file_exists( NV_ROOTDIR . "/language/" . $lang_i . "/global.php" ) )
  19. {
  20. $allow_sitelangs[] = $lang_i;
  21. }
  22. }
  23. $proxy_blocker_array = array( //
  24. 0 => $lang_module['proxy_blocker_0'], //
  25. 1 => $lang_module['proxy_blocker_1'], //
  26. 2 => $lang_module['proxy_blocker_2'], //
  27. 3 => $lang_module['proxy_blocker_3'] //
  28. );
  29. if ( $submit )
  30. {
  31. $array_config_global = array();
  32. $array_config_global['admin_theme'] = filter_text_input( 'admin_theme', 'post', '', 1, 255 );
  33. if ( empty( $array_config_global['admin_theme'] ) or ! in_array( $array_config_global['admin_theme'], $themeadmin_array ) )
  34. {
  35. $array_config_global['admin_theme'] = $global_config['admin_theme'];
  36. }
  37. $array_config_global['gfx_chk'] = $nv_Request->get_int( 'gfx_chk', 'post' );
  38. $array_config_global['site_keywords'] = filter_text_input( 'site_keywords', 'post', '', 1, 255 );
  39. if ( ! empty( $array_config_global['site_keywords'] ) )
  40. {
  41. $site_keywords = array_map( "trim", explode( ",", $array_config_global['site_keywords'] ) );
  42. $array_config_global['site_keywords'] = array();
  43. if ( ! empty( $site_keywords ) )
  44. {
  45. foreach ( $site_keywords as $keywords )
  46. {
  47. if ( ! empty( $keywords ) and ! is_numeric( $keywords ) )
  48. {
  49. $array_config_global['site_keywords'][] = $keywords;
  50. }
  51. }
  52. }
  53. $array_config_global['site_keywords'] = ( ! empty( $array_config_global['site_keywords'] ) ) ? implode( ", ", $array_config_global['site_keywords'] ) : "";
  54. }
  55. $array_config_global['site_email'] = filter_text_input( 'site_email', 'post', '', 1, 255 );
  56. if ( nv_check_valid_email( $array_config_global['site_email'] ) != '' )
  57. {
  58. $array_config_global['site_email'] = $global_config['site_email'];
  59. }
  60. $array_config_global['error_send_email'] = filter_text_input( 'error_send_email', 'post', '', 1, 255 );
  61. if ( nv_check_valid_email( $array_config_global['error_send_email'] ) != '' )
  62. {
  63. $array_config_global['error_send_email'] = $global_config['error_send_email'];
  64. }
  65. $array_config_global['site_phone'] = filter_text_input( 'site_phone', 'post', '', 1, 255 );
  66. $array_config_global['site_lang'] = filter_text_input( 'site_lang', 'post', '', 1, 255 );
  67. if ( ! in_array( $array_config_global['site_lang'], $allow_sitelangs ) )
  68. {
  69. $array_config_global['site_lang'] = 'vi';
  70. }
  71. $array_config_global['site_timezone'] = filter_text_input( 'site_timezone', 'post', '', 1, 255 );
  72. $array_config_global['date_pattern'] = filter_text_input( 'date_pattern', 'post', '', 1, 255 );
  73. $array_config_global['time_pattern'] = filter_text_input( 'time_pattern', 'post', '', 1, 255 );
  74. $array_config_global['my_domains'] = filter_text_input( 'my_domains', 'post', '', 1, 255 );
  75. $my_domains = array(
  76. NV_SERVER_NAME
  77. );
  78. if ( ! empty( $array_config_global['my_domains'] ) )
  79. {
  80. $array_config_global['my_domains'] = array_map( "trim", explode( ",", $array_config_global['my_domains'] ) );
  81. foreach ( $array_config_global['my_domains'] as $dm )
  82. {
  83. if ( ! empty( $dm ) )
  84. {
  85. $dm2 = ( ! preg_match( "/^(http|https|ftp|gopher)\:\/\//", $dm ) ) ? "http://" . $dm : $dm;
  86. if ( nv_is_url( $dm2 ) )
  87. {
  88. $my_domains[] = $dm;
  89. }
  90. }
  91. }
  92. }
  93. $my_domains = array_unique( $my_domains );
  94. $array_config_global['my_domains'] = implode( ",", $my_domains );
  95. $array_config_global['cookie_prefix'] = filter_text_input( 'cookie_prefix', 'post', '', 1, 255 );
  96. $array_config_global['session_prefix'] = filter_text_input( 'session_prefix', 'post', '', 1, 255 );
  97. $array_config_global['gzip_method'] = $nv_Request->get_int( 'gzip_method', 'post' );
  98. $array_config_global['online_upd'] = $nv_Request->get_int( 'online_upd', 'post' );
  99. $array_config_global['statistic'] = $nv_Request->get_int( 'statistic', 'post' );
  100. $array_config_global['lang_multi'] = $nv_Request->get_int( 'lang_multi', 'post' );
  101. $array_config_global['proxy_blocker'] = $nv_Request->get_int( 'proxy_blocker', 'post' );
  102. if ( ! isset( $proxy_blocker_array[$array_config_global['proxy_blocker']] ) )
  103. {
  104. $array_config_global['proxy_blocker'] = 0;
  105. }
  106. $array_config_global['str_referer_blocker'] = $nv_Request->get_int( 'str_referer_blocker', 'post' );
  107. if ( $sys_info['supports_rewrite'] !== false )
  108. {
  109. $array_config_global['is_url_rewrite'] = $nv_Request->get_int( 'is_url_rewrite', 'post' );
  110. if ( $array_config_global['lang_multi'] == 0 )
  111. {
  112. $array_config_global['rewrite_optional'] = $nv_Request->get_int( 'rewrite_optional', 'post' );
  113. }
  114. else
  115. {
  116. $array_config_global['rewrite_optional'] = 0;
  117. }
  118. }
  119. if ( isset( $array_config_global['is_url_rewrite'] ) and $array_config_global['is_url_rewrite'] == 1 )
  120. {
  121. require_once ( NV_ROOTDIR . "/includes/rewrite.php" );
  122. $errormess = nv_rewrite_change( $array_config_global );
  123. if ( ! empty( $errormess ) )
  124. {
  125. $array_config_global['is_url_rewrite'] = 0;
  126. $array_config_global['rewrite_optional'] = 0;
  127. }
  128. }
  129. foreach ( $array_config_global as $config_name => $config_value )
  130. {
  131. $db->sql_query( "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET
  132. `config_value`=" . $db->dbescape_string( $config_value ) . "
  133. WHERE `config_name` = " . $db->dbescape_string( $config_name ) . "
  134. AND `lang` = 'sys' AND `module`='global'
  135. LIMIT 1" );
  136. }
  137. nv_save_file_config_global();
  138. if ( empty( $errormess ) )
  139. {
  140. Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass() );
  141. exit();
  142. }
  143. else
  144. {
  145. $sql = $db->constructQuery( "SELECT `module`, `config_name`, `config_value` FROM `" . NV_CONFIG_GLOBALTABLE . "`
  146. WHERE `lang`='" . NV_LANG_DATA . "' ORDER BY `module` ASC", NV_LANG_DATA );
  147. $result = $db->sql_query( $sql );
  148. while ( list( $c_module, $c_config_name, $c_config_value ) = $db->sql_fetchrow( $result ) )
  149. {
  150. if ( $c_module == "global" )
  151. {
  152. $global_config[$c_config_name] = $c_config_value;
  153. }
  154. else
  155. {
  156. $module_config[$c_module][$c_config_name] = $c_config_value;
  157. }
  158. }
  159. }
  160. }
  161. $captcha_array = array( //
  162. 0 => $lang_module['captcha_0'], //
  163. 1 => $lang_module['captcha_1'], //
  164. 2 => $lang_module['captcha_2'], //
  165. 3 => $lang_module['captcha_3'], //
  166. 4 => $lang_module['captcha_4'], //
  167. 5 => $lang_module['captcha_5'], //
  168. 6 => $lang_module['captcha_6'], //
  169. 7 => $lang_module['captcha_7'] //
  170. );
  171. $array_config_global['gzip_method'] = ( $global_config['gzip_method'] ) ? " checked" : "";
  172. $array_config_global['online_upd'] = ( $global_config['online_upd'] ) ? " checked" : "";
  173. $array_config_global['statistic'] = ( $global_config['statistic'] ) ? " checked" : "";
  174. $array_config_global['lang_multi'] = ( $global_config['lang_multi'] ) ? " checked" : "";
  175. $array_config_global['str_referer_blocker'] = ( $global_config['str_referer_blocker'] ) ? " checked" : "";
  176. $array_config_global['my_domains'] = implode( ",", $global_config['my_domains'] );
  177. $xtpl = new XTemplate( "system.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file . "" );
  178. $xtpl->assign( 'LANG', $lang_module );
  179. $xtpl->assign( 'DATA', $array_config_global );
  180. foreach ( $themeadmin_array as $folder )
  181. {
  182. $xtpl->assign( 'SELECTED', ( $global_config['admin_theme'] == $folder ) ? ' selected="selected"' : '' );
  183. $xtpl->assign( 'SITE_THEME_ADMIN', $folder );
  184. $xtpl->parse( 'main.admin_theme' );
  185. }
  186. foreach ( $captcha_array as $gfx_chk_i => $gfx_chk_lang )
  187. {
  188. $xtpl->assign( 'GFX_CHK_SELECTED', ( $global_config['gfx_chk'] == $gfx_chk_i ) ? ' selected="selected"' : '' );
  189. $xtpl->assign( 'GFX_CHK_VALUE', $gfx_chk_i );
  190. $xtpl->assign( 'GFX_CHK_TITLE', $gfx_chk_lang );
  191. $xtpl->parse( 'main.opcaptcha' );
  192. }
  193. foreach ( $proxy_blocker_array as $proxy_blocker_i => $proxy_blocker_v )
  194. {
  195. $xtpl->assign( 'PROXYSELECTED', ( $global_config['proxy_blocker'] == $proxy_blocker_i ) ? ' selected="selected"' : '' );
  196. $xtpl->assign( 'PROXYOP', $proxy_blocker_i );
  197. $xtpl->assign( 'PROXYVALUE', $proxy_blocker_v );
  198. $xtpl->parse( 'main.proxy_blocker' );
  199. }
  200. if ( $sys_info['supports_rewrite'] !== false )
  201. {
  202. $xtpl->assign( 'CHECKED1', ( $global_config['is_url_rewrite'] == 1 ) ? ' checked ' : '' );
  203. $xtpl->parse( 'main.support_rewrite' );
  204. }
  205. if ( $sys_info['supports_rewrite'] !== false and $global_config['lang_multi'] == 0 )
  206. {
  207. $xtpl->assign( 'CHECKED2', ( $global_config['rewrite_optional'] == 1 ) ? ' checked ' : '' );
  208. $xtpl->parse( 'main.rewrite_optional' );
  209. }
  210. foreach ( $allow_sitelangs as $lang_i )
  211. {
  212. $xtpl->assign( 'LANGOP', $lang_i );
  213. $xtpl->assign( 'SELECTED', ( $lang_i == $global_config['site_lang'] ) ? "selected='selected'" : "" );
  214. $xtpl->assign( 'LANGVALUE', $language_array[$lang_i]['name'] );
  215. $xtpl->parse( 'main.site_lang_option' );
  216. }
  217. $timezone_array = array_keys( nv_parse_ini_file( NV_ROOTDIR . '/includes/ini/timezone.ini', true ) );
  218. foreach ( $timezone_array as $site_timezone_i )
  219. {
  220. $xtpl->assign( 'TIMEZONEOP', $site_timezone_i );
  221. $xtpl->assign( 'TIMEZONESELECTED', ( $site_timezone_i == $global_config['site_timezone'] ) ? "selected='selected'" : "" );
  222. $xtpl->assign( 'TIMEZONELANGVALUE', $site_timezone_i );
  223. $xtpl->parse( 'main.opsite_timezone' );
  224. }
  225. $xtpl->parse( 'main' );
  226. $content = "";
  227. if ( $errormess != "" )
  228. {
  229. $content .= "<div class=\"quote\" style=\"width:780px;\">\n";
  230. $content .= "<blockquote class=\"error\"><span>" . $errormess . "</span></blockquote>\n";
  231. $content .= "</div>\n";
  232. $content .= "<div class=\"clear\"></div>\n";
  233. }
  234. $content .= $xtpl->text( 'main' );
  235. include ( NV_ROOTDIR . "/includes/header.php" );
  236. echo nv_admin_theme( $content );
  237. include ( NV_ROOTDIR . "/includes/footer.php" );
  238. ?>