Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
migrator.php
1<?php
9namespace Bitrix\Main\Config;
10
12{
13 public static function wnc()
14 {
15 $ar = array(
16 "utf_mode" => array("value" => defined('BX_UTF'), "readonly" => true),
17 "default_charset" => array("value" => defined('BX_DEFAULT_CHARSET') ? BX_DEFAULT_CHARSET : null, "readonly" => false),
18 "no_accelerator_reset" => array("value" => defined('BX_NO_ACCELERATOR_RESET'), "readonly" => false),
19 "http_status" => array("value" => (defined('BX_HTTP_STATUS') && BX_HTTP_STATUS), "readonly" => false),
20 );
21
22 $cache = array();
23 if (defined('BX_CACHE_SID'))
24 $cache["sid"] = BX_CACHE_SID;
25 if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/cluster/memcache.php"))
26 {
27 $arList = null;
28 include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/cluster/memcache.php");
29 if (defined("BX_MEMCACHE_CLUSTER") && is_array($arList))
30 {
31 foreach ($arList as $listKey => $listVal)
32 {
33 $bOtherGroup = defined("BX_CLUSTER_GROUP") && ($listVal["GROUP_ID"] !== BX_CLUSTER_GROUP);
34
35 if (($listVal["STATUS"] !== "ONLINE") || $bOtherGroup)
36 unset($arList[$listKey]);
37 }
38
39 if (!empty($arList))
40 {
41 $cache["type"] = array(
42 "extension" => "memcache",
43 "required_file" => "modules/cluster/classes/general/memcache_cache.php",
44 "class_name" => "CPHPCacheMemcacheCluster",
45 );
46 }
47 }
48 }
49 if (!isset($cache["type"]))
50 {
51 if (defined('BX_CACHE_TYPE'))
52 {
53 $cache["type"] = BX_CACHE_TYPE;
54
55 switch ($cache["type"])
56 {
57 case "memcache":
58 case "CPHPCacheMemcache":
59 $cache["type"] = "memcache";
60 break;
61 case "eaccelerator":
62 case "CPHPCacheEAccelerator":
63 $cache["type"] = "eaccelerator";
64 break;
65 case "apc":
66 case "CPHPCacheAPC":
67 $cache["type"] = "apc";
68 break;
69 case "xcache":
70 case "CPHPCacheXCache":
71 $cache["type"] = array(
72 "extension" => "xcache",
73 "required_file" => "modules/main/classes/general/cache_xcache.php",
74 "class_name" => "CPHPCacheXCache",
75 );
76 break;
77 default:
78 if (defined("BX_CACHE_CLASS_FILE") && file_exists(BX_CACHE_CLASS_FILE))
79 {
80 $cache["type"] = array(
81 "required_remote_file" => BX_CACHE_CLASS_FILE,
82 "class_name" => BX_CACHE_TYPE
83 );
84 }
85 else
86 {
87 $cache["type"] = "files";
88 }
89 break;
90 }
91 }
92 else
93 {
94 $cache["type"] = "files";
95 }
96 }
97 if (defined("BX_MEMCACHE_PORT"))
98 $cache["memcache"]["port"] = intval(BX_MEMCACHE_PORT);
99 if (defined("BX_MEMCACHE_HOST"))
100 $cache["memcache"]["host"] = BX_MEMCACHE_HOST;
101 $ar["cache"] = array("value" => $cache, "readonly" => false);
102
103 $cacheFlags = array();
104 $arCacheConsts = array("CACHED_b_option" => "config_options", "CACHED_b_lang_domain" => "site_domain");
105 foreach ($arCacheConsts as $const => $name)
106 $cacheFlags[$name] = defined($const) ? constant($const) : 0;
107 $ar["cache_flags"] = array("value" => $cacheFlags, "readonly" => false);
108
109 $ar["cookies"] = array("value" => array("secure" => false, "http_only" => true), "readonly" => false);
110
111 $ar["exception_handling"] = array(
112 "value" => array(
113 "debug" => true,
114 "handled_errors_types" => E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE,
115 "exception_errors_types" => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_WARNING & ~E_COMPILE_WARNING & ~E_DEPRECATED,
116 "ignore_silence" => false,
117 "assertion_throws_exception" => true,
118 "assertion_error_type" => E_USER_ERROR,
119 "log" => array(
120 /*"class_name" => "...",
121 "extension" => "...",
122 "required_file" => "...",*/
123 "settings" => array(
124 "file" => "bitrix/modules/error.log",
125 "log_size" => 1000000
126 )
127 ),
128 ),
129 "readonly" => false
130 );
131
132 global $DBHost, $DBName, $DBLogin, $DBPassword;
133
134 $dbClassName = defined('BX_USE_MYSQLI') && BX_USE_MYSQLI === true ? "\\Bitrix\\Main\\DB\\MysqliConnection" : "\\Bitrix\\Main\\DB\\MysqlConnection";
135
136 $ar['connections']['value']['default'] = array(
137 'className' => $dbClassName,
138 'host' => $DBHost,
139 'database' => $DBName,
140 'login' => $DBLogin,
141 'password' => $DBPassword,
142 'options' => ((!defined("DBPersistent") || DBPersistent) ? 1 : 0) | ((defined("DELAY_DB_CONNECT") && DELAY_DB_CONNECT === true) ? 2 : 0)
143 );
144 $ar['connections']['readonly'] = true;
145
146 $configuration = Configuration::getInstance();
147
148 foreach ($ar as $k => $v)
149 {
150 if ($configuration->get($k) === null)
151 {
152 if ($v["readonly"])
153 $configuration->addReadonly($k, $v["value"]);
154 else
155 $configuration->add($k, $v["value"]);
156 }
157 }
158
159 $configuration->saveConfiguration();
160
161 $filename1 = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect.php";
162 $filename2 = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect_d7.php";
163 if (file_exists($filename1) && !file_exists($filename2))
164 {
165 $source = file_get_contents($filename1);
166 $source = trim($source);
167 $source = preg_replace("#\\\$DB->Query\‍(#i", "\$this->queryExecute(", $source);
168 file_put_contents($filename2, $source);
169 }
170 }
171}
static getInstance($moduleId=null)