PageRenderTime 43ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/01.Source/01.CORE/includes/ini.php

http://creative-portal.googlecode.com/
PHP | 150 lines | 121 code | 15 blank | 14 comment | 29 complexity | 606f53e1d07992f3acc8cd51806f73fe 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 31/05/2010, 00:36
  7. */
  8. if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );
  9. if ( headers_sent() || connection_status() != 0 || connection_aborted() )
  10. {
  11. trigger_error( "Warning: Headers already sent", E_USER_WARNING );
  12. }
  13. if ( $sys_info['ini_set_support'] )
  14. {
  15. ini_set( 'magic_quotes_runtime', 'Off' );
  16. ini_set( 'magic_quotes_sybase', 'Off' );
  17. ini_set( 'session.save_handler', 'files' );
  18. ini_set( 'session.use_trans_sid', 0 );
  19. ini_set( 'session.auto_start', 0 );
  20. ini_set( 'session.use_cookies', 1 );
  21. ini_set( 'session.use_only_cookies', 1 );
  22. ini_set( 'session.cookie_httponly', 1 );
  23. ini_set( 'session.gc_probability', 1 ); //Kha nang chay Garbage Collection - trinh xoa session da het han truoc khi bat dau session_start();
  24. ini_set( 'session.gc_divisor', 1000 ); //gc_probability / gc_divisor = phan tram (phan nghin) kha nang chay Garbage Collection
  25. ini_set( 'session.gc_maxlifetime', 3600 ); //thoi gian sau khi het han phien lam viec de Garbage Collection tien hanh xoa, 60 phut
  26. ini_set( 'allow_url_fopen', 1 );
  27. ini_set( "user_agent", 'NV3' );
  28. ini_set( "default_charset", $global_config['site_charset'] );
  29. ini_set( 'sendmail_from', $global_config['site_email'] );
  30. $memoryLimitMB = ( integer )ini_get( 'memory_limit' );
  31. if ( $memoryLimitMB < 64 )
  32. {
  33. ini_set( "memory_limit", "64M" );
  34. }
  35. ini_set( 'arg_separator.output', '&' );
  36. ini_set( 'auto_detect_line_endings', 0 );
  37. }
  38. $sys_info['safe_mode'] = ( ini_get( 'safe_mode' ) == '1' || strtolower( ini_get( 'safe_mode' ) ) == 'on' ) ? 1 : 0;
  39. $sys_info['php_support'] = ( function_exists( 'version_compare' ) and version_compare( phpversion(), '5.0.0', '>=' ) ) ? 1 : 0;
  40. $sys_info['mysql_support'] = ( extension_loaded( 'mysql' ) and function_exists( 'mysql_connect' ) ) ? 1 : 0;
  41. $sys_info['opendir_support'] = ( function_exists( 'opendir' ) and ! in_array( 'opendir', $sys_info['disable_functions'] ) ) ? 1 : 0;
  42. $sys_info['gd_support'] = ( extension_loaded( 'gd' ) ) ? 1 : 0;
  43. $sys_info['fileuploads_support'] = ( ini_get( 'file_uploads' ) ) ? 1 : 0;
  44. $sys_info['zlib_support'] = ( extension_loaded( 'zlib' ) ) ? 1 : 0;
  45. $sys_info['session_support'] = ( extension_loaded( 'session' ) ) ? 1 : 0;
  46. $sys_info['mb_support'] = ( extension_loaded( 'mbstring' ) ) ? 1 : 0;
  47. $sys_info['iconv_support'] = ( extension_loaded( 'iconv' ) ) ? 1 : 0;
  48. $sys_info['curl_support'] = ( extension_loaded( 'curl' ) and function_exists( "curl_init" ) and ! in_array( 'curl_init', $sys_info['disable_functions'] ) ) ? 1 : 0;
  49. $sys_info['allowed_set_time_limit'] = ( ! $sys_info['safe_mode'] and function_exists( "set_time_limit" ) and ! in_array( 'set_time_limit', $sys_info['disable_functions'] ) ) ? 1 : 0;
  50. $sys_info['os'] = strtoupper( ( function_exists( 'php_uname' ) and ! in_array( 'php_uname', $sys_info['disable_functions'] ) and strtoupper( php_uname( 's' ) ) != '' ) ? php_uname( 's' ) : PHP_OS );
  51. if ( $sys_info['os'] == "LINUX" )
  52. {
  53. $sys_info['ftp_support'] = ( function_exists( "ftp_connect" ) and ! in_array( 'ftp_connect', $sys_info['disable_functions'] ) and function_exists( "ftp_chmod" ) and ! in_array( 'ftp_chmod', $sys_info['disable_functions'] ) and function_exists( "ftp_mkdir" ) and ! in_array( 'ftp_mkdir', $sys_info['disable_functions'] ) and function_exists( "ftp_chdir" ) and ! in_array( 'ftp_chdir', $sys_info['disable_functions'] ) and function_exists( "ftp_nlist" ) and ! in_array( 'ftp_nlist', $sys_info['disable_functions'] ) ) ? 1 : 0;
  54. }
  55. else
  56. {
  57. $sys_info['ftp_support'] = 0;
  58. }
  59. //Neu he thong khong ho tro php se bao loi
  60. if ( ! $sys_info['php_support'] )
  61. {
  62. trigger_error( "You are running an unsupported PHP version. Please upgrade to PHP 5.0 or higher before trying to install Nukeviet Portal", 256 );
  63. }
  64. //Neu he thong khong ho tro MySQL se bao loi
  65. if ( ! $sys_info['mysql_support'] )
  66. {
  67. trigger_error( "MySQL is not supported", 256 );
  68. }
  69. //Neu he thong khong ho tro opendir se bao loi
  70. if ( ! $sys_info['opendir_support'] )
  71. {
  72. trigger_error( "Opendir function is not supported", 256 );
  73. }
  74. //Neu he thong khong ho tro GD se bao loi
  75. if ( ! $sys_info['gd_support'] )
  76. {
  77. trigger_error( "GD not installed", 256 );
  78. }
  79. //Neu he thong khong ho tro session se bao loi
  80. if ( ! $sys_info['session_support'] )
  81. {
  82. trigger_error( "Session object not supported", 256 );
  83. }
  84. if ( $sys_info['allowed_set_time_limit'] )
  85. {
  86. if ( defined( 'NV_WYSIWYG' ) )
  87. {
  88. set_time_limit( 0 );
  89. }
  90. else
  91. {
  92. set_time_limit( 300 );
  93. }
  94. }
  95. //Xac dinh tien ich mo rong lam viec voi string
  96. $sys_info['string_handler'] = $sys_info['mb_support'] ? 'mb' : ( $sys_info['iconv_support'] ? 'iconv' : 'php' );
  97. //Kiem tra ho tro rewrite
  98. $sys_info['supports_rewrite'] = false;
  99. if ( function_exists( 'apache_get_modules' ) )
  100. {
  101. $apache_modules = apache_get_modules();
  102. if ( in_array( "mod_rewrite", $apache_modules ) )
  103. {
  104. $sys_info['supports_rewrite'] = "rewrite_mode_apache";
  105. }
  106. }
  107. elseif ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.' ) !== false )
  108. {
  109. if ( isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( php_sapi_name() == 'cgi-fcgi' ) && class_exists( 'DOMDocument' ) )
  110. {
  111. $sys_info['supports_rewrite'] = "rewrite_mode_iis";
  112. }
  113. }
  114. elseif ( $sys_info['os'] == "LINUX" )
  115. {
  116. $sys_info['supports_rewrite'] = "rewrite_mode_apache";
  117. }
  118. //Xac dinh function nen string
  119. $sys_info['str_compress'] = array();
  120. if ( $sys_info['zlib_support'] )
  121. {
  122. if ( function_exists( 'gzcompress' ) and function_exists( 'gzuncompress' ) )
  123. {
  124. $sys_info['str_compress'] = array(
  125. 'gzcompress', 'gzuncompress'
  126. );
  127. }
  128. elseif ( function_exists( 'gzdeflate' ) and function_exists( 'gzinflate' ) )
  129. {
  130. $sys_info['str_compress'] = array(
  131. 'gzdeflate', 'gzinflate'
  132. );
  133. }
  134. }
  135. ?>