本文整理汇总了PHP中Daemon::parseSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::parseSize方法的具体用法?PHP Daemon::parseSize怎么用?PHP Daemon::parseSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::parseSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadSettings
public static function loadSettings($settings)
{
$error = FALSE;
static $ktr = array('-' => '');
foreach ($settings as $k => $v) {
$k = strtolower(strtr($k, $ktr));
if ($k === 'config') {
$k = 'configfile';
}
if ($k === 'user' || $k === 'group') {
if ($v === '') {
$v = NULL;
}
}
if (array_key_exists($k, Daemon::$settings)) {
if ($k === 'maxmemoryusage') {
Daemon::$parsedSettings[$k] = Daemon::parseSize($v);
} elseif ($k === 'maxrequests') {
Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
} elseif ($k === 'autogc') {
Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
} elseif ($k === 'maxidle') {
Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
} elseif ($k === 'autoreload') {
Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
} elseif ($k === 'maxconcurrentrequestsperworker') {
Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
} elseif ($k === 'keepalive') {
Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
} elseif ($k === 'mpmdelay') {
Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
} elseif ($k === 'chunksize') {
Daemon::$parsedSettings[$k] = Daemon::parseSize($v);
}
if (is_int(Daemon::$settings[$k])) {
Daemon::$settings[$k] = (int) $v;
} else {
Daemon::$settings[$k] = $v;
}
} elseif (strpos($k, 'mod') === 0) {
Daemon::$settings[$k] = $v;
} else {
Daemon::log('Unrecognized parameter \'' . $k . '\'');
$error = TRUE;
}
}
if (isset($settings['path'])) {
if (isset(Daemon::$settings['chroot'])) {
Daemon::$pathReal = realpath(Daemon::$settings['chroot'] . (substr(Daemon::$settings['chroot'], -1) != '/' ? '/' : '') . Daemon::$settings['path']);
} else {
Daemon::$pathReal = realpath(Daemon::$settings['path']);
}
}
return !$error;
}
示例2: update
public function update()
{
Daemon::$parsedSettings['mod' . $this->modname . 'maxallowedpacket'] = Daemon::parseSize(Daemon::$settings['mod' . $this->modname . 'maxallowedpacket']);
}
示例3: parseStdin
public function parseStdin()
{
do {
if ($this->boundary === FALSE) {
break;
}
$continue = FALSE;
if ($this->mpartstate === 0) {
if (($p = strpos($this->attrs->stdinbuf, $ndl = '--' . $this->boundary . "\r\n", $this->mpartoffset)) !== FALSE) {
// we have found the nearest boundary at position $p
$this->mpartoffset = $p + strlen($ndl);
$this->mpartstate = 1;
$continue = TRUE;
}
} elseif ($this->mpartstate === 1) {
$this->mpartcondisp = FALSE;
if (($p = strpos($this->attrs->stdinbuf, "\r\n\r\n", $this->mpartoffset)) !== FALSE) {
$h = explode("\r\n", binarySubstr($this->attrs->stdinbuf, $this->mpartoffset, $p - $this->mpartoffset));
$this->mpartoffset = $p + 4;
$this->attrs->stdinbuf = binarySubstr($this->attrs->stdinbuf, $this->mpartoffset);
$this->mpartoffset = 0;
for ($i = 0, $s = sizeof($h); $i < $s; ++$i) {
$e = explode(':', $h[$i], 2);
$e[0] = strtr(strtoupper($e[0]), Request::$htr);
if (isset($e[1])) {
$e[1] = ltrim($e[1]);
}
if ($e[0] == 'CONTENT_DISPOSITION' && isset($e[1])) {
parse_str(strtr($e[1], Request::$hvaltr), $this->mpartcondisp);
if (!isset($this->mpartcondisp['form-data'])) {
break;
}
if (!isset($this->mpartcondisp['name'])) {
break;
}
$this->mpartcondisp['name'] = trim($this->mpartcondisp['name'], '"');
if (isset($this->mpartcondisp['filename'])) {
$this->mpartcondisp['filename'] = trim($this->mpartcondisp['filename'], '"');
if (!ini_get('file_uploads')) {
break;
}
$this->attrs->files[$this->mpartcondisp['name']] = array('name' => $this->mpartcondisp['filename'], 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_OK, 'size' => 0);
$tmpdir = ini_get('upload_tmp_dir');
if ($tmpdir === FALSE) {
$this->attrs->files[$this->mpartcondisp['name']]['fp'] = FALSE;
$this->attrs->files[$this->mpartcondisp['name']]['error'] = UPLOAD_ERR_NO_TMP_DIR;
} else {
$this->attrs->files[$this->mpartcondisp['name']]['fp'] = @fopen($this->attrs->files[$this->mpartcondisp['name']]['tmp_name'] = tempnam($tmpdir, 'php'), 'w');
if (!$this->attrs->files[$this->mpartcondisp['name']]['fp']) {
$this->attrs->files[$this->mpartcondisp['name']]['error'] = UPLOAD_ERR_CANT_WRITE;
}
}
$this->mpartstate = 3;
} else {
$this->attrs->post[$this->mpartcondisp['name']] = '';
}
} elseif ($e[0] == 'CONTENT_TYPE' && isset($e[1])) {
if (isset($this->mpartcondisp['name']) && isset($this->mpartcondisp['filename'])) {
$this->attrs->files[$this->mpartcondisp['name']]['type'] = $e[1];
}
}
}
if ($this->mpartstate === 1) {
$this->mpartstate = 2;
}
$continue = TRUE;
}
} elseif ($this->mpartstate === 2 || $this->mpartstate === 3) {
if (($p = strpos($this->attrs->stdinbuf, $ndl = "\r\n--" . $this->boundary . "\r\n", $this->mpartoffset)) !== FALSE || ($p = strpos($this->attrs->stdinbuf, $ndl = "\r\n--" . $this->boundary . "--\r\n", $this->mpartoffset)) !== FALSE) {
if ($this->mpartstate === 2 && isset($this->mpartcondisp['name'])) {
$this->attrs->post[$this->mpartcondisp['name']] .= binarySubstr($this->attrs->stdinbuf, $this->mpartoffset, $p - $this->mpartoffset);
} elseif ($this->mpartstate === 3 && isset($this->mpartcondisp['filename'])) {
if ($this->attrs->files[$this->mpartcondisp['name']]['fp']) {
fwrite($this->attrs->files[$this->mpartcondisp['name']]['fp'], binarySubstr($this->attrs->stdinbuf, $this->mpartoffset, $p - $this->mpartoffset));
}
$this->attrs->files[$this->mpartcondisp['name']]['size'] += $p - $this->mpartoffset;
}
if ($ndl === "\r\n--" . $this->boundary . "--\r\n") {
$this->mpartoffset = $p + strlen($ndl);
$this->mpartstate = 0;
// we done at all
} else {
$this->mpartoffset = $p;
$this->mpartstate = 1;
// let us parse the next part
$continue = TRUE;
}
$this->attrs->stdinbuf = binarySubstr($this->attrs->stdinbuf, $this->mpartoffset);
$this->mpartoffset = 0;
} else {
$p = strrpos($this->attrs->stdinbuf, "\r\n", $this->mpartoffset);
if ($p !== FALSE) {
if ($this->mpartstate === 2 && isset($this->mpartcondisp['name'])) {
$this->attrs->post[$this->mpartcondisp['name']] .= binarySubstr($this->attrs->stdinbuf, $this->mpartoffset, $p - $this->mpartoffset);
} elseif ($this->mpartstate === 3 && isset($this->mpartcondisp['filename'])) {
if ($this->attrs->files[$this->mpartcondisp['name']]['fp']) {
fwrite($this->attrs->files[$this->mpartcondisp['name']]['fp'], binarySubstr($this->attrs->stdinbuf, $this->mpartoffset, $p - $this->mpartoffset));
}
$this->attrs->files[$this->mpartcondisp['name']]['size'] += $p - $this->mpartoffset;
if (Daemon::parseSize(ini_get('upload_max_filesize')) < $this->attrs->files[$this->mpartcondisp['name']]['size']) {
//.........这里部分代码省略.........