public function logData() { global $wgUDPProfilerHost, $wgUDPProfilerPort; $this->close(); if (isset($this->mCollated['-total']) && $this->mCollated['-total']['real'] < $this->mMinimumTime) { # Less than minimum, ignore return; } if (!MWInit::functionExists('socket_create')) { # Sockets are not enabled return; } $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $plength = 0; $packet = ""; foreach ($this->mCollated as $entry => $pfdata) { if (!isset($pfdata['count']) || !isset($pfdata['cpu']) || !isset($pfdata['cpu_sq']) || !isset($pfdata['real']) || !isset($pfdata['real_sq'])) { continue; } $pfline = sprintf("%s %s %d %f %f %f %f %s\n", $this->getProfileID(), "-", $pfdata['count'], $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry); $length = strlen($pfline); /* printf("<!-- $pfline -->"); */ if ($length + $plength > 1400) { socket_sendto($sock, $packet, $plength, 0, $wgUDPProfilerHost, $wgUDPProfilerPort); $packet = ""; $plength = 0; } $packet .= $pfline; $plength += $length; } socket_sendto($sock, $packet, $plength, 0x100, $wgUDPProfilerHost, $wgUDPProfilerPort); }
/** Fetch the math */ function fetchMath($sum) { if (MWInit::classExists('MathRenderer')) { $math = MathRenderer::getRenderer($sum, array(), MW_MATH_PNG); } else { throw new MWException('MathCaptcha requires the Math extension for MediaWiki versions 1.18 and above.'); } $html = $math->render(); return preg_replace('/alt=".*?"/', '', $html); }
/** * Get the version of HipHop used to compile, or false if MediaWiki was not * compiled. This works by having our build script insert a special function * into the compiled code. */ static function getCompilerVersion() { if (self::$compilerVersion === null) { if (self::functionExists('wfHipHopCompilerVersion')) { self::$compilerVersion = wfHipHopCompilerVersion(); } else { self::$compilerVersion = false; } } return self::$compilerVersion; }
/** * Get an external store object of the given type, with the given parameters * * @param string $proto Type of external storage, should be a value in $wgExternalStores * @param array $params Associative array of ExternalStoreMedium parameters * @return ExternalStoreMedium|bool The store class or false on error */ public static function getStoreObject($proto, array $params = array()) { global $wgExternalStores; if (!$wgExternalStores || !in_array($proto, $wgExternalStores)) { return false; // protocol not enabled } $class = 'ExternalStore' . ucfirst($proto); // Any custom modules should be added to $wgAutoLoadClasses for on-demand loading return MWInit::classExists($class) ? new $class($params) : false; }
/** * Get a job queue object of the specified type. * $params includes: * class : What job class to use (determines job type) * wiki : wiki ID of the wiki the jobs are for (defaults to current wiki) * type : The name of the job types this queue handles * order : Order that pop() selects jobs, either "timestamp" or "random". * If "timestamp" is used, the queue will effectively be FIFO. Note that * pop() will not be exactly FIFO, and even if it was, job completion would * not appear to be exactly FIFO since jobs can take different times to finish. * If "random" is used, pop() will pick jobs in random order. This might be * useful for improving concurrency depending on the queue storage medium. * * @param $params array * @return JobQueue * @throws MWException */ public static final function factory(array $params) { $class = $params['class']; if (!MWInit::classExists($class)) { throw new MWException("Invalid job queue class '{$class}'."); } $obj = new $class($params); if (!$obj instanceof self) { throw new MWException("Class '{$class}' is not a " . __CLASS__ . " class."); } return $obj; }
public function load() { if ($this->mLoaded) { return; } if (!MWInit::classExists('luasandbox')) { throw new MWException('luasandbox PHP extension is not installed'); } $this->mSandbox = new LuaSandbox(); $this->mSandbox->setMemoryLimit($this->mOptions['memoryLimit']); $this->mSandbox->setCPULimit($this->mOptions['maxCPU']); $this->mSandbox->registerLibrary('mw', array('import' => array($this, 'importModule'))); $this->mLoaded = true; }
/** * Get an external store object of the given type, with the given parameters * * @param $proto String: type of external storage, should be a value in $wgExternalStores * @param $params Array: associative array of parameters for the ExternalStore object. * @return ExternalStore subclass or false on error */ static function getStoreObject($proto, $params = array()) { global $wgExternalStores; if (!$wgExternalStores) { return false; } /* Protocol not enabled */ if (!in_array($proto, $wgExternalStores)) { return false; } $class = 'ExternalStore' . ucfirst($proto); /* Any custom modules should be added to $wgAutoLoadClasses for on-demand loading */ if (!MWInit::classExists($class)) { return false; } return new $class($params); }
/** * Override the core loadSettings. */ public function loadSettings() { global $IP, $wgNoDBParam, $wgConf, $site, $lang; if ( empty( $wgNoDBParam ) ) { # Check if we were passed a db name if ( isset( $this->mOptions['wiki'] ) ) { $db = $this->mOptions['wiki']; } else { $db = array_shift( $this->mArgs ); } list( $site, $lang ) = $wgConf->siteFromDB( $db ); # If not, work out the language and site the old way if ( is_null( $site ) || is_null( $lang ) ) { if ( !$db ) { $lang = 'aa'; } else { $lang = $db; } if ( isset( $this->mArgs[0] ) ) { $site = array_shift( $this->mArgs ); } else { $site = 'wikipedia'; } } } else { $lang = 'aa'; $site = 'wikipedia'; } putenv( 'wikilang=' . $lang ); ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" ); if ( $lang == 'test' && $site == 'wikipedia' ) { if ( !defined( 'TESTWIKI' ) ) { define( 'TESTWIKI', 1 ); } } return MWInit::interpretedPath( '../wmf-config/CommonSettings.php' ); }
/** * Loads hieroglyph information */ private static function loadData() { if (self::$phonemes) { return; } if (MWInit::isHipHop()) { require_once MWInit::extCompiledPath('wikihiero/data/tables.php'); self::$phonemes = $wh_phonemes; self::$prefabs = $wh_prefabs; self::$files = $wh_files; } else { $fileName = dirname(__FILE__) . '/data/tables.ser'; $stream = file_get_contents($fileName); if (!$stream) { throw new MWException("Cannot open serialized hieroglyph data file {$fileName}!"); } $data = unserialize($stream); self::$phonemes = $data['wh_phonemes']; self::$prefabs = $data['wh_prefabs']; self::$files = $data['wh_files']; } }
/** * Factory method for loading a skin of a given type * @param string $key 'monobook', 'standard', etc. * @return Skin */ static function &newFromKey($key) { global $wgStyleDirectory; $key = Skin::normalizeKey($key); $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; $className = "Skin{$skinName}"; # Grab the skin class and initialise it. if (!MWInit::classExists($className)) { if (!defined('MW_COMPILED')) { require_once "{$wgStyleDirectory}/{$skinName}.php"; } # Check if we got if not fallback to default skin if (!MWInit::classExists($className)) { # DO NOT die if the class isn't found. This breaks maintenance # scripts and can cause a user account to be unrecoverable # except by SQL manipulation if a previously valid skin name # is no longer valid. wfDebug("Skin class does not exist: {$className}\n"); $className = 'SkinVector'; if (!defined('MW_COMPILED')) { require_once "{$wgStyleDirectory}/Vector.php"; } } } $skin = new $className($key); return $skin; }
/** * @see FileBackendStore::__construct() * Additional $config params include: * - swiftAuthUrl : Swift authentication server URL * - swiftUser : Swift user used by MediaWiki (account:username) * - swiftKey : Swift authentication key for the above user * - swiftAuthTTL : Swift authentication TTL (seconds) * - swiftAnonUser : Swift user used for end-user requests (account:username). * If set, then views of public containers are assumed to go * through this user. If not set, then public containers are * accessible to unauthenticated requests via ".r:*" in the ACL. * - swiftUseCDN : Whether a Cloud Files Content Delivery Network is set up * - swiftCDNExpiry : How long (in seconds) to store content in the CDN. * If files may likely change, this should probably not exceed * a few days. For example, deletions may take this long to apply. * If object purging is enabled, however, this is not an issue. * - swiftCDNPurgable : Whether object purge requests are allowed by the CDN. * - shardViaHashLevels : Map of container names to sharding config with: * - base : base of hash characters, 16 or 36 * - levels : the number of hash levels (and digits) * - repeat : hash subdirectories are prefixed with all the * parent hash directory names (e.g. "a/ab/abc") * - cacheAuthInfo : Whether to cache authentication tokens in APC, XCache, ect. * If those are not available, then the main cache will be used. * This is probably insecure in shared hosting environments. */ public function __construct(array $config) { parent::__construct($config); if (!MWInit::classExists('CF_Constants')) { throw new MWException('SwiftCloudFiles extension not installed.'); } // Required settings $this->auth = new CF_Authentication($config['swiftUser'], $config['swiftKey'], null, $config['swiftAuthUrl']); // Optional settings $this->authTTL = isset($config['swiftAuthTTL']) ? $config['swiftAuthTTL'] : 5 * 60; // some sane number $this->swiftAnonUser = isset($config['swiftAnonUser']) ? $config['swiftAnonUser'] : ''; $this->shardViaHashLevels = isset($config['shardViaHashLevels']) ? $config['shardViaHashLevels'] : ''; $this->swiftUseCDN = isset($config['swiftUseCDN']) ? $config['swiftUseCDN'] : false; $this->swiftCDNExpiry = isset($config['swiftCDNExpiry']) ? $config['swiftCDNExpiry'] : 12 * 3600; // 12 hours is safe (tokens last 24 hours per http://docs.openstack.org) $this->swiftCDNPurgable = isset($config['swiftCDNPurgable']) ? $config['swiftCDNPurgable'] : true; // Cache container information to mask latency $this->memCache = wfGetMainCache(); // Process cache for container info $this->connContainerCache = new ProcessCacheLRU(300); // Cache auth token information to avoid RTTs if (!empty($config['cacheAuthInfo'])) { if (php_sapi_name() === 'cli') { $this->srvCache = wfGetMainCache(); // preferrably memcached } else { try { // look for APC, XCache, WinCache, ect... $this->srvCache = ObjectCache::newAccelerator(array()); } catch (Exception $e) { } } } $this->srvCache = $this->srvCache ? $this->srvCache : new EmptyBagOStuff(); }
MWFunction::call(MW_CONFIG_CALLBACK); } elseif (file_exists("{$IP}/../wmf-config/wikimedia-mode")) { // Load settings, using wikimedia-mode if needed // @todo FIXME: Replace this hack with general farm-friendly code # @todo FIXME: Wikimedia-specific stuff needs to go away to an ext # Maybe a hook? global $cluster; $cluster = 'pmtpa'; require MWInit::interpretedPath('../wmf-config/wgConf.php'); $maintenance->loadWikimediaSettings(); require MWInit::interpretedPath('../wmf-config/CommonSettings.php'); } else { require_once $maintenance->loadSettings(); } if ($maintenance->getDbType() === Maintenance::DB_ADMIN && is_readable("{$IP}/AdminSettings.php")) { require MWInit::interpretedPath('AdminSettings.php'); } $maintenance->finalSetup(); // Some last includes require_once MWInit::compiledPath('includes/Setup.php'); // Much much faster startup than creating a title object $wgTitle = null; // Do the work try { $maintenance->execute(); // Potentially debug globals $maintenance->globals(); } catch (MWException $mwe) { echo $mwe->getText(); exit(1); }
public static function get_extensions_dir() { return MWInit::getExtensionsDirectory(); }
/** * Wrapper for posix_isatty() * We default as considering stdin a tty (for nice readline methods) * but treating stout as not a tty to avoid color codes * * @param $fd int File descriptor * @return bool */ public static function posix_isatty($fd) { if (!MWInit::functionExists('posix_isatty')) { return !$fd; } else { return posix_isatty($fd); } }
define('WIKIHIERO_VERSION', '1.0alpha2'); $wgHooks['ParserFirstCallInit'][] = 'wfRegisterWikiHiero'; $wgHooks['BeforePageDisplay'][] = 'wfHieroBeforePageDisplay'; // Register MediaWiki extension $wgExtensionCredits['parserhook'][] = array('path' => __FILE__, 'name' => 'WikiHiero', 'version' => WIKIHIERO_VERSION, 'author' => array('Guillaume Blanchard', 'Max Semenik'), 'url' => '//www.mediawiki.org/wiki/Extension:WikiHiero', 'descriptionmsg' => 'wikihiero-desc'); $dir = dirname(__FILE__); $wgExtensionMessagesFiles['Wikihiero'] = "{$dir}/wikihiero.i18n.php"; $wgExtensionMessagesFiles['HieroglyphsAlias'] = "{$dir}/wikihiero.alias.php"; $wgAutoloadClasses['WikiHiero'] = "{$dir}/wikihiero.body.php"; $wgAutoloadClasses['SpecialHieroglyphs'] = "{$dir}/SpecialHieroglyphs.php"; $wgParserTestFiles[] = "{$dir}/tests.txt"; $wgSpecialPages['Hieroglyphs'] = 'SpecialHieroglyphs'; $wgSpecialPageGroups['Hieroglyphs'] = 'wiki'; $wgResourceModules['ext.wikihiero'] = array('styles' => 'ext.wikihiero.css', 'localBasePath' => "{$dir}/modules", 'remoteExtPath' => 'wikihiero/modules'); $wgResourceModules['ext.wikihiero.Special'] = array('scripts' => 'ext.wikihiero.Special.js', 'styles' => 'ext.wikihiero.Special.css', 'localBasePath' => dirname(__FILE__) . '/modules', 'remoteExtPath' => 'wikihiero/modules', 'dependencies' => array('jquery.spinner'), 'messages' => array('wikihiero-input', 'wikihiero-result', 'wikihiero-load-error')); $wgCompiledFiles[] = MWInit::extCompiledPath('wikihiero/data/tables.php'); /** * Because <hiero> tag is used rarely, we don't need to load its body on every hook call, * so we keep our simple hook handlers here. * * @param $parser Parser * @return bool */ function wfRegisterWikiHiero(&$parser) { $parser->setHook('hiero', 'WikiHiero::parserHook'); return true; } /** * @param $out OutputPage * @return bool
/** * Use the HTML tidy extension to use the tidy library in-process, * saving the overhead of spawning a new process. * * @param $text String: HTML to check * @param $stderr Boolean: Whether to read result from error status instead of output * @param &$retval Exit code (-1 on internal error) * @return mixed String or null */ private static function execInternalTidy($text, $stderr = false, &$retval = null) { global $wgTidyConf, $wgDebugTidy; wfProfileIn(__METHOD__); if (!MWInit::classExists('tidy')) { wfWarn("Unable to load internal tidy class."); $retval = -1; wfProfileOut(__METHOD__); return null; } $tidy = new tidy(); $tidy->parseString($text, $wgTidyConf, 'utf8'); if ($stderr) { $retval = $tidy->getStatus(); wfProfileOut(__METHOD__); return $tidy->errorBuffer; } else { $tidy->cleanRepair(); $retval = $tidy->getStatus(); if ($retval == 2) { // 2 is magic number for fatal error // http://www.php.net/manual/en/function.tidy-get-status.php $cleansource = null; } else { $cleansource = tidy_get_output($tidy); if ($wgDebugTidy && $retval > 0) { $cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '-->', $tidy->errorBuffer) . "\n-->"; } } wfProfileOut(__METHOD__); return $cleansource; } }
$wgLogNames['gblrights'] = 'centralauth-rightslog-name'; $wgLogHeaders['gblrights'] = 'centralauth-rightslog-header'; $wgLogActions['gblrights/usergroups'] = 'centralauth-rightslog-entry-usergroups'; $wgLogActions['gblrights/groupperms'] = 'centralauth-rightslog-entry-groupperms'; $wgLogActions['gblrights/groupprms2'] = 'centralauth-rightslog-entry-groupperms2'; $wgLogActions['gblrights/groupprms3'] = 'centralauth-rightslog-entry-groupperms3'; foreach (array('newset', 'setrename', 'setnewtype', 'setchange', 'deleteset') as $type) { $wgLogActionsHandlers["gblrights/{$type}"] = 'efHandleWikiSetLogEntry'; } $commonModuleInfo = array('localBasePath' => dirname(__FILE__) . '/modules', 'remoteExtPath' => 'CentralAuth/modules'); $wgResourceModules['ext.centralauth'] = array('scripts' => 'ext.centralauth.js', 'styles' => 'ext.centralauth.css', 'messages' => array('centralauth-merge-method-primary', 'centralauth-merge-method-primary-desc', 'centralauth-merge-method-new', 'centralauth-merge-method-new-desc', 'centralauth-merge-method-empty', 'centralauth-merge-method-empty-desc', 'centralauth-merge-method-password', 'centralauth-merge-method-password-desc', 'centralauth-merge-method-mail', 'centralauth-merge-method-mail-desc', 'centralauth-merge-method-admin', 'centralauth-merge-method-admin-desc', 'centralauth-merge-method-login', 'centralauth-merge-method-login-desc')) + $commonModuleInfo; $wgResourceModules['ext.centralauth.noflash'] = array('styles' => 'ext.centralauth.noflash.css') + $commonModuleInfo; // If AntiSpoof is installed, we can do some AntiSpoof stuff for CA // Though, doing it this way, AntiSpoof has to be loaded/included first // I guess this is bug 30234 if (MWInit::classExists('AntiSpoof')) { $wgExtensionCredits['antispam'][] = array('path' => __FILE__, 'name' => 'AntiSpoof for CentralAuth', 'url' => 'https://www.mediawiki.org/wiki/Extension:AntiSpoof', 'author' => 'Sam Reed', 'descriptionmsg' => 'centralauth-antispoof-desc'); $wgAutoloadClasses['CentralAuthSpoofUser'] = "******"; $wgAutoloadClasses['CentralAuthAntiSpoofHooks'] = "{$caBase}/AntiSpoof/CentralAuthAntiSpoofHooks.php"; $wgHooks['AbortNewAccount'][] = 'CentralAuthAntiSpoofHooks::asAbortNewAccountHook'; $wgHooks['AddNewAccount'][] = 'CentralAuthAntiSpoofHooks::asAddNewAccountHook'; $wgHooks['RenameUserComplete'][] = 'CentralAuthAntiSpoofHooks::asAddRenameUserHook'; } /** * @param $type * @param $action * @param $title * @param $skin Skin * @param $params * @param $filterWikilinks bool * @return String
$wgLogNames['newusers'] = 'newuserlogpage'; $wgLogHeaders['newusers'] = 'newuserlogpagetext'; # newusers, create, create2, autocreate $wgLogActionsHandlers['newusers/*'] = 'NewUsersLogFormatter'; } if ($wgCookieSecure === 'detect') { $wgCookieSecure = substr($wgServer, 0, 6) === 'https:'; } // Disable MWDebug for command line mode, this prevents MWDebug from eating up // all the memory from logging SQL queries on maintenance scripts global $wgCommandLineMode; if ($wgDebugToolbar && !$wgCommandLineMode) { MWDebug::init(); } if (!defined('MW_COMPILED')) { if (!MWInit::classExists('AutoLoader')) { require_once "{$IP}/includes/AutoLoader.php"; } wfProfileIn($fname . '-exception'); MWExceptionHandler::installHandler(); wfProfileOut($fname . '-exception'); wfProfileIn($fname . '-includes'); require_once "{$IP}/includes/normal/UtfNormalUtil.php"; require_once "{$IP}/includes/GlobalFunctions.php"; require_once "{$IP}/includes/ProxyTools.php"; require_once "{$IP}/includes/ImageFunctions.php"; require_once "{$IP}/includes/normal/UtfNormalDefines.php"; wfProfileOut($fname . '-includes'); } # Now that GlobalFunctions is loaded, set the default for $wgCanonicalServer if ($wgCanonicalServer === false) {
/** * Get an array of language names, indexed by code. * @param $inLanguage null|string: Code of language in which to return the names * Use null for autonyms (native names) * @param $include string: * 'all' all available languages * 'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames (default) * 'mwfile' only if the language is in 'mw' *and* has a message file * @return array: language code => language name * @since 1.20 */ public static function fetchLanguageNames($inLanguage = null, $include = 'mw') { global $wgExtraLanguageNames; static $coreLanguageNames; if ($coreLanguageNames === null) { include MWInit::compiledPath('languages/Names.php'); } $names = array(); if ($inLanguage) { # TODO: also include when $inLanguage is null, when this code is more efficient wfRunHooks('LanguageGetTranslatedLanguageNames', array(&$names, $inLanguage)); } $mwNames = $wgExtraLanguageNames + $coreLanguageNames; foreach ($mwNames as $mwCode => $mwName) { # - Prefer own MediaWiki native name when not using the hook # - For other names just add if not added through the hook if ($mwCode === $inLanguage || !isset($names[$mwCode])) { $names[$mwCode] = $mwName; } } if ($include === 'all') { return $names; } $returnMw = array(); $coreCodes = array_keys($mwNames); foreach ($coreCodes as $coreCode) { $returnMw[$coreCode] = $names[$coreCode]; } if ($include === 'mwfile') { $namesMwFile = array(); # We do this using a foreach over the codes instead of a directory # loop so that messages files in extensions will work correctly. foreach ($returnMw as $code => $value) { if (is_readable(self::getMessagesFileName($code))) { $namesMwFile[$code] = $names[$code]; } } return $namesMwFile; } # 'mw' option; default if it's not one of the other two options (all/mwfile) return $returnMw; }
/** * @param $dir string file system directory */ public function __construct($dir) { $dir = realpath($dir); // normalize $this->suffixStart = strlen($dir) + 1; // size of "path/to/dir/" try { # Get an iterator that will return leaf nodes (non-directories) if (MWInit::classExists('FilesystemIterator')) { // PHP >= 5.3 # RecursiveDirectoryIterator extends FilesystemIterator. # FilesystemIterator::SKIP_DOTS default is inconsistent in PHP 5.3.x. $flags = FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS; $this->iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, $flags)); } else { // PHP < 5.3 # RecursiveDirectoryIterator extends DirectoryIterator $this->iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)); } } catch (UnexpectedValueException $e) { $this->iter = null; // bad permissions? deleted? } }
/** * Run a child maintenance script. Pass all of the current arguments * to it. * @param $maintClass String: a name of a child maintenance class * @param $classFile String: full path of where the child is * @return Maintenance child */ public function runChild($maintClass, $classFile = null) { // Make sure the class is loaded first if (!MWInit::classExists($maintClass)) { if ($classFile) { require_once $classFile; } if (!MWInit::classExists($maintClass)) { $this->error("Cannot spawn child: {$maintClass}"); } } $child = new $maintClass(); $child->loadParamsAndArgs($this->mSelf, $this->mOptions, $this->mArgs); if (!is_null($this->mDb)) { $child->setDB($this->mDb); } return $child; }
/** * Create a new fatal error * * @return FileRepoStatus */ function newFatal($message) { $params = func_get_args(); array_unshift($params, $this); return MWInit::callStaticMethod('FileRepoStatus', 'newFatal', $params); }
# Check that there is no previous output or previously set up buffers, because # that would cause us to potentially mix gzip and non-gzip output, creating a # big mess. if (!defined('MW_NO_OUTPUT_BUFFER') && ob_get_level() == 0) { if (!defined('MW_COMPILED')) { require_once "{$IP}/includes/OutputHandler.php"; } ob_start('wfOutputHandler'); } // Wikia change - begin - @author: wladek // Catch all output echo $initialOutput; // Wikia change - end wfProfileOut('WebStart.php-ob_start'); if (!defined('MW_NO_SETUP')) { require_once MWInit::compiledPath("includes/Setup.php"); } if (is_object($wgRequest) && $wgRequest->wasPosted() && wfReadOnly()) { if (strpos(strtolower($_SERVER['SCRIPT_URL']), 'datacenter') === false && strpos(strtolower($_SERVER['SCRIPT_URL']), 'api.php') === false) { $js = <<<EOD <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-288915-41"); pageTracker._trackEvent("error", "PostInReadOnly"); } catch(err) {}</script> EOD; echo "<html><head>{$js}</head><body>{$wgReadOnly}</body></html>";
/** * Get language names, indexed by code. * If $customisedOnly is true, only returns codes with a messages file * * @param $customisedOnly bool * * @return array */ public static function getLanguageNames($customisedOnly = false) { global $wgExtraLanguageNames; static $coreLanguageNames; if ($coreLanguageNames === null) { include MWInit::compiledPath('languages/Names.php'); } $allNames = $wgExtraLanguageNames + $coreLanguageNames; if (!$customisedOnly) { return $allNames; } global $IP; $names = array(); $dir = opendir("{$IP}/languages/messages"); while (false !== ($file = readdir($dir))) { $code = self::getCodeFromFileName($file, 'Messages'); if ($code && isset($allNames[$code])) { $names[$code] = $allNames[$code]; } } closedir($dir); return $names; }
/** * Get native language names, indexed by code. * Only those defined in MediaWiki, no other data like CLDR. * If $customisedOnly is true, only returns codes with a messages file * * @param $customisedOnly bool * * @return array */ public static function getLanguageNames($customisedOnly = false) { global $wgExtraLanguageNames; static $coreLanguageNames; if ($coreLanguageNames === null) { include MWInit::compiledPath('languages/Names.php'); } $allNames = $wgExtraLanguageNames + $coreLanguageNames; if (!$customisedOnly) { return $allNames; } $names = array(); // We do this using a foreach over the codes instead of a directory // loop so that messages files in extensions will work correctly. foreach ($allNames as $code => $value) { if (is_readable(self::getMessagesFileName($code))) { $names[$code] = $allNames[$code]; } } return $names; }