📄 header_php.php
字号:
<?php
/**
* @package Installer
* @access private
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: header_php.php 7421 2007-11-11 09:20:27Z drbyte $
*
* @TODO - http://dev.mysql.com/doc/refman/5.0/en/user-resources.html
*/
$advanced_mode = (isset($_GET['adv'])) ? true : false;
$zen_cart_previous_version_installed = false;
$zen_cart_database_connect_OK = false;
$zen_cart_allow_database_upgrade = false;
$zdb_sql_cache = '';
$configWriteOverride = (isset($_GET['overrideconfig'])) ? true : false;
if (file_exists('../includes/configure.php')) {
// read the existing configure.php file(s) to get values and guess whether it looks like a valid prior install
if (zen_read_config_value('HTTP_SERVER') == 'http://localhost') $zen_cart_previous_version_installed = 'maybe';
if (zen_read_config_value('DIR_FS_CATALOG') == '/var/www/html/') $zen_cart_previous_version_installed = 'maybe';
if (zen_read_config_value('HTTP_SERVER') != '' ) $zen_cart_previous_version_installed = true;
if (zen_read_config_value('DIR_WS_CLASSES') != '' ) $zen_cart_previous_version_installed = true;
if (zen_read_config_value('DIR_FS_CATALOG') != '' ) $zen_cart_previous_version_installed = true;
if (strpos(zen_read_config_value('DIR_FS_SQL_CACHE'),'/path/to/')>0) $zen_cart_previous_version_installed = false;
if (zen_read_config_value('DB_DATABASE') == '' ) $zen_cart_previous_version_installed = false;
//read the configure.php file and look for hints that it's just a copy of dist-configure.php
$lines = file('../includes/configure.php');
foreach ($lines as $line) {
if (substr_count($line,'dist-configure.php') > 0) $zen_cart_previous_version_installed = false;
} //end foreach
$zdb_type = zen_read_config_value('DB_TYPE');
$zdb_prefix = zen_read_config_value('DB_PREFIX');
$zdb_server = zen_read_config_value('DB_SERVER');
$zdb_user = zen_read_config_value('DB_SERVER_USERNAME');
$zdb_pwd = zen_read_config_value('DB_SERVER_PASSWORD');
$zdb_name = zen_read_config_value('DB_DATABASE');
$zdb_sql_cache= zen_read_config_value('DIR_FS_SQL_CACHE');
if (strpos($zdb_sql_cache,'/path/to/')>0) $zdb_sql_cache=''; // /path/to/ comes from dist-configure.php. Invalid, thus make null.
if (ZC_UPG_DEBUG==true) {
echo 'db-type=' . $zdb_type . '<br>';
echo 'db-prefix=' . $zdb_prefix . '<br>';
echo 'db-host=' . $zdb_server . '<br>';
echo 'db-name=' . $zdb_name . '<br>';
echo 'db-user=' . $zdb_user . '<br>';
echo 'cache_folder=' . $zdb_sql_cache . '<br>';
}
define('DIR_FS_CATALOG', '../');
define('DB_TYPE', 'mysql');
define('SQL_CACHE_METHOD', 'none');
if ($zdb_type!='' && $zdb_name !='') {
// now check database connectivity
require('../includes/' . 'classes/db/' . $zdb_type . '/query_factory.php');
$zc_install->functionExists($zdb_type, '', '');
$zc_install->dbConnect($zdb_type, $zdb_server, $zdb_name, $zdb_user, $zdb_pwd, '', '');
if ($zc_install->error == false) $zen_cart_database_connect_OK = true;
if ($zc_install->error == true) {
$zen_cart_previous_version_installed = false;
if (ZC_UPG_DEBUG==true) echo 'db-connection failed using the credentials supplied';
if (ZC_UPG_DEBUG==true) $zc_install->logDetails('db-connection failed using the credentials supplied');
}
//reset error-check class after connection attempt
$zc_install->error = false;
$zc_install->fatal_error = false;
$zc_install->error_list = array();
} //endif check for db_type and db_name defined
if ($zen_cart_database_connect_OK) { #1
//open database connection to run queries against it
$db_test = new queryFactory;
$db_test->Connect($zdb_server, $zdb_user, $zdb_pwd, $zdb_name) or $zen_cart_database_connect_OK = false;
if ($zen_cart_database_connect_OK) { //#2 This check is done again just in case connect fails on previous line
//set database table prefix
define('DB_PREFIX',$zdb_prefix);
// Now check the database for what version it's at, if found
require('includes/classes/class.installer_version_manager.php');
$dbinfo = new versionManager;
// Check to see whether we should offer the option to upgrade "database only", rather than rebuild configure.php files too.
// For v1.2.1, the only check we need is whether we're at v1.2.0 already or not.
// Future versions may require more extensive checking if the core configure.php files change.
// NOTE: This flag is also used to determine whether or not we prevent moving to next screen if the configure.php files are not writable
if ($dbinfo->found_version >= '1.2.0') {
$zen_cart_allow_database_upgrade=true;
}
} //endif $zen_cart_database_connect_OK #2
} //endif $zen_cart_database_connect_OK
} else {
$zen_cart_previous_version_installed = false;
if (ZC_UPG_DEBUG==true) echo 'NOTE: Did not find existing configure.php file. Assuming fresh install.';
if (ZC_UPG_DEBUG==true) $zc_install->logDetails('NOTE: Did not find existing configure.php file. Assuming fresh install.');
} //endif exists configure.php
// if ($check_count > 1) $zen_cart_version_already_installed = false; // if more than one test failed, it must be a fresh install
if ($zen_cart_previous_version_installed == true && $zen_cart_database_connect_OK == true) {
$is_upgradable = true;
if ($dbinfo->zdb_configuration_table_found) {
$zdb_version_message = sprintf(LABEL_PREVIOUS_VERSION_NUMBER, $dbinfo->found_version);
} else {
$zdb_version_message = LABEL_PREVIOUS_VERSION_NUMBER_UNKNOWN;
}
}
///////////////////////////////////
// Run System Pre-Flight Check:
///////////////////////////////////
$status_check = array();
$status_check2 = array();
$dir_fs_www_root = $zc_install->detectDocumentRoot();
//Structure is this:
//$status_check[] = array('Importance' => '', 'Title' => '', 'Status' => '', 'Class' => '', 'HelpURL' =>'', 'HelpLabel'=>'');
//WebServer OS as reported by env check
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_WEBSERVER, 'Status' => getenv("SERVER_SOFTWARE"), 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//General info
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_HTTP_HOST, 'Status' => $_SERVER['HTTP_HOST'], 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
$path_trans = @$_SERVER['PATH_TRANSLATED'];
$path_trans_display = $path_trans;
if (empty($path_trans)) {
$path_trans_display = $_SERVER['SCRIPT_FILENAME'] . '(SCRIPT_FILENAME)';
$path_trans = $_SERVER['SCRIPT_FILENAME'];
}
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_PATH_TRANLSATED, 'Status' => $path_trans_display, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
$real_path = realpath(dirname(basename($PHP_SELF)).'/..');
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_REALPATH, 'Status' => $real_path, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//get list of disabled functions
$disabled_funcs = ini_get("disable_functions");
if (!strstr($disabled_funcs,'disk_free_space')) {
// get free space on disk
$disk_freespaceGB=round(@disk_free_space($path_trans)/1024/1024/1024,2);
$disk_freespaceMB=round(@disk_free_space($path_trans)/1024/1024,2);
if ($disk_freespaceGB >0) $status_check[] = array('Importance' => 'Info', 'Title' => LABEL_DISK_FREE_SPACE, 'Status' => $disk_freespaceGB . ' GB' . (($disk_freespaceGB==0) ? ' (can be ignored)' : ''), 'Class' => ($disk_freespaceMB<1000 && $disk_freespaceGB != 0)?'FAIL':'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
}
// Operating System as reported by PHP:
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_OS, 'Status' => PHP_OS, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//PHP mode (module, cgi, etc)
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_PHP_API_MODE, 'Status' => @php_sapi_name(), 'Class' => (@strstr(php_sapi_name(),'cgi') ? 'WARN' : 'NA'), 'HelpURL' =>ERROR_CODE_PHP_AS_CGI, 'HelpLabel'=>ERROR_TEXT_PHP_AS_CGI);
//Set Time Limit setting
$set_time_limit = ini_get("max_execution_time");
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_SET_TIME_LIMIT, 'Status' => $set_time_limit, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//get list of disabled functions
if (!zen_not_null($disabled_funcs)) $disabled_funcs = ini_get("disable_functions");
if (zen_not_null($disabled_funcs)) $status_check[] = array('Importance' => 'Recommended', 'Title' => LABEL_DISABLED_FUNCTIONS, 'Status' => $disabled_funcs, 'Class' => (@substr_count($disabled_funcs,'set_time_limit') ? 'WARN' : 'NA'), 'HelpURL' =>ERROR_CODE_DISABLE_FUNCTIONS, ERROR_TEXT_DISABLE_FUNCTIONS);
// Check Register Globals
$register_globals = ini_get("register_globals");
if ($register_globals == '' || $register_globals =='0' || strtoupper($register_globals) =='OFF') {
$register_globals = OFF; // Having register globals "off" is more secure
$this_class='OK';
} else {
$register_globals = "<span class='errors'>".ON.'</span>';
$this_class='WARN';
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -