本文整理汇总了PHP中CUtil::BinStrlen方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::BinStrlen方法的具体用法?PHP CUtil::BinStrlen怎么用?PHP CUtil::BinStrlen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtil
的用法示例。
在下文中一共展示了CUtil::BinStrlen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doPostAction
protected function doPostAction($isEdit, $action)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
if ($isEdit) {
$APPLICATION->RestartBuffer();
header('Content-Type: application/json', true);
echo CSecurityJsonHelper::encode($this->arResult);
die;
} else {
switch ($action) {
case 'download':
$APPLICATION->restartBuffer();
header('Content-Type: text/plain', true);
header('Content-Disposition: attachment; filename="recovery_codes.txt"');
header('Content-Transfer-Encoding: binary');
header(sprintf('Content-Length: %d', CUtil::BinStrlen($this->arResult['PLAIN_RESPONSE'])));
echo $this->arResult['PLAIN_RESPONSE'];
exit;
break;
case 'print':
$APPLICATION->restartBuffer();
$this->includeComponentTemplate(static::PRINT_PAGE);
exit;
break;
case 'view':
default:
$this->includeComponentTemplate(static::VIEW_PAGE);
break;
}
}
}
示例2: ToInt
protected static function ToInt($bin)
{
$result = 0;
$len = CUtil::BinStrlen($bin);
for ($i = 0; $i < $len; $i++) {
$byte = self::ReadByte($bin);
$result += $byte << ($len - $i - 1) * 8;
}
return $result;
}
示例3: getBatch
/**
* Returns batch of the message
* @return string
*/
public function getBatch()
{
$data = array("data" => array('contentTitle' => $this->title, "contentText" => $this->text, "messageParams" => $this->customProperties), "time_to_live" => $this->expiryValue, "registration_ids" => $this->deviceTokens);
$data = CPushManager::_MakeJson($data, "", true);
$batch = "Content-type: application/json\r\n";
$batch .= "Content-length: " . CUtil::BinStrlen($data) . "\r\n";
$batch .= "\r\n";
$batch .= $data;
return base64_encode($batch);
}
示例4: 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;
}
示例5: getBatch
public function getBatch()
{
$arTokens = $this->getRecipients();
$sPayload = $this->getPayload();
$nPayloadLength = CUtil::BinStrlen($sPayload);
$totalBatch = "";
for ($i = 0; $i < count($arTokens); $i++) {
$sDeviceToken = $arTokens[$i];
$nTokenLength = strlen($sDeviceToken);
$sRet = pack('CNNnH*', 1, $this->getCustomIdentifier(), $this->getExpiry() > 0 ? time() + $this->getExpiry() : 0, 32, $sDeviceToken);
$sRet .= pack('n', $nPayloadLength);
$sRet .= $sPayload;
if (strlen($totalBatch) > 0) {
$totalBatch .= ";";
}
$totalBatch .= base64_encode($sRet);
}
return $totalBatch;
}
示例6: AddAttachment
function AddAttachment($arFields)
{
global $DB;
$strSql = "SELECT ATTACHMENTS FROM b_mail_message WHERE ID=" . IntVal($arFields["MESSAGE_ID"]);
$dbr = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!($dbr_arr = $dbr->Fetch())) {
return false;
}
$n = IntVal($dbr_arr["ATTACHMENTS"]) + 1;
if (strlen($arFields["FILE_NAME"]) <= 0) {
$arFields["FILE_NAME"] = $n . ".";
if (strpos($arFields["CONTENT_TYPE"], "message/") === 0) {
$arFields["FILE_NAME"] .= "msg";
} else {
$arFields["FILE_NAME"] .= "tmp";
}
}
if (is_set($arFields, "CONTENT_TYPE")) {
$arFields["CONTENT_TYPE"] = strtolower($arFields["CONTENT_TYPE"]);
}
if (strpos($arFields["CONTENT_TYPE"], "image/") === 0 && (!is_set($arFields, "IMAGE_WIDTH") || !is_set($arFields, "IMAGE_HEIGHT")) && is_set($arFields, "FILE_DATA")) {
$filename = CTempFile::GetFileName(md5(uniqid("")) . '.tmp');
CheckDirPath($filename);
if (file_put_contents($filename, $arFields["FILE_DATA"]) !== false) {
$img_arr = CFile::GetImageSize($filename);
$arFields["IMAGE_WIDTH"] = $img_arr ? $img_arr[0] : 0;
$arFields["IMAGE_HEIGHT"] = $img_arr ? $img_arr[1] : 0;
}
}
if (is_set($arFields, "FILE_DATA") && !is_set($arFields, "FILE_SIZE")) {
$arFields["FILE_SIZE"] = CUtil::BinStrlen($arFields["FILE_DATA"]);
}
$file = array('name' => md5($arFields['FILE_NAME']), 'size' => $arFields['FILE_SIZE'], 'type' => $arFields['CONTENT_TYPE'], 'content' => $arFields['FILE_DATA'], 'MODULE_ID' => 'mail');
if (!($file_id = CFile::saveFile($file, 'mail/attachment'))) {
return false;
}
unset($arFields['FILE_DATA']);
$arFields['FILE_ID'] = $file_id;
$ID = $DB->add('b_mail_msg_attachment', $arFields);
if ($ID > 0) {
$strSql = 'UPDATE b_mail_message SET ATTACHMENTS = ' . $n . ' WHERE ID = ' . intval($arFields['MESSAGE_ID']);
$DB->query($strSql, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
}
return $ID;
}
示例7: elseif
strFinalStatus = "'.CUtil::JSEscape($strFinalStatus).'";
strGroupName = "'.CUtil::JSEscape($oTest->group_name).'";
strGroupDesc = "'.CUtil::JSEscape($oTest->group_desc).'";
test_result = '.($oTest->result === true ? 1 : ($oTest->result === false ? -1 : 0)).'; // 0 = note
';
}
else
echo '<h1>Permission denied: BITRIX SESSID ERROR</h1>';
exit;
}
elseif ($_REQUEST['read_log']) // after prolog to send correct charset
{
$oTest = new CSiteCheckerTest();
$str = htmlspecialcharsEx(file_get_contents($_SERVER['DOCUMENT_ROOT'].$oTest->LogFile));
if (($s = CUtil::BinStrlen($str)) > ini_get('pcre.backtrack_limit'))
@ini_set('pcre.backtrack_limit', $s);
?><!DOCTYPE HTML><html><body style="color:#666"><h1 style="color:#000"><?php
echo GetMessage("MAIN_SC_SYSTEST_LOG");
?>
</h1><?
$str = preg_replace('#^[0-9]{4}-...-[0-9]{2} .*\):#m','<span style="color:#000">$0</span>', $str);
if (preg_match('#[a-z_0-9]+#', $a = $_REQUEST['anchor']))
$str = preg_replace('#^.+\('.$a.'\)#m','<a name="'.$a.'" style="background-color:#EE3">$0</a>', $str);
$str = preg_replace('#Ok$#m', '<span style="color:#408218">$0</span>', $str);
$str = preg_replace('#Warning$#m', '<span style="color:#663300">$0</span>', $str);
$str = preg_replace('#Fail$#m', '<span style="color:#DD0000">$0</span>', $str);
echo '<pre>'.$str.'</pre>';
exit;
示例8: check_compression
function check_compression()
{
$strRequest = "GET "."/bitrix/admin/site_checker.php?test_type=compression&unique_id=".checker_get_unique_id()." HTTP/1.1\r\n";
$strRequest.= "Host: ".$this->host."\r\n";
$strRequest.= "Accept-Encoding: gzip, deflate\r\n";
$strRequest.= "\r\n";
$retVal = false;
if (!$res = $this->ConnectToHost())
return false;
$compression = IsModuleInstalled('compression');
$strRes = GetHttpResponse($res, $strRequest, $strHeaders);
if (preg_match('#gzip|deflate#mi', $strHeaders) && CUtil::BinStrlen($strRes) < 64 * 1024) // comression not supported by server
return $compression ? $this->Result(false, GetMessage("MAIN_SC_ENABLED")) : $this->Result(true, GetMessage("MAIN_SC_ENABLED_MOD"));
else
return $compression ? $this->Result(false, GetMessage("MAIN_SC_COMP_DISABLED")) : $this->Result(false, GetMessage("MAIN_SC_COMP_DISABLED_MOD"));
}
示例9: Analyze
function Analyze(&$content)
{
static $arLocalCache = array();
$content_len = CUtil::BinStrlen($content) * 2;
CUtil::AdjustPcreBacktrackLimit($content_len);
$this->stylewithiframe = preg_match("/<style.*>\\s*iframe/", $content);
$arData = preg_split("/(<script.*?>.*?<\\/script.*?>|<iframe.*?>.*?<\\/iframe.*?>)/is", $content, -1, PREG_SPLIT_DELIM_CAPTURE);
$cData = count($arData);
if ($cData < 2) {
return;
}
$bDataChanged = false;
for ($iData = 1; $iData < $cData; $iData += 2) {
$this->data = $arData[$iData];
//полный код блока, включая ограничивающие теги
// < 1 2 > 3 4
if (!preg_match('/^<(script|iframe)(.*?)>(.*?)(<\\/\\1.*?>)$/is', $this->data, $ret)) {
continue;
}
if ($iData > 1) {
$this->prev = $arData[$iData - 2] . $arData[$iData - 1];
} else {
$this->prev = $arData[$iData - 1];
}
if ($iData < $cData - 2) {
$this->next = $arData[$iData + 1] . $arData[$iData + 2];
} else {
$this->next = $arData[$iData + 1];
}
$this->resultrules = array();
$this->bodylines = false;
$this->atributes = $ret[2];
if (strtolower($ret[1]) == 'script') {
$this->body = $this->returnscriptbody($this->data);
$this->type = 'script';
} else {
$this->body = '';
$this->type = 'iframe';
}
$this->whitelist_id = $this->isinwhitelist();
if (!$this->whitelist_id) {
$cache_id = md5($this->data);
if (!isset($arLocalCache[$cache_id])) {
$arLocalCache[$cache_id] = $this->returnblockrating();
}
if ($arLocalCache[$cache_id] >= $this->maxrating) {
$this->dolog();
$arData[$iData] = $this->end_blkblock();
if ($this->replace) {
$bDataChanged = true;
}
}
}
$this->cnt++;
}
if ($bDataChanged) {
$content = implode('', $arData);
}
}
示例10: PrintHTTP
function PrintHTTP($strRequest, $strHeaders, $strRes)
{
echo
"== Request ==\n".
$strRequest.
"== Response ==\n".
$strHeaders.
"== Body ==\n".
(($l = CUtil::BinStrlen($strRes)) > 1000 ? CUtil::BinSubstr($strRes, 0, 1000).' ... ('.$l.' bytes)' : $strRes).
"==========\n";
}
示例11: AddAttachment
function AddAttachment($arFields)
{
global $DB;
$strSql = "SELECT ATTACHMENTS FROM b_mail_message WHERE ID=" . IntVal($arFields["MESSAGE_ID"]);
$dbr = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!($dbr_arr = $dbr->Fetch())) {
return false;
}
$n = IntVal($dbr_arr["ATTACHMENTS"]) + 1;
if (strlen($arFields["FILE_NAME"]) <= 0) {
$arFields["FILE_NAME"] = $n . ".";
if (strpos($arFields["CONTENT_TYPE"], "message/") === 0) {
$arFields["FILE_NAME"] .= "msg";
} else {
$arFields["FILE_NAME"] .= "tmp";
}
}
if (is_set($arFields, "CONTENT_TYPE")) {
$arFields["CONTENT_TYPE"] = strtolower($arFields["CONTENT_TYPE"]);
}
if (strpos($arFields["CONTENT_TYPE"], "image/") === 0 && (!is_set($arFields, "IMAGE_WIDTH") || !is_set($arFields, "IMAGE_HEIGHT")) && is_set($arFields, "FILE_DATA")) {
$filename = CTempFile::GetFileName(md5(uniqid("")) . '.tmp');
CheckDirPath($filename);
if (file_put_contents($filename, $arFields["FILE_DATA"]) !== false) {
$img_arr = CFile::GetImageSize($filename);
$arFields["IMAGE_WIDTH"] = $img_arr ? $img_arr[0] : 0;
$arFields["IMAGE_HEIGHT"] = $img_arr ? $img_arr[1] : 0;
}
}
if (is_set($arFields, "FILE_DATA") && !is_set($arFields, "FILE_SIZE")) {
$arFields["FILE_SIZE"] = CUtil::BinStrlen($arFields["FILE_DATA"]);
}
if (!CMailUtil::IsSizeAllowed(strlen($DB->ForSQL($arFields["FILE_DATA"])) + 100)) {
return false;
}
$ID = $DB->Add("b_mail_msg_attachment", $arFields, array("FILE_DATA"));
if ($ID > 0) {
$strSql = "UPDATE b_mail_message SET ATTACHMENTS=" . $n . " WHERE ID=" . IntVal($arFields["MESSAGE_ID"]);
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $ID;
/*
$arFile = Array(
"name"=>$filename,
"size"=>strlen($part["BODY"]),
"type"=>$part["CONTENT-TYPE"],
"content"=>$part["BODY"],
"MODULE_ID"=>"mail"
);
$file_id = CFile::SaveFile($arFile, "mail");
*/
}
示例12: SaveFile
public function SaveFile($arBucket, $filePath, $arFile)
{
global $APPLICATION;
if ($arBucket["PREFIX"]) {
if (substr($filePath, 0, strlen($arBucket["PREFIX"]) + 2) != "/" . $arBucket["PREFIX"] . "/") {
$filePath = "/" . $arBucket["PREFIX"] . "/" . ltrim($filePath, "/");
}
}
$filePath = CCloudUtil::URLEncode($filePath, "UTF-8");
$additional_headers = array();
if ($this->_public) {
$additional_headers["x-amz-acl"] = "public-read";
}
$additional_headers["Content-Type"] = $arFile["type"];
$additional_headers["Content-Length"] = array_key_exists("content", $arFile) ? CUtil::BinStrlen($arFile["content"]) : filesize($arFile["tmp_name"]);
$this->SetLocation($arBucket["LOCATION"]);
$response = $this->SendRequest($arBucket["SETTINGS"], 'PUT', $arBucket["BUCKET"], $filePath, '', array_key_exists("content", $arFile) ? $arFile["content"] : fopen($arFile["tmp_name"], "rb"), $additional_headers);
if ($this->status == 200) {
return true;
} elseif ($this->status == 403) {
return false;
} else {
$APPLICATION->ResetException();
return false;
}
}
示例13: HOTP
/**
* @param $pSecret
* @param $pCount
* @param int $pDigits
* @return bool|int
*/
protected static function HOTP($pSecret, $pCount, $pDigits = 6)
{
if(CUtil::BinStrlen($pSecret) <= 25)
$sha_hash = self::hmacsha1(pack("NN", 0, $pCount), $pSecret);
else
$sha_hash = self::hmacsha256(pack("NN", 0, $pCount), $pSecret);
if($sha_hash !== false)
{
$dwOffset = hexdec(substr($sha_hash, -1, 1));
$dbc1 = hexdec(substr($sha_hash, $dwOffset * 2, 8 ));
$dbc2 = $dbc1 & 0x7fffffff;
$hotp = $dbc2 % pow(10, $pDigits);
return str_pad($hotp, $pDigits, "0", STR_PAD_LEFT);
}
else
{
return false;
}
}
示例14: AdjustPcreBacktrackLimit
/**
* @param $pString
* @return bool
*/
protected static function AdjustPcreBacktrackLimit($pString)
{
if (!is_string($pString)) {
return false;
}
$strlen = CUtil::BinStrlen($pString) * 2;
CUtil::AdjustPcreBacktrackLimit($strlen);
return true;
}
示例15: 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;
}