require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/webprostor.core/prolog.php"); use Bitrix\Main\Localization\Loc, Bitrix\Main\Config\Option, Bitrix\Main\Loader; Class CWebprostorCoreFunctions { public static function dump($data) { echo '
'; var_dump($data); echo ''; } public static function GenerateRandomCode($lenght = false) { $min_lenght= 0; $max_lenght = 100; $bigL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $smallL = "abcdefghijklmnopqrstuvwxyz"; $number = "0123456789"; $bigB = str_shuffle($bigL); $smallS = str_shuffle($smallL); $numberS = str_shuffle($number); $subA = substr($bigB,0,5); $subB = substr($bigB,6,5); $subC = substr($bigB,10,5); $subD = substr($smallS,0,5); $subE = substr($smallS,6,5); $subF = substr($smallS,10,5); $subG = substr($numberS,0,5); $subH = substr($numberS,6,5); $subI = substr($numberS,10,5); $RandCode1 = str_shuffle($subA.$subG.$subD.$subB.$subH.$subF.$subC.$subI.$subE); $RandCode2 = str_shuffle($RandCode1); $RandCode = $RandCode1.$RandCode2; if ($lenght>$min_lenght && $lenght<$max_lenght) { $result = substr($RandCode,0,$lenght); } else { $result = $RandCode; } return $result; } public static function GetCorrectWord($num, $str1, $str2, $str3) { $val = $num % 100; if ($val > 10 && $val < 20) return $num .' '. $str3; else { $val = $num % 10; if ($val == 1) return $num .' '. $str1; elseif ($val > 1 && $val < 5) return $num .' '. $str2; else return $num .' '. $str3; } } public static function ReturnBytes($val) { $val = trim($val); $last = strtolower($val[strlen($val)-1]); switch($last) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; } public static function mb_ucfirst($str) { $result = ''; if(is_string($str) && strlen($str) > 0) $result = mb_strtoupper(mb_substr($str, 0, 1)).mb_substr($str, 1); return $result; } public static function ShowFormFields($arFields = Array()) { global $USER; if(is_array($arFields) && count($arFields)) { foreach($arFields as $arSection) { if(isset($arSection["LABEL"]) && $arSection["LABEL"]) { ?>