本文整理汇总了PHP中wfShorthandToInteger函数的典型用法代码示例。如果您正苦于以下问题:PHP wfShorthandToInteger函数的具体用法?PHP wfShorthandToInteger怎么用?PHP wfShorthandToInteger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfShorthandToInteger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyUpload
/**
* @return array
*/
public function verifyUpload()
{
# Check for a post_max_size or upload_max_size overflow, so that a
# proper error can be shown to the user
if (is_null($this->mTempPath) || $this->isEmptyFile()) {
if ($this->mUpload->isIniSizeOverflow()) {
return array('status' => UploadBase::FILE_TOO_LARGE, 'max' => min(self::getMaxUploadSize($this->getSourceType()), wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))));
}
}
return parent::verifyUpload();
}
示例2: dieout
}
# Check for PCRE support
if (!function_exists('preg_match')) {
dieout("The PCRE support module appears to be missing. MediaWiki requires the\n\tPerl-compatible regular expression functions.");
}
# The installer can take a while, and we really don't want it to time out
wfSuppressWarnings();
set_time_limit(0);
wfRestoreWarnings();
$memlimit = ini_get("memory_limit");
if ($memlimit == -1) {
print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
} else {
print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars($memlimit) . " bytes. ";
$newlimit = wfMemoryLimit();
$memlimit = wfShorthandToInteger($memlimit);
if ($newlimit < $memlimit) {
print "<b>Failed raising limit, installation may fail.</b>";
} elseif ($newlimit > $memlimit) {
print "Raised <tt>memory_limit</tt> to " . htmlspecialchars($newlimit) . " bytes. ";
}
print "</li>\n";
}
$conf->xcache = function_exists('xcache_get');
if ($conf->xcache) {
print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
}
$conf->apc = function_exists('apc_fetch');
if ($conf->apc) {
print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
}
示例3: getSourceSection
/**
* Get the descriptor of the fieldset that contains the file source
* selection. The section is 'source'
*
* @return array Descriptor array
*/
protected function getSourceSection()
{
if ($this->mSessionKey) {
return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash'));
}
$canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()) === true && $this->getConfig()->get('CopyUploadsFromSpecialUpload');
$radio = $canUploadByUrl;
$selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
$descriptor = array();
if ($this->mTextTop) {
$descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
}
$this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file');
# Limit to upload_max_filesize unless we are running under HipHop and
# that setting doesn't exist
if (!wfIsHHVM()) {
$this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size')));
}
$help = $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse();
// If the user can also upload by URL, there are 2 different file size limits.
// This extra message helps stress which limit corresponds to what.
if ($canUploadByUrl) {
$help .= $this->msg('word-separator')->escaped();
$help .= $this->msg('upload_source_file')->parse();
}
$descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'radio-id' => 'wpSourceTypeFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $help, 'checked' => $selectedSourceType == 'file');
if ($canUploadByUrl) {
$this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url');
$descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'radio-id' => 'wpSourceTypeurl', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . $this->msg('word-separator')->escaped() . $this->msg('upload_source_url')->parse(), 'checked' => $selectedSourceType == 'url');
}
Hooks::run('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
$descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true);
return $descriptor;
}
示例4: getSourceSection
/**
* Get the descriptor of the fieldset that contains the file source
* selection. The section is 'source'
*
* @return Array: descriptor array
*/
protected function getSourceSection()
{
if ($this->mSessionKey) {
return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash'));
}
$canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser());
$radio = $canUploadByUrl;
$selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
$descriptor = array();
if ($this->mTextTop) {
$descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
}
$this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file');
# Limit to upload_max_filesize unless we are running under HipHop and
# that setting doesn't exist
if (!wfIsHipHop()) {
$this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size')));
}
$descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse() . ' ' . $this->msg('upload_source_file')->escaped(), 'checked' => $selectedSourceType == 'file');
if ($canUploadByUrl) {
$this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url');
$descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . ' ' . $this->msg('upload_source_url')->escaped(), 'checked' => $selectedSourceType == 'url');
}
wfRunHooks('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
$descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true);
return $descriptor;
}
示例5: wfMemoryLimit
/**
* Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit;
*
* @return int Value the memory limit was set to.
*/
function wfMemoryLimit()
{
global $wgMemoryLimit;
$memlimit = wfShorthandToInteger(ini_get('memory_limit'));
if ($memlimit != -1) {
$conflimit = wfShorthandToInteger($wgMemoryLimit);
if ($conflimit == -1) {
wfDebug("Removing PHP's memory limit\n");
MediaWiki\suppressWarnings();
ini_set('memory_limit', $conflimit);
MediaWiki\restoreWarnings();
return $conflimit;
} elseif ($conflimit > $memlimit) {
wfDebug("Raising PHP's memory limit to {$conflimit} bytes\n");
MediaWiki\suppressWarnings();
ini_set('memory_limit', $conflimit);
MediaWiki\restoreWarnings();
return $conflimit;
}
}
return $memlimit;
}
示例6: str_replace
if ($wgMetaNamespace === false) {
$wgMetaNamespace = str_replace(' ', '_', $wgSitename);
}
// Default value is 2000 or the suhosin limit if it is between 1 and 2000
if ($wgResourceLoaderMaxQueryLength === false) {
$suhosinMaxValueLength = (int) ini_get('suhosin.get.max_value_length');
if ($suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000) {
$wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
} else {
$wgResourceLoaderMaxQueryLength = 2000;
}
unset($suhosinMaxValueLength);
}
// Ensure the minimum chunk size is less than PHP upload limits or the maximum
// upload size.
$wgMinUploadChunkSize = min($wgMinUploadChunkSize, UploadBase::getMaxUploadSize('file'), UploadBase::getMaxPhpUploadSize(), (wfShorthandToInteger(ini_get('post_max_size') ?: ini_get('hhvm.server.max_post_size'), PHP_INT_MAX) ?: PHP_INT_MAX) - 1024);
/**
* Definitions of the NS_ constants are in Defines.php
* @private
*/
$wgCanonicalNamespaceNames = [NS_MEDIA => 'Media', NS_SPECIAL => 'Special', NS_TALK => 'Talk', NS_USER => 'User', NS_USER_TALK => 'User_talk', NS_PROJECT => 'Project', NS_PROJECT_TALK => 'Project_talk', NS_FILE => 'File', NS_FILE_TALK => 'File_talk', NS_MEDIAWIKI => 'MediaWiki', NS_MEDIAWIKI_TALK => 'MediaWiki_talk', NS_TEMPLATE => 'Template', NS_TEMPLATE_TALK => 'Template_talk', NS_HELP => 'Help', NS_HELP_TALK => 'Help_talk', NS_CATEGORY => 'Category', NS_CATEGORY_TALK => 'Category_talk'];
/// @todo UGLY UGLY
if (is_array($wgExtraNamespaces)) {
$wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
}
// These are now the same, always
// To determine the user language, use $wgLang->getCode()
$wgContLanguageCode = $wgLanguageCode;
// Easy to forget to falsify $wgDebugToolbar for static caches.
// If file cache or CDN cache is on, just disable this (DWIMD).
if ($wgUseFileCache || $wgUseSquid) {
示例7: testWfShorthandToInteger
/**
* test @see wfShorthandToInteger()
* @dataProvider provideShorthand
* @covers ::wfShorthandToInteger
*/
public function testWfShorthandToInteger($shorthand, $expected)
{
$this->assertEquals($expected, wfShorthandToInteger($shorthand));
}
示例8: getDescriptors
protected function getDescriptors()
{
global $wgUser, $wgLang, $wgMaxUploadSize;
$descriptor = $this->getCommonFields();
$size = $wgLang->formatSize(wfShorthandToInteger(min(wfShorthandToInteger(ini_get('upload_max_filesize')), $wgMaxUploadSize)));
$upload_source_file = wfMessage('upload_source_file')->escaped();
$descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => wfMessage('upload-maxfilesize', $size)->text() . " {$upload_source_file}", 'checked' => true);
$descriptor['Extensions'] = array('type' => 'info', 'default' => $this->getExtensionsMessage(), 'raw' => true);
$descriptor['DestFile'] = array('type' => 'text', 'id' => 'wpDestFile', 'label-message' => 'destfilename', 'size' => 60, 'default' => $this->mDesiredDestName, 'nodata' => strval($this->mDesiredDestName) !== '');
$descriptor['UploadDescription'] = array('type' => 'textarea', 'id' => 'wpUploadDescription', 'label-message' => $this->mForReUpload ? 'filereuploadsummary' : 'fileuploadsummary', 'default' => $this->mComment, 'cols' => intval($wgUser->getOption('cols')), 'rows' => 8);
$descriptor['IgnoreWarning'] = array('type' => 'hidden', 'id' => 'wpIgnoreWarning', 'label-message' => 'ignorewarnings', 'default' => '1');
$descriptor['DestFileWarningAck'] = array('type' => 'hidden', 'id' => 'wpDestFileWarningAck', 'default' => '1');
$descriptor['ForReUpload'] = array('type' => 'hidden', 'id' => 'wpForReUpload', 'default' => '1');
return $descriptor;
}
示例9: getSourceSection
/**
* Get the descriptor of the fieldset that contains the file source
* selection. The section is 'source'
*
* @return array Descriptor array
*/
protected function getSourceSection()
{
if ($this->mSessionKey) {
return array('wpSessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'wpSourceType' => array('type' => 'hidden', 'default' => 'Stash'));
}
$canUploadByUrl = UploadFromUrl::isEnabled() && $this->getUser()->isAllowed('upload_by_url');
$radio = $canUploadByUrl;
$selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
$descriptor = array();
if ($this->mTextTop) {
$descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
}
$descriptor['UploadFile'] = array('class' => 'SFUploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => wfMessage('upload-maxfilesize', $this->getLanguage()->formatSize(wfShorthandToInteger(ini_get('upload_max_filesize'))))->parse() . ' ' . wfMessage('upload_source_file')->escaped(), 'checked' => $selectedSourceType == 'file');
if ($canUploadByUrl) {
global $wgMaxUploadSize;
$descriptor['UploadFileURL'] = array('class' => 'SFUploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'Url', 'radio' => &$radio, 'help' => wfMessage('upload-maxfilesize', $this->getLanguage()->formatSize($wgMaxUploadSize))->parse() . ' ' . wfMessage('upload_source_url')->escaped(), 'checked' => $selectedSourceType == 'url');
}
Hooks::run('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
$descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true);
return $descriptor;
}
示例10: getSourceSection
/**
* Get the descriptor of the fieldset that contains the file source
* selection. The section is 'source'
*
* @return array Descriptor array
*/
protected function getSourceSection()
{
if (sizeof($this->mSessionKeys) > 0) {
$data = array('wpSourceType' => array('type' => 'hidden', 'default' => 'Stash'));
$index = 0;
foreach ($this->mDestFiles as $k => $v) {
if ($v == '') {
continue;
}
$data['wpDestFile' . $index] = array('type' => 'hidden', 'default' => $v);
$data['wpSessionKey' . $index] = array('type' => 'hidden', 'default' => $this->mSessionKeys['sessionkey' . $v]);
$index++;
}
return $data;
}
$canUploadByUrl = UploadFromUrl::isEnabled() && $this->getUser()->isAllowed('upload_by_url');
$radio = $canUploadByUrl;
$selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
$descriptor = array();
if ($this->mTextTop) {
$descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
}
for ($i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++) {
$descriptor['UploadFile' . $i] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile' . $i, 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'checked' => $selectedSourceType == 'file');
$descriptor['DestFile' . $i] = array('type' => 'text', 'section' => 'source', 'id' => 'wpDestFile' . $i, 'label-message' => 'destfilename', 'size' => 60, 'default' => $this->mDestFiles[$i], 'nodata' => strval($this->mDestFile) !== '');
if ($canUploadByUrl) {
global $wgMaxUploadSize;
$descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => wfMsgExt('upload-maxfilesize', array('parseinline', 'escapenoentities'), $this->getLang()->formatSize($wgMaxUploadSize)) . ' ' . wfMsgHtml('upload_source_url'), 'checked' => $selectedSourceType == 'url');
}
}
wfRunHooks('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
$descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true, 'help' => wfMsgExt('upload-maxfilesize', array('parseinline', 'escapenoentities'), $this->getLang()->formatSize(wfShorthandToInteger(ini_get('upload_max_filesize')))) . ' ' . wfMsgHtml('upload_source_file'));
return $descriptor;
}
示例11: getMaxPhpUploadSize
/**
* Get the PHP maximum uploaded file size, based on ini settings. If there is no limit or the
* limit can't be guessed, returns a very large number (PHP_INT_MAX).
*
* @since 1.27
* @return int
*/
public static function getMaxPhpUploadSize()
{
$phpMaxFileSize = wfShorthandToInteger(ini_get('upload_max_filesize') ?: ini_get('hhvm.server.upload.upload_max_file_size'), PHP_INT_MAX);
$phpMaxPostSize = wfShorthandToInteger(ini_get('post_max_size') ?: ini_get('hhvm.server.max_post_size'), PHP_INT_MAX) ?: PHP_INT_MAX;
return min($phpMaxFileSize, $phpMaxPostSize);
}
示例12: isIniSizeOverflow
/**
* Returns whether this upload failed because of overflow of a maximum set
* in php.ini
*
* @return bool
*/
public function isIniSizeOverflow()
{
if ($this->getError() == UPLOAD_ERR_INI_SIZE) {
# PHP indicated that upload_max_filesize is exceeded
return true;
}
$contentLength = $this->request->getHeader('Content-Length');
$maxPostSize = wfShorthandToInteger(ini_get('post_max_size') ?: ini_get('hhvm.server.max_post_size'), 0);
if ($maxPostSize && $contentLength > $maxPostSize) {
# post_max_size is exceeded
return true;
}
return false;
}
示例13: testWfShorthandToInteger
/**
* @dataProvider provideABunchOfShorthands
*/
function testWfShorthandToInteger($input, $output, $description)
{
$this->assertEquals(wfShorthandToInteger($input), $output, $description);
}
示例14: str_replace
if ($wgMetaNamespace === false) {
$wgMetaNamespace = str_replace(' ', '_', $wgSitename);
}
// Default value is 2000 or the suhosin limit if it is between 1 and 2000
if ($wgResourceLoaderMaxQueryLength === false) {
$suhosinMaxValueLength = (int) ini_get('suhosin.get.max_value_length');
if ($suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000) {
$wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
} else {
$wgResourceLoaderMaxQueryLength = 2000;
}
unset($suhosinMaxValueLength);
}
// Ensure the minimum chunk size is less than PHP upload limits or the maximum
// upload size.
$wgMinUploadChunkSize = min($wgMinUploadChunkSize, $wgMaxUploadSize, wfShorthandToInteger(ini_get('upload_max_filesize'), 1.0E+100), wfShorthandToInteger(ini_get('post_max_size'), 1.0E+100) - 1024);
/**
* Definitions of the NS_ constants are in Defines.php
* @private
*/
$wgCanonicalNamespaceNames = array(NS_MEDIA => 'Media', NS_SPECIAL => 'Special', NS_TALK => 'Talk', NS_USER => 'User', NS_USER_TALK => 'User_talk', NS_PROJECT => 'Project', NS_PROJECT_TALK => 'Project_talk', NS_FILE => 'File', NS_FILE_TALK => 'File_talk', NS_MEDIAWIKI => 'MediaWiki', NS_MEDIAWIKI_TALK => 'MediaWiki_talk', NS_TEMPLATE => 'Template', NS_TEMPLATE_TALK => 'Template_talk', NS_HELP => 'Help', NS_HELP_TALK => 'Help_talk', NS_CATEGORY => 'Category', NS_CATEGORY_TALK => 'Category_talk');
/// @todo UGLY UGLY
if (is_array($wgExtraNamespaces)) {
$wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
}
// These are now the same, always
// To determine the user language, use $wgLang->getCode()
$wgContLanguageCode = $wgLanguageCode;
// Easy to forget to falsify $wgShowIPinHeader for static caches.
// If file cache or squid cache is on, just disable this (DWIMD).
// Do the same for $wgDebugToolbar.
示例15: envCheckMemory
/**
* Environment check for available memory.
*/
protected function envCheckMemory()
{
$limit = ini_get('memory_limit');
if (!$limit || $limit == -1) {
return true;
}
$n = wfShorthandToInteger($limit);
if ($n < $this->minMemorySize * 1024 * 1024) {
$newLimit = "{$this->minMemorySize}M";
if (ini_set("memory_limit", $newLimit) === false) {
$this->showMessage('config-memory-bad', $limit);
} else {
$this->showMessage('config-memory-raised', $limit, $newLimit);
$this->setVar('_RaiseMemory', true);
}
} else {
return true;
}
}