本文整理汇总了PHP中wfIniGetBool函数的典型用法代码示例。如果您正苦于以下问题:PHP wfIniGetBool函数的具体用法?PHP wfIniGetBool怎么用?PHP wfIniGetBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfIniGetBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isEnabled
/**
* Returns true if uploads are enabled.
* Can be override by subclasses.
* @return bool
*/
public static function isEnabled()
{
global $wgEnableUploads;
if (!$wgEnableUploads) {
return false;
}
# Check php's file_uploads setting
return wfIsHHVM() || wfIniGetBool('file_uploads');
}
示例2: provideGeneralEncoding
public static function provideGeneralEncoding()
{
// Sigh. Docs claim it's a boolean, but can have values 0, 1, or 2.
// Fortunately wfIniGetBool does the right thing.
if (wfIniGetBool('xdebug.overload_var_dump')) {
return array(array(array(), 'Cannot test ApiFormatDump when xDebug overloads var_dump', array('SKIP' => true)));
}
$warning = "\n [\"warnings\"]=>\n array(1) {\n [\"dump\"]=>\n array(1) {\n [\"*\"]=>\n" . " string(64) \"format=dump has been deprecated. Please use format=json instead.\"\n" . " }\n }";
return array(array(array(null), "array(2) {{$warning}\n [0]=>\n NULL\n}\n"), array(array(true), "array(2) {{$warning}\n [0]=>\n string(0) \"\"\n}\n"), array(array(false), "array(1) {{$warning}\n}\n"), array(array(true, ApiResult::META_BC_BOOLS => array(0)), "array(2) {{$warning}\n [0]=>\n bool(true)\n}\n"), array(array(false, ApiResult::META_BC_BOOLS => array(0)), "array(2) {{$warning}\n [0]=>\n bool(false)\n}\n"), array(array(42), "array(2) {{$warning}\n [0]=>\n int(42)\n}\n"), array(array(42.5), "array(2) {{$warning}\n [0]=>\n float(42.5)\n}\n"), array(array(1.0E+42), "array(2) {{$warning}\n [0]=>\n float(1.0E+42)\n}\n"), array(array('foo'), "array(2) {{$warning}\n [0]=>\n string(3) \"foo\"\n}\n"), array(array('fóo'), "array(2) {{$warning}\n [0]=>\n string(4) \"fóo\"\n}\n"), array(array(array()), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n"), array(array(array(1)), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n"), array(array(array('x' => 1)), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n"), array(array(array(2 => 1)), "array(2) {{$warning}\n [0]=>\n array(1) {\n [2]=>\n int(1)\n }\n}\n"), array(array((object) array()), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n"), array(array(array(1, ApiResult::META_TYPE => 'assoc')), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n"), array(array(array('x' => 1, ApiResult::META_TYPE => 'array')), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n"), array(array(array('x' => 1, ApiResult::META_TYPE => 'kvp')), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n"), array(array(array('x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key')), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n array(2) {\n [\"key\"]=>\n string(1) \"x\"\n [\"*\"]=>\n int(1)\n }\n }\n}\n"), array(array(array('x' => 1, ApiResult::META_TYPE => 'BCarray')), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n"), array(array(array('a', 'b', ApiResult::META_TYPE => 'BCassoc')), "array(2) {{$warning}\n [0]=>\n array(2) {\n [0]=>\n string(1) \"a\"\n [1]=>\n string(1) \"b\"\n }\n}\n"), array(array('content' => 'foo', ApiResult::META_CONTENT => 'content'), "array(2) {{$warning}\n [\"*\"]=>\n string(3) \"foo\"\n}\n"), array(array('foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array('foo')), "array(2) {{$warning}\n [\"foo\"]=>\n array(1) {\n [\"*\"]=>\n string(3) \"foo\"\n }\n}\n"));
}
示例3: isEnabled
/**
* Returns true if uploads are enabled.
* Can be override by subclasses.
*/
public static function isEnabled()
{
global $wgEnableUploads;
if (!$wgEnableUploads) {
return false;
}
# Check php's file_uploads setting
if (!wfIniGetBool('file_uploads')) {
return false;
}
return true;
}
示例4: factory
public static function factory($url, $options = null)
{
if (!Http::$httpEngine) {
Http::$httpEngine = function_exists('curl_init') ? 'curl' : 'php';
} elseif (Http::$httpEngine == 'curl' && !function_exists('curl_init')) {
throw new MWException(__METHOD__ . ': curl (http://php.net/curl) is not installed, but' . 'Http::$httpEngine is set to "curl"');
}
switch (Http::$httpEngine) {
case 'curl':
return new CurlHttpRequestTester($url, $options);
case 'php':
if (!wfIniGetBool('allow_url_fopen')) {
throw new MWException(__METHOD__ . ': allow_url_fopen needs to be enabled for pure PHP' . ' http requests to work. If possible, curl should be used instead. See http://php.net/curl.');
}
return new PhpHttpRequestTester($url, $options);
default:
}
}
示例5: setup
function setup()
{
putenv("http_proxy");
/* Remove any proxy env var, so curl doesn't get confused */
if (is_array(self::$content)) {
return;
}
self::$has_curl = function_exists('curl_init');
self::$has_fopen = wfIniGetBool('allow_url_fopen');
if (!file_exists("/usr/bin/curl")) {
$this->markTestIncomplete("This test requires the curl binary at /usr/bin/curl.\t If you have curl, please file a bug on this test, or, better yet, provide a patch.");
}
$content = tempnam(wfTempDir(), "");
$headers = tempnam(wfTempDir(), "");
if (!$content && !$headers) {
die("Couldn't create temp file!");
}
// This probably isn't the best test for a proxy, but it works on my system!
system("curl -0 -o {$content} -s " . self::$proxy);
$out = file_get_contents($content);
if ($out) {
self::$has_proxy = true;
}
/* Maybe use wget instead of curl here ... just to use a different codebase? */
foreach ($this->test_geturl as $u) {
system("curl -0 -s -D {$headers} '{$u}' -o {$content}");
self::$content["GET {$u}"] = file_get_contents($content);
self::$headers["GET {$u}"] = file_get_contents($headers);
}
foreach ($this->test_requesturl as $u) {
system("curl -0 -s -X POST -H 'Content-Length: 0' -D {$headers} '{$u}' -o {$content}");
self::$content["POST {$u}"] = file_get_contents($content);
self::$headers["POST {$u}"] = file_get_contents($headers);
}
foreach ($this->test_posturl as $u => $postData) {
system("curl -0 -s -X POST -d '{$postData}' -D {$headers} '{$u}' -o {$content}");
self::$content["POST {$u} => {$postData}"] = file_get_contents($content);
self::$headers["POST {$u} => {$postData}"] = file_get_contents($headers);
}
unlink($content);
unlink($headers);
}
示例6: testInstall
public function testInstall()
{
$reset = $this->getResetter($rProp);
$rProp->setValue(null);
session_write_close();
ini_set('session.use_cookies', 1);
ini_set('session.use_trans_sid', 1);
$store = new \HashBagOStuff();
$logger = new \TestLogger();
$manager = new SessionManager(array('store' => $store, 'logger' => $logger));
$this->assertFalse(PHPSessionHandler::isInstalled());
PHPSessionHandler::install($manager);
$this->assertTrue(PHPSessionHandler::isInstalled());
$this->assertFalse(wfIniGetBool('session.use_cookies'));
$this->assertFalse(wfIniGetBool('session.use_trans_sid'));
$this->assertNotNull($rProp->getValue());
$priv = \TestingAccessWrapper::newFromObject($rProp->getValue());
$this->assertSame($manager, $priv->manager);
$this->assertSame($store, $priv->store);
$this->assertSame($logger, $priv->logger);
}
示例7: sendInternal
//.........这里部分代码省略.........
}
if ($mime === null) {
// sending text only, either deliberately or as a fallback
if (wfIsWindows()) {
$body = str_replace("\n", "\r\n", $body);
}
$headers['MIME-Version'] = '1.0';
$headers['Content-type'] = is_null($contentType) ? 'text/plain; charset=UTF-8' : $contentType;
$headers['Content-transfer-encoding'] = '8bit';
}
// allow transformation of MIME-encoded message
if (!Hooks::run('UserMailerTransformMessage', array($to, $from, &$subject, &$headers, &$body, &$error))) {
if ($error) {
return Status::newFatal('php-mail-error', $error);
} else {
return Status::newFatal('php-mail-error-unknown');
}
}
$ret = Hooks::run('AlternateUserMailer', array($headers, $to, $from, $subject, $body));
if ($ret === false) {
// the hook implementation will return false to skip regular mail sending
return Status::newGood();
} elseif ($ret !== true) {
// the hook implementation will return a string to pass an error message
return Status::newFatal('php-mail-error', $ret);
}
if (is_array($wgSMTP)) {
// Check if pear/mail is already loaded (via composer)
if (!class_exists('Mail')) {
// PEAR MAILER
if (!stream_resolve_include_path('Mail.php')) {
throw new MWException('PEAR mail package is not installed');
}
require_once 'Mail.php';
}
MediaWiki\suppressWarnings();
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $wgSMTP);
if (PEAR::isError($mail_object)) {
wfDebug("PEAR::Mail factory failed: " . $mail_object->getMessage() . "\n");
MediaWiki\restoreWarnings();
return Status::newFatal('pear-mail-error', $mail_object->getMessage());
}
wfDebug("Sending mail via PEAR::Mail\n");
$headers['Subject'] = self::quotedPrintable($subject);
// When sending only to one recipient, shows it its email using To:
if (count($to) == 1) {
$headers['To'] = $to[0]->toString();
}
// Split jobs since SMTP servers tends to limit the maximum
// number of possible recipients.
$chunks = array_chunk($to, $wgEnotifMaxRecips);
foreach ($chunks as $chunk) {
$status = self::sendWithPear($mail_object, $chunk, $headers, $body);
// FIXME : some chunks might be sent while others are not!
if (!$status->isOK()) {
MediaWiki\restoreWarnings();
return $status;
}
}
MediaWiki\restoreWarnings();
return Status::newGood();
} else {
// PHP mail()
if (count($to) > 1) {
$headers['To'] = 'undisclosed-recipients:;';
}
$headers = self::arrayToHeaderString($headers, $endl);
wfDebug("Sending mail via internal mail() function\n");
self::$mErrorString = '';
$html_errors = ini_get('html_errors');
ini_set('html_errors', '0');
set_error_handler('UserMailer::errorHandler');
try {
$safeMode = wfIniGetBool('safe_mode');
foreach ($to as $recip) {
if ($safeMode) {
$sent = mail($recip, self::quotedPrintable($subject), $body, $headers);
} else {
$sent = mail($recip, self::quotedPrintable($subject), $body, $headers, $extraParams);
}
}
} catch (Exception $e) {
restore_error_handler();
throw $e;
}
restore_error_handler();
ini_set('html_errors', $html_errors);
if (self::$mErrorString) {
wfDebug("Error sending mail: " . self::$mErrorString . "\n");
return Status::newFatal('php-mail-error', self::$mErrorString);
} elseif (!$sent) {
// mail function only tells if there's an error
wfDebug("Unknown error sending mail\n");
return Status::newFatal('php-mail-error-unknown');
} else {
return Status::newGood();
}
}
}
示例8: startSession
/**
* Start the PHP session. This may be called before execute() to start the PHP session.
*
* @return bool
*/
public function startSession()
{
if (wfIniGetBool('session.auto_start') || session_id()) {
// Done already
return true;
}
$this->phpErrors = array();
set_error_handler(array($this, 'errorHandler'));
session_start();
restore_error_handler();
if ($this->phpErrors) {
$this->showError('config-session-error', $this->phpErrors[0]);
return false;
}
return true;
}
示例9: envCheckSafeMode
/**
* Environment check for safe_mode.
*/
protected function envCheckSafeMode()
{
if (wfIniGetBool('safe_mode')) {
$this->setVar('_SafeMode', true);
$this->showMessage('config-safe-mode');
}
}
示例10: execute
/**
* Start doing stuff
* @access public
*/
function execute()
{
global $wgUser, $wgOut;
global $wgEnableUploads;
# Check php's file_uploads setting
if (!wfIniGetBool('file_uploads')) {
$wgOut->showErrorPage('uploaddisabled', 'php-uploaddisabledtext', array($this->mDesiredDestName));
return;
}
# Check uploading enabled
if (!$wgEnableUploads) {
$wgOut->showErrorPage('uploaddisabled', 'uploaddisabledtext', array($this->mDesiredDestName));
return;
}
# Check permissions
if (!$wgUser->isAllowed('upload')) {
if (!$wgUser->isLoggedIn()) {
$wgOut->showErrorPage('uploadnologin', 'uploadnologintext');
} else {
$wgOut->permissionRequired('upload');
}
return;
}
# Check blocks
if ($wgUser->isBlocked()) {
$wgOut->blockedPage();
return;
}
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
if ($this->mReUpload) {
if (!$this->unsaveUploadedFile()) {
return;
}
# Because it is probably checked and shouldn't be
$this->mIgnoreWarning = false;
$this->mainUploadForm();
} else {
if ('submit' == $this->mAction || $this->mUploadClicked) {
$this->processUpload();
} else {
$this->mainUploadForm();
}
}
$this->cleanupTempFile();
}
示例11: getShellLocale
function getShellLocale($wikiLang)
{
# Give up now if we're in safe mode or open_basedir
# It's theoretically possible but tricky to work with
if (wfIniGetBool("safe_mode") || ini_get('open_basedir') || !function_exists('exec')) {
return false;
}
$os = php_uname('s');
$supported = array('Linux', 'SunOS', 'HP-UX');
# Tested these
if (!in_array($os, $supported)) {
return false;
}
# Get a list of available locales
$lines = $ret = false;
$lines = wfShellExec('/usr/bin/locale -a', $ret, true);
if ($ret) {
return false;
}
$lines = wfArrayMap('trim', explode("\n", $lines));
$candidatesByLocale = array();
$candidatesByLang = array();
foreach ($lines as $line) {
if ($line === '') {
continue;
}
if (!preg_match('/^([a-zA-Z]+)(_[a-zA-Z]+|)\\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m)) {
continue;
}
list($all, $lang, $territory, $charset, $modifier) = $m;
$candidatesByLocale[$m[0]] = $m;
$candidatesByLang[$lang][] = $m;
}
# Try the current value of LANG
if (isset($candidatesByLocale[getenv('LANG')])) {
return getenv('LANG');
}
# Try the most common ones
$commonLocales = array('en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8');
foreach ($commonLocales as $commonLocale) {
if (isset($candidatesByLocale[$commonLocale])) {
return $commonLocale;
}
}
# Is there an available locale in the Wiki's language?
if (isset($candidatesByLang[$wikiLang])) {
$m = reset($candidatesByLang[$wikiLang]);
return $m[0];
}
# Are there any at all?
if (count($candidatesByLocale)) {
$m = reset($candidatesByLocale);
return $m[0];
}
# Give up
return false;
}
示例12: get_class
$wgAuth = new MediaWiki\Auth\AuthManagerAuthPlugin();
Hooks::run('AuthPluginSetup', [&$wgAuth]);
}
if ($wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin) {
MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders([new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider(['authoritative' => false]), new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider($wgAuth), new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider(['authoritative' => true])], '$wgAuth is ' . get_class($wgAuth));
}
// Set up the session
$ps_session = Profiler::instance()->scopedProfileIn($fname . '-session');
/**
* @var MediaWiki\Session\SessionId|null $wgInitialSessionId The persistent
* session ID (if any) loaded at startup
*/
$wgInitialSessionId = null;
if (!defined('MW_NO_SESSION') && !$wgCommandLineMode) {
// If session.auto_start is there, we can't touch session name
if ($wgPHPSessionHandling !== 'disable' && !wfIniGetBool('session.auto_start')) {
session_name($wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session');
}
// Create the SessionManager singleton and set up our session handler,
// unless we're specifically asked not to.
if (!defined('MW_NO_SESSION_HANDLER')) {
MediaWiki\Session\PHPSessionHandler::install(MediaWiki\Session\SessionManager::singleton());
}
// Initialize the session
try {
$session = MediaWiki\Session\SessionManager::getGlobalSession();
} catch (OverflowException $ex) {
if (isset($ex->sessionInfos) && count($ex->sessionInfos) >= 2) {
// The exception is because the request had multiple possible
// sessions tied for top priority. Report this to the user.
$list = [];
示例13: newAccelerator
/**
* Factory function referenced from DefaultSettings.php for CACHE_ACCEL.
*
* @param $params array
* @throws MWException
* @return ObjectCache
*/
static function newAccelerator($params)
{
if (function_exists('apc_fetch')) {
$id = 'apc';
} elseif (function_exists('xcache_get') && wfIniGetBool('xcache.var_size')) {
$id = 'xcache';
} elseif (function_exists('wincache_ucache_get')) {
$id = 'wincache';
} else {
throw new MWException("CACHE_ACCEL requested but no suitable object " . "cache is present. You may want to install APC.");
}
return self::newFromId($id);
}
示例14: wfDebug
}
wfDebug($debug);
}
Profiler::instance()->scopedProfileOut($ps_misc);
$ps_memcached = Profiler::instance()->scopedProfileIn($fname . '-memcached');
$wgMemc = wfGetMainCache();
$messageMemc = wfGetMessageCacheStorage();
$parserMemc = wfGetParserCacheStorage();
wfDebugLog('caches', 'main: ' . get_class($wgMemc) . ', message: ' . get_class($messageMemc) . ', parser: ' . get_class($parserMemc));
Profiler::instance()->scopedProfileOut($ps_memcached);
// Most of the config is out, some might want to run hooks here.
Hooks::run('SetupAfterCache');
$ps_session = Profiler::instance()->scopedProfileIn($fname . '-session');
if (!defined('MW_NO_SESSION') && !$wgCommandLineMode) {
// If session.auto_start is there, we can't touch session name
if (!wfIniGetBool('session.auto_start')) {
session_name($wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session');
}
if ($wgRequest->checkSessionCookie() || isset($_COOKIE[$wgCookiePrefix . 'Token'])) {
wfSetupSession();
}
}
Profiler::instance()->scopedProfileOut($ps_session);
$ps_globals = Profiler::instance()->scopedProfileIn($fname . '-globals');
/**
* @var Language $wgContLang
*/
$wgContLang = Language::factory($wgLanguageCode);
$wgContLang->initEncoding();
$wgContLang->initContLang();
// Now that variant lists may be available...
示例15: exit
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*/
if (!defined('MEDIAWIKI')) {
exit(1);
}
# make sure that everything that needs to be set/loaded is that way
$err = '';
if (!wfIniGetBool('allow_url_fopen') && !extension_loaded('curl')) {
# we need allow_url_fopen or curl to be on in order for the Http::get() call to work on the amazon url
$err .= "\n<li>allow_url_fopen or curl must be enabled in php.ini</li>";
}
if (!extension_loaded('simplexml')) {
# we need the simplexml extension loaded to parse the xml string
$err .= "\n<li>The SimpleXML extension for PHP must be loaded</li>";
}
# if there were errors found, die with the messages
if ($err) {
$html = '<html><head><title>Error</title></head><body>
The following errors were discovered with the AmazonPlus extension for MediaWiki:
<ul>' . $err . '</ul></body></html>';
echo $html;
die(1);
}