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

/admin/modules/settings/system.php

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