本文整理汇总了PHP中SiteStatsUpdate类的典型用法代码示例。如果您正苦于以下问题:PHP SiteStatsUpdate类的具体用法?PHP SiteStatsUpdate怎么用?PHP SiteStatsUpdate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SiteStatsUpdate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (!class_exists('CentralAuthUser')) {
$this->error("CentralAuth isn't enabled on this wiki\n", 1);
}
$username = $this->getArg(0);
$user = User::newFromName($username);
if ($user === false) {
$this->error("'{$username}' is an invalid username\n", 1);
}
// Normalize username
$username = $user->getName();
if ($user->getId()) {
$this->error("User '{$username}' already exists\n", 1);
} else {
global $wgAuth;
$central = CentralAuthUser::getInstance($user);
if (!$central->exists()) {
$this->error("No such global user: '{$username}'\n", 1);
}
$user->loadDefaults($username);
$user->addToDatabase();
$wgAuth->initUser($user, true);
$wgAuth->updateUser($user);
# Notify hooks (e.g. Newuserlog)
Hooks::run('AuthPluginAutoCreate', array($user));
# Update user count
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
$this->output("User '{$username}' created\n");
}
}
示例2: execute
public function execute()
{
$username = $this->getArg(0);
$password = $this->getArg(1);
$this->output(wfWikiID() . ": Creating and promoting User:{$username}...");
$user = User::newFromName($username);
if (!is_object($user)) {
$this->error("invalid username.", true);
} elseif (0 != $user->idForName()) {
$this->error("account exists.", true);
}
# Try to set the password
try {
$user->setPassword($password);
} catch (PasswordError $pwe) {
$this->error($pwe->getText(), true);
}
# Insert the account into the database
$user->addToDatabase();
$user->saveSettings();
# Promote user
if ($this->hasOption('sysop')) {
$user->addGroup('sysop');
}
if ($this->hasOption('bureaucrat')) {
$user->addGroup('bureaucrat');
}
# Increment site_stats.ss_users
$ssu = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssu->doUpdate();
$this->output("done.\n");
}
示例3: go_auth
function go_auth()
{
global $wgUser, $wgLanguageCode, $wgRequest, $wgOut;
// For a few special pages, don't do anything.
$title = $wgRequest->getVal('title');
$lg = Language::factory($wgLanguageCode);
if ($title == $lg->specialPage("Userlogout") || $title == $lg->specialPage("Userlogin")) {
return true;
}
$data = go_getsession();
if ($wgUser->IsAnon() || $data && $wgUser->getName() != $data['username']) {
if (isset($data['user_id'])) {
$wgUser = User::newFromName($data['username']);
// Create a new account if the user does not exists
if ($wgUser->getID() == 0) {
// Create the user
$wgUser->addToDatabase();
$wgUser->setRealName($data['username']);
//$wgUser->setEmail($data['GO_SESSION']['email']);
$wgUser->setPassword(md5($data['username'] . 'zout'));
// do something random
$wgUser->setToken();
$wgUser->saveSettings();
// Update user count
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
}
$wgUser->setOption("rememberpassword", 1);
$wgUser->setCookies();
$wgOut->returnToMain();
}
}
return true;
}
示例4: getMessengerUser
/**
* Sets up the messenger account for our use if it hasn't been already.
* Based on code from AbuseFilter
* https://mediawiki.org/wiki/Extension:AbuseFilter
*
* @return User
*/
public static function getMessengerUser()
{
global $wgMassMessageAccountUsername;
// Function kinda copied from the AbuseFilter
$user = User::newFromName($wgMassMessageAccountUsername);
$user->load();
if ($user->getId() && $user->mPassword == '') {
// We've already stolen the account
return $user;
}
if (!$user->getId()) {
$user->addToDatabase();
$user->saveSettings();
// Increment site_stats.ss_users
$ssu = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssu->doUpdate();
} else {
// Someone already created the account, lets take it over.
$user->setPassword(null);
$user->setEmail(null);
$user->saveSettings();
}
// Make the user a bot so it doesn't look weird
$user->addGroup('bot');
return $user;
}
示例5: execute
public function execute()
{
$name = $this->getArg();
$delete = $this->getOption('delete', false);
$ns = $this->getOption('ns', NS_MAIN);
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
$tbl_pag = $dbw->tableName('page');
$tbl_rec = $dbw->tableName('recentchanges');
$tbl_rev = $dbw->tableName('revision');
# Get page ID
$this->output("Searching for \"{$name}\"...");
$title = Title::newFromText($name, $ns);
if ($title) {
$id = $title->getArticleID();
$real = $title->getPrefixedText();
$isGoodArticle = $title->isContentPage();
$this->output("found \"{$real}\" with ID {$id}.\n");
# Get corresponding revisions
$this->output("Searching for revisions...");
$res = $dbw->query("SELECT rev_id FROM {$tbl_rev} WHERE rev_page = {$id}");
$revs = array();
foreach ($res as $row) {
$revs[] = $row->rev_id;
}
$count = count($revs);
$this->output("found {$count}.\n");
# Delete the page record and associated recent changes entries
if ($delete) {
$this->output("Deleting page record...");
$dbw->query("DELETE FROM {$tbl_pag} WHERE page_id = {$id}");
$this->output("done.\n");
$this->output("Cleaning up recent changes...");
$dbw->query("DELETE FROM {$tbl_rec} WHERE rc_cur_id = {$id}");
$this->output("done.\n");
}
$dbw->commit();
# Delete revisions as appropriate
if ($delete && $count) {
$this->output("Deleting revisions...");
$this->deleteRevisions($revs);
$this->output("done.\n");
$this->purgeRedundantText(true);
}
# Update stats as appropriate
if ($delete) {
$this->output("Updating site stats...");
$ga = $isGoodArticle ? -1 : 0;
// if it was good, decrement that too
$stats = new SiteStatsUpdate(0, -$count, $ga, -1);
$stats->doUpdate();
$this->output("done.\n");
}
} else {
$this->output("not found in database.\n");
$dbw->commit();
}
}
示例6: wfSpecialStatistics
/**
* constructor
*/
function wfSpecialStatistics()
{
global $wgUser, $wgOut, $wgLang, $wgRequest;
$fname = 'wfSpecialStatistics';
$action = $wgRequest->getVal('action');
$dbr =& wfGetDB(DB_SLAVE);
extract($dbr->tableNames('page', 'site_stats', 'user', 'user_groups'));
$row = $dbr->selectRow('site_stats', '*', false, $fname);
$views = $row->ss_total_views;
$edits = $row->ss_total_edits;
$good = $row->ss_good_articles;
# This code is somewhat schema-agnostic, because I'm changing it in a minor release -- TS
if (isset($row->ss_total_pages) && $row->ss_total_pages == -1) {
# Update schema
$u = new SiteStatsUpdate(0, 0, 0);
$u->doUpdate();
$row = $dbr->selectRow('site_stats', '*', false, $fname);
}
if (isset($row->ss_total_pages)) {
$total = $row->ss_total_pages;
} else {
$sql = "SELECT COUNT(page_namespace) AS total FROM {$page}";
$res = $dbr->query($sql, $fname);
$pageRow = $dbr->fetchObject($res);
$total = $pageRow->total;
}
if (isset($row->ss_users)) {
$users = $row->ss_users;
} else {
$sql = "SELECT MAX(user_id) AS total FROM {$user}";
$res = $dbr->query($sql, $fname);
$userRow = $dbr->fetchObject($res);
$users = $userRow->total;
}
$sql = "SELECT COUNT(*) AS total FROM {$user_groups} WHERE ug_group='sysop'";
$res = $dbr->query($sql, $fname);
$row = $dbr->fetchObject($res);
$admins = $row->total;
if ($action == 'raw') {
$wgOut->disable();
header('Pragma: nocache');
echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins}\n";
return;
} else {
$text = '==' . wfMsg('sitestats') . "==\n";
$text .= wfMsg('sitestatstext', $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)));
$text .= "\n==" . wfMsg('userstats') . "==\n";
$text .= wfMsg('userstatstext', $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsg('administrators') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)));
$wgOut->addWikiText($text);
}
}
示例7: onOpauthUserAuthorized
public static function onOpauthUserAuthorized($provider, $uid, $info, $raw)
{
global $wgUser, $wgOut;
// Called when user was successfully authenticated from Opauth
// This function should compare UID with internal storage and decide to create new account for this user
// or load existing user from database
if (OpauthLogin::isUidLinked($uid, $provider)) {
// Login existing user into system
$user = OpauthLogin::getUidUser($uid, $provider);
wfRunHooks('OpauthLoginUserAuthorized', array($user, $provider, $uid, $info));
} else {
// Create new user from external data, $info refers to https://github.com/opauth/opauth/wiki/Auth-response
/**
* We set UID based string as user name in mediawiki to avoid
* user nicknames override and collisions problems. We store external user name into
* "real name" field of user object. This should be supported in skin.
*/
$user = User::newFromName(md5($provider . $uid) . '_' . $uid, false);
$user->setRealName($info['name']);
if (array_key_exists('email', $info)) {
if (!OpauthLogin::isEmailCollate($info['email'])) {
$user->setEmail($info['email']);
}
}
$user->setPassword(md5($info['name'] . time()));
$user->setToken();
$user->confirmEmail();
// Mark email address as confirmed by default
$user->addToDatabase();
// Commit changes to database
OpauthLogin::addUidLink($uid, $provider, $user->getId());
// Update site stats
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
// Run AddNewAccount hook for proper handling
wfRunHooks('AddNewAccount', array($user, false));
wfRunHooks('OpauthLoginUserCreated', array($user, $provider, $info, $uid));
}
// Replace current user with new one
$wgUser = $user;
$wgUser->setCookies(null, null, true);
if (array_key_exists('opauth_returnto', $_SESSION) && isset($_SESSION['opauth_returnto'])) {
$returnToTitle = Title::newFromText($_SESSION['opauth_returnto']);
unset($_SESSION['opauth_returnto']);
$wgOut->redirect($returnToTitle->getFullURL());
return true;
}
$wgOut->redirect(Title::newMainPage()->getFullURL());
return true;
}
示例8: load
static function load($recache = false)
{
if (self::$loaded && !$recache) {
return;
}
$dbr =& wfGetDB(DB_SLAVE);
self::$row = $dbr->selectRow('site_stats', '*', false, __METHOD__);
# This code is somewhat schema-agnostic, because I'm changing it in a minor release -- TS
if (!isset(self::$row->ss_total_pages) && self::$row->ss_total_pages == -1) {
# Update schema
$u = new SiteStatsUpdate(0, 0, 0);
$u->doUpdate();
self::$row = $dbr->selectRow('site_stats', '*', false, __METHOD__);
}
}
示例9: execute
public function execute()
{
$this->output("Refresh Site Statistics\n\n");
$counter = new SiteStatsInit($this->hasOption('use-master'));
$this->output("Counting total edits...");
$edits = $counter->edits();
$this->output("{$edits}\nCounting number of articles...");
$good = $counter->articles();
$this->output("{$good}\nCounting total pages...");
$pages = $counter->pages();
$this->output("{$pages}\nCounting number of users...");
$users = $counter->users();
$this->output("{$users}\nCounting number of images...");
$image = $counter->files();
$this->output("{$image}\n");
if (!$this->hasOption('noviews')) {
$this->output("Counting total page views...");
$views = $counter->views();
$this->output("{$views}\n");
}
if ($this->hasOption('active')) {
$this->output("Counting active users...");
$active = SiteStatsUpdate::cacheUpdate();
$this->output("{$active}\n");
}
$this->output("\nUpdating site statistics...");
if ($this->hasOption('update')) {
$counter->update();
} else {
$counter->refresh();
}
$this->output("done.\n");
}
示例10: execute
public function execute()
{
$this->output("Refresh Site Statistics\n\n");
$counter = new SiteStatsInit($this->hasOption('use-master'));
$this->output("Counting total edits...");
$edits = $counter->edits();
$this->output("{$edits}\nCounting number of articles...");
$good = $counter->articles();
$this->output("{$good}\nCounting total pages...");
$pages = $counter->pages();
$this->output("{$pages}\nCounting number of users...");
$users = $counter->users();
$this->output("{$users}\nCounting number of images...");
$image = $counter->files();
$this->output("{$image}\n");
if ($this->hasOption('update')) {
$this->output("\nUpdating site statistics...");
$counter->refresh();
$this->output("done.\n");
} else {
$this->output("\nTo update the site statistics table, run the script " . "with the --update option.\n");
}
if ($this->hasOption('active')) {
$this->output("\nCounting and updating active users...");
$active = SiteStatsUpdate::cacheUpdate($this->getDB(DB_MASTER));
$this->output("{$active}\n");
}
$this->output("\nDone.\n");
}
示例11: execute
public function execute($par)
{
global $wgMemc, $wgDisableCounters, $wgMiserMode;
$this->setHeaders();
$this->getOutput()->addModuleStyles('mediawiki.special');
$this->views = SiteStats::views();
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->total = SiteStats::pages();
$this->users = SiteStats::users();
$this->activeUsers = SiteStats::activeUsers();
$this->hook = '';
# Staticic - views
$viewsStats = '';
if (!$wgDisableCounters) {
$viewsStats = $this->getViewsStats();
}
# Set active user count
if (!$wgMiserMode) {
$key = wfMemcKey('sitestats', 'activeusers-updated');
// Re-calculate the count if the last tally is old...
if (!$wgMemc->get($key)) {
$dbw = wfGetDB(DB_MASTER);
SiteStatsUpdate::cacheUpdate($dbw);
$wgMemc->set($key, '1', 24 * 3600);
// don't update for 1 day
}
}
$text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
# Statistic - pages
$text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
# Statistic - users
$text .= $this->getUserStats();
# Statistic - usergroups
$text .= $this->getGroupStats();
$text .= $viewsStats;
# Statistic - popular pages
if (!$wgDisableCounters && !$wgMiserMode) {
$text .= $this->getMostViewedPages();
}
# Statistic - other
$extraStats = array();
if (wfRunHooks('SpecialStatsAddExtra', array(&$extraStats))) {
$text .= $this->getOtherStats($extraStats);
}
$text .= Xml::closeElement('table');
#<Wikia>
wfRunHooks("CustomSpecialStatistics", array(&$this, &$text));
#</Wikia>
# Customizable footer
$footer = wfMessage('statistics-footer');
if (!$footer->isBlank()) {
$text .= "\n" . $footer->parse();
}
$this->getOutput()->addHTML($text);
}
示例12: execute
public function execute($par)
{
global $wgOut, $wgMemc;
global $wgDisableCounters, $wgMiserMode;
$this->setHeaders();
$this->views = SiteStats::views();
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->total = SiteStats::pages();
$this->users = SiteStats::users();
$this->activeUsers = SiteStats::activeUsers();
$this->admins = SiteStats::numberingroup('sysop');
$this->hook = '';
# Staticic - views
$viewsStats = '';
if (!$wgDisableCounters) {
$viewsStats = $this->getViewsStats();
}
# Set active user count
if (!$wgMiserMode) {
$key = wfMemcKey('sitestats', 'activeusers-updated');
// Re-calculate the count if the last tally is old...
if (!$wgMemc->get($key)) {
$dbw = wfGetDB(DB_MASTER);
SiteStatsUpdate::cacheUpdate($dbw);
$wgMemc->set($key, '1', 24 * 3600);
// don't update for 1 day
}
}
$text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
# Statistic - pages
$text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
# Statistic - users
$text .= $this->getUserStats();
# Statistic - usergroups
$text .= $this->getGroupStats();
$text .= $viewsStats;
# Statistic - popular pages
if (!$wgDisableCounters && !$wgMiserMode) {
$text .= $this->getMostViewedPages();
}
# Statistic - other
$extraStats = array();
if (wfRunHooks('SpecialStatsAddExtra', array(&$extraStats))) {
$text .= $this->getOtherStats($extraStats);
}
$text .= Xml::closeElement('table');
# Customizable footer
$footer = wfMsgExt('statistics-footer', array('parseinline'));
if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
$text .= "\n" . $footer;
}
$wgOut->addHTML($text);
}
示例13: execute
public function execute($par)
{
global $wgOut, $wgRequest, $wgMessageCache;
global $wgDisableCounters, $wgMiserMode;
$wgMessageCache->loadAllMessages();
$this->setHeaders();
$this->views = SiteStats::views();
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->total = SiteStats::pages();
$this->users = SiteStats::users();
$this->activeUsers = SiteStats::activeUsers();
$this->admins = SiteStats::numberingroup('sysop');
$this->numJobs = SiteStats::jobs();
# Staticic - views
$viewsStats = '';
if (!$wgDisableCounters) {
$viewsStats = $this->getViewsStats();
}
# Set active user count
if (!$wgMiserMode) {
$dbw = wfGetDB(DB_MASTER);
SiteStatsUpdate::cacheUpdate($dbw);
}
# Do raw output
if ($wgRequest->getVal('action') == 'raw') {
$this->doRawOutput();
}
$text = Xml::openElement('table', array('class' => 'mw-statistics-table'));
# Statistic - pages
$text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
# Statistic - users
$text .= $this->getUserStats();
# Statistic - usergroups
$text .= $this->getGroupStats();
$text .= $viewsStats;
# Statistic - popular pages
if (!$wgDisableCounters && !$wgMiserMode) {
$text .= $this->getMostViewedPages();
}
$text .= Xml::closeElement('table');
# Customizable footer
$footer = wfMsgExt('statistics-footer', array('parseinline'));
if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
$text .= "\n" . $footer;
}
$wgOut->addHTML($text);
}
示例14: attemptAddUser
/**
* @param $user User
* @param $mungedUsername String
* @return bool
*/
public static function attemptAddUser($user, $mungedUsername)
{
/**
* @var $wgAuth LdapAuthenticationPlugin
*/
global $wgAuth;
if (!$wgAuth->autoCreate()) {
$wgAuth->printDebug("Cannot automatically create accounts.", NONSENSITIVE);
return false;
}
$wgAuth->printDebug("User does not exist in local database; creating.", NONSENSITIVE);
// Checks passed, create the user
$user->loadDefaults($mungedUsername);
$user->addToDatabase();
$wgAuth->initUser($user, true);
$user->setCookies();
wfSetupSession();
# Update user count
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
# Notify hooks (e.g. Newuserlog)
wfRunHooks('AuthPluginAutoCreate', array($user));
return true;
}
示例15: execute
public function execute($par)
{
global $wgMemc;
$miserMode = $this->getConfig()->get('MiserMode');
$this->setHeaders();
$this->getOutput()->addModuleStyles('mediawiki.special');
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->total = SiteStats::pages();
$this->users = SiteStats::users();
$this->activeUsers = SiteStats::activeUsers();
$this->hook = '';
# Set active user count
if (!$miserMode) {
$key = wfMemcKey('sitestats', 'activeusers-updated');
// Re-calculate the count if the last tally is old...
if (!$wgMemc->get($key)) {
$dbw = wfGetDB(DB_MASTER);
SiteStatsUpdate::cacheUpdate($dbw);
$wgMemc->set($key, '1', 24 * 3600);
// don't update for 1 day
}
}
$text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
# Statistic - pages
$text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
# Statistic - users
$text .= $this->getUserStats();
# Statistic - usergroups
$text .= $this->getGroupStats();
# Statistic - other
$extraStats = array();
if (Hooks::run('SpecialStatsAddExtra', array(&$extraStats, $this->getContext()))) {
$text .= $this->getOtherStats($extraStats);
}
$text .= Xml::closeElement('table');
# Customizable footer
$footer = $this->msg('statistics-footer');
if (!$footer->isBlank()) {
$text .= "\n" . $footer->parse();
}
$this->getOutput()->addHTML($text);
}