本文整理汇总了PHP中wfDie函数的典型用法代码示例。如果您正苦于以下问题:PHP wfDie函数的具体用法?PHP wfDie怎么用?PHP wfDie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfDie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addWiki
function addWiki($lang, $site, $dbName)
{
global $IP, $wgLanguageNames, $wgDefaultExternalStore;
$name = $wgLanguageNames[$lang];
$dbw =& wfGetDB(DB_WRITE);
$common = "/home/wikipedia/common";
$maintenance = "{$IP}/maintenance";
print "Creating database {$dbName} for {$lang}.{$site}\n";
# Set up the database
$dbw->query("SET table_type=Innodb");
$dbw->query("CREATE DATABASE {$dbName}");
$dbw->selectDB($dbName);
print "Initialising tables\n";
dbsource("{$maintenance}/tables.sql", $dbw);
dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
$dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
# Initialise external storage
if ($wgDefaultExternalStore && preg_match('!^DB://(.*)$!', $wgDefaultExternalStore, $m)) {
print "Initialising external storage...\n";
require_once 'ExternalStoreDB.php';
global $wgDBuser, $wgDBpassword, $wgExternalServers;
$cluster = $m[1];
# Hack
$wgExternalServers[$cluster][0]['user'] = $wgDBuser;
$wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
$store = new ExternalStoreDB();
$extdb =& $store->getMaster($cluster);
$extdb->query("SET table_type=InnoDB");
$extdb->query("CREATE DATABASE {$dbName}");
$extdb->selectDB($dbName);
dbsource("{$maintenance}/storage/blobs.sql", $extdb);
$extdb->immediateCommit();
}
$wgTitle = Title::newMainPage();
$wgArticle = new Article($wgTitle);
$ucsite = ucfirst($site);
$wgArticle->insertNewArticle("\n==This subdomain is reserved for the creation of a {$ucsite} in '''[[:en:{$name}|{$name}]]''' language==\n\nIf you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.\n\nGo ahead. Translate this page and start working on your encyclopedia.\n\nFor help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.\n\n==Sister projects==\n[http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]\n\nSee the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.\n\n[[aa:]]\n[[af:]]\n[[als:]]\n[[ar:]]\n[[de:]]\n[[en:]]\n[[as:]]\n[[ast:]]\n[[ay:]]\n[[az:]]\n[[be:]]\n[[bg:]]\n[[bn:]]\n[[bo:]]\n[[bs:]]\n[[cs:]]\n[[co:]]\n[[cs:]]\n[[cy:]]\n[[da:]]\n[[el:]]\n[[eo:]]\n[[es:]]\n[[et:]]\n[[eu:]]\n[[fa:]]\n[[fi:]]\n[[fr:]]\n[[fy:]]\n[[ga:]]\n[[gl:]]\n[[gn:]]\n[[gu:]]\n[[he:]]\n[[hi:]]\n[[hr:]]\n[[hy:]]\n[[ia:]]\n[[id:]]\n[[is:]]\n[[it:]]\n[[ja:]]\n[[ka:]]\n[[kk:]]\n[[km:]]\n[[kn:]]\n[[ko:]]\n[[ks:]]\n[[ku:]]\n[[ky:]]\n[[la:]]\n[[ln:]]\n[[lo:]]\n[[lt:]]\n[[lv:]]\n[[hu:]]\n[[mi:]]\n[[mk:]]\n[[ml:]]\n[[mn:]]\n[[mr:]]\n[[ms:]]\n[[mt:]]\n[[my:]]\n[[na:]]\n[[nah:]]\n[[nds:]]\n[[ne:]]\n[[nl:]]\n[[no:]]\n[[oc:]]\n[[om:]]\n[[pa:]]\n[[pl:]]\n[[ps:]]\n[[pt:]]\n[[qu:]]\n[[ro:]]\n[[ru:]]\n[[sa:]]\n[[si:]]\n[[sk:]]\n[[sl:]]\n[[sq:]]\n[[sr:]]\n[[sv:]]\n[[sw:]]\n[[ta:]]\n[[te:]]\n[[tg:]]\n[[th:]]\n[[tk:]]\n[[tl:]]\n[[tr:]]\n[[tt:]]\n[[ug:]]\n[[uk:]]\n[[ur:]]\n[[uz:]]\n[[vi:]]\n[[vo:]]\n[[xh:]]\n[[yo:]]\n[[za:]]\n[[zh:]]\n[[zu:]]\n", '', false, false);
print "Adding to dblists\n";
# Add to dblist
$file = fopen("{$common}/all.dblist", "a");
fwrite($file, "{$dbName}\n");
fclose($file);
# Update the sublists
system("cd {$common} && ./refresh-dblist");
print "Constructing interwiki SQL\n";
# Rebuild interwiki tables
$sql = getRebuildInterwikiSQL();
$tempname = tempnam('/tmp', 'addwiki');
$file = fopen($tempname, 'w');
if (!$file) {
wfDie("Error, unable to open temporary file {$tempname}\n");
}
fwrite($file, $sql);
fclose($file);
print "Sourcing interwiki SQL\n";
dbsource($tempname, $dbw);
unlink($tempname);
print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
示例2: ChangePassword
function ChangePassword($user, $password)
{
global $USAGE;
if (!strlen($user) or !strlen($password)) {
wfDie($USAGE);
}
$this->user = User::newFromName($user);
if (!$this->user->getId()) {
die("No such user: {$user}\n");
}
$this->password = $password;
$this->dbw = wfGetDB(DB_MASTER);
}
示例3: dump
function dump()
{
# This shouldn't happen if on console... ;)
header('Content-type: text/html; charset=UTF-8');
# Notice messages will foul up your XML output even if they're
# relatively harmless.
// ini_set( 'display_errors', false );
$this->initProgress($this->history);
$this->db =& $this->backupDb();
$this->egress = new ExportProgressFilter($this->sink, $this);
$input = fopen($this->input, "rt");
$result = $this->readDump($input);
if (WikiError::isError($result)) {
wfDie($result->getMessage());
}
$this->report(true);
}
示例4: open
/**
* Usually aborts on failure
* If the failFunction is set to a non-zero integer, returns success
*/
function open($server, $user, $password, $dbName)
{
if (!function_exists('oci_connect')) {
wfDie("Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n");
}
$this->close();
$this->mServer = $server;
$this->mUser = $user;
$this->mPassword = $password;
$this->mDBname = $dbName;
$success = false;
$hstring = "";
$this->mConn = oci_new_connect($user, $password, $dbName, "AL32UTF8");
if ($this->mConn === false) {
wfDebug("DB connection error\n");
wfDebug("Server: {$server}, Database: {$dbName}, User: {$user}, Password: " . substr($password, 0, 3) . "...\n");
wfDebug($this->lastError() . "\n");
} else {
$this->mOpened = true;
}
return $this->mConn;
}
示例5: buildTestDatabase
/**
* @param string $serverType
* @param array $tables
*/
protected function buildTestDatabase($tables)
{
global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
$wgDBprefix = 'parsertest';
$db = new Database($wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname);
if ($db->isOpen()) {
if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
# Database that supports CREATE TABLE ... LIKE
foreach ($tables as $tbl) {
$newTableName = $db->tableName($tbl);
#$tableName = $this->oldTableNames[$tbl];
$tableName = $tbl;
$db->query("CREATE TEMPORARY TABLE {$newTableName} (LIKE {$tableName})");
}
} else {
# Hack for MySQL versions < 4.1, which don't support
# "CREATE TABLE ... LIKE". Note that
# "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
# would not create the indexes we need....
foreach ($tables as $tbl) {
$res = $db->query("SHOW CREATE TABLE {$tbl}");
$row = $db->fetchRow($res);
$create = $row[1];
$create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `' . $wgDBprefix . '\\1`', $create);
if ($create === $create_tmp) {
# Couldn't do replacement
wfDie("could not create temporary table {$tbl}");
}
$db->query($create_tmp);
}
}
return $db;
} else {
// Something amiss
return null;
}
}
示例6: moveInconsistentPage
function moveInconsistentPage($row, $title)
{
if ($title->exists() || $title->getInterwiki()) {
if ($title->getInterwiki()) {
$prior = $title->getPrefixedDbKey();
} else {
$prior = $title->getDbKey();
}
$clean = 'Broken/' . $prior;
$verified = Title::makeTitleSafe($row->page_namespace, $clean);
if ($verified->exists()) {
$blah = "Broken/id:" . $row->page_id;
$this->log("Couldn't legalize; form '{$clean}' exists; using '{$blah}'");
$verified = Title::makeTitleSafe($row->page_namespace, $blah);
}
$title = $verified;
}
if (is_null($title)) {
wfDie("Something awry; empty title.\n");
}
$ns = $title->getNamespace();
$dest = $title->getDbKey();
if ($this->dryrun) {
$this->log("DRY RUN: would rename {$row->page_id} ({$row->page_namespace},'{$row->page_title}') to ({$row->page_namespace},'{$dest}')");
} else {
$this->log("renaming {$row->page_id} ({$row->page_namespace},'{$row->page_title}') to ({$ns},'{$dest}')");
$dbw =& wfGetDB(DB_MASTER);
$dbw->update('page', array('page_namespace' => $ns, 'page_title' => $dest), array('page_id' => $row->page_id), 'cleanupTitles::moveInconsistentPage');
$linkCache =& LinkCache::singleton();
$linkCache->clear();
}
}
示例7: importFromHandle
}
function importFromHandle($handle)
{
$this->startTime = wfTime();
$source = new ImportStreamSource($handle);
$importer = new WikiImporter($source);
$importer->setDebug($this->debug);
$importer->setPageCallback(array(&$this, 'reportPage'));
$this->importCallback = $importer->setRevisionCallback(array(&$this, 'handleRevision'));
$this->uploadCallback = $importer->setUploadCallback(array(&$this, 'handleUpload'));
$this->logItemCallback = $importer->setLogItemCallback(array(&$this, 'handleLogItem'));
return $importer->doImport();
}
}
if (wfReadOnly()) {
wfDie("Wiki is in read-only mode; you'll need to disable it for import to work.\n");
}
$reader = new BackupReader();
if (isset($options['quiet'])) {
$reader->reporting = false;
}
if (isset($options['report'])) {
$reader->reportingInterval = intval($options['report']);
}
if (isset($options['dry-run'])) {
$reader->dryRun = true;
}
if (isset($options['debug'])) {
$reader->debug = true;
}
if (isset($options['uploads'])) {
示例8: dirname
<?php
/**
* Dumb program that tries to get the memory usage
* for each language file.
*/
/** This is a command line script */
require_once dirname(__FILE__) . '/../commandLine.inc';
require_once dirname(__FILE__) . '/languages.inc';
$langtool = new languages();
if (!function_exists('memory_get_usage')) {
wfDie("You must compile PHP with --enable-memory-limit\n");
}
$memlast = $memstart = memory_get_usage();
print 'Base memory usage: ' . $memstart . "\n";
foreach ($langtool->getLanguages() as $langcode) {
Language::factory($langcode);
$memstep = memory_get_usage();
printf("%12s: %d\n", $langcode, $memstep - $memlast);
$memlast = $memstep;
}
$memend = memory_get_usage();
echo ' Total Usage: ' . ($memend - $memstart) . "\n";
示例9: run
public function run(PHPUnit_Framework_TestResult $result = NULL)
{
PHPUnit_Framework_Assert::resetCount();
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
}
$t = MediaWikiParserTestSuite::$iter->current();
$k = MediaWikiParserTestSuite::$iter->key();
if (!MediaWikiParserTestSuite::$iter->valid()) {
return;
}
// The only way this should happen is if the parserTest.txt
// file were modified while the script is running.
if ($k != $this->number) {
$i = $this->number;
wfDie("I got confused!\n");
}
$result->startTest($this);
PHPUnit_Util_Timer::start();
$r = false;
try {
$r = MediaWikiParserTestSuite::$parser->runTest($t['test'], $t['input'], $t['result'], $t['options'], $t['config']);
PHPUnit_Framework_Assert::assertTrue(true, $t['test']);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
} catch (Exception $e) {
$result->addError($this, $e, PHPUnit_Util_Timer::stop());
}
PHPUnit_Framework_Assert::assertTrue(true, $t['test']);
$result->endTest($this, PHPUnit_Util_Timer::stop());
MediaWikiParserTestSuite::$parser->recorder->record($t['test'], $r);
MediaWikiParserTestSuite::$iter->next();
$this->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
return $result;
}
示例10: loadDefaultTables
/**
* Load default conversion tables.
* This method must be implemented in derived class.
*
* @private
*/
function loadDefaultTables()
{
$name = get_class($this);
wfDie("Must implement loadDefaultTables() method in class {$name}");
}
示例11: getMediawikiMessages
/**
* Return a $wgAllmessages array shipped in MediaWiki
* @param string $languageCode Formated language code
* @return array The MediaWiki default $wgAllMessages array requested
*/
function getMediawikiMessages($languageCode = 'En')
{
$foo = "wgAllMessages{$languageCode}";
global ${$foo};
global $wgSkinNamesEn;
// potentially unused global declaration?
// it might already be loaded in LocalSettings.php
if (!isset(${$foo})) {
global $IP;
$langFile = $IP . '/languages/classes/Language' . $languageCode . '.php';
if (file_exists($langFile)) {
print "Including {$langFile}\n";
include $langFile;
} else {
wfDie("ERROR: The file {$langFile} does not exist !\n");
}
}
return ${$foo};
}
示例12: ini_set
<?php
if (!defined('MEDIAWIKI')) {
ini_set("include_path", dirname(__FILE__) . "/..");
require_once 'commandLine.inc';
}
$USAGE = "Usage: php generateLangFile.php [--lang=(all|ja|zh|zh-tw|pl|...)] [--removedb=(no|yes)] [--merge=(no|yes)] [--filename=Messages%s.php] [--dir=/tmp] | --help\n" . "\toptions:\n" . "\t\t--help\tshow this message\n" . "\t\t--lang\tlanguage code (default: 'all': generate all messages)\n" . "\t\t--removedb\tremove articles from database, default: no\n" . "\t\t--merge\tmerge with existing wikia messages, default: no\n" . "\t\t--filename\tformat of output filename, default: Messages%s.php (where '%s' is a --lang parameter)\n" . "\t\t--dir\t output dir name, default: '/tmp' \n";
if (in_array('--help', $argv)) {
wfDie($USAGE);
}
$params = @$options;
$lang = array_key_exists('lang', $params) && !empty($params['lang']) ? $params['lang'] : 'all';
$removedb = array_key_exists('removedb', $params) && !empty($params['removedb']) ? $params['removedb'] : 'no';
$merge = array_key_exists('merge', $params) && !empty($params['merge']) ? $params['merge'] : 'no';
$filename = array_key_exists('filename', $params) && !empty($params['filename']) ? $params['filename'] : 'Messages%s.php';
$dir = array_key_exists('dir', $params) && !empty($params['dir']) ? $params['dir'] : '/tmp';
$maxRevId = wfGenerateMessagesFile($lang, $removedb, $merge, $filename, $dir);
echo "\n\$maxRevId = {$maxRevId}\n";
function wfGenerateMessagesFile($lang_param, $removedb, $merge, $filename, $dir)
{
global $wgDefaultMessagesDB, $wgContLang, $IP;
#-- takes data from DB
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select(array("`{$wgDefaultMessagesDB}`.`page`", "`{$wgDefaultMessagesDB}`.`revision`", "`{$wgDefaultMessagesDB}`.`text`"), array('page_id', 'page_title', 'old_text', 'old_flags', 'page_namespace', 'rev_id'), array('rev_text_id=old_id', 'page_latest=rev_id', 'page_is_redirect' => 0, 'page_namespace' => NS_MEDIAWIKI), __METHOD__);
$defaultMessages = array();
$articleToRemove = array();
$maxRevId = 0;
while ($row = $dbr->fetchObject($res)) {
$maxRevId = max($maxRevId, $row->rev_id);
$lckey = $wgContLang->lcfirst($row->page_title);
if (strpos($lckey, '/')) {
示例13: randomUrl
function randomUrl()
{
global $wgServer, $wgArticlePath;
return $wgServer . str_replace('$1', randomTitle(), $wgArticlePath);
}
/** @todo document */
function randomTitle()
{
$str = '';
$length = mt_rand(1, 20);
for ($i = 0; $i < $length; $i++) {
$str .= chr(mt_rand(ord('a'), ord('z')));
}
return ucfirst($str);
}
if (!$wgUseSquid) {
wfDie("Squid purge benchmark doesn't do much without squid support on.\n");
} else {
printf("There are %d defined squid servers:\n", count($wgSquidServers));
#echo implode( "\n", $wgSquidServers ) . "\n";
if (isset($options['count'])) {
$lengths = array(intval($options['count']));
} else {
$lengths = array(1, 10, 100);
}
foreach ($lengths as $length) {
$urls = randomUrlList($length);
$trial = benchSquid($urls);
print "{$trial}\n";
}
}
示例14: array
* -c <chunk-size> maximum number of revisions in a concat chunk
* -b <begin-date> earliest date to check for uncompressed revisions
* -e <end-date> latest revision date to compress
* -s <start-id> the old_id to start from
* --extdb <cluster> store specified revisions in an external cluster (untested)
*
* @file
* @ingroup Maintenance ExternalStorage
*/
$optionsWithArgs = array('t', 'c', 's', 'f', 'h', 'extdb', 'endid', 'e');
require_once dirname(__FILE__) . '/../commandLine.inc';
require_once "compressOld.inc";
if (!function_exists("gzdeflate")) {
print "You must enable zlib support in PHP to compress old revisions!\n";
print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
wfDie();
}
$defaults = array('t' => 'concat', 'c' => 20, 's' => 0, 'b' => '', 'e' => '', 'extdb' => '', 'endid' => false);
$options = $options + $defaults;
if ($options['t'] != 'concat' && $options['t'] != 'gzip') {
print "Type \"{$options['t']}\" not supported\n";
}
if ($options['extdb'] != '') {
print "Compressing database {$wgDBname} to external cluster {$options['extdb']}\n" . str_repeat('-', 76) . "\n\n";
} else {
print "Compressing database {$wgDBname}\n" . str_repeat('-', 76) . "\n\n";
}
$success = true;
if ($options['t'] == 'concat') {
$success = compressWithConcat($options['s'], $options['c'], $options['b'], $options['e'], $options['extdb'], $options['endid']);
} else {
示例15: rawurlencode
return;
}
$display = $title->getPrefixedText();
$this->count++;
$sanitized = rawurlencode($display);
$filename = sprintf("%s/wiki-%07d-%s.html", $this->outputDirectory, $this->count, $sanitized);
fprintf($this->stderr, "%s\n", $filename, $display);
// fixme
$user = new User();
$parser = new Parser();
$options = ParserOptions::newFromUser($user);
$output = $parser->parse($rev->getText(), $title, $options);
file_put_contents($filename, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " . "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" . "<head>\n" . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" . "<title>" . htmlspecialchars($display) . "</title>\n" . "</head>\n" . "<body>\n" . $output->getText() . "</body>\n" . "</html>");
}
function run()
{
$this->startTime = wfTime();
$file = fopen('php://stdin', 'rt');
$source = new ImportStreamSource($file);
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'handleRevision'));
return $importer->doImport();
}
}
if (isset($options['output-dir'])) {
$dir = $options['output-dir'];
} else {
wfDie("Must use --output-dir=/some/dir\n");
}
$render = new DumpRenderer($dir);
$render->run();