本文整理汇总了PHP中mb_orig_strlen函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_orig_strlen函数的具体用法?PHP mb_orig_strlen怎么用?PHP mb_orig_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_orig_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Import
* @param mixed $id ID
* @return mixed
*/
public static function import($id)
{
if ($id instanceof static) {
return $id;
} elseif ($id instanceof \MongoId) {
$id = (string) $id;
} elseif (!is_string($id)) {
if (is_array($id) && isset($id['$id'])) {
return static::import($id['$id']);
}
return false;
} elseif (mb_orig_strlen($id) === 24) {
if (!ctype_xdigit($id)) {
return false;
}
} elseif (ctype_alnum($id)) {
$id = gmp_strval(gmp_init(strrev($id), 62), 16);
if (mb_orig_strlen($id) > 24) {
return false;
}
if (mb_orig_strlen($id) < 24) {
$id = str_pad($id, 24, '0', STR_PAD_LEFT);
}
} else {
return false;
}
return new static($id);
}
示例2: sendPacket
/**
* @TODO DESCR
* @param $p
*/
public function sendPacket($p)
{
if ($p === null) {
return;
}
$data = \igbinary_serialize($p);
$this->write(pack('N', mb_orig_strlen($data)) . $data);
}
示例3: checksum
/**
* Build checksum
* @param string $data Source
* @return string Checksum
*/
protected static function checksum($data)
{
$bit = unpack('n*', $data);
$sum = array_sum($bit);
if (mb_orig_strlen($data) % 2) {
$temp = unpack('C*', $data[mb_orig_strlen($data) - 1]);
$sum += $temp[1];
}
$sum = ($sum >> 16) + ($sum & 0xffff);
$sum += $sum >> 16;
return pack('n*', ~$sum);
}
示例4: __call
/**
* Magic __call
* Example:
* $gibson->set(3600, 'key', 'value');
* $gibson->get('key', function ($conn) {...});
* @param string $name Command name
* @param array $args Arguments
* @return void
*/
public function __call($name, $args)
{
$name = strtolower($name);
$onResponse = null;
if (($e = end($args)) && (is_array($e) || is_object($e)) && is_callable($e)) {
$onResponse = array_pop($args);
}
if (!isset($this->opCodes[$name])) {
throw new UndefinedMethodCalled();
}
$data = implode(" ", $args);
$this->requestByServer(null, pack('LS', mb_orig_strlen($data) + 2, $this->opCodes[$name]) . $data, $onResponse);
}
示例5: compareStrings
function compareStrings($expected, $actual)
{
if (function_exists('mb_orig_strlen')) {
$lenExpected = mb_orig_strlen($expected);
$lenActual = mb_orig_strlen($actual);
} else {
$lenExpected = strlen($expected);
$lenActual = strlen($actual);
}
$status = $lenExpected ^ $lenActual;
$len = min($lenExpected, $lenActual);
for ($i = 0; $i < $len; $i++) {
$status |= ord($expected[$i]) ^ ord($actual[$i]);
}
return $status === 0;
}
示例6: extract
/**
* Extract key and value pair from line.
* @param string $line
* @return array
*/
public static function extract($line)
{
$e = explode(': ', $line, 2);
$header = strtolower(trim($e[0]));
$value = isset($e[1]) ? trim($e[1]) : null;
$safe = false;
foreach (self::$safeCaseValues as $item) {
if (strncasecmp($header, $item, mb_orig_strlen($item)) === 0) {
$safe = true;
break;
}
if (strncasecmp($value, $item, mb_orig_strlen($item)) === 0) {
$safe = true;
break;
}
}
if (!$safe) {
$value = strtolower($value);
}
return [$header, $value];
}
示例7: compareStrings
/**
* A timing safe comparison method.
*
* C function memcmp() internally used by PHP, exits as soon as a difference
* is found in the two buffers. That makes possible of leaking
* timing information useful to an attacker attempting to iteratively guess
* the unknown string (e.g. password).
*
* @param string $expected
* @param string $actual
* @throws \Freetrix\Main\ArgumentTypeException
* @return bool
*/
protected function compareStrings($expected, $actual)
{
if (!is_string($expected)) {
throw new ArgumentTypeException('expected', 'string');
}
if (!is_string($actual)) {
throw new ArgumentTypeException('actual', 'string');
}
if (function_exists('mb_orig_strlen')) {
$lenExpected = mb_orig_strlen($expected);
$lenActual = mb_orig_strlen($actual);
} else {
$lenExpected = strlen($expected);
$lenActual = strlen($actual);
}
$status = $lenExpected ^ $lenActual;
$len = min($lenExpected, $lenActual);
for ($i = 0; $i < $len; $i++) {
$status |= ord($expected[$i]) ^ ord($actual[$i]);
}
return $status === 0;
}
示例8: init
/**
* Constructor
* @return void
*/
public function init()
{
parent::init();
if (isset($this->attrs->version)) {
$this->version = $this->attrs->version;
}
$this->header('Cache-Control: max-age=31536000, public, pre-check=0, post-check=0');
$this->header('Expires: ' . date('r', strtotime('+1 year')));
$html = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
document.domain = document.domain;
_sockjs_onload = function(){SockJS.bootstrap_iframe();};
</script>
<script src="https://cdn.jsdelivr.net/sockjs/' . htmlentities($this->version, ENT_QUOTES, 'UTF-8') . '/sockjs.min.js"></script>
</head>
<body>
<h2>Don\'t panic!</h2>
<p>This is a SockJS hidden iframe. It\'s used for cross domain magic.</p>
</body>
</html>';
$etag = 'W/"' . sha1($html) . '"';
$this->header('ETag: ' . $etag);
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
if ($_SERVER['HTTP_IF_NONE_MATCH'] === $etag) {
$this->status(304);
$this->removeHeader('Content-Type');
$this->finish();
return;
}
}
$this->header('Content-Length: ' . mb_orig_strlen($html));
echo $html;
$this->finish();
}
示例9: strlen
function strlen($s)
{
if (function_exists('mb_orig_strlen')) {
return mb_orig_strlen($s);
}
return strlen($s);
}
示例10: drawTable
/**
* Draw a table
* @param array Array of table's rows
* @return void
*/
public function drawTable($rows)
{
$pad = [];
foreach ($rows as $row) {
foreach ($row as $k => $v) {
if (substr($k, 0, 1) === '_') {
continue;
}
if (!isset($pad[$k]) || strlen($v) > $pad[$k]) {
$pad[$k] = mb_orig_strlen($v);
}
}
}
foreach ($rows as $row) {
if (isset($row['_color'])) {
$this->setStyle($row['_color']);
}
if (isset($row['_bold'])) {
$this->setStyle('1');
}
if (isset($row['_'])) {
echo $row['_'];
} else {
$i = 0;
foreach ($row as $k => $v) {
if (substr($k, 0, 1) === '_') {
continue;
}
if ($i > 0) {
echo "\t";
}
echo str_pad($v, $pad[$k]);
++$i;
}
}
$this->resetStyle();
echo "\n";
}
}
示例11: createXMLStream
/**
* @TODO DESCR
*/
public function createXMLStream()
{
$this->xml = new XMLStream();
$this->xml->setDefaultNS('jabber:client');
$this->xml->addXPathHandler('{http://etherx.jabber.org/streams}features', function ($xml) {
/** @var XMLStream $xml */
if ($xml->hasSub('starttls') and $this->use_encryption) {
$this->sendXML("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
} elseif ($xml->hasSub('bind') and $this->authorized) {
$id = $this->getId();
$this->iqSet('<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>' . $this->path . '</resource></bind>', function ($xml) {
if ($xml->attrs['type'] === 'result') {
$this->fulljid = $xml->sub('bind')->sub('jid')->data;
$jidarray = explode('/', $this->fulljid);
$this->jid = $jidarray[0];
}
$this->iqSet('<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />', function ($xml) {
$this->roster = new XMPPRoster($this);
if ($this->onConnected) {
$this->connected = true;
$this->onConnected->executeAll($this);
$this->onConnected = null;
}
$this->event('connected');
});
});
} else {
if (mb_orig_strlen($this->password)) {
$this->sendXML("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("" . $this->user . "" . $this->password) . "</auth>");
} else {
$this->sendXML("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>");
}
}
});
$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}success', function ($xml) {
$this->authorized = true;
$this->xml->finish();
$this->createXMLStream();
$this->startXMLStream();
});
$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}failure', function ($xml) {
if ($this->onConnected) {
$this->connected = false;
$func = $this->onConnected;
$func($this);
$this->onConnected = null;
}
$this->finish();
});
$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-tls}proceed', function ($xml) {
Daemon::log("XMPPClient: TLS not supported.");
});
$this->xml->addXPathHandler('{jabber:client}message', function ($xml) {
if (isset($xml->attrs['type'])) {
$payload['type'] = $xml->attrs['type'];
} else {
$payload['type'] = 'chat';
}
$payload['xml'] = $xml;
$payload['from'] = $xml->attrs['from'];
if ($xml->hasSub('body')) {
$payload['body'] = $xml->sub('body')->data;
$this->event('message', $payload);
}
});
}
示例12: read
/**
* Read from shared memory
* @param integer $offset Offset
* @param integer $length Length
* @return string Data
*/
public function read($offset, $length = 1)
{
$ret = '';
$segno = floor($offset / $this->segsize);
$sOffset = $offset % $this->segsize;
while (true) {
if (!isset($this->segments[$segno])) {
if (!$this->open($segno)) {
goto ret;
}
}
$ret .= shmop_read($this->segments[$segno], $sOffset, min($length - mb_orig_strlen($ret), $this->segsize));
if (mb_orig_strlen($ret) >= $length) {
goto ret;
}
++$segno;
$sOffset = 0;
}
ret:
return $ret === '' ? false : $ret;
}
示例13: sendChunk
/**
* Sends a chunk
* @param object $req Request
* @param string $chunk Data
* @return bool
*/
public function sendChunk($req, $chunk)
{
$packet = "" . "" . pack('nn', $req->attrs->id, mb_orig_strlen($chunk)) . "" . "";
// reserved
return $this->write($packet) && $this->write($chunk);
// content
}
示例14: _get_xml_chunk_mb_orig
public function _get_xml_chunk_mb_orig($fp)
{
if ($this->buf_position >= $this->buf_len) {
if (!feof($fp)) {
$this->buf = fread($fp, $this->read_size);
$this->buf_position = 0;
$this->buf_len = mb_orig_strlen($this->buf);
} else {
return false;
}
}
//Skip line delimiters (ltrim)
$xml_position = mb_orig_strpos($this->buf, "<", $this->buf_position);
while ($xml_position === $this->buf_position) {
$this->buf_position++;
$this->file_position++;
//Buffer ended with white space so we can refill it
if ($this->buf_position >= $this->buf_len) {
if (!feof($fp)) {
$this->buf = fread($fp, $this->read_size);
$this->buf_position = 0;
$this->buf_len = mb_orig_strlen($this->buf);
} else {
return false;
}
}
$xml_position = mb_orig_strpos($this->buf, "<", $this->buf_position);
}
//Let's find next line delimiter
while ($xml_position === false) {
$next_search = $this->buf_len;
//Delimiter not in buffer so try to add more data to it
if (!feof($fp)) {
$this->buf .= fread($fp, $this->read_size);
$this->buf_len = mb_orig_strlen($this->buf);
} else {
break;
}
//Let's find xml tag start
$xml_position = mb_orig_strpos($this->buf, "<", $next_search);
}
if ($xml_position === false) {
$xml_position = $this->buf_len + 1;
}
$len = $xml_position - $this->buf_position;
$this->file_position += $len;
$result = mb_orig_substr($this->buf, $this->buf_position, $len);
$this->buf_position = $xml_position;
return $result;
}
示例15: mask
/**
* Apply mask
* @param $data
* @param string|false $mask
* @return mixed
*/
public function mask($data, $mask)
{
for ($i = 0, $l = mb_orig_strlen($data), $ml = mb_orig_strlen($mask); $i < $l; $i++) {
$data[$i] = $data[$i] ^ $mask[$i % $ml];
}
return $data;
}