2013-07-17 66 views
0
<?php 
define('TYPO3_MODE','FE'); 

require('typo3conf/localconf.php'); 
require('t3lib/class.t3lib_db.php'); 
require('t3lib/class.t3lib_div.php'); 

define('TYPO3_db_host', $typo_db_host); 
define('TYPO3_db_username', $typo_db_username); 
define('TYPO3_db_password', $typo_db_password); 
define('TYPO3_db', $typo_db); 

define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME'])))); 
define('PATH_site', dirname(PATH_thisScript).'/'); 

$DB = new t3lib_DB(); 
$DB->connectDB(); 
... 

問:爲什麼我們把那些在TYPO3自定義腳本定義()

在TYPO3自定義腳本,我上面define()看到的,但實際上在整個腳本,沒有使用這些常量,如TYPO3_MODTYPO3_db_host ...爲什麼把這些define()放在腳本中?或者這是typo3系統的要求,如果是這樣,通常我們應該把什麼define()放入腳本?

+0

如果TYPO3不能繞過正常的引導,除非你真的知道你在做什麼。改用eId腳本。這將處理一個正確的引導程序,然後你不需要定義這些常量。 – pgampe

回答

0

t3lib_DB使用常量來獲取與用於typo3的數據庫的連接。

/** 
* Connects to database for TYPO3 sites: 
* 
* @param string $host 
* @param string $user 
* @param string $password 
* @param string $db 
* @return void 
*/ 
function connectDB($host = TYPO3_db_host, $user = TYPO3_db_username, $password = TYPO3_db_password, $db = TYPO3_db) { 
     // If no db is given we throw immediately. This is a sign for a fresh (not configured) 
     // TYPO3 installation and is used in FE to redirect to 1-2-3 install tool 
     ... 

但這不是連接數據庫的要求。你也可以直接傳遞這些值$DB->connectDB();

相關問題