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


PHP CUtil::BinSubstr方法代码示例

本文整理汇总了PHP中CUtil::BinSubstr方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::BinSubstr方法的具体用法?PHP CUtil::BinSubstr怎么用?PHP CUtil::BinSubstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUtil的用法示例。


在下文中一共展示了CUtil::BinSubstr方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetValue

 public function GetValue()
 {
     $result = $this->value;
     if (ord($result[0]) == 0x0) {
         $result = CUtil::BinSubstr($result, 1);
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:8,代码来源:asn.php

示例2: CRCCryptData

function CRCCryptData($data, $pwdString, $type)
{
    $type = strtoupper($type);
    if ($type != "D") {
        $type = "E";
    }
    $res_data = "";
    if ($type == 'D') {
        $data = urldecode($data);
    }
    $key[] = "";
    $box[] = "";
    $temp_swap = "";
    $pwdLength = CUtil::BinStrlen($pwdString);
    for ($i = 0; $i <= 255; $i++) {
        $key[$i] = ord(CUtil::BinSubstr($pwdString, $i % $pwdLength, 1));
        $box[$i] = $i;
    }
    $x = 0;
    for ($i = 0; $i <= 255; $i++) {
        $x = ($x + $box[$i] + $key[$i]) % 256;
        $temp_swap = $box[$i];
        $box[$i] = $box[$x];
        $box[$x] = $temp_swap;
    }
    $temp = "";
    $k = "";
    $cipherby = "";
    $cipher = "";
    $a = 0;
    $j = 0;
    for ($i = 0, $n = CUtil::BinStrlen($data); $i < $n; $i++) {
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;
        $temp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $temp;
        $k = $box[($box[$a] + $box[$j]) % 256];
        $cipherby = ord(CUtil::BinSubstr($data, $i, 1)) ^ $k;
        $cipher .= chr($cipherby);
    }
    if ($type == 'D') {
        $res_data = urldecode(urlencode($cipher));
    } else {
        $res_data = urlencode($cipher);
    }
    return $res_data;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:48,代码来源:file_checker.php

示例3: getPayload

 public function getPayload()
 {
     $sJSONPayload = str_replace('"' . self::APPLE_RESERVED_NAMESPACE . '":[]', '"' . self::APPLE_RESERVED_NAMESPACE . '":{}', CPushManager::_MakeJson($this->_getPayload(), "", false));
     $nJSONPayloadLen = CUtil::BinStrlen($sJSONPayload);
     if ($nJSONPayloadLen > $this->payloadMaxSize) {
         if ($this->_bAutoAdjustLongPayload) {
             $nMaxTextLen = $nTextLen = CUtil::BinStrlen($this->text) - ($nJSONPayloadLen - $this->payloadMaxSize);
             if ($nMaxTextLen > 0) {
                 while (CUtil::BinStrlen($this->text = CUtil::BinSubstr($this->text, 0, --$nTextLen)) > $nMaxTextLen) {
                 }
                 return $this->getPayload();
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     return $sJSONPayload;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:20,代码来源:apple_push.php

示例4: getPayload

 public function getPayload()
 {
     $sJSONPayload = str_replace('"' . self::APPLE_RESERVED_NAMESPACE . '":[]', '"' . self::APPLE_RESERVED_NAMESPACE . '":{}', CPushManager::_MakeJson($this->_getPayload(), "", false));
     $nJSONPayloadLen = CUtil::BinStrlen($sJSONPayload);
     if ($nJSONPayloadLen > self::PAYLOAD_MAXIMUM_SIZE) {
         if ($this->_bAutoAdjustLongPayload) {
             $nMaxTextLen = $nTextLen = CUtil::BinStrlen($this->text) - ($nJSONPayloadLen - self::PAYLOAD_MAXIMUM_SIZE);
             if ($nMaxTextLen > 0) {
                 while (CUtil::BinStrlen($this->text = CUtil::BinSubstr($this->text, 0, --$nTextLen)) > $nMaxTextLen) {
                 }
                 return $this->getPayload();
             } else {
                 throw new Exception("JSON Payload is too long: {$nJSONPayloadLen} bytes. Maximum size is " . self::PAYLOAD_MAXIMUM_SIZE . " bytes. The message text can not be auto-adjusted.");
             }
         } else {
             throw new Exception("JSON Payload is too long: {$nJSONPayloadLen} bytes. Maximum size is " . self::PAYLOAD_MAXIMUM_SIZE . " bytes");
         }
     }
     return $sJSONPayload;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:20,代码来源:apple_push.php

示例5: PrintHTTP

function PrintHTTP($strRequest, $strHeaders, $strRes)
{
	echo 
	"== Request ==\n".
	(($l = CUtil::BinStrlen($strRequest)) > 1000 ? CUtil::BinSubstr($strRequest, 0, 1000).' ... ('.$l.' bytes)' : $strRequest)."\n".
	"== Response ==\n".
	$strHeaders."\n".
	"== Body ==\n".
	(($l = CUtil::BinStrlen($strRes)) > 1000 ? CUtil::BinSubstr($strRes, 0, 1000).' ... ('.$l.' bytes)' : $strRes)."\n".
	"==========\n";
}
开发者ID:nycmic,项目名称:bittest,代码行数:11,代码来源:site_checker.php

示例6: Crypt

	public static function Crypt($str, $key=false)
	{
		$res = '';
		if($key===false)
			$key = COption::GetOptionString("main", "pwdhashadd", "");
		$key1 = CMailUtil::BinMD5($key);
		while($str)
		{
			$m = CUtil::BinSubstr($str, 0, 16);
			$str = CUtil::BinSubstr($str, 16);
			$res .= CMailUtil::ByteXOR($m, $key1, 16);
			$key1 = CMailUtil::BinMD5($key.$key1.$m);
		}
		return(base64_encode($res));
	}
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:15,代码来源:mail.php

示例7: PrepareSearchResult


//.........这里部分代码省略.........
				if (isset($search))
				{
					$p = $oneCase[0][1];
					if (!isset($arPos[$search]))
						$arPos[$search] = $p;
					//Add to the tail of the running window
					$arPosP[] = $p;
					$arPosW[] = $search;
					$cc = count($arPosW);
					if ($cc >= $wordsCount)
					{
						//This cuts the tail of the running window
						while ($cc > $wordsCount)
						{
							array_shift($arPosW);
							array_shift($arPosP);
							$cc--;
						}
						//Check if all the words present in the current window
						if (count(array_unique($arPosW)) == $wordsCount)
						{
							//And check if positions is the best
							if (
								!$arPosLast
								|| (
									(max($arPosP) - min($arPosP)) < (max($arPosLast) - min($arPosLast))
								))
								$arPosLast = $arPosP;
						}
					}
				}
			}
		}

		if ($arPosLast)
			$arPos = $arPosLast;

		//Nothing found just cut some text
		if (empty($arPos))
		{
			$str_len = strlen($str);
			$pos_end = 500;
			while (($pos_end < $str_len) && (strpos(" ,.\n\r", substr($str, $pos_end, 1)) === false))
				$pos_end++;
			return substr($str, 0, $pos_end).($pos_end < $str_len? "...": "");
		}

		sort($arPos);

		$str_len = CUtil::BinStrlen($str);
		$delta = 250/count($arPos);
		$arOtr = array();
		//Have to do it two times because Positions eat each other
		for ($i = 0; $i < 2; $i++)
		{
			$arOtr = array();
			$last_pos = -1;
			foreach ($arPos as $pos_mid)
			{
				//Find where sentence begins
				$pos_beg = $pos_mid - $delta;
				if($pos_beg <= 0)
					$pos_beg = 0;
				while(($pos_beg > 0) && (strpos(" ,.!?\n\r", CUtil::BinSubstr($str, $pos_beg, 1)) === false))
					$pos_beg--;

				//Find where sentence ends
				$pos_end = $pos_mid + $delta;
				if($pos_end > $str_len)
					$pos_end = $str_len;
				while(($pos_end < $str_len) && (strpos(" ,.!?\n\r", CUtil::BinSubstr($str, $pos_end, 1)) === false))
					$pos_end++;

				if($pos_beg <= $last_pos)
					$arOtr[count($arOtr)-1][1] = $pos_end;
				else
					$arOtr[] = array($pos_beg, $pos_end);

				$last_pos = $pos_end;
			}
			//Adjust length of the text
			$delta = 250/count($arOtr);
		}

		$str_result = "";
		foreach ($arOtr as $borders)
		{
			$str_result .= ($borders[0]<=0? "": " ...")
				.CUtil::BinSubstr($str, $borders[0], $borders[1] - $borders[0] + 1)
				.($borders[1] >= $str_len? "": "... ")
			;
		}

		foreach ($words as $search => $type)
			$str_result = $this->repl($search, $type, $str_result);

		$str_result = str_replace("%/^%", "</b>", str_replace("%^%","<b>", $str_result));

		return $str_result;
	}
开发者ID:nycmic,项目名称:bittest,代码行数:101,代码来源:search.php

示例8: EncodeHeaderFrom

 function EncodeHeaderFrom($text, $charset)
 {
     $i = CUtil::BinStrlen($text);
     while ($i > 0) {
         if (ord(CUtil::BinSubstr($text, $i - 1, 1)) >> 7) {
             break;
         }
         $i--;
     }
     if ($i == 0) {
         return $text;
     } else {
         return "=?" . $charset . "?B?" . base64_encode(CUtil::BinSubstr($text, 0, $i)) . "?=" . CUtil::BinSubstr($text, $i);
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:15,代码来源:posting.php

示例9: getFrameIndexes

 /**
  * @param string $content
  * @return array|bool
  */
 private static function getFrameIndexes($content)
 {
     $openTag = "<!--'start_frame_cache_";
     $closingTag = "<!--'end_frame_cache_";
     $ending = "'-->";
     $areas = array();
     $offset = 0;
     while (($openTagStart = \CUtil::BinStrpos($content, $openTag, $offset)) !== false) {
         $endingPos = \CUtil::BinStrpos($content, $ending, $openTagStart);
         if ($endingPos === false) {
             break;
         }
         $idStart = $openTagStart + strlen($openTag);
         $idLength = $endingPos - $idStart;
         $areaId = \CUtil::BinSubstr($content, $idStart, $idLength);
         $openTagEnd = $endingPos + strlen($ending);
         $realClosingTag = $closingTag . $areaId . $ending;
         $closingTagStart = \CUtil::BinStrpos($content, $realClosingTag, $openTagEnd);
         if ($closingTagStart === false) {
             $offset = $openTagEnd;
             continue;
         }
         $closingTagEnd = $closingTagStart + strlen($realClosingTag);
         $area = new \stdClass();
         $area->id = $areaId;
         $area->openTagStart = $openTagStart;
         $area->openTagEnd = $openTagEnd;
         $area->closingTagStart = $closingTagStart;
         $area->closingTagEnd = $closingTagEnd;
         $areas[] = $area;
         $offset = $closingTagEnd;
     }
     return count($areas) > 0 ? $areas : false;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:38,代码来源:frame.php

示例10: unpack

 /**
  * Unpack values from string (something like rsplit).
  * Simple example for separator ".":
  * <code>
  *  // Unpack all values:
  *  unpack('test.all.values', 0) -> ['test', 'all', 'values']
  *
  *  // Unpack 2 values (by default). First element containing the rest of string.
  *  unpack('test.all.values') -> ['test.all', 'values']
  *
  *  // Exception if separator is missing
  *  unpack('test.all values', 3) -> throws BadSignatureException
  * </code>
  *
  * @param string $value String for unpacking.
  * @param int $limit If $limit === 0 - unpack all values, default - 2.
  * @return array
  * @throws BadSignatureException
  */
 protected function unpack($value, $limit = 2)
 {
     // Some kind of optimization
     if ($limit === 0) {
         if (strpos($value, $this->separator) === false) {
             throw new BadSignatureException('Separator not found in value');
         }
         return explode($this->separator, $value);
     }
     $result = array();
     while (--$limit > 0) {
         $pos = bxstrrpos($value, $this->separator);
         if ($pos === false) {
             throw new BadSignatureException('Separator not found in value');
         }
         $result[] = \CUtil::BinSubstr($value, $pos + 1);
         $value = \CUtil::BinSubstr($value, 0, $pos);
     }
     $result[] = $value;
     return array_reverse($result);
 }
开发者ID:rasuldev,项目名称:torino,代码行数:40,代码来源:signer.php


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