uawdijnntqw1x1x1
IP : 216.73.216.163
Hostname : yjpwxulqtt
Kernel : Linux yjpwxulqtt 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec,proc_open,popen
OS : Linux
PATH:
/
home
/
user
/
web
/
pansionat-v-yaroslavle.ru
/
public_html
/
bitrix
/
modules
/
main
/
lib
/
userconsent
/
.
/
text.php
/
/
<?php /** * Bitrix Framework * @package bitrix * @subpackage main * @copyright 2001-2016 Bitrix */ namespace Bitrix\Main\UserConsent; use Bitrix\Main\Localization\Loc; use Bitrix\Main\Text\BinaryString; Loc::loadLanguageFile(__FILE__); /** * Class Text * @package Bitrix\Main\UserConsent */ class Text { /** * Replace template by data. * * @param string $template Template text. * @param array $data Replace data. * @param bool $isCut Is cut areas if empty data. * @return string */ public static function replace($template, array $data, $isCut = false) { $from = array(); $to = array(); $dataTmp = array(); foreach ($data as $key => $value) { $key = strtolower($key); if (is_array($value)) { $value = self::formatArrayToText($value); } else { $value = (string) $value; } $dataTmp[$key] = $value; } $data = $dataTmp; foreach ($data as $key => $value) { $from[] = '%' . $key . '%'; $to[] = $value; } $template = str_replace($from, $to, $template); if ($isCut) { $template = self::cut($template, $data); } return $template; } protected static function cut($template, array $data) { $from = array(); $to = array(); $matchResult = preg_match_all('/\%cut\.([A-Za-z0-9_\.]*)\.(start|end)\%/', $template, $matches, PREG_OFFSET_CAPTURE); if (!$matchResult) { return $template; } $cut = array(); foreach ($matches[0] as $key => $match) { $tag = $match[0]; $pos = $match[1]; $var = $matches[1][$key][0]; $mod = $matches[2][$key][0]; $from[] = $tag; $to[] = ''; if (!isset($cut[$var])) { $cut[$var] = array('start' => array(), 'end' => array()); } if (!isset($cut[$var][$mod])) { continue; } if ($mod == 'end') { $pos += BinaryString::getLength($tag); } $cut[$var][$mod][] = $pos; } $items = array(); foreach ($cut as $key => $item) { foreach ($item['start'] as $index => $position) { if (!isset($item['end'][$index])) { continue; } $sortBy = $item['end'][$index]; $items[$sortBy] = array( 'key' => $key, 'start' => $item['start'][$index], 'end' => $item['end'][$index] ); } } krsort($items); foreach ($items as $item) { if (!empty($data[$item['key']])) { continue; } $start = $item['start']; $end = $item['end']; if ($start <= 0 || $end <= 0) { continue; } $template = BinaryString::getSubstring($template, 0, $start) . BinaryString::getSubstring($template, $end); } return str_replace($from, $to, $template); } /** * Format array to text. * * @param array $list List. * @return string */ public static function formatArrayToText(array $list) { $result = array(); $num = 0; $count = count($list); foreach ($list as $item) { $num++; $isLast = $num >= $count; $result[] = '- ' . $item . ($isLast ? '.': ';'); } return implode("\n", $result); } }
/home/user/web/pansionat-v-yaroslavle.ru/public_html/bitrix/modules/main/lib/userconsent/./text.php