PageRenderTime 22ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/nukeviet/admin/modules/settings/system.php

http://nuke-viet.googlecode.com/
PHP | 302 lines | 244 code | 52 blank | 6 comment | 40 complexity | 28d35335d2f0b493928a2c9f54a344c8 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.x
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2012 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-2-2010 12:55
  7. */
  8. if( ! defined( 'NV_IS_FILE_SETTINGS' ) ) die( 'Stop!!!' );
  9. $adminThemes = array( '' );
  10. $adminThemes = array_merge( $adminThemes, nv_scandir( NV_ROOTDIR . "/themes", $global_config['check_theme_admin'] ) );
  11. unset( $adminThemes[0] );
  12. $closed_site_Modes = array( //
  13. '0' => $lang_module['closed_site_0'], //
  14. '1' => $lang_module['closed_site_1'], //
  15. '2' => $lang_module['closed_site_2'], //
  16. '3' => $lang_module['closed_site_3'] //
  17. );
  18. $captcha_array = array( //
  19. 0 => $lang_module['captcha_0'], //
  20. 1 => $lang_module['captcha_1'], //
  21. 2 => $lang_module['captcha_2'], //
  22. 3 => $lang_module['captcha_3'], //
  23. 4 => $lang_module['captcha_4'], //
  24. 5 => $lang_module['captcha_5'], //
  25. 6 => $lang_module['captcha_6'], //
  26. 7 => $lang_module['captcha_7'] //
  27. );
  28. $captcha_type_array = array( //
  29. 0 => $lang_module['captcha_type_0'], //
  30. 1 => $lang_module['captcha_type_1'] //
  31. );
  32. $allow_sitelangs = array();
  33. foreach( $global_config['allow_sitelangs'] as $lang_i )
  34. {
  35. if( file_exists( NV_ROOTDIR . "/language/" . $lang_i . "/global.php" ) )
  36. {
  37. $allow_sitelangs[] = $lang_i;
  38. }
  39. }
  40. $timezone_array = array_keys( nv_parse_ini_file( NV_ROOTDIR . '/includes/ini/timezone.ini', true ) );
  41. $proxy_blocker_array = array( //
  42. 0 => $lang_module['proxy_blocker_0'], //
  43. 1 => $lang_module['proxy_blocker_1'], //
  44. 2 => $lang_module['proxy_blocker_2'], //
  45. 3 => $lang_module['proxy_blocker_3']
  46. );
  47. if( $nv_Request->isset_request( 'submit', 'post' ) )
  48. {
  49. $array_config_global = array();
  50. $admin_theme = $nv_Request->get_string( 'admin_theme', 'post' );
  51. if( ! empty( $admin_theme ) and in_array( $admin_theme, $adminThemes ) )
  52. {
  53. $array_config_global['admin_theme'] = $admin_theme;
  54. }
  55. $closed_site = $nv_Request->get_int( 'closed_site', 'post' );
  56. if( isset( $closed_site_Modes[$closed_site] ) )
  57. {
  58. $array_config_global['closed_site'] = $closed_site;
  59. }
  60. $gfx_chk = $nv_Request->get_int( 'gfx_chk', 'post' );
  61. if( isset( $captcha_array[$gfx_chk] ) )
  62. {
  63. $array_config_global['gfx_chk'] = $gfx_chk;
  64. }
  65. $captcha_type = $nv_Request->get_int( 'captcha_type', 'post' );
  66. if( isset( $captcha_type_array[$captcha_type] ) )
  67. {
  68. $array_config_global['captcha_type'] = $captcha_type;
  69. }
  70. $site_email = filter_text_input( 'site_email', 'post', '', 1, 255 );
  71. if( nv_check_valid_email( $site_email ) == '' )
  72. {
  73. $array_config_global['site_email'] = $site_email;
  74. }
  75. $error_send_email = filter_text_input( 'error_send_email', 'post', '', 1, 255 );
  76. if( nv_check_valid_email( $error_send_email ) == '' )
  77. {
  78. $array_config_global['error_send_email'] = $error_send_email;
  79. }
  80. $array_config_global['site_phone'] = filter_text_input( 'site_phone', 'post', '', 1, 255 );
  81. $site_lang = filter_text_input( 'site_lang', 'post', '', 1, 255 );
  82. if( ! empty( $site_lang ) and in_array( $site_lang, $allow_sitelangs ) )
  83. {
  84. $array_config_global['site_lang'] = $site_lang;
  85. }
  86. $site_timezone = filter_text_input( 'site_timezone', 'post', '', 0, 255 );
  87. if( empty( $site_timezone ) or ( ! empty( $site_timezone ) and ( in_array( $site_timezone, $timezone_array ) or $site_timezone == "byCountry" ) ) )
  88. {
  89. $array_config_global['site_timezone'] = $site_timezone;
  90. }
  91. $array_config_global['date_pattern'] = filter_text_input( 'date_pattern', 'post', '', 1, 255 );
  92. $array_config_global['time_pattern'] = filter_text_input( 'time_pattern', 'post', '', 1, 255 );
  93. $my_domains = filter_text_input( 'my_domains', 'post', '' );
  94. $array_config_global['my_domains'] = array( NV_SERVER_NAME );
  95. if( ! empty( $my_domains ) )
  96. {
  97. $my_domains = array_map( "trim", explode( ",", $my_domains ) );
  98. foreach( $my_domains as $dm )
  99. {
  100. if( ! empty( $dm ) )
  101. {
  102. $dm2 = ( ! preg_match( "/^(http|https|ftp|gopher)\:\/\//", $dm ) ) ? "http://" . $dm : $dm;
  103. if( nv_is_url( $dm2 ) or $dm == "localhost" or filter_var($dm, FILTER_VALIDATE_IP))
  104. {
  105. $array_config_global['my_domains'][] = $dm;
  106. }
  107. }
  108. }
  109. }
  110. $array_config_global['my_domains'] = array_unique( $array_config_global['my_domains'] );
  111. $array_config_global['my_domains'] = implode( ",", $array_config_global['my_domains'] );
  112. $array_config_global['cookie_prefix'] = filter_text_input( 'cookie_prefix', 'post', '', 1, 255 );
  113. $array_config_global['session_prefix'] = filter_text_input( 'session_prefix', 'post', '', 1, 255 );
  114. $array_config_global['searchEngineUniqueID'] = filter_text_input( 'searchEngineUniqueID', 'post', '' );
  115. if( preg_match( "/[^a-zA-Z0-9\:\-\_\.]/", $array_config_global['searchEngineUniqueID'] ) ) $array_config_global['searchEngineUniqueID'] = "";
  116. $array_config_global['gzip_method'] = $nv_Request->get_int( 'gzip_method', 'post' );
  117. $array_config_global['lang_multi'] = $nv_Request->get_int( 'lang_multi', 'post' );
  118. $array_config_global['optActive'] = $nv_Request->get_int( 'optActive', 'post' );
  119. $array_config_global['getloadavg'] = $nv_Request->get_int( 'getloadavg', 'post' );
  120. $array_config_global['str_referer_blocker'] = $nv_Request->get_int( 'str_referer_blocker', 'post' );
  121. $array_config_global['is_url_rewrite'] = $nv_Request->get_int( 'is_url_rewrite', 'post', 0 );
  122. $proxy_blocker = $nv_Request->get_int( 'proxy_blocker', 'post' );
  123. if( isset( $proxy_blocker_array[$proxy_blocker] ) )
  124. {
  125. $array_config_global['proxy_blocker'] = $proxy_blocker;
  126. }
  127. if( $array_config_global['lang_multi'] == 0 )
  128. {
  129. $array_config_global['rewrite_optional'] = $nv_Request->get_int( 'rewrite_optional', 'post', 0 );
  130. $array_config_global['lang_geo'] = 0;
  131. }
  132. else
  133. {
  134. $array_config_global['rewrite_optional'] = 0;
  135. $array_config_global['lang_geo'] = $nv_Request->get_int( 'lang_geo', 'post', 0 );
  136. }
  137. foreach( $array_config_global as $config_name => $config_value )
  138. {
  139. $db->sql_query( "REPLACE INTO `" . NV_CONFIG_GLOBALTABLE . "` (`lang`, `module`, `config_name`, `config_value`) VALUES ('sys', 'global', '" . mysql_real_escape_string( $config_name ) . "', " . $db->dbescape( $config_value ) . ")" );
  140. }
  141. nv_save_file_config_global();
  142. if( $global_config['is_url_rewrite'] != $array_config_global['is_url_rewrite'] or $global_config['rewrite_optional'] != $array_config_global['rewrite_optional'] )
  143. {
  144. $array_config_global['rewrite_endurl'] = $global_config['rewrite_endurl'];
  145. $array_config_global['rewrite_exturl'] = $global_config['rewrite_exturl'];
  146. nv_rewrite_change( $array_config_global );
  147. }
  148. Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass() );
  149. exit();
  150. }
  151. $page_title = $lang_module['global_config'];
  152. $optActive_Modes = array(
  153. '0' => $lang_module['optActive_no'],
  154. '1' => $lang_module['optActive_all'],
  155. '2' => $lang_module['optActive_site'],
  156. '3' => $lang_module['optActive_admin']
  157. );
  158. $sql = "SELECT `config_name`, `config_value` FROM `" . NV_CONFIG_GLOBALTABLE . "` WHERE `lang`='sys' AND `module`='global'";
  159. $result = $db->sql_query( $sql );
  160. while( list( $c_config_name, $c_config_value ) = $db->sql_fetchrow( $result ) )
  161. {
  162. $array_config_global[$c_config_name] = $c_config_value;
  163. }
  164. $lang_multi = $array_config_global['lang_multi'];
  165. $array_config_global['gzip_method'] = ( $array_config_global['gzip_method'] ) ? ' checked="checked"' : '';
  166. $array_config_global['lang_multi'] = ( $array_config_global['lang_multi'] ) ? ' checked="checked"' : '';
  167. $array_config_global['str_referer_blocker'] = ( $array_config_global['str_referer_blocker'] ) ? ' checked="checked"' : '';
  168. $array_config_global['getloadavg'] = ( $array_config_global['getloadavg'] ) ? ' checked="checked"' : '';
  169. $array_config_global['searchEngineUniqueID'] = isset( $array_config_global['searchEngineUniqueID'] ) ? $array_config_global['searchEngineUniqueID'] : "";
  170. $xtpl = new XTemplate( "system.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file . "" );
  171. $xtpl->assign( 'LANG', $lang_module );
  172. $xtpl->assign( 'DATA', $array_config_global );
  173. foreach( $adminThemes as $name )
  174. {
  175. $xtpl->assign( 'THEME_NAME', $name );
  176. $xtpl->assign( 'THEME_SELECTED', ( $name == $array_config_global['admin_theme'] ? " selected=\"selected\"" : "" ) );
  177. $xtpl->parse( 'main.admin_theme' );
  178. }
  179. foreach( $closed_site_Modes as $value => $name )
  180. {
  181. $xtpl->assign( 'MODE_VALUE', $value );
  182. $xtpl->assign( 'MODE_NAME', $name );
  183. $xtpl->assign( 'MODE_SELECTED', ( $value == $array_config_global['closed_site'] ? " selected=\"selected\"" : "" ) );
  184. $xtpl->parse( 'main.closed_site_mode' );
  185. }
  186. foreach( $captcha_array as $gfx_chk_i => $gfx_chk_lang )
  187. {
  188. $xtpl->assign( 'GFX_CHK_SELECTED', ( $array_config_global['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( $captcha_type_array as $captcha_type_i => $captcha_type_lang )
  194. {
  195. $xtpl->assign( 'CAPTCHA_TYPE_SELECTED', ( $array_config_global['captcha_type'] == $captcha_type_i ) ? ' selected="selected"' : '' );
  196. $xtpl->assign( 'CAPTCHA_TYPE_VALUE', $captcha_type_i );
  197. $xtpl->assign( 'CAPTCHA_TYPE_TITLE', $captcha_type_lang );
  198. $xtpl->parse( 'main.captcha_type' );
  199. }
  200. foreach( $proxy_blocker_array as $proxy_blocker_i => $proxy_blocker_v )
  201. {
  202. $xtpl->assign( 'PROXYSELECTED', ( $array_config_global['proxy_blocker'] == $proxy_blocker_i ) ? ' selected="selected"' : '' );
  203. $xtpl->assign( 'PROXYOP', $proxy_blocker_i );
  204. $xtpl->assign( 'PROXYVALUE', $proxy_blocker_v );
  205. $xtpl->parse( 'main.proxy_blocker' );
  206. }
  207. $xtpl->assign( 'CHECKED1', ( $array_config_global['is_url_rewrite'] == 1 ) ? ' checked ' : '' );
  208. if( $lang_multi == 0 )
  209. {
  210. $xtpl->assign( 'CHECKED2', ( $array_config_global['rewrite_optional'] == 1 ) ? ' checked ' : '' );
  211. $xtpl->parse( 'main.rewrite_optional' );
  212. }
  213. if( $lang_multi and sizeof( $global_config['allow_sitelangs'] ) > 1 )
  214. {
  215. $xtpl->assign( 'CONFIG_LANG_GEO', NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=language&op&' . NV_OP_VARIABLE . '=countries' );
  216. $xtpl->assign( 'CHECKED_LANG_GEO', ( $array_config_global['lang_geo'] == 1 ) ? ' checked ' : '' );
  217. foreach( $allow_sitelangs as $lang_i )
  218. {
  219. $xtpl->assign( 'LANGOP', $lang_i );
  220. $xtpl->assign( 'SELECTED', ( $lang_i == $array_config_global['site_lang'] ) ? "selected='selected'" : "" );
  221. $xtpl->assign( 'LANGVALUE', $language_array[$lang_i]['name'] );
  222. $xtpl->parse( 'main.lang_multi.site_lang_option' );
  223. }
  224. $xtpl->parse( 'main.lang_multi' );
  225. }
  226. foreach( $optActive_Modes as $key => $value )
  227. {
  228. $xtpl->assign( 'OPTACTIVE_OP', $key );
  229. $xtpl->assign( 'OPTACTIVE_SELECTED', ( $key == $array_config_global['optActive'] ) ? "selected='selected'" : "" );
  230. $xtpl->assign( 'OPTACTIVE_TEXT', $value );
  231. $xtpl->parse( 'main.optActive' );
  232. }
  233. $xtpl->assign( 'TIMEZONEOP', "byCountry" );
  234. $xtpl->assign( 'TIMEZONESELECTED', ( $array_config_global['site_timezone'] == "byCountry" ) ? "selected='selected'" : "" );
  235. $xtpl->assign( 'TIMEZONELANGVALUE', $lang_module['timezoneByCountry'] );
  236. $xtpl->parse( 'main.opsite_timezone' );
  237. sort( $timezone_array );
  238. foreach( $timezone_array as $site_timezone_i )
  239. {
  240. $xtpl->assign( 'TIMEZONEOP', $site_timezone_i );
  241. $xtpl->assign( 'TIMEZONESELECTED', ( $site_timezone_i == $array_config_global['site_timezone'] ) ? "selected='selected'" : "" );
  242. $xtpl->assign( 'TIMEZONELANGVALUE', $site_timezone_i );
  243. $xtpl->parse( 'main.opsite_timezone' );
  244. }
  245. $xtpl->parse( 'main' );
  246. $content = $xtpl->text( 'main' );
  247. include ( NV_ROOTDIR . "/includes/header.php" );
  248. echo nv_admin_theme( $content );
  249. include ( NV_ROOTDIR . "/includes/footer.php" );
  250. ?>