本文整理汇总了PHP中CUtil::binStrlen方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::binStrlen方法的具体用法?PHP CUtil::binStrlen怎么用?PHP CUtil::binStrlen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtil
的用法示例。
在下文中一共展示了CUtil::binStrlen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSecret
/**
* Set new secret
*
* @param string $secret Secret (binary).
* @return $this
*/
public function setSecret($secret)
{
$this->secret = $secret;
// Backward compatibility. This is the old logic and i can't change it right now:-(
if (\CUtil::binStrlen($this->secret) > 25) {
$this->digest = 'sha256';
}
return $this;
}
示例2: addLogo
public static function addLogo($token, $domain, $file, &$error)
{
$http = new \Bitrix\Main\Web\HttpClient();
$boundary = 'CMY' . md5(rand() . time());
$data = '';
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="token"' . "\r\n\r\n";
$data .= $token . "\r\n";
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="domain"' . "\r\n\r\n";
$data .= $domain . "\r\n";
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="file"; filename="file"' . "\r\n";
$data .= 'Content-Type: application/octet-stream' . "\r\n\r\n";
$data .= file_get_contents($file) . "\r\n";
$data .= '--' . $boundary . "--\r\n";
$http->setHeader('Content-type', 'multipart/form-data; boundary=' . $boundary);
$http->setHeader('Content-length', CUtil::binStrlen($data));
$response = $http->post('https://pddimp.yandex.ru/api/add_logo.xml', $data);
$result = new CDataXML();
$result->loadString($response);
if ($logoUrlNode = $result->selectNodes('/action/domains/domain/logo/url')) {
return $logoUrlNode->textContent();
}
self::setError2($result, $error);
return false;
}
示例3: setLogo
public static function setLogo($token, $domain, $file, &$error)
{
$http = new \Bitrix\Main\Web\HttpClient();
$boundary = 'CMY2' . md5(rand() . time());
$data = '';
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="token"' . "\r\n\r\n";
$data .= $token . "\r\n";
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="domain"' . "\r\n\r\n";
$data .= $domain . "\r\n";
$data .= '--' . $boundary . "\r\n";
$data .= 'Content-Disposition: form-data; name="file"; filename="logo"' . "\r\n";
$data .= 'Content-Type: application/octet-stream' . "\r\n\r\n";
$data .= file_get_contents($file) . "\r\n";
$data .= '--' . $boundary . "--\r\n";
$http->setHeader('Content-type', 'multipart/form-data; boundary=' . $boundary);
$http->setHeader('Content-length', CUtil::binStrlen($data));
$response = $http->post('https://pddimp.yandex.ru/api2/admin/domain/logo/set', $data);
$result = json_decode($response, true);
if (isset($result['success']) && $result['success'] == 'ok') {
return true;
}
self::setError($result, $error);
return false;
}
示例4: decode
/**
* Decode Base32 encoded string
*
* @param string $base32String Base32 encoded string.
* @throws ArgumentTypeException
* @throws DecodingException
* @return string Original data.
*/
public static function decode($base32String)
{
if (!$base32String) {
return '';
}
if (!is_string($base32String)) {
throw new ArgumentTypeException('base32String', 'string');
}
$base32String = strtoupper($base32String);
$base32Array = str_split($base32String);
$string = '';
foreach ($base32Array as $str) {
// skip padding
if ($str === '=') {
continue;
}
if (!isset(self::$alphabet[$str])) {
throw new DecodingException(sprintf('Illegal character: %s', $str));
}
$char = self::$alphabet[$str];
$char = decbin($char);
$string .= str_pad($char, 5, 0, STR_PAD_LEFT);
}
while (\CUtil::binStrlen($string) % 8 !== 0) {
$string = \CUtil::binSubstr($string, 0, -1);
}
$binaryArray = self::chunk($string, 8);
$realString = '';
foreach ($binaryArray as $bin) {
// Pad each value to 8 bits
$bin = str_pad($bin, 8, 0, STR_PAD_RIGHT);
// Convert binary strings to ASCII
$realString .= chr(bindec($bin));
}
return $realString;
}
示例5: adjustPcreBacktrackLimit
/**
* @param $string
* @return bool
*/
protected static function adjustPcreBacktrackLimit($string)
{
if (!is_string($string)) {
return false;
}
$strlen = \CUtil::binStrlen($string) * 2;
\CUtil::adjustPcreBacktrackLimit($strlen);
return true;
}
示例6: convertCharset
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;
}