📄 header_php.php
字号:
//session.trans_sid check
$php_session_trans_sid = (ini_get('session.use_trans_sid')) ? ON : OFF;
$status_check[] = array('Importance' => 'Recommended', 'Title' => LABEL_PHP_SESSION_TRANS_SID, 'Status' => $php_session_trans_sid, 'Class' => ($php_session_trans_sid==ON)?'WARN':'OK', 'HelpURL' =>ERROR_CODE_PHP_SESSION_TRANS_SID, 'HelpLabel'=>ERROR_TEXT_PHP_SESSION_TRANS_SID);
// Check for 'tmp' folder for file-based caching. This checks numerous places, and tests actual writing of a file to those folders.
$script_filename = $_SERVER['PATH_TRANSLATED'];
if (empty($script_filename)) {
$script_filename = $_SERVER['SCRIPT_FILENAME'];
}
$script_filename = str_replace('\\', '/', $script_filename);
$script_filename = str_replace('//', '/', $script_filename);
$dir_fs_www_root_array = explode('/', dirname($script_filename));
$dir_fs_www_root = array();
for ($i=0, $n=sizeof($dir_fs_www_root_array)-1; $i<$n; $i++) {
$dir_fs_www_root[] = $dir_fs_www_root_array[$i];
}
$dir_fs_www_root = implode('/', $dir_fs_www_root);
$session_save_path = (@ini_get('session.save_path')) ? ini_get('session.save_path') : UNKNOWN;
$session_save_path_writable = (@is_writable( $session_save_path )) ? WRITABLE : UNWRITABLE ;
$status_check2[3] = array('Importance' => 'Recommended', 'Title' => LABEL_PHP_EXT_SAVE_PATH, 'Status' => $session_save_path . ($session_save_path != UNKNOWN ? ' -->' . $session_save_path_writable : ''), 'Class' => ($session_save_path_writable ==WRITABLE || $session_save_path == UNKNOWN) ? 'OK' : 'WARN', 'HelpURL' =>ERROR_CODE_SESSION_SAVE_PATH, 'HelpLabel'=>ERROR_TEXT_SESSION_SAVE_PATH);
//check various options for cache storage:
//foreach (array(@ini_get("session.save_path"), '/tmp', '/var/lib/php/session', $dir_fs_www_root . '/tmp', $dir_fs_www_root . '/cache', 'c:/php/tmp', 'c:/php/sessiondata', 'c:/windows/temp', 'c:/temp') as $cache_test) {
foreach (array($dir_fs_www_root . '/cache') as $cache_test) {
if (is_dir($cache_test) && @is_writable($cache_test) ) { // does it exist? Is is writable?
$filename = $cache_test . '/zentest.tst';
$fp = @fopen($filename,"w"); // if this fails, then the file is not really writable
@fwrite($fp,'cache test');
@fclose($fp);
$fp = @fopen($filename,"rb"); // read it back to be sure it's ok
$contents = @fread($fp, filesize($filename));
@fclose($fp);
@unlink($filename);
if ($contents == 'cache test') {
$suggested_cache=$cache_test; // if contents were read ok, then path is OK
break;
}
}
}
$sugg_cache_class = 'OK'; //default
$sugg_cache_code = '';
$sugg_cache_text = '';
if ($suggested_cache == '') {
$suggested_cache = $dir_fs_www_root . '/cache'; //suggest to use catalog path if no alternative was found usable
$sugg_cache_class = 'WARN';
$sugg_cache_code = ERROR_CODE_CACHE_CUSTOM_NEEDED;
$sugg_cache_text = '<br />'.ERROR_TEXT_CACHE_CUSTOM_NEEDED; // the <br> tag is for line-wrap for a long message displayed
} elseif (!is_dir($suggested_cache)) {
$sugg_cache_code = ERROR_CODE_CACHE_DIR_ISDIR;
$sugg_cache_text = ERROR_TEXT_CACHE_DIR_ISDIR;
$sugg_cache_class = 'WARN';
} elseif (!@is_writable($suggested_cache)) {
$sugg_cache_code = ERROR_CODE_CACHE_DIR_ISWRITABLE;
$sugg_cache_text = ERROR_TEXT_CACHE_DIR_ISWRITABLE;
$sugg_cache_class = 'WARN';
}//endif $suggested_cache
$zdb_sql_cache_writable = (@is_writable($zdb_sql_cache)) ? WRITABLE : UNWRITABLE;
if ($zdb_sql_cache != '') $status_check[] = array('Importance' => 'Recommended', 'Title' => LABEL_CURRENT_CACHE_PATH, 'Status' => $zdb_sql_cache . ' -->' . $zdb_sql_cache_writable , 'Class' => ($zdb_sql_cache_writable ==WRITABLE) ? 'OK' : 'WARN', 'HelpURL' =>ERROR_CODE_CACHE_DIR_ISWRITEABLE, 'HelpLabel'=>ERROR_TEXT_CACHE_DIR_ISWRITEABLE);
$status_check[] = array('Importance' => 'Recommended', 'Title' => LABEL_SUGGESTED_CACHE_PATH, 'Status' => $suggested_cache, 'Class' => $sugg_cache_class, 'HelpURL' =>$sugg_cache_code, 'HelpLabel'=>$sugg_cache_text);
//PHP MagicQuotesRuntime
$php_magic_quotes_runtime = (@get_magic_quotes_runtime() > 0) ? ON : OFF;
$status_check[] = array('Importance' => 'Recommended', 'Title' => LABEL_PHP_MAG_QT_RUN, 'Status' => $php_magic_quotes_runtime , 'Class' => ($php_magic_quotes_runtime==OFF)?'OK':'WARN', 'HelpURL' =>ERROR_CODE_MAGIC_QUOTES_RUNTIME, 'HelpLabel'=>ERROR_TEXT_MAGIC_QUOTES_RUNTIME);
//PHP GD support check
$php_ext_gd = (@extension_loaded('gd')) ? ON : OFF;
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_EXT_GD, 'Status' => $php_ext_gd , 'Class' => ($php_ext_gd==ON)?'OK':'WARN', 'HelpURL' =>ERROR_CODE_GD_SUPPORT, 'HelpLabel'=>ERROR_TEXT_GD_SUPPORT);
if (function_exists('gd_info')) $gd_info = @gd_info();
$gd_ver = 'GD ' . $gd_info['GD Version'];
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_GD_VER, 'Status' => $gd_ver , 'Class' => ($php_ext_gd==ON && strstr($gd_ver,'2.') )?'OK':'WARN', 'HelpURL' =>ERROR_CODE_GD_SUPPORT, 'HelpLabel'=>ERROR_TEXT_GD_SUPPORT);
//check for zLib Compression Support
$php_ext_zlib = (@extension_loaded('zlib')) ? ON : OFF;
$status_check[] = array('Importance' => '', 'Title' => LABEL_PHP_EXT_ZLIB, 'Status' => $php_ext_zlib, 'Class' => ($php_ext_zlib==ON)?'OK':'WARN', 'HelpURL' =>'', 'HelpLabel'=>'');
//Check for OpenSSL support (only relevant for Apache)
$php_ext_openssl = (@extension_loaded('openssl')) ? ON : OFF;
if ($php_ext_openssl == ON) $status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_EXT_OPENSSL, 'Status' => $php_ext_openssl, 'Class' => ($php_ext_openssl==ON)?'OK':'WARN', 'HelpURL' =>ERROR_CODE_OPENSSL_WARN, 'HelpLabel'=>ERROR_TEXT_OPENSSL_WARN);
//Check for cURL support (ie: for payment/shipping gateways)
// could also check for (function_exists('curl_init'))
$php_ext_curl = (@extension_loaded('curl')) ? ON : OFF;
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_EXT_CURL, 'Status' => $php_ext_curl, 'Class' => ($php_ext_curl==ON)?'OK':'WARN', 'HelpURL' =>ERROR_CODE_CURL_SUPPORT, 'HelpLabel'=>ERROR_TEXT_CURL_SUPPORT);
//Check for upload support built in to PHP
$php_uploads = (@ini_get('file_uploads')) ? ON : OFF;
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_UPLOAD_STATUS, 'Status' => $php_uploads . sprintf(' upload_max_filesize=%s; post_max_size=%s',@ini_get('upload_max_filesize'), @ini_get('post_max_size')) , 'Class' => ($php_uploads==ON)?'OK':'WARN', 'HelpURL' =>ERROR_CODE_UPLOADS_DISABLED, 'HelpLabel'=>ERROR_TEXT_UPLOADS_DISABLED);
//Upload TMP dir setting
$upload_tmp_dir = ini_get("upload_tmp_dir");
$status_check[] = array('Importance' => 'Info', 'Title' => LABEL_UPLOAD_TMP_DIR, 'Status' => $upload_tmp_dir, 'Class' => 'OK', 'HelpURL' =>'', 'HelpLabel'=>'');
//Check for XML Support
$xml_support = function_exists('xml_parser_create') ? ON : OFF;
$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_XML_SUPPORT, 'Status' => $xml_support, 'Class' => ($xml_support==ON)?'OK':'WARN', 'HelpURL' =>'', 'HelpLabel'=>'');
//Check for FTP support built in to PHP (for manual sending of configure.php files to server if applicable)
$php_ext_ftp = (@extension_loaded('ftp')) ? ON : OFF;
if ($php_ext_ftp == ON) $status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_EXT_FTP, 'Status' => $php_ext_ftp, 'Class' => ($php_ext_ftp==ON)?'OK':'WARN', 'HelpURL' =>'', 'HelpLabel'=>'');
//Check for pfpro support in PHP for Verisign Payflow Pro payment gateway (Verisign SDK required)
$php_ext_pfpro = (@extension_loaded('pfpro')) ? ON : OFF;
if ($php_ext_pfpro==ON) $status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_PHP_EXT_PFPRO, 'Status' => $php_ext_pfpro, 'Class' => ($php_ext_pfpro==ON)?'OK':'WARN', 'HelpURL' =>'', 'HelpLabel'=>'');
//Check PostgreSQL availability
$pg_support = (function_exists( 'pg_connect' )) ? ON : OFF;
// turn off display of Postgres status until we support it again
//$status_check[] = array('Importance' => 'Optional', 'Title' => LABEL_POSTGRES_AVAILABLE, 'Status' => $pg_support, 'Class' => ($pg_support==ON) ? 'OK' : 'WARN', 'HelpURL' =>ERROR_CODE_DB_NOTSUPPORTED, 'HelpLabel'=>ERROR_TEXT_DB_NOTSUPPORTED);
//OpenBaseDir setting
// read restrictions, and check whether the working folder falls within the list of restricted areas
$script_filename = str_replace(array('\\','//'), '/', $path_trans);
$dir_fs_www_root_array = explode('/', dirname($script_filename));
$dir_fs_www_root_tmp = array();
for ($i=0, $n=sizeof($dir_fs_www_root_array)-1; $i<$n; $i++) {
$dir_fs_www_root_tmp[] = $dir_fs_www_root_array[$i];
}
$dir_fs_www_root = implode('/', $dir_fs_www_root_tmp);
$this_class = 'OK';
if ($open_basedir = ini_get('open_basedir')) {
$found_basedir = false;
// if anything is found for open_basedir, set to warning:
if ($open_basedir) $this_class = 'WARN';
// expand based on : symbol
$basedir_check_array = explode(':',$open_basedir);
if (!is_array($basedir_check_array)) $basedir_check_array = explode(';',$open_basedir);
// now loop thru paths in the open_basedir settings to find a match to our site. If not found, issue warning.
if (is_array($basedir_check_array)) {
foreach($basedir_check_array as $basedir_check) {
// echo 'www-root: ' . $dir_fs_www_root . '<br /> basedir: ' . $basedir_check . '<br /><br />';
if (strstr($dir_fs_www_root, $basedir_check)) {
//echo 'FOUND<br /><br />';
$found_basedir=true;
}
}
}
if (!$found_basedir) $this_class = 'FAIL';
}
$status_check2[] = array('Importance' => 'Recommended', 'Title' => LABEL_OPEN_BASEDIR, 'Status' => $open_basedir, 'Class' => $this_class, 'HelpURL' =>'', 'HelpLabel'=>'Could have problems uploading files or doing backups');
//Sendmail-From setting (PHP configuration)
$sendmail_from = @ini_get("sendmail_from");
$status_check2[] = array('Importance' => 'Info', 'Title' => LABEL_SENDMAIL_FROM, 'Status' => $sendmail_from, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//Sendmail Path setting (PHP configuration)
$sendmail_path = @ini_get("sendmail_path");
$status_check2[] = array('Importance' => 'Info', 'Title' => LABEL_SENDMAIL_PATH, 'Status' => $sendmail_path, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//SMTP (vs sendmail) setting (PHP configuration)
$smtp = @ini_get("SMTP");
$status_check2[] = array('Importance' => 'Info', 'Title' => LABEL_SMTP_MAIL, 'Status' => $smtp, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
//include_path (PHP configuration)
$includePath = @ini_get("include_path");
$status_check2[] = array('Importance' => 'Info', 'Title' => LABEL_INCLUDE_PATH, 'Status' => $includePath, 'Class' => 'NA', 'HelpURL' =>'', 'HelpLabel'=>'');
// reverse the order for slightly more pleasant display
$status_check2 = array_reverse($status_check2);
// error-condition-detection
$php_extensions = get_loaded_extensions();
$admin_config_exists = $zc_install->test_admin_configure(ERROR_TEXT_ADMIN_CONFIGURE,ERROR_CODE_ADMIN_CONFIGURE);
$store_config_exists = $zc_install->test_store_configure(ERROR_TEXT_STORE_CONFIGURE,ERROR_CODE_STORE_CONFIGURE);
if ($php_ext_sessions=="OFF") {$zc_install->setError(ERROR_TEXT_PHP_SESSION_SUPPORT, ERROR_CODE_PHP_SESSION_SUPPORT, true);}
// don't restrict ability to proceed with installation if upgrading the database w/o touching configure.php files is a suitable option
$zen_cart_allow_database_upgrade_button_disable = $zc_install->fatal_error;
// now check for writability of the configure.php files (after capturing fatal_error status above).
if ($admin_config_exists) $admin_config_writable = $zc_install->test_admin_configure_write(ERROR_TEXT_ADMIN_CONFIGURE_WRITE,ERROR_CODE_ADMIN_CONFIGURE_WRITE);
if ($store_config_exists) $store_config_writable = $zc_install->test_store_configure_write(ERROR_TEXT_STORE_CONFIGURE_WRITE,ERROR_CODE_STORE_CONFIGURE_WRITE);
foreach (array('includes/configure.php', 'admin/includes/configure.php') as $file) {
$this_writable='';
$this_exists='';
if (file_exists('../' . $file)) {
$this_exists='';
if ($zc_install->isWriteable('../' . $file)) {
$this_class = 'OK';
$this_writable=WRITABLE;
} else {
$this_class = 'FAIL';
$this_writable=UNWRITABLE;
}
} else {
$this_exists=NOT_EXIST;
$this_class='FAIL';
}
$file_status[]=array('file'=>$file, 'exists'=>$this_exists, 'writable'=>$this_writable, 'class'=> $this_class);
}
//check folders status
foreach (array('cache'=>'777 read/write/execute',
'images'=>'777 read/write/execute (INCLUDE SUBDIRECTORIES TOO)',
'includes/languages/english/html_includes'=>'777 read/write (INCLUDE SUBDIRECTORIES TOO)',
'media'=>'777 read/write/execute',
'pub'=>'777 read/write/execute',
'admin/backups'=>'777 read/write',
'admin/images/graphs'=>'777 read/write/execute'
) as $folder=>$chmod) {
$folder_status[]=array('folder'=>$folder, 'writable'=>(@is_writable('../'.$folder)) ? OK : UNWRITABLE, 'class'=> (@is_writable('../'.$folder)) ? 'OK' : 'WARN', 'chmod'=>$chmod);
}
// disable Install/Upgrade buttons if fatal error discovered
$button_status = ($zc_install->fatal_error && !isset($_GET['ignorefatal'])) ? 'disabled="disabled"' : '';
$button_status_upg = ($zen_cart_allow_database_upgrade_button_disable && !isset($_GET['ignorefatal'])) ? 'disabled="disabled"' : '';
// PROCESS TEMPLATE BUTTONS, IF CLICKED
if (isset($_POST['submit'])) {
if (!$zc_install->fatal_error) {
header('location: index.php?main_page=system_setup&language=' . $language . '&sql_cache='.$suggested_cache);
exit;
}
}
if (isset($_POST['upgrade'])) {
if (!$zc_install->fatal_error) {
header('location: index.php?main_page=system_setup&language=' . $language . '&sql_cache='.$suggested_cache . '&is_upgrade=1');
exit;
}
}
if (isset($_POST['db_upgrade'])) {
if (!$zen_cart_allow_database_upgrade_button_disable) {
header('location: index.php?main_page=database_upgrade&language=' . $language . '&is_upgrade=1');
exit;
}
}
if (isset($_POST['refresh'])) {
header('location: index.php?main_page=inspect&language=' . $language . '&sql_cache='.$suggested_cache);
exit;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -