本文整理汇总了PHP中php_to_byte函数的典型用法代码示例。如果您正苦于以下问题:PHP php_to_byte函数的具体用法?PHP php_to_byte怎么用?PHP php_to_byte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_to_byte函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _validate
/**
* @throws Exception max size, required or upload error
*/
protected function _validate()
{
global $lang;
parent::_validate();
$file = $this->getParam('file');
if ($file['error'] == 1 || $file['error'] == 2) {
throw new Exception(sprintf($lang['uploadsize'], filesize_h(php_to_byte(ini_get('upload_max_filesize')))));
} else {
if ($file['error'] == 4) {
if (!isset($this->opt['optional'])) {
throw new Exception(sprintf($this->getLang('e_required'), hsc($this->opt['label'])));
}
} else {
if ($file['error'] || !is_uploaded_file($file['tmp_name'])) {
throw new Exception(hsc($this->opt['label']) . ' ' . $lang['uploadfail'] . ' (' . $file['error'] . ')');
}
}
}
}
示例2: is_mem_available
/**
* Checks if the given amount of memory is available
*
* If the memory_get_usage() function is not available the
* function just assumes $bytes of already allocated memory
*
* @author Filip Oscadal <webmaster@illusionsoftworks.cz>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param int $mem Size of memory you want to allocate in bytes
* @param int $bytes
* @internal param int $used already allocated memory (see above)
* @return bool
*/
function is_mem_available($mem, $bytes = 1048576)
{
$limit = trim(ini_get('memory_limit'));
if (empty($limit)) {
return true;
}
// no limit set!
// parse limit to bytes
$limit = php_to_byte($limit);
// get used memory if possible
if (function_exists('memory_get_usage')) {
$used = memory_get_usage();
} else {
$used = $bytes;
}
if ($used + $mem > $limit) {
return false;
}
return true;
}
示例3: check
/**
* Run a few sanity checks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check()
{
global $conf;
global $INFO;
msg('DokuWiki version: ' . getVersion(), 1);
if (version_compare(phpversion(), '5.1.2', '<')) {
msg('Your PHP version is too old (' . phpversion() . ' vs. 5.1.2+ needed)', -1);
} else {
msg('PHP version ' . phpversion(), 1);
}
$mem = (int) php_to_byte(ini_get('memory_limit'));
if ($mem) {
if ($mem < 16777216) {
msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1);
} elseif ($mem < 20971520) {
msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1);
} elseif ($mem < 33554432) {
msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0);
} else {
msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1);
}
}
if (is_writable($conf['changelog'])) {
msg('Changelog is writable', 1);
} else {
if (@file_exists($conf['changelog'])) {
msg('Changelog is not writable', -1);
}
}
if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) {
msg('Old changelog exists', 0);
}
if (@file_exists($conf['changelog'] . '_failed')) {
msg('Importing old changelog failed', -1);
} else {
if (@file_exists($conf['changelog'] . '_importing')) {
msg('Importing old changelog now.', 0);
} else {
if (@file_exists($conf['changelog'] . '_import_ok')) {
msg('Old changelog imported', 1);
if (!plugin_isdisabled('importoldchangelog')) {
msg('Importoldchangelog plugin not disabled after import', -1);
}
}
}
}
if (is_writable($conf['datadir'])) {
msg('Datadir is writable', 1);
} else {
msg('Datadir is not writable', -1);
}
if (is_writable($conf['olddir'])) {
msg('Attic is writable', 1);
} else {
msg('Attic is not writable', -1);
}
if (is_writable($conf['mediadir'])) {
msg('Mediadir is writable', 1);
} else {
msg('Mediadir is not writable', -1);
}
if (is_writable($conf['cachedir'])) {
msg('Cachedir is writable', 1);
} else {
msg('Cachedir is not writable', -1);
}
if (is_writable($conf['lockdir'])) {
msg('Lockdir is writable', 1);
} else {
msg('Lockdir is not writable', -1);
}
if ($conf['authtype'] == 'plain') {
if (is_writable(DOKU_CONF . 'users.auth.php')) {
msg('conf/users.auth.php is writable', 1);
} else {
msg('conf/users.auth.php is not writable', 0);
}
}
if (function_exists('mb_strpos')) {
if (defined('UTF8_NOMBSTRING')) {
msg('mb_string extension is available but will not be used', 0);
} else {
msg('mb_string extension is available and will be used', 1);
if (ini_get('mbstring.func_overload') != 0) {
msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1);
}
}
} else {
msg('mb_string extension not available - PHP only replacements will be used', 0);
}
if ($conf['allowdebug']) {
msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1);
} else {
msg('Debugging support is disabled', 1);
}
//.........这里部分代码省略.........
示例4: check
/**
* Run a few sanity checks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check()
{
global $conf;
global $INFO;
if ($INFO['isadmin'] || $INFO['ismanager']) {
msg('DokuWiki version: ' . getVersion(), 1);
}
if (version_compare(phpversion(), '5.2.0', '<')) {
msg('Your PHP version is too old (' . phpversion() . ' vs. 5.2.0+ needed)', -1);
} else {
msg('PHP version ' . phpversion(), 1);
}
$mem = (int) php_to_byte(ini_get('memory_limit'));
if ($mem) {
if ($mem < 16777216) {
msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1);
} elseif ($mem < 20971520) {
msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1);
} elseif ($mem < 33554432) {
msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0);
} else {
msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1);
}
}
if (is_writable($conf['changelog'])) {
msg('Changelog is writable', 1);
} else {
if (@file_exists($conf['changelog'])) {
msg('Changelog is not writable', -1);
}
}
if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) {
msg('Old changelog exists', 0);
}
if (@file_exists($conf['changelog'] . '_failed')) {
msg('Importing old changelog failed', -1);
} else {
if (@file_exists($conf['changelog'] . '_importing')) {
msg('Importing old changelog now.', 0);
} else {
if (@file_exists($conf['changelog'] . '_import_ok')) {
msg('Old changelog imported', 1);
if (!plugin_isdisabled('importoldchangelog')) {
msg('Importoldchangelog plugin not disabled after import', -1);
}
}
}
}
if (is_writable(DOKU_CONF)) {
msg('conf directory is writable', 1);
} else {
msg('conf directory is not writable', -1);
}
if ($conf['authtype'] == 'plain') {
global $config_cascade;
if (is_writable($config_cascade['plainauth.users']['default'])) {
msg('conf/users.auth.php is writable', 1);
} else {
msg('conf/users.auth.php is not writable', 0);
}
}
if (function_exists('mb_strpos')) {
if (defined('UTF8_NOMBSTRING')) {
msg('mb_string extension is available but will not be used', 0);
} else {
msg('mb_string extension is available and will be used', 1);
if (ini_get('mbstring.func_overload') != 0) {
msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1);
}
}
} else {
msg('mb_string extension not available - PHP only replacements will be used', 0);
}
if (!UTF8_PREGSUPPORT) {
msg('PHP is missing UTF-8 support in Perl-Compatible Regular Expressions (PCRE)', -1);
}
if (!UTF8_PROPERTYSUPPORT) {
msg('PHP is missing Unicode properties support in Perl-Compatible Regular Expressions (PCRE)', -1);
}
$loc = setlocale(LC_ALL, 0);
if (!$loc) {
msg('No valid locale is set for your PHP setup. You should fix this', -1);
} elseif (stripos($loc, 'utf') === false) {
msg('Your locale <code>' . hsc($loc) . '</code> seems not to be a UTF-8 locale, you should fix this if you encounter problems.', 0);
} else {
msg('Valid locale ' . hsc($loc) . ' found.', 1);
}
if ($conf['allowdebug']) {
msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1);
} else {
msg('Debugging support is disabled', 1);
}
if ($INFO['userinfo']['name']) {
msg('You are currently logged in as ' . $_SERVER['REMOTE_USER'] . ' (' . $INFO['userinfo']['name'] . ')', 0);
msg('You are part of the groups ' . join($INFO['userinfo']['grps'], ', '), 0);
//.........这里部分代码省略.........
示例5: media_upload
if (isset($_FILES['Filedata'])) {
$_FILES['upload'] =& $_FILES['Filedata'];
$JUMPTO = media_upload($NS, $AUTH);
if ($JUMPTO == false) {
header("HTTP/1.0 400 Bad Request");
echo 'Upload failed';
}
echo 'ok';
exit;
}
// give info on PHP catched upload errors
if ($_FILES['upload']['error']) {
switch ($_FILES['upload']['error']) {
case 1:
case 2:
msg(sprintf($lang['uploadsize'], filesize_h(php_to_byte(ini_get('upload_max_filesize')))), -1);
break;
default:
msg($lang['uploadfail'] . ' (' . $_FILES['upload']['error'] . ')', -1);
}
unset($_FILES['upload']);
}
// handle upload
if ($_FILES['upload']['tmp_name']) {
$JUMPTO = media_upload($NS, $AUTH);
if ($JUMPTO) {
$NS = getNS($JUMPTO);
}
}
// handle meta saving
if ($IMG && $_REQUEST['do']['save']) {
示例6: media_getuploadsize
/**
* Returns the size uploaded files may have
*
* This uses a conservative approach using the lowest number found
* in any of the limiting ini settings
*
* @returns int size in bytes
*/
function media_getuploadsize()
{
$okay = 0;
$post = (int) php_to_byte(@ini_get('post_max_size'));
$suho = (int) php_to_byte(@ini_get('suhosin.post.max_value_length'));
$upld = (int) php_to_byte(@ini_get('upload_max_filesize'));
if ($post && ($post < $okay || $okay == 0)) {
$okay = $post;
}
if ($suho && ($suho < $okay || $okay == 0)) {
$okay = $suho;
}
if ($upld && ($upld < $okay || $okay == 0)) {
$okay = $upld;
}
return $okay;
}
示例7: media_uploadform
/**
* Print the media upload form if permissions are correct
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function media_uploadform($ns, $auth)
{
global $lang;
if ($auth < AUTH_UPLOAD) {
return;
}
//fixme print info on missing permissions?
// The default HTML upload form
$form = new Doku_Form(array('id' => 'dw__upload', 'action' => DOKU_BASE . 'lib/exe/mediamanager.php', 'enctype' => 'multipart/form-data'));
$form->addElement('<div class="upload">' . $lang['mediaupload'] . '</div>');
$form->addElement(formSecurityToken());
$form->addHidden('ns', hsc($ns));
$form->addElement(form_makeOpenTag('p'));
$form->addElement(form_makeFileField('upload', $lang['txt_upload'] . ':', 'upload__file'));
$form->addElement(form_makeCloseTag('p'));
$form->addElement(form_makeOpenTag('p'));
$form->addElement(form_makeTextField('id', '', $lang['txt_filename'] . ':', 'upload__name'));
$form->addElement(form_makeButton('submit', '', $lang['btn_upload']));
$form->addElement(form_makeCloseTag('p'));
if ($auth >= AUTH_DELETE) {
$form->addElement(form_makeOpenTag('p'));
$form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check'));
$form->addElement(form_makeCloseTag('p'));
}
html_form('upload', $form);
// prepare flashvars for multiupload
$opt = array('L_gridname' => $lang['mu_gridname'], 'L_gridsize' => $lang['mu_gridsize'], 'L_gridstat' => $lang['mu_gridstat'], 'L_namespace' => $lang['mu_namespace'], 'L_overwrite' => $lang['txt_overwrt'], 'L_browse' => $lang['mu_browse'], 'L_upload' => $lang['btn_upload'], 'L_toobig' => $lang['mu_toobig'], 'L_ready' => $lang['mu_ready'], 'L_done' => $lang['mu_done'], 'L_fail' => $lang['mu_fail'], 'L_authfail' => $lang['mu_authfail'], 'L_progress' => $lang['mu_progress'], 'L_filetypes' => $lang['mu_filetypes'], 'L_info' => $lang['mu_info'], 'L_lasterr' => $lang['mu_lasterr'], 'O_ns' => ":{$ns}", 'O_backend' => 'mediamanager.php?' . session_name() . '=' . session_id(), 'O_maxsize' => php_to_byte(ini_get('upload_max_filesize')), 'O_extensions' => join('|', array_keys(getMimeTypes())), 'O_overwrite' => $auth >= AUTH_DELETE, 'O_sectok' => getSecurityToken(), 'O_authtok' => auth_createToken());
$var = buildURLparams($opt);
// output the flash uploader
?>
<div id="dw__flashupload" style="display:none">
<div class="upload"><?php
echo $lang['mu_intro'];
?>
</div>
<?php
echo html_flashobject('multipleUpload.swf', '500', '190', null, $opt);
?>
</div>
<?php
}
示例8: check
/**
* Run a few sanity checks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check()
{
global $conf;
global $INFO;
if ($INFO['isadmin'] || $INFO['ismanager']) {
msg('DokuWiki version: ' . getVersion(), 1);
}
if (version_compare(phpversion(), '5.1.2', '<')) {
msg('Your PHP version is too old (' . phpversion() . ' vs. 5.1.2+ needed)', -1);
} else {
msg('PHP version ' . phpversion(), 1);
}
$mem = (int) php_to_byte(ini_get('memory_limit'));
if ($mem) {
if ($mem < 16777216) {
msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1);
} elseif ($mem < 20971520) {
msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1);
} elseif ($mem < 33554432) {
msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0);
} else {
msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1);
}
}
if (is_writable($conf['changelog'])) {
msg('Changelog is writable', 1);
} else {
if (@file_exists($conf['changelog'])) {
msg('Changelog is not writable', -1);
}
}
if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) {
msg('Old changelog exists', 0);
}
if (@file_exists($conf['changelog'] . '_failed')) {
msg('Importing old changelog failed', -1);
} else {
if (@file_exists($conf['changelog'] . '_importing')) {
msg('Importing old changelog now.', 0);
} else {
if (@file_exists($conf['changelog'] . '_import_ok')) {
msg('Old changelog imported', 1);
if (!plugin_isdisabled('importoldchangelog')) {
msg('Importoldchangelog plugin not disabled after import', -1);
}
}
}
}
if (is_writable($conf['datadir'])) {
msg('Datadir is writable', 1);
} else {
msg('Datadir is not writable', -1);
}
if (is_writable($conf['olddir'])) {
msg('Attic is writable', 1);
} else {
msg('Attic is not writable', -1);
}
if (is_writable($conf['mediadir'])) {
msg('Mediadir is writable', 1);
} else {
msg('Mediadir is not writable', -1);
}
if (is_writable($conf['cachedir'])) {
msg('Cachedir is writable', 1);
} else {
msg('Cachedir is not writable', -1);
}
if (is_writable($conf['lockdir'])) {
msg('Lockdir is writable', 1);
} else {
msg('Lockdir is not writable', -1);
}
if (is_writable(DOKU_CONF)) {
msg('conf directory is writable', 1);
} else {
msg('conf directory is not writable', -1);
}
if ($conf['authtype'] == 'plain') {
global $config_cascade;
if (is_writable($config_cascade['plainauth.users']['default'])) {
msg('conf/users.auth.php is writable', 1);
} else {
msg('conf/users.auth.php is not writable', 0);
}
}
if (function_exists('mb_strpos')) {
if (defined('UTF8_NOMBSTRING')) {
msg('mb_string extension is available but will not be used', 0);
} else {
msg('mb_string extension is available and will be used', 1);
if (ini_get('mbstring.func_overload') != 0) {
msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1);
}
}
//.........这里部分代码省略.........
示例9: check
/**
* Run a few sanity checks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check()
{
global $conf;
global $INFO;
msg('DokuWiki version: ' . getVersion(), 1);
if (version_compare(phpversion(), '4.3.3', '<')) {
msg('Your PHP version is too old (' . phpversion() . ' vs. 4.3.3+ recommended)', -1);
} elseif (version_compare(phpversion(), '4.3.10', '<')) {
msg('Consider upgrading PHP to 4.3.10 or higher for security reasons (your version: ' . phpversion() . ')', 0);
} else {
msg('PHP version ' . phpversion(), 1);
}
$mem = (int) php_to_byte(ini_get('memory_limit'));
if ($mem) {
if ($mem < 16777216) {
msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1);
} elseif ($mem < 20971520) {
msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1);
} elseif ($mem < 33554432) {
msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0);
} else {
msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1);
}
}
if (is_writable($conf['changelog'])) {
msg('Changelog is writable', 1);
} else {
if (@file_exists($conf['changelog'])) {
msg('Changelog is not writable', -1);
}
}
if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) {
msg('Old changelog exists', 0);
}
if (@file_exists($conf['changelog'] . '_failed')) {
msg('Importing old changelog failed', -1);
} elseif (@file_exists($conf['changelog'] . '_importing')) {
msg('Importing old changelog now.', 0);
} elseif (@file_exists($conf['changelog'] . '_import_ok')) {
msg('Old changelog imported', 1);
if (!plugin_isdisabled('importoldchangelog')) {
msg('Importoldchangelog plugin not disabled after import', -1);
}
}
if (is_writable($conf['datadir'])) {
msg('Datadir is writable', 1);
} else {
msg('Datadir is not writable', -1);
}
if (is_writable($conf['olddir'])) {
msg('Attic is writable', 1);
} else {
msg('Attic is not writable', -1);
}
if (is_writable($conf['mediadir'])) {
msg('Mediadir is writable', 1);
} else {
msg('Mediadir is not writable', -1);
}
if (is_writable($conf['cachedir'])) {
msg('Cachedir is writable', 1);
} else {
msg('Cachedir is not writable', -1);
}
if (is_writable($conf['lockdir'])) {
msg('Lockdir is writable', 1);
} else {
msg('Lockdir is not writable', -1);
}
if ($conf['authtype'] == 'plain') {
if (is_writable(DOKU_CONF . 'users.auth.php')) {
msg('conf/users.auth.php is writable', 1);
} else {
msg('conf/users.auth.php is not writable', 0);
}
}
if (function_exists('mb_strpos')) {
if (defined('UTF8_NOMBSTRING')) {
msg('mb_string extension is available but will not be used', 0);
} else {
msg('mb_string extension is available and will be used', 1);
}
} else {
msg('mb_string extension not available - PHP only replacements will be used', 0);
}
if ($conf['allowdebug']) {
msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1);
} else {
msg('Debugging support is disabled', 1);
}
if ($INFO['userinfo']['name']) {
msg('You are currently logged in as ' . $_SERVER['REMOTE_USER'] . ' (' . $INFO['userinfo']['name'] . ')', 0);
msg('You are part of the groups ' . join($INFO['userinfo']['grps'], ', '), 0);
} else {
msg('You are currently not logged in', 0);
//.........这里部分代码省略.........