- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/system/compatiblestrategy.php
- Класс: BitrixMainSystemCompatibleStrategy
- Вызов: CompatibleStrategy::createDatabaseConnection
public function createDatabaseConnection()
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//read database connection parameters require_once
global $DBType, $DBDebug;
if(defined("BX_URLREWRITE"))
{
global $DBHost, $DBName, $DBLogin, $DBPassword, $DBDebugToFile, $DBSQLServerType;
}
else
{
$DBType = "mysql";
$DBDebug = false;
require_once($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/php_interface/dbconn.php");
}
if(defined('BX_UTF'))
define('BX_UTF_PCRE_MODIFIER', 'u');
else
define('BX_UTF_PCRE_MODIFIER', '');
if(!defined("CACHED_b_lang")) define("CACHED_b_lang", 3600);
if(!defined("CACHED_b_option")) define("CACHED_b_option", 3600);
if(!defined("CACHED_b_lang_domain")) define("CACHED_b_lang_domain", 3600);
if(!defined("CACHED_b_site_template")) define("CACHED_b_site_template", 3600);
if(!defined("CACHED_b_event")) define("CACHED_b_event", 3600);
if(!defined("CACHED_b_agent")) define("CACHED_b_agent", 3660);
if(!defined("CACHED_menu")) define("CACHED_menu", 3600);
if(!defined("CACHED_b_file")) define("CACHED_b_file", false);
if(!defined("CACHED_b_file_bucket_size")) define("CACHED_b_file_bucket_size", 100);
if(!defined("CACHED_b_user_field")) define("CACHED_b_user_field", 3600);
if(!defined("CACHED_b_user_field_enum")) define("CACHED_b_user_field_enum", 3600);
if(!defined("CACHED_b_task")) define("CACHED_b_task", 3600);
if(!defined("CACHED_b_task_operation")) define("CACHED_b_task_operation", 3600);
if(!defined("CACHED_b_rating")) define("CACHED_b_rating", 3600);
if(!defined("POST_FORM_ACTION_URI"))
define("POST_FORM_ACTION_URI", htmlspecialcharsbx($_SERVER["REQUEST_URI"]));
////////////////////////////////////////////////////////////////////////////////////////////////////
//connect to database, from here global variable $DB is available (CDatabase class)
if(isset($DBSQLServerType) && $DBSQLServerType == "NATIVE")
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/classes/".$DBType."/database_ms.php");
else
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/classes/".$DBType."/database.php");
$GLOBALS["DB"] = new CDatabase;
$GLOBALS["DB"]->debug = $DBDebug;
$GLOBALS["DB"]->DebugToFile = $DBDebugToFile;
//magic parameters: show sql queries statistics
$show_sql_stat = "";
if(array_key_exists("show_sql_stat", $_GET))
{
$show_sql_stat = (strtoupper($_GET["show_sql_stat"]) == "Y"? "Y":"");
setcookie("show_sql_stat", $show_sql_stat, false, "/");
}
elseif(array_key_exists("show_sql_stat", $_COOKIE))
{
$show_sql_stat = $_COOKIE["show_sql_stat"];
}
$GLOBALS["DB"]->ShowSqlStat = ($show_sql_stat == "Y");
if(!($GLOBALS["DB"]->connect($DBHost, $DBName, $DBLogin, $DBPassword)))
{
if(file_exists(($fname = $_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/php_interface/dbconn_error.php")))
include($fname);
else
include($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/dbconn_error.php");
die();
}
}