当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtil::binStrlen方法代码示例

本文整理汇总了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;
 }
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:15,代码来源:hotpalgorithm.php

示例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;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:27,代码来源:yandex.php

示例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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:26,代码来源:yandex2.php

示例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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:44,代码来源:base32.php

示例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;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:13,代码来源:request.php

示例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;
    }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:24,代码来源:mail.php


注:本文中的CUtil::binStrlen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。