function wfCheckQC(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision) { global $wgChangedTemplatesToQC; // if an article becomes a redirect, vanquish all previous qc entries if (preg_match("@^#REDIRECT@", $text)) { QCRule::markAllAsPatrolled($article->getTitle()); return true; } // check for bots $bots = WikihowUser::getBotIDs(); if (in_array($user->getID(), $bots)) { return true; } // ignore reverted edits if (preg_match("@Reverted edits by@", $summary)) { return true; } // check for intro image change, reverts are ok for this one // $l = new QCRuleIntroImage($revision, $article); // $l->process(); // do the templates foreach ($wgChangedTemplatesToQC as $t) { wfDebug("QC: About to process template change {$t}\n"); $l = new QCRuleTemplateChange($t, $revision, $article); $l->process(); } // check for video changes $l = new QCRuleVideoChange($revision, $article); $l->process(); return true; }
static function getAuthors($articleID) { global $wgMemc; $cachekey = self::getLoadAuthorsCachekey($articleID); $authors = $wgMemc->get($cachekey); if (is_array($authors)) { return $authors; } $authors = array(); $dbr = wfGetDB(DB_SLAVE); // filter out bots $bad = WikihowUser::getBotIDs(); $bad[] = 0; // filter out anons too, as per Jack $opts = array('rev_page' => $articleID); if (sizeof($bad) > 0) { $opts[] = 'rev_user NOT IN (' . $dbr->makeList($bad) . ')'; } $res = $dbr->select('revision', array('rev_user', 'rev_user_text'), $opts, __METHOD__, array('ORDER BY' => 'rev_timestamp')); foreach ($res as $row) { if ($row->rev_user == 0) { $authors['anonymous'] = 1; } elseif (!isset($authors[$row->user_text])) { $authors[$row->rev_user_text] = 1; } } if ($authors) { $wgMemc->set($cachekey, $authors); } return $authors; }
private static function getBotIDs() { if (!is_array(self::$mBots)) { self::$mBots = WikihowUser::getBotIDs(); } return self::$mBots; }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $startdate = strtotime('7 days ago'); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $bots = WikihowUser::getBotIDs(); $bot = ""; if (sizeof($bots) > 0) { $bot = " AND fe_user NOT IN (" . $dbr->makeList($bots) . ", '0') "; } $sql = "SELECT fe_user_text, fe_user, count(fe_user) as fe_count, MAX(fe_timestamp) as fe_timestamp " . "FROM firstedit left join page on fe_page = page_id left join suggested_titles on page_title= st_title " . "WHERE fe_timestamp >= '{$starttimestamp}' AND st_isrequest IS NOT NULL" . $bot . " GROUP BY fe_user ORDER BY fe_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->fe_user, $row->fe_timestamp); }
function getLastEditedInfo() { global $wgTitle; if (self::$mLastEditedInfo) { return self::$mLastEditedInfo; } $dbr = wfGetDB(DB_SLAVE); $bad = WikihowUser::getBotIDs(); $bad[] = 0; // filter out anons too, as per Jack $row = $dbr->selectRow('revision', array('rev_user', 'rev_user_text', 'rev_timestamp'), array('rev_user NOT IN (' . $dbr->makeList($bad) . ")", "rev_page" => $wgTitle->getArticleID()), __METHOD__, array("ORDER BY" => "rev_id DESC", "LIMIT" => 1)); $info->rev_user_text = $row->rev_user_text; $info->rev_user = $row->rev_user; $info->rev_timestamp = $row->rev_timestamp; self::$mLastEditedInfo = $info; return $info; }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $startdate = strtotime("7 days ago"); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = "img_user NOT IN (" . $dbr->makeList($bots) . ")"; } if ($sql != "") { $res = $dbr->select('image', array('*', 'count(img_user) as img_count', 'MAX(img_timestamp) as recent_timestamp'), array("img_user_text != 'WRM'", 'img_timestamp > "' . $starttimestamp . '"', $sql), 'AddImagesAppWidget::getTopContributor', array("GROUP BY" => 'img_user', "ORDER BY" => "img_count DESC", "LIMIT" => 1)); } else { $res = $dbr->select('image', array('*', 'count(img_user) as img_count', 'MAX(img_timestamp) as recent_timestamp'), array("img_user_text != 'WRM'", 'img_timestamp > "' . $starttimestamp . '"'), 'AddImagesAppWidget::getTopContributor', array("GROUP BY" => 'img_user', "ORDER BY" => "img_count DESC", "LIMIT" => 1)); } $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->img_user, $row->recent_timestamp); }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = "log_user NOT IN (" . $dbr->makeList($bots) . ")"; } $startdate = strtotime("7 days ago"); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; if ($sql != "") { $res = $dbr->select('logging', array('*', 'count(*) as C', 'MAX(log_timestamp) as log_recent'), array('log_type' => 'EF_topic', 'log_timestamp > "' . $starttimestamp . '"', $sql), 'StubAppWidget::getTopContributor', array("GROUP BY" => 'log_user', "ORDER BY" => "C DESC", "LIMIT" => 1)); } else { $res = $dbr->select('logging', array('*', 'count(*) as C', 'MAX(log_timestamp) as log_recent'), array('log_type' => 'EF_topic', 'log_timestamp > "' . $starttimestamp . '"'), 'StubAppWidget::getTopContributor', array("GROUP BY" => 'log_user', "ORDER BY" => "C DESC", "LIMIT" => 1)); } $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->log_user, $row->log_recent); }
function wfCheckNFD(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision) { //we only do NFD Guardian for articles if ($article->getTitle()->getNamespace() != NS_MAIN) { return true; } // if an article becomes a redirect, vanquish all previous nfd entries if (preg_match("@^#REDIRECT@", $text)) { NFDProcessor::markPreviousAsInactive($article->getID()); return true; } // check for bots $bots = WikihowUser::getBotIDs(); if (in_array($user->getID(), $bots)) { return true; } if ($revision && $article) { // do the templates wfDebug("NFD: Looking for NFD templates\n"); $l = new NFDProcessor($revision, $article); $l->process(); } return true; }
private function displayNABConsole(&$dbw, &$dbr, $target) { global $wgOut, $wgRequest, $wgUser, $wgParser; $not_found = false; $title = Title::newFromURL($target); if (!$title || !$title->exists()) { $articleName = $title ? $title->getFullText() : $target; $wgOut->addHTML("<p>Error: Article “{$articleName}” not found. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>"); $not_found = true; } if (!$not_found) { $rev = Revision::newFromTitle($title); if (!$rev) { $wgOut->addHTML("<p>Error: No revision for “{$title->getFullText()}”. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>"); $not_found = true; } } if (!$not_found) { $in_nab = $dbr->selectField('newarticlepatrol', 'count(*)', array('nap_page' => $title->getArticleID()), __METHOD__) > 0; if (!$in_nab) { $wgOut->addHTML("<p>Error: This article is not in the NAB list.</p>"); $not_found = true; } } if ($not_found) { $pageid = $wgRequest->getVal('page'); if (strpos($target, ':') !== false && $pageid) { $wgOut->addHTML('<p>We can to try to <a href="/Special:NABClean/' . $pageid . '">delete this title</a> if you know this title exists in NAB yet is likely bad data.</p>'); } return; } $locked = false; $min_timestamp = $dbr->selectField("revision", "min(rev_timestamp)", "rev_page=" . $title->getArticleId(), __METHOD__); $first_user = $dbr->selectField("revision", "rev_user_text", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__); $first_user_id = $dbr->selectField("revision", "rev_user", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__); $user = new User(); if ($first_user_id) { $user->setId($first_user_id); $user->loadFromDatabase(); } else { $user->setName($first_user); } $user_talk = $user->getTalkPage(); $ut_id = $user_talk->getArticleID(); $display_name = $user->getRealName() ? $user->getRealName() : $user->getName(); $wgOut->setPageTitle(wfMsg('nap_title', $title->getFullText())); $count = $dbr->selectField('suggested_titles', array('count(*)'), array('st_title' => $title->getDBKey()), __METHOD__); $extra = $count > 0 ? ' - from Suggested Titles database' : ''; $wgOut->addWikiText(wfMsg('nap_writtenby', $user->getName(), $display_name, $extra)); $wgOut->addHTML(wfMsgExt('nap_quicklinks', 'parseinline', $this->me->getFullText() . "/" . $title->getFullText())); /// CHECK TO SEE IF ARTICLE IS LOCKED OR ALREADY PATROLLED $aid = $title->getArticleID(); $half_hour_ago = wfTimestamp(TS_MW, time() - 30 * 60); $patrolled = $dbr->selectField('newarticlepatrol', 'nap_patrolled', array("nap_page={$aid}"), __METHOD__); if ($patrolled) { $locked = true; $wgOut->addHTML(wfMsgExt("nap_patrolled", 'parse')); } else { $user_co = $dbr->selectField('newarticlepatrol', 'nap_user_co', array("nap_page={$aid}", "nap_timestamp_co > '{$half_hour_ago}'"), __METHOD__); if ($user_co != '' && $user_co != 0 && $user_co != $wgUser->getId()) { $x = User::newFromId($user_co); $wgOut->addHTML(wfMsgExt("nap_usercheckedout", 'parse', $x->getName())); $locked = true; } else { // CHECK OUT THE ARTICLE TO THIS USER $ts = wfTimestampNow(); $dbw->update('newarticlepatrol', array('nap_timestamp_co' => $ts, 'nap_user_co' => $wgUser->getId()), array("nap_page = {$aid}"), __METHOD__); } } $expandSpan = '<span class="nap_expand">▼</span>'; $externalLinkImg = '<img src="' . wfGetPad('/skins/common/images/external.png') . '"/>'; /// SIMILAR RESULT $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_similarresults') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $count = 0; $l = new LSearch(); $hits = $l->googleSearchResultTitles($title->getFullText(), 0, 5); if (sizeof($hits) > 0) { $html = ""; foreach ($hits as $hit) { $t1 = $hit; $id = rand(0, 500); if ($t1 == null || $t1->getFullURL() == $title->getFullURL() || $t1->getNamespace() != NS_MAIN || !$t1->exists()) { continue; } $safe_title = htmlspecialchars(str_replace("'", "'", $t1->getText())); $html .= "<tr><td>" . $this->skin->makeLinkObj($t1, wfMsg('howto', $t1->getText())) . "</td><td style='text-align:right; width: 200px;'>[<a href='#action' onclick='nap_Merge(\"{$safe_title}\");'>" . wfMsg('nap_merge') . "</a>] " . " [<a href='#action' onclick='javascript:nap_Dupe(\"{$safe_title}\");'>" . wfMsg('nap_duplicate') . "</a>] " . " <span id='mr_{$id}'>[<a onclick='javascript:nap_MarkRelated({$id}, {$t1->getArticleID()}, {$title->getArticleID()});'>" . wfMsg('nap_related') . "</a>]</span> " . "</td></tr>"; $count++; } } if ($count == 0) { $wgOut->addHTML(wfMsg('nap_no-related-topics')); } else { $wgOut->addHTML(wfMsg('nap_already-related-topics') . "<table style='width:100%;'>{$html}</table>"); } $wgOut->addHTML(wfMsg('nap_othersearches', urlencode($title->getFullText()))); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// COPYRIGHT CHECKER $cc_check = SpecialPage::getTitleFor('Copyrightchecker', $title->getText()); $wgOut->addHTML("<script type='text/javascript'>window.onload = nap_cCheck; var nap_cc_url = \"{$cc_check->getFullURL()}\";</script>"); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_copyrightchecker') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='nap_copyrightresults'><center><img src='/extensions/wikihow/rotate.gif' alt='loading...'/></center></div>"); $wgOut->addHTML("<center><input type='button' class='button primary' onclick='nap_cCheck();' value='Check'/></center>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// ARTICLE PREVIEW $editUrl = Title::makeTitle(NS_SPECIAL, "QuickEdit")->getFullURL() . "?type=editform&target=" . urlencode($title->getFullText()) . "&fromnab=1"; $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='article' id='anchor-article'></a>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_articlepreview') . " - <a href=\"{$title->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getEditURL()}\" target=\"new\">" . wfMsg('edit') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getFullURL()}?action=history\" target=\"new\">" . wfMsg('history') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getTalkPage()->getFullURL()}\" target=\"new\">" . wfMsg('discuss') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='article_contents' ondblclick='nap_editClick(\"{$editUrl}\");'>"); $popts = $wgOut->parserOptions(); $popts->setTidy(true); // $parserOutput = $wgOut->parse($rev->getText(), $title, $popts); $output = $wgParser->parse($rev->getText(), $title, $popts); $parserOutput = $output->getText(); $magic = WikihowArticleHTML::grabTheMagic($rev->getText()); $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => $title->getNamespace(), 'magic-word' => $magic)); $wgOut->addHTML($html); $wgOut->addHTML("</div>"); $wgOut->addHTML("<center><input id='editButton' type='button' class='button primary' name='wpEdit' value='" . wfMsg('edit') . "' onclick='nap_editClick(\"{$editUrl}\");'/></center>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML('<div style="clear: both;"></div>'); /// DISCUSSION PREVIEW $talkPage = $title->getTalkPage(); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='talk' id='anchor-talk'></a>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_discussion') . " - <a href=\"{$talkPage->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='disc_page'>"); if ($talkPage->getArticleID() > 0) { $rp = Revision::newFromTitle($talkPage); $wgOut->addHTML($wgOut->parse($rp->getText())); } else { $wgOut->addHTML(wfMsg('nap_discussionnocontent')); } $wgOut->addHTML(PostComment::getForm(true, $talkPage, true)); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// USER INFORMATION $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='user' id='anchor-user'></a>"); $used_templates = array(); if ($ut_id > 0) { $res = $dbr->select('templatelinks', array('tl_title'), array('tl_from=' . $ut_id), __METHOD__); while ($row = $dbr->fetchObject($res)) { $used_templates[] = strtolower($row->tl_title); } $dbr->freeResult($res); } $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_userinfo') . " - <a href=\"{$user_talk->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $contribs = SpecialPage::getTitleFor('Contributions', $user->getName()); $regDateTxt = ""; if ($user->getRegistration() > 0) { preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/D', $user->getRegistration(), $da); $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]); $regdate = gmdate('F j, Y', $uts); $regDateTxt = wfMsg('nap_regdatetext', $regdate) . ' '; } $key = 'nap_userinfodetails_anon'; if ($user->getID() != 0) { $key = 'nap_userinfodetails'; } $wgOut->addWikiText(wfMsg($key, $user->getName(), number_format(WikihowUser::getAuthorStats($first_user), 0, "", ","), $title->getFullText(), $regDateTxt)); if (WikihowUser::getAuthorStats($first_user) < 50) { if ($user_talk->getArticleId() == 0) { $wgOut->addHTML(wfMsg('nap_newwithouttalkpage')); } else { $rp = Revision::newFromTitle($user_talk); $xtra = ""; if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 8.0") === false) { $xtra = "max-height: 300px; overflow: scroll;"; } $output = $wgParser->parse($rp->getText(), $user_talk, $popts); $parserOutput = $output->getText(); $wgOut->addHTML("<div style='border: 1px solid #eee; {$xtra}'>" . $parserOutput . "</div>"); } } if ($user_talk->getArticleId() != 0 && sizeof($used_templates) > 0) { $wgOut->addHTML('<br />' . wfMsg('nap_usertalktemplates', implode($used_templates, ", "))); } $wgOut->addHTML(PostComment::getForm(true, $user_talk, true)); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// ACTION INFORMATION $maxrcid = $dbr->selectField('recentchanges', 'max(rc_id)', array('rc_cur_id=' . $aid), __METHOD__); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='action' id='anchor-action'></a>"); $wgOut->addHTML("<h2 class='nap_header'> " . wfMsg('nap_action') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<form action='{$this->me->getFullURL()}' name='nap_form' method='post' onsubmit='return checkNap();'>"); $wgOut->addHTML("<input type='hidden' name='target' value='" . htmlspecialchars($title->getText()) . "'/>"); $wgOut->addHTML("<input type='hidden' name='page' value='{$aid}'/>"); $wgOut->addHTML("<input type='hidden' name='newbie' value='" . $wgRequest->getVal('newbie', 0) . "'/>"); $wgOut->addHTML("<input type='hidden' name='prevuser' value='" . $user->getName() . "'/>"); $wgOut->addHTML("<input type='hidden' name='maxrcid' value='{$maxrcid}'/>"); $wgOut->addHTML("<table>"); $suggested = $dbr->selectField('suggested_titles', 'count(*)', array('st_title' => $title->getDBKey()), __METHOD__); if ($suggested > 0) { $wgOut->addHTML("<tr><td valign='top'>" . wfMsg('nap_suggested_warning') . "</td></tr>"); } $wgOut->addHTML("</table>"); $wgOut->addHTML(wfMsg('nap_actiontemplates')); if ($wgUser->isAllowed('delete') || $wgUser->isAllowed('move')) { $wgOut->addHTML(wfMsg('nap_actionmovedeleteheader')); if ($wgUser->isAllowed('move')) { $wgOut->addHTML(wfMsg('nap_actionmove', htmlspecialchars($title->getText()))); } if ($wgUser->isAllowed('delete')) { $wgOut->addHTML(wfMsg('nap_actiondelete')); } } // BUTTONS $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_skip') . "' id='nap_skip' name='nap_skip' class='button secondary' />"); if (!$locked) { $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_markaspatrolled') . "' id='nap_submit' name='nap_submit' class='button primary' />"); } $wgOut->addHTML("</form>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML(<<<END <script type='text/javascript'> var tabindex = 1; for(i = 0; i < document.forms.length; i++) { \tfor (j = 0; j < document.forms[i].elements.length; j++) { \t\tswitch (document.forms[i].elements[j].type) { \t\t\tcase 'submit': \t\t\tcase 'text': \t\t\tcase 'textarea': \t\t\tcase 'checkbox': \t\t\tcase 'button': \t\t\t\tdocument.forms[i].elements[j].tabIndex = tabindex++; \t\t\t\tbreak; \t\t\tdefault: \t\t\t\tbreak; \t\t} \t} } // Handlers for expand/contract arrows (function (\$) { \$('.nap_expand').click(function() { \tvar thisSpan = \$(this); \tvar body = thisSpan.parent().next(); \tvar footer = body.next(); \tif (body.css('display') != 'none') { \t\tfooter.hide(); \t\tbody.css('overflow', 'hidden'); \t\tvar oldHeight = body.height(); \t\tbody.animate( \t\t\t{ height: 0 }, \t\t\t200, \t\t\t'swing', \t\t\tfunction () { \t\t\t\tthisSpan.html('►'); \t\t\t\tbody \t\t\t\t\t.hide() \t\t\t\t\t.height(oldHeight); \t\t\t}); \t} else { \t\tvar oldHeight = body.height(); \t\tbody.height(0); \t\tbody.animate( \t\t\t{ height: oldHeight }, \t\t\t200, \t\t\t'swing', \t\t\tfunction () { \t\t\t\tthisSpan.html('▼'); \t\t\t\tfooter.show(); \t\t\t\tbody.css('overflow', 'visible'); \t\t\t}); \t} \treturn false; }); })(jQuery); </script> END ); }
function getContributions() { global $wgTitle, $wgUser; $user = $this->user; $username = $user->getName(); $real_name = User::whoIsReal($user->getId()); $real_name = $real_name ? $real_name : $username; $contribsPage = SpecialPage::getTitleFor('Contributions', $username); $isLoggedIn = $wgUser && $wgUser->getID() > 0; $userstats = "<div id='userstats'>"; if ($user && $user->getID() > 0) { $editsMade = number_format(WikihowUser::getAuthorStats($username), 0, "", ","); if ($isLoggedIn) { $userstats .= wfMsg('contributions-made', $real_name, $editsMade, $contribsPage->getFullURL()); } else { $userstats .= wfMsg('contributions-made-anon', $real_name, $editsMade); } } else { // showing an anon user page if ($isLoggedIn) { $link = '<a href="' . $contribsPage->getFullURL() . '">' . $wgTitle->getText() . '</a>'; $userstats .= wfMsg('contributions-link', $link); } } $userstats .= "</div>"; return $userstats; }
function showArticlesPage($page, $period, $starttimestamp, $user) { global $wgOut, $wgUser; $wgOut->addHTML(" <style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/Leaderboard.css?rev=') . WH_SITEREV . "'; /*]]>*/</style>\n\t\t\t<script type='text/javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/Leaderboard.js?rev=') . WH_SITEREV . "'></script>"); $wgOut->addHTML(" <script type='text/javascript'>\n\t\t\t\tvar lb_page = '{$target}';\n\t\t\t\tvar lb_period = '{$period}';\n\t\t\t</script>\n"); //$wgOut->addHTML(" TEST: $page $starttimestamp $user <br/>\n"); $data = array(); $subtitle = ''; switch ($page) { case 'articles_written': $data = $this->getArticlesWritten($starttimestamp, $user, true); $subtitle = 'Articles Written by '; break; case 'risingstars_received': $data = $this->getRisingStar($starttimestamp, $user, true); $subtitle = 'Articles that received a Risingstar by '; break; case 'requested_topics': $data = $this->getRequestedTopics($starttimestamp, $user, true); $subtitle = 'Articles from requested topics by '; break; case 'articles_nabed': $data = $this->getArticlesNABed($starttimestamp, $user, true); $subtitle = 'New Articles Boosted by '; break; case 'risingstars_nabed': $data = $this->getRisingStarsNABed($starttimestamp, $user, true); $subtitle = 'New Articles nominated for Risingstar by '; break; case 'rc_edits': $data = $this->getRCEdits($starttimestamp, $user, true); $subtitle = 'Articles Patrolled - '; break; case 'rc_quick_edits': $data = $this->getRCQuickEdits($starttimestamp, $user, true); $subtitle = 'Quick Edits made while patrolling - '; break; case 'total_edits': $data = $this->getTotalEdits($starttimestamp, $user, true); $subtitle = 'Total Edits - '; break; case 'articles_categorized': $data = $this->getArticlesCategorized($starttimestamp, $user, true); $subtitle = 'Articles Categorized - '; break; case 'images_added': $data = $this->getImagesAdded($starttimestamp, $user, true); $subtitle = 'Images Added - '; break; case 'videos_reviewed': $data = $this->getVideosReviewed($starttimestamp, $user, true); $subtitle = 'Videos Added - '; break; case 'repair_format': $data = $this->getArticlesRepaired($starttimestamp, 'format', $user, true); $subtitle = 'Formats Fixed - '; break; case 'repair_stub': $data = $this->getArticlesRepaired($starttimestamp, 'stub', $user, true); $subtitle = 'Stubs Fixed - '; break; case 'repair_topic': $data = $this->getArticlesRepaired($starttimestamp, 'topic', $user, true); $subtitle = 'Fixed by Topic - '; break; case 'repair_copyedit': $data = $this->getArticlesRepaired($starttimestamp, 'copyedit', $user, true); $subtitle = 'Copyedit Fixed - '; break; case 'repair_cleanup': $data = $this->getArticlesRepaired($starttimestamp, 'cleanup', $user, true); $subtitle = 'Cleanup Fixed - '; break; case 'nfd': $data = $this->getNfdsReviewed($starttimestamp, $user, true); $subtitle = 'NFDs Reviewed - '; break; case 'spellchecked': $data = $this->getSpellchecked($starttimestamp, $user, true); $subtitle = 'Articles Spell Checked - '; break; case 'methodguardian': $data = $this->getMethodGuardian($starttimestamp, $user, true); $subtitle = 'Methods Guarded - '; break; case 'methodeditor': $data = $this->getMethodEditor($starttimestamp, $user, true); $subtitle = 'Methods Edited - '; break; case 'welcomewagon': $data = $this->getWelcomeWagon($starttimestamp, $user, true); $subtitle = 'Welcome Wagon Messages Sent - '; break; default: return; } switch ($period) { case 7: $subtitle .= $user . " in the last week"; break; case 31: $subtitle .= $user . " in the last month"; break; default: $subtitle .= $user . " in the last day"; break; } $sk = $wgUser->getSkin(); $u = User::newFromName($user); if (isset($u)) { $u->load(); } $userlink = $sk->makeLinkObj($u->getUserPage(), $u->getName()); $regdate = "Jan 1, 1970"; if ($u->getRegistration() != '') { $regdate = gmdate('M d, Y', wfTimestamp(TS_UNIX, $u->getRegistration())); } else { $regdate = gmdate('M d, Y', wfTimestamp(TS_UNIX, '20060725043938')); } $contributions = number_format(WikihowUser::getAuthorStats($u->getName()), 0, "", ","); $contribsPage = SpecialPage::getTitleFor('Contributions', $user); $contriblink = $sk->makeLinkObj($contribsPage, 'contrib'); $talkpagelink = $sk->makeLinkObj($u->getTalkPage(), 'talk'); $otherlinks = "({$contriblink} | {$talkpagelink})"; $wgOut->addHTML("\n<div id='Leaderboard'>\n"); $wgOut->addHTML("<br />{$subtitle}<br/>\n\t\t\t" . wfMsg('leaderboard_articlespage_msg', $userlink, $regdate, $contributions, $otherlinks) . "<br/>\n\t\t\t\n"); $wgOut->addHTML("<table class='leader_table' style='width:475px; margin:0 auto;'>"); $index = 1; $wgOut->addHTML("<tr>\n\t\t\t<td class='leader_title'>Article</td>\n\t\t\t</tr>\n\t\t"); $index = 1; foreach ($data as $key => $value) { $class = ""; if ($index % 2 == 1) { $class = 'class="odd"'; } $t = Title::newFromText($value); if ($page == 'images_added_NOT_SETUP_YET') { //In the future we can display the actual image added on this page. $wgOut->addHTML("<tr {$class}><td style='text-align:left;'><img src='/{$key}' /><a href='/{$key}' >{$value}</a></td</tr>\n"); } else { if ($page == 'welcomewagon') { $wgOut->addHTML("<tr><td class='leader_image'><a href='/{$key}' >{$value}</a></td</tr>\n"); } else { $wgOut->addHTML("<tr><td class='leader_image'><a href='/{$key}' >{$value}</a> (<a href='" . $t->getLocalURL('action=history') . "' >history</a>)</td</tr>\n"); } } $index++; } $wgOut->addHTML("</table></center>"); $wgOut->addHTML("<br /><a href='/Special:Leaderboard/{$page}?period={$period}' >Back</a></div>\n"); return; }
function execute($par) { global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname; global $wgRequest, $wgSitename, $wgLanguageCode, $IP; global $wgScript, $wgParser, $wgFilterCallback, $wgScriptPath; $fname = "wfSpecialRequestTopic"; $action = ""; if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if (!$wgRequest->wasPosted()) { $wgOut->addHTML("<b>" . wfMsg('lookingforhow') . "</b> <br/> " . wfMsg('requestarticleexdog') . "<br/><br/> "); $this->getForm(); } else { // this is a post, accept the POST data and create the // Request article $topic = $wgRequest->getVal('topic'); $details = $wgRequest->getVal('details'); if ($wgUser->getID() == 0 && preg_match("@http://@i", $details)) { $wgOut->addHTML("Error: anonymous users are not allowed to include links in requests."); return; } if (!isset($_POST['override']) && $wgLanguageCode == 'en') { $l = new LSearch(); $titles = $l->googleSearchResultTitles($topic, 0, 5); if (sizeof($titles) > 0) { $wgOut->addHTML(wfMsg('already-related-topics') . "<br>\n\t\t\t\t\t<ul id=Things_You27ll_Need>"); $count = 0; foreach ($titles as $t) { if ($count == 10) { break; } if ($t == null) { continue; } $wgOut->addHTML("<li style='margin-bottom: 0px'><a href=" . $t->getFullURL() . ">How to " . $t->getText() . "</a></li>"); $count++; } $wgOut->addHTML("</ul>"); $wgOut->addHTML(wfMsg('no-submit-existing-topic')); $this->getForm(true); return; } } // cut off extra ?'s or whatever if ($wgLanguageCode == 'en') { while (!ereg('[a-zA-Z0-9)\\"]$', $topic)) { $topic = substr($topic, 0, strlen($topic) - 1); } } if ($wgLanguageCode == 'en') { require_once 'EditPageWrapper.php'; $topic = EditPageWrapper::formatTitle($topic); } $title = Title::newFromText($topic, NS_ARTICLE_REQUEST); $category = $wgRequest->getVal("category", ""); if ($category == "") { $category = "Other"; } $details .= "\n[[Category:{$category} Requests]]"; // check if we can do this if ($wgUser->isBlocked()) { $wgOut->addWikiText(wfMsg('blocked-ip')); return; } if ($wgUser->pingLimiter()) { $wgOut->rateLimited(); return; } if ($wgFilterCallback && $wgFilterCallback($title, $details, $tmp)) { // Error messages or other handling should be performed by // the filter function return; } // create a user $user = null; if ($wgUser->getID() == 0) { if ($wgRequest->getVal('email', null)) { $user = WikihowUser::createTemporaryUser($wgRequest->getVal('name'), $wgRequest->getVal('email')); $wgUser = $user; } } if ($title->getArticleID() <= 0) { // not yet created. good. $article = new Article($title); $ret = $article->insertNewArticle($details, "", false, false, false, $user); wfRunHooks('ArticleSaveComplete', array(&$article, &$user, $details, "", false, false, NULL)); //clear the redirect that is set by insertNewArticle $wgOut->redirect(''); $options = ParserOptions::newFromUser($wgUser); $wgParser->parse($details, $title, $options); } else { // TODO: what to do here? give error / warning? append details? // this question has already been asked, if you want to ask // a slightly different question, go here: } $wgOut->addWikiText(wfMsg('thank-you-requesting-topic')); $wgOut->returnToMain(false); } }
/** * * Returns the id/date of the highest VAdder */ function getHighestVA(&$dbr, $period = '7 days ago') { $startdate = strtotime($period); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = " AND va_user NOT IN (" . $dbr->makeList($bots) . ") "; } $sql = "SELECT *, count(va_user) as va_count, MAX(va_timestamp) as va_recent FROM `videoadder` WHERE va_timestamp >= '" . $starttimestamp . "'" . $sql . " AND va_skipped_accepted IN ('0','1') GROUP BY va_user ORDER BY va_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $vauser = array(); $vauser['id'] = $row->va_user; $vauser['date'] = wfTimeAgo($row->va_recent); return $vauser; }
/** * Internally authenticate the login request. * * This may create a local account as a side effect if the * authentication plugin allows transparent local account * creation. * * @public */ function authenticateUserData() { global $wgUser, $wgAuth; if ('' == $this->mName) { return self::NO_NAME; } // XXCHANGED - by Reuben to allow login via Username or Email $u = null; // Check if $this->mName is actually an email address $looksLikeEmail = strpos($this->mName, '@') !== false; if ($looksLikeEmail) { list($u, $count) = WikihowUser::newFromEmailAddress($this->mName); } // Only do the username lookup if it didn't look like an email address // or the email addresses didn't have exactly 1 account attached if (is_null($u)) { $u = User::newFromName($this->mName); // Show error specific to email addresses if there's no username // with an '@' in it either if ($looksLikeEmail) { if ($count < 1) { return self::NO_EMAIL; } elseif ($count > 1) { return self::MULTIPLE_EMAILS; } } if (is_null($u) || !User::isUsableName($u->getName())) { return self::ILLEGAL; } } if (0 == $u->getID()) { global $wgAuth; /** * If the external authentication plugin allows it, * automatically create a new account for users that * are externally defined but have not yet logged in. */ if ($wgAuth->autoCreate() && $wgAuth->userExists($u->getName())) { if ($wgAuth->authenticate($u->getName(), $this->mPassword)) { $u = $this->initUser($u, true); } else { return self::WRONG_PLUGIN_PASS; } } else { return self::NOT_EXISTS; } } else { $u->load(); } // Give general extensions, such as a captcha, a chance to abort logins $abort = self::ABORTED; if (!wfRunHooks('AbortLogin', array($u, $this->mPassword, &$abort))) { return $abort; } if (!$u->checkPassword($this->mPassword)) { if ($u->checkTemporaryPassword($this->mPassword)) { // The e-mailed temporary password should not be used // for actual logins; that's a very sloppy habit, // and insecure if an attacker has a few seconds to // click "search" on someone's open mail reader. // // Allow it to be used only to reset the password // a single time to a new value, which won't be in // the user's e-mail archives. // // For backwards compatibility, we'll still recognize // it at the login form to minimize surprises for // people who have been logging in with a temporary // password for some time. // // As a side-effect, we can authenticate the user's // e-mail address if it's not already done, since // the temporary password was sent via e-mail. // if (!$u->isEmailConfirmed()) { $u->confirmEmail(); } // At this point we just return an appropriate code // indicating that the UI should show a password // reset form; bot interfaces etc will probably just // fail cleanly here. // $retval = self::RESET_PASS; } else { $retval = '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS; } } else { $wgAuth->updateUser($u); $wgUser = $u; $retval = self::SUCCESS; } wfRunHooks('LoginAuthenticateAudit', array($u, $this->mPassword, $retval)); return $retval; }
/** * Internally authenticate the login request. * * This may create a local account as a side effect if the * authentication plugin allows transparent local account * creation. * @return int */ public function authenticateUserData() { global $wgUser, $wgAuth; $this->load(); if ($this->mUsername == '') { return self::NO_NAME; } // We require a login token to prevent login CSRF // Handle part of this before incrementing the throttle so // token-less login attempts don't count towards the throttle // but wrong-token attempts do. // Upgrade hack by Gershon Bialer // Removed token verification to get static header login working // XXXXX // If the user doesn't have a login token yet, set one. /*if ( !self::getLoginToken() ) { self::setLoginToken(); return self::NEED_TOKEN; } // If the user didn't pass a login token, tell them we need one if ( !$this->mToken ) { return self::NEED_TOKEN; }*/ $throttleCount = self::incLoginThrottle($this->mUsername); if ($throttleCount === true) { return self::THROTTLED; } // Upgrade hack by Gershon Bialer // Removed token verification to get static header login working // XXXXX // Validate the login token //if ( $this->mToken !== self::getLoginToken() ) { // return self::WRONG_TOKEN; //} // Load the current user now, and check to see if we're logging in as // the same name. This is necessary because loading the current user // (say by calling getName()) calls the UserLoadFromSession hook, which // potentially creates the user in the database. Until we load $wgUser, // checking for user existence using User::newFromName($name)->getId() below // will effectively be using stale data. if ($this->getUser()->getName() === $this->mUsername) { wfDebug(__METHOD__ . ": already logged in as {$this->mUsername}\n"); return self::SUCCESS; } //XXCHANGEDXX - added our login by email logic back [sc] // Check if $this->mName is actually an email address $u = null; $looksLikeEmail = strpos($this->mUsername, '@') !== false; if ($looksLikeEmail) { list($u, $count) = WikihowUser::newFromEmailAddress($this->mUsername); } // Only do the username lookup if it didn't look like an email address // or the email addresses didn't have exactly 1 account attached if (is_null($u)) { $u = User::newFromName($this->mUsername); // Show error specific to email addresses if there's no username // with an '@' in it either if ($looksLikeEmail) { if ($count < 1) { return self::NO_EMAIL; } elseif ($count > 1) { return self::MULTIPLE_EMAILS; } } $u = User::newFromName($this->mUsername); if (!$u instanceof User || !User::isUsableName($u->getName())) { return self::ILLEGAL; } } $isAutoCreated = false; if ($u->getID() == 0) { $status = $this->attemptAutoCreate($u); if ($status !== self::SUCCESS) { return $status; } else { $isAutoCreated = true; } } else { $u->load(); } // Give general extensions, such as a captcha, a chance to abort logins $abort = self::ABORTED; $msg = null; if (!wfRunHooks('AbortLogin', array($u, $this->mPassword, &$abort, &$msg))) { $this->mAbortLoginErrorMsg = $msg; return $abort; } global $wgBlockDisablesLogin; if (!$u->checkPassword($this->mPassword)) { if ($u->checkTemporaryPassword($this->mPassword)) { // The e-mailed temporary password should not be used for actu- // al logins; that's a very sloppy habit, and insecure if an // attacker has a few seconds to click "search" on someone's o- // pen mail reader. // // Allow it to be used only to reset the password a single time // to a new value, which won't be in the user's e-mail ar- // chives. // // For backwards compatibility, we'll still recognize it at the // login form to minimize surprises for people who have been // logging in with a temporary password for some time. // // As a side-effect, we can authenticate the user's e-mail ad- // dress if it's not already done, since the temporary password // was sent via e-mail. if (!$u->isEmailConfirmed()) { $u->confirmEmail(); $u->saveSettings(); } // At this point we just return an appropriate code/ indicating // that the UI should show a password reset form; bot inter- // faces etc will probably just fail cleanly here. $retval = self::RESET_PASS; } else { $retval = $this->mPassword == '' ? self::EMPTY_PASS : self::WRONG_PASS; } } elseif ($wgBlockDisablesLogin && $u->isBlocked()) { // If we've enabled it, make it so that a blocked user cannot login $retval = self::USER_BLOCKED; } else { $wgAuth->updateUser($u); $wgUser = $u; // This should set it for OutputPage and the Skin // which is needed or the personal links will be // wrong. $this->getContext()->setUser($u); // Please reset throttle for successful logins, thanks! if ($throttleCount) { self::clearLoginThrottle($this->mUsername); } if ($isAutoCreated) { // Must be run after $wgUser is set, for correct new user log wfRunHooks('AuthPluginAutoCreate', array($u)); } $retval = self::SUCCESS; } wfRunHooks('LoginAuthenticateAudit', array($u, $this->mPassword, $retval)); return $retval; }
/** * Check for G+ authorship */ private function isGPlusAuthor() { if ($this->title->getNamespace() != NS_USER) { return 0; } $u = explode("/", $this->title->getText()); return WikihowUser::isGPlusAuthor($u[0]); }
function mailPassword() { global $wgUser, $wgOut, $wgAuth, $wgRequest; $result = array(); if (!$wgAuth->allowPasswordChange()) { $result['error_general'] = wfMsg('resetpass_forbidden'); return $result; } # Check against blocked IPs # fixme -- should we not? if ($wgUser->isBlocked()) { $result['error_general'] = wfMsg('blocked-mailpassword'); return $result; } # Check against the rate limiter if ($wgUser->pingLimiter('mailpassword')) { // Commented out By Gershon Bialer on 12/9/2013 // because they prevented error from showing in the upgrade //$wgOut->disable(); //$wgOut->rateLimited(); $result['error_general'] = "<h4>" . wfMsg('actionthrottled') . "</h4>"; $result['error_general'] .= wfMsg('actionthrottledtext'); return $result; } $name = $wgRequest->getVal('name'); if (!isset($name) || '' == $name) { $result['error_username'] = wfMsg('noname'); return $result; } $name = trim($name); $u = null; // If $name looks like an email address, we look it up by email // address first $looksLikeEmail = strpos($name, '@') !== false; if ($looksLikeEmail) { list($u, $count) = WikihowUser::newFromEmailAddress($name); } if (is_null($u)) { $u = User::newFromName($name); // Show error specific to email addresses if there's no username // with an '@' in it either if ($looksLikeEmail) { if ($count < 1) { $result['error_username'] = wfMsg('noemail_login'); return $result; } elseif ($count > 1) { $result['error_username'] = wfMsg('multipleemails_login'); return $result; } } } if (is_null($u)) { $result['error_username'] = wfMsg('noname'); return $result; } if (0 == $u->getID()) { $result['error_username'] = wfMsg('nosuchuser', $u->getName()); return $result; } $abortError = ''; if (!wfRunHooks('AbortAccountReminder', array($u, &$abortError))) { // Hook point to add extra creation throttles and blocks wfDebug("LoginForm::addNewAccountInternal: a hook blocked creation\n"); $result['error_captcha'] = $abortError; //had a problem with the captcha, need to load a new one $template = new QuickTemplateWrapper(); $template->set('header', ''); wfRunHooks('AccountReminderNewCaptcha', array(&$template)); //hack since templates ECHO the data you want ob_start(); $template->html('header'); $var = ob_get_contents(); ob_end_clean(); //end hack $result['newCaptcha'] = $var; return $result; } # Check against password throttle if ($u->isPasswordReminderThrottled()) { global $wgPasswordReminderResendTime; # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds. $result['error_general'] = wfMsg('throttled-mailpassword', round($wgPasswordReminderResendTime, 3)); return $result; } $mailResult = $this->mailPasswordInternal($u, true, 'passwordremindertitle', 'passwordremindertext'); if (WikiError::isError($mailResult)) { $result['error_general'] = wfMsg('mailerror', $mailResult->getMessage()); return $result; } else { $result['success'] = wfMsgHtml('passwordsent', $u->getName()); return $result; } }
<?php require_once 'commandLine.inc'; $ignore_cats = array("Featured Articles", "Merge", "Cleanup", "Stub"); $pages = array(); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('firstedit', 'page'), array('fe_user', 'fe_user_text', 'fe_page'), array('fe_page=page_id', 'page_namespace' => NS_MAIN, 'fe_user > 0'), "init_followcats", array("LIMIT" => 30000)); echo $dbr->lastQuery() . "\n"; while ($row = $dbr->fetchObject($res)) { $pages[$row->fe_page] = $row; } $bots = WikihowUser::getBotIDs(); echo "Got " . sizeof($pages) . " articles\n"; foreach ($pages as $p) { $res = $dbr->select('categorylinks', array('cl_to'), array('cl_from' => $p->fe_page)); while ($row = $dbr->fetchObject($res)) { if (in_array($p->fe_user, $bots)) { continue; } $cat = Title::makeTitle(NS_CATEGORY, $row->cl_to); $u = User::newFromName($p->fe_user_text); $t = Title::newFromID($p->fe_page); if (!$t || !$cat || !$u) { continue; } if (!in_array($cat->getText(), $ignore_cats) && !preg_match("@NFD@", $cat->getText())) { Follow::followCat($t, $cat->getText(), $u); echo "{$u->getName()} is following {$cat->getText()} because of {$t->getFullText()}\n"; } } }
function getQuickNoteLink($title, $userId, $userText, $editor = null) { if (!$editor) { $editor = User::newFromId($userId); $editor->loadFromId(); } $regdate = $editor->getRegistration(); if ($regdate != "") { $ts = wfTimestamp(TS_UNIX, $regdate); $regdate = date('M j, Y', $ts); } $contrib = number_format(WikihowUser::getAuthorStats($userText), 0, "", ","); return "<a href='' id='qn_button' onclick=\"return initQuickNote('" . urlencode($title->getPrefixedText()) . "','" . $userText . "','" . $contrib . "','" . $regdate . "') ;\">quick note</a>"; }
function getSQL($ts) { $bots = WikihowUser::getBotIDs(); $bot = ""; if (sizeof($bots) > 0) { $dbr = wfGetDB(DB_SLAVE); $bot = " AND fe_user NOT IN (" . $dbr->makeList($bots) . ", '0') "; } $sql = "SELECT page_title,\n\t\t\t\tfe_user_text as user_text,\n\t\t\t\tcount(*) as C\n \t\t\t\tFROM firstedit left join page on fe_page = page_id left join suggested_titles on page_title= st_title\n \t\t\t\tWHERE fe_timestamp >= '{$ts}' AND st_isrequest IS NOT NULL" . $bot . " group by user_text order by C limit 25"; return $sql; }
/** * @throws PasswordError when cannot set the new password because requirements not met. */ function attemptReset($newpass, $retype) { $looksLikeEmail = strpos($this->mName, '@') !== false; if ($looksLikeEmail) { list($user, $count) = WikihowUser::newFromEmailAddress($this->mName); } else { $user = User::newFromName($this->mName); } if ($user->isAnon()) { throw new PasswordError('no such user'); } if (!$user->checkTemporaryPassword($this->mTemporaryPassword)) { throw new PasswordError(wfMsg('resetpass_bad_temporary')); } if ($newpass !== $retype) { throw new PasswordError(wfMsg('badretype')); } $user->setPassword($newpass); $user->saveSettings(); }