Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ini.php
1<?php
2
3namespace Bitrix\Main\Config;
4
5class Ini
6{
7 public static function getBool(string $param): bool
8 {
9 $val = ini_get($param);
10 return ($val == '1' || strtolower($val) == 'on');
11 }
12
13 public static function getInt(string $param): int
14 {
15 $val = ini_get($param);
16 return static::unformatInt($val);
17 }
18
19 public static function unformatInt(string $str): int
20 {
21 $str = strtolower($str);
22 $res = intval($str);
23
24 $suffix = substr($str, -1);
25 if ($suffix == "k")
26 {
27 $res *= 1024;
28 }
29 elseif ($suffix == "m")
30 {
31 $res *= 1048576;
32 }
33 elseif ($suffix == "g")
34 {
35 $res *= 1048576*1024;
36 }
37 elseif ($suffix == "b")
38 {
39 $res = self::unformatInt(substr($str, 0, -1));
40 }
41
42 return $res;
43 }
44
45 public static function adjustPcreBacktrackLimit(int $val): void
46 {
47 if ($val > 0)
48 {
49 $pcreBacktrackLimit = self::getInt('pcre.backtrack_limit');
50 if ($pcreBacktrackLimit < $val)
51 {
52 @ini_set('pcre.backtrack_limit', $val);
53 }
54 }
55 }
56}
static adjustPcreBacktrackLimit(int $val)
Definition ini.php:45
static unformatInt(string $str)
Definition ini.php:19
static getBool(string $param)
Definition ini.php:7
static getInt(string $param)
Definition ini.php:13