本文整理汇总了PHP中mb_orig_substr函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_orig_substr函数的具体用法?PHP mb_orig_substr怎么用?PHP mb_orig_substr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_orig_substr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: substr
function substr($s, $a, $b = null)
{
if (function_exists('mb_orig_substr')) {
return $b === null ? mb_orig_substr($s, $a) : mb_orig_substr($s, $a, $b);
}
return $b === null ? substr($s, $a) : substr($s, $a, $b);
}
示例2: substr
public static function substr($s, $a, $b = null)
{
if (function_exists('mb_orig_substr'))
return $b === null ? mb_orig_substr($s, $a) : mb_orig_substr($s, $a, $b);
return $b === null ? substr($s, $a) : substr($s, $a, $b);
}
示例3: write
/**
* Write to shared memory
* @param string $data Data
* @param integer $offset Offset
* @return boolean Success
*/
public function write($data, $offset)
{
$segno = floor($offset / $this->segsize);
if (!isset($this->segments[$segno])) {
if (!$this->open($segno, true)) {
return false;
}
}
$sOffset = $offset % $this->segsize;
$d = $this->segsize - ($sOffset + mb_orig_strlen($data));
if ($d < 0) {
$this->write(mb_orig_substr($data, $d), ($segno + 1) * $this->segsize);
$data = mb_orig_substr($data, 0, $d);
}
//Daemon::log('writing to #'.$offset.' (segno '.$segno.')');
shmop_write($this->segments[$segno], $data, $sOffset);
return true;
}
示例4: onRead
/**
* Called when new data received
* @return void
*/
public function onRead()
{
Timer::setTimeout($this->keepaliveTimer);
while (($line = $this->readline()) !== null) {
if ($line === '') {
continue;
}
if (mb_orig_strlen($line) > 512) {
Daemon::$process->log('IRCBouncerConnection error: buffer overflow.');
$this->finish();
return;
}
$line = mb_orig_substr($line, 0, -mb_orig_strlen($this->EOL));
$p = mb_orig_strpos($line, ':', 1);
$max = $p ? substr_count($line, " ", 0, $p) + 1 : 18;
$e = explode(" ", $line, $max);
$i = 0;
$cmd = $e[$i++];
$args = [];
for ($s = min(sizeof($e), 14); $i < $s; ++$i) {
if ($e[$i][0] === ':') {
$args[] = mb_orig_substr($e[$i], 1);
break;
}
$args[] = $e[$i];
}
if (ctype_digit($cmd)) {
$code = (int) $cmd;
$cmd = isset(IRC::$codes[$code]) ? IRC::$codes[$code] : 'UNKNOWN-' . $code;
}
$this->onCommand($cmd, $args);
}
if (mb_orig_strlen($this->buf) > 512) {
Daemon::$process->log('IRCClientConnection error: buffer overflow.');
$this->finish();
}
}
示例5: onUdpPacket
/**
* Called when new UDP packet received.
* @param string $pct
* @return void
*/
public function onUdpPacket($pct)
{
if (mb_orig_strlen($pct) < 10) {
return;
}
$orig = $pct;
$this->response = [];
Binary::getWord($pct);
// ID
$bitmap = Binary::getBitmap(Binary::getByte($pct)) . Binary::getBitmap(Binary::getByte($pct));
//$qr = (int) $bitmap[0];
$opcode = bindec(substr($bitmap, 1, 4));
//$aa = (int) $bitmap[5];
//$tc = (int) $bitmap[6];
//$rd = (int) $bitmap[7];
//$ra = (int) $bitmap[8];
//$z = bindec(substr($bitmap, 9, 3));
$rcode = bindec(mb_orig_substr($bitmap, 12));
$this->response['status'] = ['rcode' => $rcode, 'msg' => $this->getMessageByRcode($rcode)];
$qdcount = Binary::getWord($pct);
$ancount = Binary::getWord($pct);
$nscount = Binary::getWord($pct);
$arcount = Binary::getWord($pct);
for ($i = 0; $i < $qdcount; ++$i) {
$name = Binary::parseLabels($pct, $orig);
$typeInt = Binary::getWord($pct);
$type = isset(Pool::$type[$typeInt]) ? Pool::$type[$typeInt] : 'UNK(' . $typeInt . ')';
$classInt = Binary::getWord($pct);
$class = isset(Pool::$class[$classInt]) ? Pool::$class[$classInt] : 'UNK(' . $classInt . ')';
if (!isset($this->response[$type])) {
$this->response[$type] = [];
}
$record = ['name' => $name, 'type' => $type, 'class' => $class];
$this->response['query'][] = $record;
}
$getResRecord = function (&$pct) use($orig) {
$name = Binary::parseLabels($pct, $orig);
$typeInt = Binary::getWord($pct);
$type = isset(Pool::$type[$typeInt]) ? Pool::$type[$typeInt] : 'UNK(' . $typeInt . ')';
$classInt = Binary::getWord($pct);
$class = isset(Pool::$class[$classInt]) ? Pool::$class[$classInt] : 'UNK(' . $classInt . ')';
$ttl = Binary::getDWord($pct);
$length = Binary::getWord($pct);
$data = mb_orig_substr($pct, 0, $length);
$pct = mb_orig_substr($pct, $length);
$record = ['name' => $name, 'type' => $type, 'class' => $class, 'ttl' => $ttl];
if ($type === 'A' || $type === 'AAAA') {
if ($data === "") {
$record['ip'] = false;
$record['ttl'] = 5;
} else {
$record['ip'] = inet_ntop($data);
}
} elseif ($type === 'NS') {
$record['ns'] = Binary::parseLabels($data, $orig);
} elseif ($type === 'CNAME') {
$record['cname'] = Binary::parseLabels($data, $orig);
} elseif ($type === 'SOA') {
$record['mname'] = Binary::parseLabels($data, $orig);
$record['rname'] = Binary::parseLabels($data, $orig);
$record['serial'] = Binary::getDWord($data);
$record['refresh'] = Binary::getDWord($data);
$record['retry'] = Binary::getDWord($data);
$record['expire'] = Binary::getDWord($data);
$record['nx'] = Binary::getDWord($data);
} elseif ($type === 'MX') {
$record['preference'] = Binary::getWord($data);
$record['exchange'] = Binary::parseLabels($data, $orig);
} elseif ($type === 'TXT') {
$record['text'] = '';
$lastLength = -1;
while (($length = mb_orig_strlen($data)) > 0 && $length !== $lastLength) {
$record['text'] .= Binary::parseLabels($data, $orig);
$lastLength = $length;
}
} elseif ($type === 'SRV') {
$record['priority'] = Binary::getWord($data);
$record['weight'] = Binary::getWord($data);
$record['port'] = Binary::getWord($data);
$record['target'] = Binary::parseLabels($data, $orig);
}
return $record;
};
for ($i = 0; $i < $ancount; ++$i) {
$record = $getResRecord($pct);
if (!isset($this->response[$record['type']])) {
$this->response[$record['type']] = [];
}
$this->response[$record['type']][] = $record;
}
for ($i = 0; $i < $nscount; ++$i) {
$record = $getResRecord($pct);
if (!isset($this->response[$record['type']])) {
$this->response[$record['type']] = [];
}
//.........这里部分代码省略.........
示例6: out
/**
* Output some data
* @param string $s String to out
* @param boolean $flush ob_flush?
* @return boolean Success
*/
public function out($s, $flush = true)
{
if ($flush) {
if (!Daemon::$obInStack) {
// preventing recursion
ob_flush();
}
}
if ($this->aborted) {
return false;
}
if (!isset($this->upstream)) {
return false;
}
$l = mb_orig_strlen($s);
$this->responseLength += $l;
$this->ensureSentHeaders();
if ($this->attrs->chunked) {
for ($o = 0; $o < $l;) {
$c = min($this->upstream->pool->config->chunksize->value, $l - $o);
$chunk = dechex($c) . "\r\n" . ($c === $l ? $s : mb_orig_substr($s, $o, $c)) . "\r\n";
if ($this->sendfp) {
$this->sendfp->write($chunk);
} else {
$this->upstream->requestOut($this, $chunk);
}
$o += $c;
}
return true;
} else {
if ($this->sendfp) {
$this->sendfp->write($s);
return true;
}
if (Daemon::$compatMode) {
echo $s;
return true;
}
return $this->upstream->requestOut($this, $s);
}
}
示例7: _getFilteredDirs
private function _getFilteredDirs($dirs)
{
$curdir = getcwd();
foreach ($dirs as $idx => $dir) {
if ($dir === $curdir) {
$dir = ".";
}
if (mb_orig_strpos($dir, "{$curdir}/") === 0) {
$dir = mb_orig_substr($dir, mb_orig_strlen($curdir) + 1);
}
$parts = explode("/", $dir);
foreach ($parts as $p) {
if ($p === ".") {
continue;
}
if (isset($this->exclude[$p])) {
unset($dirs[$idx]);
continue 2;
}
}
/* check if dir is still present, because event could be delivered when dir does not exist anymore */
$stat = $this->_stat($dir);
if ($stat !== 'dir') {
unset($dirs[$idx]);
continue;
}
$dirs[$idx] = $dir;
}
return $dirs;
}
示例8: onRead
/**
* Called when new data received
* @return void
*/
protected function onRead()
{
start:
if ($this->state === static::STATE_STANDBY) {
// outside of packet
while (($l = $this->readline()) !== null) {
if ($l === '') {
continue;
}
$char = $l[0];
$val = mb_orig_substr($l, 1);
if ($char === ':') {
// inline integer
$this->pushValue((int) $val);
goto start;
} elseif ($char === '+' || $char === '-') {
// inline string
$this->error = $char === '-';
$this->pushValue($val);
goto start;
} elseif ($char === '*') {
// defines number of elements of incoming array
$length = (int) $val;
if ($length <= 0) {
$this->pushValue([]);
goto start;
}
$ptr = [];
if (is_array($this->ptr)) {
$this->ptr[] =& $ptr;
}
$this->ptr =& $ptr;
$this->stack[] = [&$ptr, $length];
$this->levelLength = $length;
unset($ptr);
goto start;
} elseif ($char === '$') {
// defines size of the data block
if ($l[1] === '-') {
$this->pushValue(null);
goto start;
}
$this->valueLength = (int) $val;
if ($this->valueLength + 2 > $this->pool->maxAllowedPacket) {
$this->log('max-allowed-packet (' . $this->pool->config->maxallowedpacket->getHumanValue() . ') exceed, aborting connection');
$this->finish();
return;
}
$this->setWatermark($this->valueLength + 2);
$this->state = static::STATE_BINARY;
// binary data block
break;
// stop reading line-by-line
}
}
}
if ($this->state === static::STATE_BINARY) {
// inside of binary data block
if ($this->getInputLength() < $this->valueLength + 2) {
return;
//we do not have a whole packet
}
$value = $this->read($this->valueLength);
if ($this->read(2) !== $this->EOL) {
$this->finish();
return;
}
$this->state = static::STATE_STANDBY;
$this->setWatermark(3);
$this->pushValue($value);
goto start;
}
}
示例9: substr
function substr($a, $b, $c = null)
{
if ($c === null) {
return function_exists('mb_orig_substr') ? mb_orig_substr($a, $b) : substr($a, $b);
} else {
return function_exists('mb_orig_substr') ? mb_orig_substr($a, $b, $c) : substr($a, $b, $c);
}
}
示例10: fastSubstr
protected static function fastSubstr($string, $start, $length = null)
{
if (function_exists("mb_orig_substr")) {
return mb_orig_substr($string, $start, $length);
}
return substr($string, $start, $length);
}
示例11: _getChunk_mb_orig
protected function _getChunk_mb_orig()
{
if ($this->_bufferPosition >= $this->_bufferLength) {
if (!feof($this->_file)) {
$this->_buffer = fread($this->_file, $this->_chunkReadSize);
$this->_bufferPosition = 0;
$this->_bufferLength = mb_orig_strlen($this->_buffer);
} else {
return false;
}
}
//Skip line delimiters (ltrim)
$position = mb_orig_strpos($this->_buffer, "<", $this->_bufferPosition);
while ($position === $this->_bufferPosition) {
$this->_bufferPosition++;
$this->_filePosition++;
//Buffer ended with white space so we can refill it
if ($this->_bufferPosition >= $this->_bufferLength) {
if (!feof($this->_file)) {
$this->_buffer = fread($this->_file, $this->_chunkReadSize);
$this->_bufferPosition = 0;
$this->_bufferLength = mb_orig_strlen($this->_buffer);
} else {
return false;
}
}
$position = mb_orig_strpos($this->_buffer, "<", $this->_bufferPosition);
}
//Let's find next line delimiter
while ($position === false) {
$next_search = $this->_bufferLength;
//Delimiter not in buffer so try to add more data to it
if (!feof($this->_file)) {
$this->_buffer .= fread($this->_file, $this->_chunkReadSize);
$this->_bufferLength = mb_orig_strlen($this->_buffer);
} else {
break;
}
//Let's find xml tag start
$position = mb_orig_strpos($this->_buffer, "<", $next_search);
}
if ($position === false) {
$position = $this->_bufferLength + 1;
}
$len = $position - $this->_bufferPosition;
$this->_filePosition += $len;
$result = mb_orig_substr($this->_buffer, $this->_bufferPosition, $len);
$this->_bufferPosition = $position;
return $result;
}
示例12: mask
/**
* @TODO
* @param string $mask
* @param string $str
* @return string
*/
protected static function mask($mask, $str)
{
$out = '';
$l = mb_orig_strlen($str);
$ml = mb_orig_strlen($mask);
while (($o = mb_orig_strlen($out)) < $l) {
$out .= mb_orig_substr($str, $o, $ml) ^ $mask;
}
return $out;
}
示例13: loadFile
/**
* @return bool
*/
public function loadFile()
{
$this->_openConnection();
fwrite($this->_socket, $this->_requestHeader);
// stream_set_blocking($this->_socket, 0); :)
$bHeaderRead = false;
$header = '';
$startTime = getmicrotime();
while (!($this->_bComplete = feof($this->_socket) || $this->_rangeTo > 0 && $this->_fileLoaded >= $this->_rangeTo)) {
if ($this->_timeLimit > 0 && getmicrotime() - $startTime > $this->_timeLimit) {
break;
}
$result = fread($this->_socket, 256 * 1024);
if (false === $bHeaderRead) {
$header .= $result;
if (static::$_bMBStringOrig) {
$posHSplit = mb_orig_strpos($header, "\r\n\r\n");
} else {
$posHSplit = strpos($header, "\r\n\r\n");
}
if ($posHSplit !== false) {
if (static::$_bMBStringOrig) {
$result = mb_orig_substr($header, $posHSplit + 4);
$header = mb_orig_substr($header, 0, $posHSplit + 2);
$this->_headerSize = mb_orig_strlen($header);
} else {
$result = substr($header, $posHSplit + 4);
$header = substr($header, 0, $posHSplit + 2);
$this->_headerSize = strlen($header);
}
$this->_readHeaderData($header);
$bHeaderRead = true;
} else {
continue;
}
}
$this->_writeResult($result);
}
if ($this->_bufferLoaded > 0) {
$result = null;
$this->_writeResult($result, true);
}
if (true === $this->_bComplete) {
@unlink($this->_dwnStateFilePath);
} else {
$this->_saveStepToFile();
}
fclose($this->_socket);
$this->_socket = null;
fclose($this->_dwnFileHandler);
$this->_dwnFileHandler = null;
return $this->_bComplete;
}
示例14: bitmap2bytes
/**
* Convert bitmap into bytes
* @param string $bitmap Bitmap
* @param integer $check_len Check length?
* @return string|false
*/
public static function bitmap2bytes($bitmap, $check_len = 0)
{
$r = '';
$bitmap = str_pad($bitmap, ceil(mb_orig_strlen($bitmap) / 8) * 8, '0', STR_PAD_LEFT);
for ($i = 0, $n = mb_orig_strlen($bitmap) / 8; $i < $n; ++$i) {
$r .= chr((int) bindec(mb_orig_substr($bitmap, $i * 8, 8)));
}
if ($check_len && mb_orig_strlen($r) !== $check_len) {
return false;
}
return $r;
}
示例15: _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;
}