1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
system_information.php
См. документацию.
1<?php
2
4{
10 public static function getSystemInformation()
11 {
12 $systemInformation = array(
13 'php' => static::getPhpInfo(),
14 'db' => static::getDbInfo(),
15 'memcache' => static::getMemCacheInfo(),
16 'environment' => static::getEnvironmentInfo()
17 );
18 return $systemInformation;
19 }
20
27 public static function getAdditionalInformation()
28 {
29 $additionalInformation = array(
30 'pulling' => static::getPullingInfo(),
31 'sites' => static::getSites(),
32 'modules' => static::getModulesInfo()
33 );
34 return $additionalInformation;
35 }
36
42 public static function getCurrentHost()
43 {
44 $host = COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]);
45 if (!$host)
46 $host = $_SERVER["HTTP_HOST"];
47 return trim(CBXPunycode::ToASCII($host, $arErrors));
48 }
49
55 public static function getCurrentHostName()
56 {
57 $host = static::getCurrentHost();
58 return preg_replace('#:\d+$#D', '', $host);
59 }
60
65 public static function isRunOnWin()
66 {
67 return (mb_strtoupper(mb_substr(PHP_OS, 0, 3)) === "WIN");
68 }
69
74 public static function isCliMode()
75 {
76 return PHP_SAPI === 'cli';
77 }
78
88 public static function isIpValid($ip, $allowPrivate = false, $allowRes = false)
89 {
90 // ToDo: what about PHP filters?
91 if (ip2long($ip) === false)
92 return false;
93
94 $ipOctets = explode('.', $ip);
95 if (!$allowPrivate)
96 {
97 // php/ext/filter/logical_filters.c, FILTER_FLAG_NO_PRIV_RANGE
98 if ($ipOctets[0] == 10)
99 return false;
100
101 if ($ipOctets[0] == 172 && $ipOctets[1] >= 16 && $ipOctets[1] <= 31)
102 return false;
103
104 if ($ipOctets[0] == 192 && $ipOctets[1] == 168)
105 return false;
106
107 }
108
109 if (!$allowRes)
110 {
111 // php/ext/filter/logical_filters.c, FILTER_FLAG_NO_RES_RANGE
112 if ($ipOctets[0] == 0)
113 return false;
114
115 if ($ipOctets[0] == 100 && $ipOctets[1] >= 64 && $ipOctets[1] <= 127)
116 return false;
117
118 if ($ipOctets[0] == 169 && $ipOctets[1] == 254)
119 return false;
120
121 if ($ipOctets[0] == 192 && $ipOctets[1] == 0 && $ipOctets[2] == 2)
122 return false;
123
124 if ($ipOctets[0] == 127 && $ipOctets[1] == 0 && $ipOctets[2] == 0)
125 return false;
126
127 if ($ipOctets[0] >= 224 && $ipOctets[0] <= 255)
128 return false;
129 }
130
131 return true;
132 }
133
139 protected static function getSites()
140 {
141 $converter = CBXPunycode::GetConverter();
142 $result = array();
143 $dbSites = CSite::GetList('sort', 'asc', array('ACTIVE' => 'Y'));
144 while ($arSite = $dbSites->Fetch())
145 {
146 $result[] = array(
147 'ID' => $arSite['ID'],
148 'DOMAINS' => array(),
149 );
150
151 $domains = explode("\n", $arSite["DOMAINS"]);
152 foreach($domains as $domainName)
153 {
154 $domainName = trim($domainName, "\r\t ");
155 if ($domainName != "")
156 {
157 $punyName = $converter->Encode($domainName);
158 if ($punyName !== false)
159 $result[count($result) - 1]['DOMAINS'][] = $punyName;
160 }
161 }
162 }
163 return $result;
164 }
165
170 protected static function getModulesInfo()
171 {
172 $modules = ['main' => SM_VERSION];
173
174 $folders = array(
175 "/local/modules",
176 "/bitrix/modules",
177 );
178
179 foreach ($folders as $folder)
180 {
181 if (!file_exists($_SERVER["DOCUMENT_ROOT"].$folder))
182 {
183 continue;
184 }
185
186 $handle = @opendir($_SERVER["DOCUMENT_ROOT"].$folder);
187 if ($handle)
188 {
189 while (false !== ($dir = readdir($handle)))
190 {
191 if (
192 !isset($modules[$dir])
193 && is_dir($_SERVER["DOCUMENT_ROOT"] . $folder . "/" . $dir)
194 && !in_array($dir, ['.', '..', 'main'], true)
195 )
196 {
197 if ($info = CModule::CreateModuleObject($dir))
198 {
199 if ($info->IsInstalled())
200 {
201 $modules[$dir] = $info->MODULE_VERSION;
202 }
203 }
204 }
205 }
206 closedir($handle);
207 }
208 }
209
210 return $modules;
211 }
212
218 protected static function getPullingInfo()
219 {
220 $result = array(
221 'enabled' => CModule::IncludeModule('pull') && CPullOptions::ModuleEnable()
222 );
223 if ($result['enabled'])
224 {
225 $result['nginx_used'] = CPullOptions::GetQueueServerStatus();
226 if ($result['nginx_used'])
227 {
228 $result['server_protocol'] = CPullOptions::GetQueueServerVersion();
229 $result['publish_url'] = CPullOptions::GetPublishUrl();
230
231 $result['pulling_url'] = CPullOptions::GetListenUrl();
232 $result['pulling_url_secure'] = CPullOptions::GetListenSecureUrl();
233
234 $result['websocket_url'] = CPullOptions::GetWebSocketUrl();
235 $result['websocket_url_secure'] = CPullOptions::GetWebSocketSecureUrl();
236 }
237 }
238 return $result;
239 }
240
246 protected static function getEnvironmentInfo()
247 {
248 return array(
249 "vm_version" => static::getBitrixVMVersion()
250 );
251 }
252
258 protected static function getBitrixVMVersion()
259 {
260 $result = getenv('BITRIX_VA_VER');
261 if(!$result)
262 $result = "";
263 return $result;
264 }
265
271 protected static function getPhpInfo()
272 {
273 $result = array(
274 "sapi" => @php_sapi_name(),
275 "version" => @phpversion(),
276 "extensions" => implode(', ',@get_loaded_extensions())
277 );
278 return $result;
279 }
280
286 protected static function getDbInfo()
287 {
288 global $DB;
289 $result = array(
290 "type" => $DB->type,
291 "version" => $DB->GetVersion(),
292 "hosts" => static::getDBHosts()
293 );
294 return $result;
295 }
296
302 protected static function getMemcacheSID()
303 {
304 $result = "";
305 if(defined("BX_MEMCACHE_CLUSTER"))
306 $result .= BX_MEMCACHE_CLUSTER;
307 if(defined("BX_CACHE_SID"))
308 $result .= BX_CACHE_SID;
309
310 return $result;
311 }
312
318 protected static function getMemCacheInfoFromCluster()
319 {
320 $result = array();
321 if(CModule::IncludeModule("cluster"))
322 {
323 $clusterMemcaches = CClusterMemcache::GetList();
324 while($clusterMemcacheServer = $clusterMemcaches->Fetch())
325 {
326// if($clusterMemcacheServer["STATUS"] == "ONLINE"){
327 $result[] = array(
328 "host" => $clusterMemcacheServer["HOST"],
329 "port" => $clusterMemcacheServer["PORT"],
330 );
331// }
332 }
333 }
334 return $result;
335 }
336
342 protected static function getMemCacheInfoFromConstants()
343 {
344 $result = array();
345 if(defined('BX_MEMCACHE_HOST'))
346 $result["host"] = BX_MEMCACHE_HOST;
347
348 if(defined('BX_MEMCACHE_PORT'))
349 $result["port"] = BX_MEMCACHE_PORT;
350
351 if(!empty($result))
352 {
353 return array($result);
354 }
355 else
356 {
357 return array();
358 }
359 }
360
366 protected static function getMemCachedHosts()
367 {
368 $clusterMemcache = static::getMemCacheInfoFromCluster();
369 $nativeMemcache = static::getMemCacheInfoFromConstants();
370 if(!empty($clusterMemcache) || !empty($nativeMemcache))
371 {
372 return array_merge($clusterMemcache, $nativeMemcache);
373 }
374 else
375 {
376 return array();
377 }
378 }
379
385 protected static function getMemCacheInfo()
386 {
387 $memcacheHosts = static::getMemCachedHosts();
388 if(!empty($memcacheHosts))
389 {
390 return array(
391 "hosts" => $memcacheHosts,
392 "sid" => static::getMemcacheSID()
393 );
394 }
395 else
396 {
397 return array();
398 }
399 }
400
404 protected static function getDBHosts()
405 {
406 $cluserDB = static::getDBHostsFromCluster();
407 $nativeDB = static::getDBHostsFromConstants();
408 if(!empty($nativeDB) || !empty($cluserDB))
409 {
410 return array_merge($nativeDB, $cluserDB);
411 }
412 else
413 {
414 return array();
415 }
416 }
417
423 protected static function getDBHostsFromCluster()
424 {
425 $result = array();
426 if(CModule::IncludeModule("cluster"))
427 {
428 $clusterDBs = CClusterDBNode::GetList(
429 array(//Order
430 "ID" => "ASC",
431 )
432 ,array(//Filter
433 "=ROLE_ID" => array("SLAVE", "MASTER")
434 )
435 ,array(//Select
436 "DB_HOST"
437 )
438 );
439 while($clusterDBServer = $clusterDBs->Fetch())
440 {
441 $result[] = array(
442 "host" => $clusterDBServer["DB_HOST"]
443 );
444 }
445 }
446 return $result;
447 }
448
454 protected static function getDBHostsFromConstants()
455 {
457 global $DB;
458 $result = array("host" => $DB->DBHost);
459 return $result;
460 }
461}
$dbSites
Определения options.php:14
static GetList($arOrder=false, $arFilter=false, $arSelect=false)
Определения dbnode.php:284
static GetConverter()
Определения punycode.php:25
static ToASCII($domainName, &$arErrors)
Определения punycode.php:44
static getDBHosts()
Определения system_information.php:404
static getDBHostsFromCluster()
Определения system_information.php:423
static getBitrixVMVersion()
Определения system_information.php:258
static getMemCacheInfo()
Определения system_information.php:385
static getMemCachedHosts()
Определения system_information.php:366
static getCurrentHostName()
Определения system_information.php:55
static getMemcacheSID()
Определения system_information.php:302
static getPhpInfo()
Определения system_information.php:271
static getEnvironmentInfo()
Определения system_information.php:246
static getAdditionalInformation()
Определения system_information.php:27
static getModulesInfo()
Определения system_information.php:170
static isIpValid($ip, $allowPrivate=false, $allowRes=false)
Определения system_information.php:88
static getPullingInfo()
Определения system_information.php:218
static getMemCacheInfoFromCluster()
Определения system_information.php:318
static getMemCacheInfoFromConstants()
Определения system_information.php:342
static getSystemInformation()
Определения system_information.php:10
static isCliMode()
Определения system_information.php:74
static isRunOnWin()
Определения system_information.php:65
static getCurrentHost()
Определения system_information.php:42
static getDBHostsFromConstants()
Определения system_information.php:454
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
$host
Определения .description.php:9
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
const SM_VERSION
Определения version.php:2
$modules
Определения bitrix.php:26
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
$dir
Определения quickway.php:303
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936