Beispiel #1
0
            }
            if (!in_array($type, array('page'))) {
                $error = getMessage('ABTEST_AJAX_ERROR');
            }
            if (!in_array($site, $arSites)) {
                $error = getMessage('ABTEST_AJAX_ERROR');
            }
            if ($error === false) {
                $value = Bitrix\Main\Text\Encoding::convertEncodingToCurrent($value);
                $value = Bitrix\ABTest\AdminHelper::getRealPath($site, $value);
                if (empty($value)) {
                    $error = getMessage('ABTEST_UNKNOWN_PAGE');
                }
                if ($error === false) {
                    $result = $value;
                }
            }
            break;
        default:
            $error = getMessage('ABTEST_AJAX_ERROR');
    }
}
if ($error === false) {
    $data = array('result' => Bitrix\Main\Text\Encoding::convertEncoding($result, LANG_CHARSET, 'UTF-8'), 'error' => false);
} else {
    $data = array('result' => 'error', 'error' => Bitrix\Main\Text\Encoding::convertEncoding($error, LANG_CHARSET, 'UTF-8'));
}
$APPLICATION->RestartBuffer();
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo json_encode($data);
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin_after.php';
Beispiel #2
0
    public static function convertCharset($str, $from, $to)
    {
        $from = trim(strtolower($from));
        $to = trim(strtolower($to));
        if (in_array($from, array('utf-8', 'utf8'))) {
            $regex = '/
				([\\x00-\\x7F]
					|[\\xC2-\\xDF][\\x80-\\xBF]
					|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])
				|(\\xE0[\\xA0-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]|\\xED[\\x80-\\x9F]
					|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{0,2}|[\\xF1-\\xF3][\\x80-\\xBF]{1,3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{0,2}
					|[\\x80-\\xFF])
			/x';
            $str = preg_replace_callback($regex, function ($matches) {
                return isset($matches[2]) ? str_repeat('?', CUtil::binStrlen($matches[2])) : $matches[1];
            }, $str);
        }
        if ($result = Bitrix\Main\Text\Encoding::convertEncoding($str, $from, $to, $error)) {
            $str = $result;
        } else {
            addMessage2Log(sprintf('Failed to convert email part. (%s -> %s : %s)', $from, $to, $error));
        }
        return $str;
    }