/** * @todo document */ function wfSpecialIpblocklist() { global $wgUser, $wgOut, $wgRequest; $ip = $wgRequest->getVal('wpUnblockAddress', $wgRequest->getVal('ip')); $reason = $wgRequest->getText('wpUnblockReason'); $action = $wgRequest->getText('action'); $ipu = new IPUnblockForm($ip, $reason); if ("success" == $action) { $ipu->showList(wfMsgWikiHtml('unblocked', htmlspecialchars($ip))); } else { if ("submit" == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) { if (!$wgUser->isAllowed('block')) { $wgOut->sysopRequired(); return; } $ipu->doSubmit(); } else { if ("unblock" == $action) { $ipu->showForm(""); } else { $ipu->showList(""); } } } }
function wfSpecialCheckmylinks($par) { global $wgRequest, $wgSitename, $wgLanguageCode; global $wgDeferredUpdateList, $wgOut, $wgUser, $wgServer, $wgParser, $wgTitle; $fname = "wfCheckmylinks"; $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_summary')); if ($wgUser->getID() > 0) { $t = Title::makeTitle(NS_USER, $wgUser->getName() . "/Mylinks"); if ($t->getArticleID() > 0) { $r = Revision::newFromTitle($t); $text = $r->getText(); if ($text != "") { $ret = "<h3>" . wfMsg('mylinks') . "</h3>"; $options = new ParserOptions(); $output = $wgParser->parse($text, $wgTitle, $options); $ret .= $output->getText(); } $size = strlen($ret); if ($size > 3000) { $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_bad', number_format($size, 0, "", ","))); } else { $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_good', number_format($size, 0, "", ","))); } } else { $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_error')); } } else { $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_notloggedin')); } }
function wfIFI_uploadWarning($u, $warning) { global $wgOut; global $wgUseCopyrightUpload; $u->mSessionKey = $u->stashSession(); if (!$u->mSessionKey) { # Couldn't save file; an error has been displayed so let's go. return; } $wgOut->addHTML("<h2>" . wfMsgHtml('uploadwarning') . "</h2>\n"); $wgOut->addHTML("<ul class='warning'>{$warning}</ul><br />\n"); $save = wfMsgHtml('savefile'); $reupload = wfMsgHtml('reupload'); $iw = wfMsgWikiHtml('ignorewarning'); $reup = wfMsgWikiHtml('reuploaddesc'); $titleObj = Title::makeTitle(NS_SPECIAL, 'Upload'); $action = $titleObj->escapeLocalURL('action=submit'); if ($wgUseCopyrightUpload) { $copyright = "\n <input type='hidden' name='wpUploadCopyStatus' value=\"" . htmlspecialchars($u->mUploadCopyStatus) . "\" />\n <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars($u->mUploadSource) . "\" />\n "; } else { $copyright = ""; } $wgOut->addHTML("\n <form id='uploadwarning' method='post' enctype='multipart/form-data' action='{$action}'>\n <input type='hidden' name='wpIgnoreWarning' value='1' />\n <input type='hidden' name='wpSessionKey' value=\"" . htmlspecialchars($u->mSessionKey) . "\" />\n <input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars($u->mUploadDescription) . "\" />\n <input type='hidden' name='wpLicense' value=\"" . htmlspecialchars($u->mLicense) . "\" />\n <input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars($u->mDestFile) . "\" />\n <input type='hidden' name='wpWatchu' value=\"" . htmlspecialchars(intval($u->mWatchu)) . "\" />\n {$copyright}\n <table border='0'>\n <tr>\n <tr>\n <td align='right'>\n <input tabindex='2' type='submit' name='wpUpload' value=\"{$save}\" />\n </td>\n <td align='left'>{$iw}</td>\n </tr>\n </tr>\n </table></form>\n" . wfMsg('importfreeimages_returntoform', $_SERVER["HTTP_REFERER"])); // $_SERVER["HTTP_REFERER"]; -- javascript.back wasn't working for some reason... hmph. }
public function execute($mode = false) { global $wgOut, $wgUser; $this->setHeaders(); $this->user =& $wgUser; if (strtolower($mode) == 'results') { if ($wgUser->isAllowed('voteadmin')) { $this->showResults(); } } else { if ($wgUser->isAnon()) { $skin =& $wgUser->getSkin(); $self = SpecialPage::getTitleFor('Vote'); $login = SpecialPage::getTitleFor('Userlogin'); $link = $skin->makeKnownLinkObj($login, wfMsgHtml('vote-login-link'), 'returnto=' . $self->getPrefixedUrl()); $wgOut->addHtml(wfMsgWikiHtml('vote-login', $link)); return; } elseif (!$wgUser->mEmailAuthenticated) { $wgOut->addWikiText("'''Email authentication is required to vote.'''\n\t\t\t\t\nPlease edit/add your e-mail using [[Special:Preferences]] and a confirmation e-mail will be sent to your e-mail address.\n\nFollow the instructions in the e-mail, to confirm that the account is actually yours."); return; } elseif (!$wgUser->isAllowed('vote')) { $wgOut->permissionRequired('vote'); return; } else { $this->showNormal(); } } }
/** * Called on every video page view. */ public function view() { $this->video = new Video($this->getTitle(), $this->getContext()); $out = $this->getContext()->getOutput(); $videoLinksHTML = '<br />' . Xml::element('h2', array('id' => 'filelinks'), wfMsg('video-links')) . "\n"; $sk = $this->getContext()->getSkin(); // No need to display noarticletext, we use our own message if ($this->getID()) { parent::view(); } else { // Just need to set the right headers $out->setArticleFlag(true); $out->setRobotPolicy('index,follow'); $out->setPageTitle($this->mTitle->getPrefixedText()); } if ($this->video->exists()) { // Display flash video $out->addHTML($this->video->getEmbedCode()); // Force embed this code to have width of 300 $this->video->setWidth(300); $out->addHTML($this->getEmbedThisTag()); $this->videoHistory(); //$wgOut->addHTML( $videoLinksHTML ); //$this->videoLinks(); } else { // Video doesn't exist, so give a link allowing user to add one with this name $title = SpecialPage::getTitleFor('AddVideo'); $link = $sk->linkKnown($title, wfMsgHtml('video-novideo-linktext'), array(), array('wpTitle' => $this->video->getName())); $out->addHTML(wfMsgWikiHtml('video-novideo', $link)); //$wgOut->addHTML( $videoLinksHTML ); //$this->videoLinks(); $this->viewUpdates(); } }
/** * Main execution point * * @param $code Confirmation code passed to the page */ function execute($code) { global $wgUser, $wgOut; $this->setHeaders(); if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if (empty($code)) { if ($wgUser->isLoggedIn()) { if (User::isValidEmailAddr($wgUser->getEmail())) { $this->showRequestForm(); } else { $wgOut->addWikiMsg('confirmemail_noemail'); } } else { $title = SpecialPage::getTitleFor('Userlogin'); $skin = $wgUser->getSkin(); $llink = $skin->linkKnown($title, wfMsgHtml('loginreqlink'), array(), array('returnto' => $this->getTitle()->getPrefixedText())); $wgOut->addHTML(wfMsgWikiHtml('confirmemail_needlogin', $llink)); } } else { $this->attemptConfirm($code); } }
/** * @param integer $namespace (Default NS_MAIN) * @param string $from list all pages from this name (default FALSE) */ function showChunk($namespace = NS_MAIN, $prefix, $including = false, $from = null) { global $wgOut, $wgUser, $wgContLang; $fname = 'indexShowChunk'; $sk = $wgUser->getSkin(); if (!isset($from)) { $from = $prefix; } $fromList = $this->getNamespaceKeyAndText($namespace, $from); $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix); if (!$prefixList || !$fromList) { $out = wfMsgWikiHtml('allpagesbadtitle'); } else { list($namespace, $prefixKey, $prefix) = $prefixList; list($fromNs, $fromKey, $from) = $fromList; ### FIXME: should complain if $fromNs != $namespace $dbr =& wfGetDB(DB_SLAVE); $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_is_redirect'), array('page_namespace' => $namespace, 'page_title LIKE \'' . $dbr->escapeLike($prefixKey) . '%\'', 'page_title >= ' . $dbr->addQuotes($fromKey)), $fname, array('ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title')); ### FIXME: side link to previous $n = 0; $out = '<table style="background: inherit;" border="0" width="100%">'; $namespaces = $wgContLang->getFormattedNamespaces(); while ($n < $this->maxPerPage && ($s = $dbr->fetchObject($res))) { $t = Title::makeTitle($s->page_namespace, $s->page_title); if ($t) { $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '') . $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()), false, false) . ($s->page_is_redirect ? '</div>' : ''); } else { $link = '[[' . htmlspecialchars($s->page_title) . ']]'; } if ($n % 3 == 0) { $out .= '<tr>'; } $out .= "<td>{$link}</td>"; $n++; if ($n % 3 == 0) { $out .= '</tr>'; } } if ($n % 3 != 0) { $out .= '</tr>'; } $out .= '</table>'; } if ($including) { $out2 = ''; } else { $nsForm = $this->namespaceForm($namespace, $prefix); $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">'; $out2 .= '<tr valign="top"><td align="left">' . $nsForm; $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' . $sk->makeKnownLink($wgContLang->specialPage($this->name), wfMsg('allpages')); if (isset($dbr) && $dbr && $n == $this->maxPerPage && ($s = $dbr->fetchObject($res))) { $namespaceparam = $namespace ? "&namespace={$namespace}" : ""; $out2 .= " | " . $sk->makeKnownLink($wgContLang->specialPage($this->name), wfMsg('nextpage', $s->page_title), "from=" . wfUrlEncode($s->page_title) . "&prefix=" . wfUrlEncode($prefix) . $namespaceparam); } $out2 .= "</td></tr></table><hr />"; } $wgOut->addHtml($out2 . $out); }
function getBadge($badgeName) { $html = "<div class='ab-box'>"; $html .= "<div class='ab-badge ab-" . $badgeName . "'></div>"; $html .= "<h3>" . wfMsg("ab-" . $badgeName . "-title") . "</h3>"; $html .= wfMsgWikiHtml("ab-" . $badgeName . "-description"); $html .= "</div>"; return $html; }
function execute($par) { global $wgRequest, $wgOut, $wgUser, $wgLang; $target = isset($par) ? $par : $wgRequest->getVal('target'); $sk = $wgUser->getSkin(); $dbr =& wfGetDB(DB_SLAVE); $wgOut->setHTMLTitle('Edits Patrol Count - wikiHow'); $wgOut->addHTML(' <style type="text/css" media="all">/*<![CDATA[*/ @import "/extensions/wikihow/Patrolcount.css"; /*]]>*/</style>'); $me = Title::makeTitle(NS_SPECIAL, "Patrolcount"); // allow the user to grab the local patrol count relative to their own timezone if ($wgRequest->getVal('patrolcountview', null)) { $wgUser->setOption('patrolcountlocal', $wgRequest->getVal('patrolcountview')); $wgUser->saveSettings(); } if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") { $links = "[" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewGMT'), "patrolcountview=GMT") . "] [" . wfMsg('patrolcount_viewlocal') . "]"; $result = Patrolcount::getPatrolcountWindow(); $date1 = $result[0]; $date2 = $result[1]; //echo "$date1 , $date2"; } else { $links = "[" . wfMsg('patrolcount_viewGMT') . "] [" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewlocal'), "patrolcountview=local") . "]"; $now = wfTimestamp(TS_UNIX); $date1 = substr(wfTimestamp(TS_MW), 0, 8) . "000000"; $date2 = substr(wfTimestamp(TS_MW, $now + 24 * 3600), 0, 8) . "000000"; } //echo "<h3>date1 $date1 to $date2</h3>"; //grab the total $total = $dbr->selectField('logging', 'count(*)', array('log_type' => 'patrol', "log_timestamp>'{$date1}'", "log_timestamp<'{$date2}'")); $wgOut->addHTML("<div id='Patrolcount'>"); $wgOut->addHTML(wfMsg('patrolcount_summary') . "<br/><br/>" . wfMsg('patrolcount_total', number_format($total, 0, '', ',')) . "<br/><br/><center>"); $wgOut->addHTML($links); $wgOut->addHTML("<br/><br/><table width='500px' align='center' class='status'>"); $sql = "select log_user, count(*) as C from logging where log_type='patrol' and log_timestamp > '{$date1}' and log_timestamp < '{$date2}' group by log_user order by C desc limit 20;"; $res = $dbr->query($sql); $index = 1; $wgOut->addHTML("<tr>\n\t <td></td>\n\t <td>User</td>\n\t <td align='right'>" . wfMsg('patrolcount_numberofeditspatrolled') . "</td>\n\t <td align='right'>" . wfMsg('patrolcount_percentangeheader') . "</td>\n\t </tr>\n\t "); while (($row = $dbr->fetchObject($res)) != null) { $u = User::newFromID($row->log_user); $percent = $total == 0 ? "0" : number_format($row->C / $total * 100, 2); $count = number_format($row->C, 0, "", ','); $class = ""; if ($index % 2 == 1) { $class = 'class="odd"'; } $log = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Log'), $count, 'type=patrol&user='******'right'>{$log}</td>\n\t\t\t\t<td align='right'> {$percent} % </td>\n\t\t\t\t</tr>\n\t\t\t"); $index++; } $wgOut->addHTML("</table></center>"); if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") { $wgOut->addHTML("<br/><br/><i><font size='-2'>" . wfMsgWikiHtml('patrolcount_viewlocal_info') . "</font></i>"); } $wgOut->addHTML("</div>"); }
/** * Check whether a user name is acceptable, * and set a message if unacceptable. * * Used by abortNewAccount and centralAuthAutoCreate * * @return bool Acceptable */ private static function acceptNewUserName($userName, $permissionsUser, &$err, $override = true) { $title = Title::makeTitleSafe(NS_USER, $userName); $blacklisted = TitleBlacklist::singleton()->userCannot($title, $permissionsUser, 'new-account', $override); if ($blacklisted instanceof TitleBlacklistEntry) { $message = $blacklisted->getErrorMessage('new-account'); $err = wfMsgWikiHtml($message, $blacklisted->getRaw(), $userName); return false; } return true; }
/** * Show a message that you are viewing a list of users of a certain test wiki * @param $pager * @param $out * @return bool */ static function onSpecialListusersHeader( $pager, &$out ) { $project = self::getProjectInput(); if( $project ) { $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' ); } else { $testwiki = IncubatorTest::getUrlParam(); if ( $testwiki ) { $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) ); $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link ); } } return true; }
/** * Main execution point * * @param $code Confirmation code passed to the page */ function execute($code) { global $wgUser, $wgOut; if (empty($code)) { if ($wgUser->isLoggedIn()) { $this->showRequestForm(); } else { $title = Title::makeTitle(NS_SPECIAL, 'Userlogin'); $self = Title::makeTitle(NS_SPECIAL, 'Confirmemail'); $skin = $wgUser->getSkin(); $llink = $skin->makeKnownLinkObj($title, wfMsgHtml('loginreqlink'), 'returnto=' . $self->getPrefixedUrl()); $wgOut->addHtml(wfMsgWikiHtml('confirmemail_needlogin', $llink)); } } else { $this->attemptConfirm($code); } }
function recent_images($rsargs) { global $wgUploadPath, $wgDBprefix; $u = User::newFromSession(); $dbw =& wfGetDB(DB_MASTER); $res = $dbw->query('select img_name from ' . $wgDBprefix . 'image where img_user='******';'); $return_text = ''; $return_empty = true; for ($i = 0; $i < $res->numRows(); $i++) { $ret = $res->fetchRow(); $return_text = $return_text . '<tr><td><img src="' . $wgUploadPath . '/' . $ret['img_name'] . '" height="100px" width="100px" onclick="n=document.getElementById(\'image_name\'); n.value=\'' . $ret['img_name'] . '\';" /></td></tr><tr><td>' . $ret['img_name'] . '</td></tr>'; $return_empty = false; } if ($return_empty) { return '<tr><td colspan="2"><strong>' . wfMsgWikiHtml('no_recent_images') . '</strong>' . ($u->isLoggedIn() ? '' : wfMsgWikiHtml('try_login')) . '</td></tr>'; } else { return $return_text; } }
function showList() { global $wgOut, $wgContLang; $fname = "BookSourceList::showList()"; # First, see if we have a custom list setup in # [[Wikipedia:Book sources]] or equivalent. $bstitle = Title::makeTitleSafe(NS_PROJECT, wfMsg("booksources")); if ($bstitle) { $revision = Revision::newFromTitle($bstitle); if ($revision) { $bstext = $revision->getText(); if ($bstext) { $bstext = str_replace("MAGICNUMBER", $this->mIsbn, $bstext); $wgOut->addWikiText($bstext); return; } } } # Otherwise, use the list of links in the default Language.php file. $s = wfMsgWikiHtml('booksourcetext') . "<ul>\n"; $bs = $wgContLang->getBookstoreList(); $bsn = array_keys($bs); foreach ($bsn as $name) { $adr = $bs[$name]; if (!$this->mIsbn) { $adr = explode(":", $adr, 2); $adr = explode("/", $adr[1]); $a = ""; while ($a == "") { $a = array_shift($adr); } $adr = "http://" . $a; } else { $adr = str_replace("\$1", $this->mIsbn, $adr); } $name = htmlspecialchars($name); $adr = htmlspecialchars($adr); $s .= "<li><a href=\"{$adr}\" class=\"external\">{$name}</a></li>\n"; } $s .= "</ul>\n"; $wgOut->addHTML($s); }
/** * Called to display the Special:Compare page * * @param unknown_type $par * @param unknown_type $specialPage */ function wfSpecialCompare($par = NULL, $specialPage) { global $wgOut, $wgScriptPath, $wgUser, $wrSidebarHtml; $compareForm = new CompareForm(); $wgOut->setPageTitle('Compare pages'); // read query parameters into variables if (!$compareForm->readQueryParms($par)) { $sideText = ''; $results = $compareForm->getCompareForm(); } else { $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/compare.7.js\"></script>"); $isGedcom = $compareForm->isGedcom(); $sideText = '<p>' . ($isGedcom ? 'Matching GEDCOM families' : 'Merge') . ' is a two-step process. In this compare step, check the boxes above the matching pages.</p>' . ($compareForm->getNamespace() == 'Family' ? '<p>To match children, choose the child number to match with.</p>' : '') . ($isGedcom ? '<p>Then scroll to the bottom of the page and click "Match" to match this family.</p>' . '<p>In the next step you\'ll be given a chance to update the matched pages with information from your GEDCOM</p>' : '<p>Then click "Prepare to merge" at the bottom of the page.</p>' . '<p>In the next step you\\ll be given a chance to decide what information to keep on the merged page.</p>') . '<p><font color="green">Green</font> boxes mean the information is specific and matches exactly.</p>' . '<p><font color="yellow">Yellow</font> boxes mean the information is non-specific (missing some pieces) or is a partial match.</p>' . '<p><font color="red">Red</font> boxes mean the information differs.</p>' . '<p>(<a href="/wiki/Help:Merging_pages">more help</a>)</p>'; $results = $compareForm->getCompareResults(); } $skin = $wgUser->getSkin(); //$wrSidebarHtml = $skin->makeKnownLink('Help:Merging pages', "Help", '', '', '', 'class="popup"'); $wrSidebarHtml = wfMsgWikiHtml('CompareHelp'); $wgOut->addHTML($results); }
/** * Main execution point * * @param $code Confirmation code passed to the page */ function execute($code) { global $wgUser, $wgOut; if (empty($code)) { if ($wgUser->isLoggedIn()) { if (User::isValidEmailAddr($wgUser->getEmail())) { $this->showRequestForm(); } else { $wgOut->addWikiText(wfMsg('confirmemail_noemail')); } } else { $title = SpecialPage::getTitleFor('Userlogin'); $self = SpecialPage::getTitleFor('Confirmemail'); $skin = $wgUser->getSkin(); $llink = $skin->makeKnownLinkObj($title, wfMsgHtml('loginreqlink'), 'returnto=' . $self->getPrefixedUrl()); $wgOut->addHtml(wfMsgWikiHtml('confirmemail_needlogin', $llink)); } } else { $this->attemptConfirm($code); } }
function wfSpecialFavoritelist($par) { global $wgUser, $wgOut, $wgLang, $wgRequest; global $wgRCShowFavoritingUsers, $wgEnotifFavoritelist, $wgShowUpdatedMarker; // Add feed links $flToken = $wgUser->getOption('favoritelisttoken'); if (!$flToken) { $flToken = sha1(mt_rand() . microtime(true)); $wgUser->setOption('favoritelisttoken', $flToken); $wgUser->saveSettings(); } global $wgServer, $wgScriptPath, $wgFeedClasses; $apiParams = array('action' => 'feedfavoritelist', 'allrev' => 'allrev', 'flowner' => $wgUser->getName(), 'fltoken' => $flToken); $feedTemplate = wfScript('api') . '?'; foreach ($wgFeedClasses as $format => $class) { $theseParams = $apiParams + array('feedformat' => $format); $url = $feedTemplate . wfArrayToCGI($theseParams); $wgOut->addFeedLink($format, $url); } $skin = $wgUser->getSkin(); $specialTitle = SpecialPage::getTitleFor('Favoritelist'); $wgOut->setRobotPolicy('noindex,nofollow'); # Anons don't get a favoritelist if ($wgUser->isAnon()) { $wgOut->setPageTitle(wfMsg('favoritenologin')); $llink = $skin->linkKnown(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), array(), array('returnto' => $specialTitle->getPrefixedText())); $wgOut->addHTML(wfMsgWikiHtml('favoritelistanontext', $llink)); return; } $wgOut->setPageTitle(wfMsg('favoritelist')); $sub = wfMsgExt('favoritelistfor', 'parseinline', $wgUser->getName()); $sub .= '<br />' . FavoritelistEditor::buildTools($wgUser->getSkin()); $wgOut->setSubtitle($sub); if (($mode = FavoritelistEditor::getMode($wgRequest, $par)) !== false) { $editor = new FavoritelistEditor(); $editor->execute($wgUser, $wgOut, $wgRequest, $mode); return; } $this->viewFavList($wgUser, $wgOut, $wgRequest, $mode); }
protected function uploadMessage($statusCode, $details) { $msg = ''; switch ($statusCode) { case UploadBase::SUCCESS: break; case UploadBase::EMPTY_FILE: $msg = wfMsgHtml('emptyfile'); break; case UploadBase::MIN_LENGTH_PARTNAME: $msg = wfMsgHtml('minlength1'); break; case UploadBase::ILLEGAL_FILENAME: $filtered = $details['filtered']; $msg = wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered)); break; case UploadBase::OVERWRITE_EXISTING_FILE: $msg = $details['overwrite']; break; case UploadBase::FILETYPE_MISSING: $msg = wfMsgExt('filetype-missing', array('parseinline')); break; case UploadBase::FILETYPE_BADTYPE: $finalExt = $details['finalExt']; $msg = wfMsgExt('filetype-banned-type', array('parseinline'), htmlspecialchars($finalExt), $this->wg->Lang->commaList($this->wg->FileExtensions), $this->wg->Lang->formatNum(count($this->wg->FileExtensions))); break; case UploadBase::VERIFICATION_ERROR: $msg = wfMsgHtml($details['details'][0]); break; case UploadBase::UPLOAD_VERIFICATION_ERROR: $msg = $details['error']; break; case self::UPLOAD_PERMISSION_ERROR: $msg = wfMsg('badaccess'); break; default: throw new MWException(__METHOD__ . ": Unknown value `{$statusCode}`"); } return $msg; }
function processLoginRequest($user, $pass) { global $wgUser, $wgRequest; $userlogin = new LoginForm($wgRequest); $userlogin->mName = $user; $userlogin->mPassword = $pass; //$auth = $userlogin->authenticateUserData(); //$r= new AjaxResponse($auth); //return $r; $msg = ''; switch ($userlogin->authenticateUserData()) { case LoginForm::SUCCESS: $wgUser->setCookies(); $msg = wfMsgWikiHtml('loginsuccess', $wgUser->getName()); break; case LoginForm::NO_NAME: case LoginForm::ILLEGAL: $msg = wfMsgWikiHtml('noname'); break; case LoginForm::WRONG_PLUGIN_PASS: $msg = wfMsgWikiHtml('wrongpassword'); break; case LoginForm::NOT_EXISTS: $msg = wfMsgWikiHtml('nosuchuser', htmlspecialchars($user)); break; case LoginForm::WRONG_PASS: $msg = wfMsgWikiHtml('wrongpassword'); break; case LoginForm::EMPTY_PASS: $msg = wfMsgWikiHtml('wrongpasswordempty'); break; case LoginForm::RESET_PASS: $msg = wfMsgWikiHtml('resetpass_announce'); break; default: wfDebugDieBacktrace("Unhandled case value"); } return new AjaxResponse('<div class="pBody">' . $msg . '</div>'); }
function printSharedImageText() { global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut, $wgUser; $url = $wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey()); $sharedtext = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml("sharedupload"); if ($wgRepositoryBaseUrl && !$wgFetchCommonsDescriptions) { $sk = $wgUser->getSkin(); $title = Title::makeTitle(NS_SPECIAL, 'Upload'); $link = $sk->makeKnownLinkObj($title, wfMsgHtml('shareduploadwiki-linktext'), array('wpDestFile' => urlencode($this->img->getName()))); $sharedtext .= " " . wfMsgWikiHtml('shareduploadwiki', $link); } $sharedtext .= "</div>"; $wgOut->addHTML($sharedtext); if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) { require_once "HttpFunctions.php"; $ur = ini_set('allow_url_fopen', true); $text = wfGetHTTP($url . '?action=render'); ini_set('allow_url_fopen', $ur); if ($text) { $this->mExtraDescription = $text; } } }
/** * @param integer $namespace (Default NS_MAIN) * @param string $from list all pages from this name (default FALSE) */ function showChunk($namespace = NS_MAIN, $from, $including = false) { global $wgOut, $wgUser, $wgContLang; $sk = $wgUser->getSkin(); $fromList = $this->getNamespaceKeyAndText($namespace, $from); $namespaces = $wgContLang->getNamespaces(); $align = $wgContLang->isRtl() ? 'left' : 'right'; $n = 0; if (!$fromList) { $out = wfMsgWikiHtml('allpagesbadtitle'); } elseif (!in_array($namespace, array_keys($namespaces))) { // Show errormessage and reset to NS_MAIN $out = wfMsgExt('allpages-bad-ns', array('parseinline'), $namespace); $namespace = NS_MAIN; } else { list($namespace, $fromKey, $from) = $fromList; $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_is_redirect'), array('page_namespace' => $namespace, 'page_title >= ' . $dbr->addQuotes($fromKey)), __METHOD__, array('ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title')); $out = '<table style="background: inherit;" border="0" width="100%">'; while ($n < $this->maxPerPage && ($s = $dbr->fetchObject($res))) { $t = Title::makeTitle($s->page_namespace, $s->page_title); if ($t) { $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '') . $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()), false, false) . ($s->page_is_redirect ? '</div>' : ''); } else { $link = '[[' . htmlspecialchars($s->page_title) . ']]'; } if ($n % 3 == 0) { $out .= '<tr>'; } $out .= "<td width=\"33%\">{$link}</td>"; $n++; if ($n % 3 == 0) { $out .= '</tr>'; } } if ($n % 3 != 0) { $out .= '</tr>'; } $out .= '</table>'; } if ($including) { $out2 = ''; } else { if ($from == '') { // First chunk; no previous link. $prevTitle = null; } else { # Get the last title from previous chunk $dbr = wfGetDB(DB_SLAVE); $res_prev = $dbr->select('page', 'page_title', array('page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes($from)), __METHOD__, array('ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => $this->maxPerPage - 1)); # Get first title of previous complete chunk if ($dbr->numrows($res_prev) >= $this->maxPerPage) { $pt = $dbr->fetchObject($res_prev); $prevTitle = Title::makeTitle($namespace, $pt->page_title); } else { # The previous chunk is not complete, need to link to the very first title # available in the database $options = array('LIMIT' => 1); if (!$dbr->implicitOrderby()) { $options['ORDER BY'] = 'page_title'; } $reallyFirstPage_title = $dbr->selectField('page', 'page_title', array('page_namespace' => $namespace), __METHOD__, $options); # Show the previous link if it s not the current requested chunk if ($from != $reallyFirstPage_title) { $prevTitle = Title::makeTitle($namespace, $reallyFirstPage_title); } else { $prevTitle = null; } } } $nsForm = $this->namespaceForm($namespace, $from); $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">'; $out2 .= '<tr valign="top"><td>' . $nsForm; $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' . $sk->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsgHtml('allpages')); $self = SpecialPage::getTitleFor('Allpages'); # Do we put a previous link ? if (isset($prevTitle) && ($pt = $prevTitle->getText())) { $q = 'from=' . $prevTitle->getPartialUrl() . ($namespace ? '&namespace=' . $namespace : ''); $prevLink = $sk->makeKnownLinkObj($self, wfMsgHTML('prevpage', $pt), $q); $out2 .= ' | ' . $prevLink; } if ($n == $this->maxPerPage && ($s = $dbr->fetchObject($res))) { # $s is the first link of the next chunk $t = Title::MakeTitle($namespace, $s->page_title); $q = 'from=' . $t->getPartialUrl() . ($namespace ? '&namespace=' . $namespace : ''); $nextLink = $sk->makeKnownLinkObj($self, wfMsgHtml('nextpage', $t->getText()), $q); $out2 .= ' | ' . $nextLink; } $out2 .= "</td></tr></table><hr />"; } $wgOut->addHtml($out2 . $out); if (isset($prevLink) or isset($nextLink)) { $wgOut->addHtml('<hr /><p style="font-size: smaller; float: ' . $align . '">'); if (isset($prevLink)) { $wgOut->addHTML($prevLink); } if (isset($prevLink) && isset($nextLink)) { $wgOut->addHTML(' | '); } if (isset($nextLink)) { $wgOut->addHTML($nextLink); } $wgOut->addHTML('</p>'); } }
function undelete() { global $wgOut, $wgUser; if (!is_null($this->mTargetObj)) { $archive = new PageArchive($this->mTargetObj); $ok = true; $ok = $archive->undelete($this->mTargetTimestamp, $this->mComment, $this->mFileVersions); if ($ok) { $skin =& $wgUser->getSkin(); $link = $skin->makeKnownLinkObj($this->mTargetObj); $wgOut->addHtml(wfMsgWikiHtml('undeletedpage', $link)); return true; } } $wgOut->showFatalError(wfMsg("cannotundelete")); return false; }
/** * @private */ function addNewAccount() { global $wgUser, $wgEmailAuthentication; # Create the account and abort if there's a problem doing so $u = $this->addNewAccountInternal(); if ($u == NULL) { return; } # If we showed up language selection links, and one was in use, be # smart (and sensible) and save that language as the user's preference global $wgLoginLanguageSelector; if ($wgLoginLanguageSelector && $this->mLanguage) { $u->setOption('language', $this->mLanguage); } # Save user settings and send out an email authentication message if needed $u->saveSettings(); if ($wgEmailAuthentication && User::isValidEmailAddr($u->getEmail())) { global $wgOut; $error = $u->sendConfirmationMail(); if (WikiError::isError($error)) { $wgOut->addWikiText(wfMsg('confirmemail_sendfailed', $error->getMessage())); } else { $wgOut->addWikiText(wfMsg('confirmemail_oncreate')); } } # If not logged in, assume the new account as the current one and set session cookies # then show a "welcome" message or a "need cookies" message as needed if ($wgUser->isAnon()) { $wgUser = $u; $wgUser->setCookies(); wfRunHooks('AddNewAccount', array($wgUser)); if ($this->hasSessionCookie()) { return $this->successfulLogin(wfMsg('welcomecreation', $wgUser->getName()), false); } else { return $this->cookieRedirectCheck('new'); } } else { # Confirm that the account was created global $wgOut; $self = SpecialPage::getTitleFor('Userlogin'); $wgOut->setPageTitle(wfMsgHtml('accountcreated')); $wgOut->setArticleRelated(false); $wgOut->setRobotPolicy('noindex,nofollow'); $wgOut->addHtml(wfMsgWikiHtml('accountcreatedtext', $u->getName())); $wgOut->returnToMain($self->getPrefixedText()); wfRunHooks('AddNewAccount', array($u)); return true; } }
/** * @private */ function mailPassword() { global $wgUser, $wgOut, $wgAuth; if (wfReadOnly()) { $wgOut->readOnlyPage(); return false; } if (!$wgAuth->allowPasswordChange()) { $this->mainLoginForm(wfMsg('resetpass_forbidden')); return; } # Check against blocked IPs # fixme -- should we not? if ($wgUser->isBlocked()) { $this->mainLoginForm(wfMsg('blocked-mailpassword')); return; } # Check against the rate limiter if ($wgUser->pingLimiter('mailpassword')) { $wgOut->rateLimited(); return; } if ('' == $this->mName) { $this->mainLoginForm(wfMsg('noname')); return; } $u = User::newFromName($this->mName); if (is_null($u)) { $this->mainLoginForm(wfMsg('noname')); return; } if (0 == $u->getID()) { $this->mainLoginForm(wfMsgWikiHtml('nosuchuser', htmlspecialchars($u->getName()))); return; } # 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. $this->mainLoginForm(wfMsgExt('throttled-mailpassword', array('parsemag'), round($wgPasswordReminderResendTime, 3))); return; } $result = $this->mailPasswordInternal($u, true, 'passwordremindertitle', 'passwordremindertext'); if (WikiError::isError($result)) { $this->mainLoginForm(wfMsg('mailerror', $result->getMessage())); } else { $this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success'); } }
function showForm($err, $hookErr = '') { global $wgOut, $wgUser, $wgContLang; $start = $wgContLang->isRTL() ? 'right' : 'left'; $end = $wgContLang->isRTL() ? 'left' : 'right'; $wgOut->setPagetitle(wfMsg('movepage')); $ot = Title::newFromURL($this->oldTitle); if (is_null($ot)) { $wgOut->showErrorPage('notargettitle', 'notargettext'); return; } $sk = $wgUser->getSkin(); $oldTitleLink = $sk->makeLinkObj($ot); $oldTitle = $ot->getPrefixedText(); $encOldTitle = htmlspecialchars($oldTitle); if ($this->newTitle == '') { # Show the current title as a default # when the form is first opened. $newTitle = $oldTitle; $encNewTitle = $encOldTitle; } else { if ($err == '') { $nt = Title::newFromURL($this->newTitle); if ($nt) { # If a title was supplied, probably from the move log revert # link, check for validity. We can then show some diagnostic # information and save a click. $newerr = $ot->isValidMoveOperation($nt); if (is_string($newerr)) { $err = $newerr; } } } $newTitle = $this->newTitle; $encNewTitle = htmlspecialchars($newTitle); } $encReason = htmlspecialchars($this->reason); if ($err == 'articleexists' && $wgUser->isAllowed('delete')) { $wgOut->addWikiMsg('delete_and_move_text', $newTitle); $movepagebtn = wfMsgHtml('delete_and_move'); $submitVar = 'wpDeleteAndMove'; $confirm = "\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td><td>" . Xml::checkLabel(wfMsg('delete_and_move_confirm'), 'wpConfirm', 'wpConfirm') . "</td>\n\t\t\t\t</tr>"; $err = ''; } else { $wgOut->addWikiMsg('movepagetext'); $movepagebtn = wfMsgHtml('movepagebtn'); $submitVar = 'wpMove'; $confirm = false; } $oldTalk = $ot->getTalkPage(); $considerTalk = !$ot->isTalkPage() && $oldTalk->exists(); if ($considerTalk) { $wgOut->addWikiMsg('movepagetalktext'); } $movearticle = wfMsgHtml('movearticle'); $newtitle = wfMsgHtml('newtitle'); $movereason = wfMsgHtml('movereason'); $titleObj = SpecialPage::getTitleFor('Movepage'); $action = $titleObj->escapeLocalURL('action=submit'); $token = htmlspecialchars($wgUser->editToken()); if ($err != '') { $wgOut->setSubtitle(wfMsg('formerror')); $errMsg = ""; if ($err == 'hookaborted') { $errMsg = "<p><strong class=\"error\">{$hookErr}</strong></p>\n"; } else { $errMsg = '<p><strong class="error">' . wfMsgWikiHtml($err) . "</strong></p>\n"; } $wgOut->addHTML($errMsg); } $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : ''; $wgOut->addHTML("\n<form id=\"movepage\" method=\"post\" action=\"{$action}\">\n\t<table border='0'>\n\t\t<tr>\n\t\t\t<td align='{$end}'>{$movearticle}</td>\n\t\t\t<td align='{$start}'><strong>{$oldTitleLink}</strong></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='{$end}'><label for='wpNewTitle'>{$newtitle}</label></td>\n\t\t\t<td align='{$start}'>\n\t\t\t\t<input type='text' size='40' name='wpNewTitle' id='wpNewTitle' value=\"{$encNewTitle}\" />\n\t\t\t\t<input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='{$end}' valign='top'><br /><label for='wpReason'>{$movereason}</label></td>\n\t\t\t<td align='{$start}' valign='top'><br />\n\t\t\t\t<textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>\n\t\t\t</td>\n\t\t</tr>"); if ($considerTalk) { $wgOut->addHTML("\n\t\t<tr>\n\t\t\t<td></td><td>" . Xml::checkLabel(wfMsg('movetalk'), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked) . "</td>\n\t\t</tr>"); } $watchChecked = $this->watch || $wgUser->getBoolOption('watchmoves') || $ot->userIsWatching(); $watch = '<tr>'; $watch .= '<td></td><td>' . Xml::checkLabel(wfMsg('move-watch'), 'wpWatch', 'watch', $watchChecked) . '</td>'; $watch .= '</tr>'; $wgOut->addHtml($watch); $wgOut->addHTML("\n\t\t{$confirm}\n\t\t<tr>\n\t\t\t<td> </td>\n\t\t\t<td align='{$start}'>\n\t\t\t\t<input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />\n\t\t\t</td>\n\t\t</tr>\n\t</table>\n\t<input type='hidden' name='wpEditToken' value=\"{$token}\" />\n</form>\n"); $this->showLogFragment($ot, $wgOut); }
/** * Show the special page * * @param mixed $par Parameter passed to the page */ public function execute($par) { global $wgOut, $wgUser, $wgRequest, $wgContLang; global $wgCapitalLinks; $this->setHeaders(); $wgOut->addWikiMsg('renameuser-summary'); if (!$wgUser->isAllowed('renameuser')) { $wgOut->permissionRequired('renameuser'); return; } if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if ($wgUser->isBlocked()) { $wgOut->blockedPage(); } $showBlockLog = $wgRequest->getBool('submit-showBlockLog'); $oldnamePar = trim(str_replace('_', ' ', $wgRequest->getText('oldusername', $par))); $oldusername = Title::makeTitle(NS_USER, $oldnamePar); // Force uppercase of newusername, otherwise wikis with wgCapitalLinks=false can create lc usernames $newusername = Title::makeTitleSafe(NS_USER, $wgContLang->ucfirst($wgRequest->getText('newusername'))); $oun = is_object($oldusername) ? $oldusername->getText() : ''; $nun = is_object($newusername) ? $newusername->getText() : ''; $token = $wgUser->editToken(); $reason = $wgRequest->getText('reason'); $move_checked = $wgRequest->getBool('movepages', !$wgRequest->wasPosted()); $suppress_checked = $wgRequest->getCheck('suppressredirect'); $warnings = array(); if ($oun && $nun && !$wgRequest->getCheck('confirmaction')) { wfRunHooks('RenameUserWarning', array($oun, $nun, &$warnings)); } $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'renameuser')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('renameuser')) . Xml::openElement('table', array('id' => 'mw-renameuser-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameuserold'), 'oldusername') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('oldusername', 20, $oun, array('type' => 'text', 'tabindex' => '1')) . ' ' . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameusernew'), 'newusername') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('newusername', 20, $nun, array('type' => 'text', 'tabindex' => '2')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameuserreason'), 'reason') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('reason', 40, $reason, array('type' => 'text', 'tabindex' => '3', 'maxlength' => 255)) . "</td>\n\t\t\t</tr>"); if ($wgUser->isAllowed('move')) { $wgOut->addHTML("\n\t\t\t\t<tr>\n\t\t\t\t\t<td> \n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('renameusermove'), 'movepages', 'movepages', $move_checked, array('tabindex' => '4')) . "</td>\n\t\t\t\t</tr>"); if ($wgUser->isAllowed('suppressredirect')) { $wgOut->addHTML("\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td> \n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('renameusersuppress'), 'suppressredirect', 'suppressredirect', $suppress_checked, array('tabindex' => '5')) . "</td>\n\t\t\t\t\t</tr>"); } } if ($warnings) { $warningsHtml = array(); foreach ($warnings as $warning) { $warningsHtml[] = is_array($warning) ? call_user_func_array('wfMsgWikiHtml', $warning) : wfMsgHtml($warning); } $wgOut->addHTML("\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . wfMsgWikiHtml('renameuserwarnings') . "\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . '<ul style="color: red; font-weight: bold"><li>' . implode('</li><li>', $warningsHtml) . '</li></ul>' . "</td>\n\t\t\t\t</tr>"); $wgOut->addHTML("\n\t\t\t\t<tr>\n\t\t\t\t\t<td> \n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('renameuserconfirm'), 'confirmaction', 'confirmaction', false, array('tabindex' => '6')) . "</td>\n\t\t\t\t</tr>"); } $wgOut->addHTML("\n\t\t\t<tr>\n\t\t\t\t<td> \n\t\t\t\t</td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('renameusersubmit'), array('name' => 'submit', 'tabindex' => '7', 'id' => 'submit')) . ' ' . Xml::submitButton(wfMsg('blocklogpage'), array('name' => 'submit-showBlockLog', 'id' => 'submit-showBlockLog', 'tabindex' => '8')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset') . Html::hidden('token', $token) . Xml::closeElement('form') . "\n"); // Show block log if requested if ($showBlockLog && is_object($oldusername)) { $this->showLogExtract($oldusername, 'block', $wgOut); return; } if ($wgRequest->getText('token') === '') { # They probably haven't even submitted the form, so don't go further. return; } elseif ($warnings) { # Let user read warnings return; } elseif (!$wgRequest->wasPosted() || !$wgUser->matchEditToken($wgRequest->getVal('token'))) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", 'renameuser-error-request'); return; } elseif (!is_object($oldusername)) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrorinvalid', $wgRequest->getText('oldusername'))); return; } elseif (!is_object($newusername)) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrorinvalid', $wgRequest->getText('newusername'))); return; } elseif ($oldusername->getText() == $newusername->getText()) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", 'renameuser-error-same-user'); return; } // Suppress username validation of old username $olduser = User::newFromName($oldusername->getText(), false); $newuser = User::newFromName($newusername->getText(), 'creatable'); // It won't be an object if for instance "|" is supplied as a value if (!is_object($olduser)) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrorinvalid', $oldusername->getText())); return; } if (!is_object($newuser) || !User::isCreatableName($newuser->getName())) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrorinvalid', $newusername->getText())); return; } // Check for the existence of lowercase oldusername in database. // Until r19631 it was possible to rename a user to a name with first character as lowercase if ($oldusername->getText() !== $wgContLang->ucfirst($oldusername->getText())) { // oldusername was entered as lowercase -> check for existence in table 'user' $dbr = wfGetDB(DB_SLAVE); $uid = $dbr->selectField('user', 'user_id', array('user_name' => $oldusername->getText()), __METHOD__); if ($uid === false) { if (!$wgCapitalLinks) { $uid = 0; // We are on a lowercase wiki but lowercase username does not exists } else { // We are on a standard uppercase wiki, use normal $uid = $olduser->idForName(); $oldusername = Title::makeTitleSafe(NS_USER, $olduser->getName()); } } } else { // oldusername was entered as upperase -> standard procedure $uid = $olduser->idForName(); } if ($uid == 0) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrordoesnotexist', $oldusername->getText())); return; } if ($newuser->idForName() != 0) { $wgOut->wrapWikiMsg("<div class=\"errorbox\">\$1</div>", array('renameusererrorexists', $newusername->getText())); return; } // Always get the edits count, it will be used for the log message $contribs = User::edits($uid); // Give other affected extensions a chance to validate or abort if (!wfRunHooks('RenameUserAbort', array($uid, $oldusername->getText(), $newusername->getText()))) { return; } // Do the heavy lifting... $rename = new RenameuserSQL($oldusername->getText(), $newusername->getText(), $uid); if (!$rename->rename()) { return; } // If this user is renaming his/herself, make sure that Title::moveTo() // doesn't make a bunch of null move edits under the old name! if ($wgUser->getId() == $uid) { $wgUser->setName($newusername->getText()); } // Log this rename $log = new LogPage('renameuser'); $log->addEntry('renameuser', $oldusername, wfMsgExt('renameuser-log', array('parsemag', 'content'), $wgContLang->formatNum($contribs), $reason), $newusername->getText()); // Move any user pages if ($wgRequest->getCheck('movepages') && $wgUser->isAllowed('move')) { $dbr = wfGetDB(DB_SLAVE); $pages = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace IN (' . NS_USER . ',' . NS_USER_TALK . ')', '(page_title ' . $dbr->buildLike($oldusername->getDBkey() . '/', $dbr->anyString()) . ' OR page_title = ' . $dbr->addQuotes($oldusername->getDBkey()) . ')'), __METHOD__); $suppressRedirect = false; if ($wgRequest->getCheck('suppressredirect') && $wgUser->isAllowed('suppressredirect')) { $suppressRedirect = true; } $output = ''; foreach ($pages as $row) { $oldPage = Title::makeTitleSafe($row->page_namespace, $row->page_title); $newPage = Title::makeTitleSafe($row->page_namespace, preg_replace('!^[^/]+!', $newusername->getDBkey(), $row->page_title)); # Do not autodelete or anything, title must not exist if ($newPage->exists() && !$oldPage->isValidMoveTarget($newPage)) { $link = Linker::linkKnown($newPage); $output .= Html::rawElement('li', array('class' => 'mw-renameuser-pe'), wfMessage('renameuser-page-exists')->rawParams($link)->escaped()); } else { $success = $oldPage->moveTo($newPage, false, wfMessage('renameuser-move-log', $oldusername->getText(), $newusername->getText())->inContentLanguage()->text(), !$suppressRedirect); if ($success === true) { # oldPage is not known in case of redirect suppression $oldLink = Linker::link($oldPage, null, array(), array('redirect' => 'no')); # newPage is always known because the move was successful $newLink = Linker::linkKnown($newPage); $output .= Html::rawElement('li', array('class' => 'mw-renameuser-pm'), wfMessage('renameuser-page-moved')->rawParams($oldLink, $newLink)->escaped()); } else { $oldLink = Linker::linkKnown($oldPage); $newLink = Linker::link($newPage); $output .= Html::rawElement('li', array('class' => 'mw-renameuser-pu'), wfMessage('renameuser-page-unmoved')->rawParams($oldLink, $newLink)->escaped()); } } } if ($output) { $wgOut->addHTML(Html::rawElement('ul', array(), $output)); } } // Output success message stuff :) $wgOut->wrapWikiMsg("<div class=\"successbox\">\$1</div><br style=\"clear:both\" />", array('renameusersuccess', $oldusername->getText(), $newusername->getText())); }
function showWarningOptions() { global $wgOut; $save = wfMsgHtml('saveallfiles'); $reupload = wfMsgHtml('reupload'); $iw = wfMsgWikiHtml('ignoreallwarnings'); $reup = wfMsgWikiHtml('reuploaddesc'); if ($wgUseCopyrightUpload) { $copyright = "\n\t<input type='hidden' name='wpUploadCopyStatus' value=\"" . htmlspecialchars($this->mUploadCopyStatus) . "\" />\n\t<input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars($this->mUploadSource) . "\" />\n\t"; } else { $copyright = ""; } $wgOut->addHTML("\n\t\t<input type='hidden' name='wpIgnoreWarning' value='1' />\n\t\t<input type='hidden' name='wpSessionKey' value=\"" . htmlspecialchars($this->mSessionKey) . "\" />\n\t\t<input type='hidden' name='wpLicense' value=\"" . htmlspecialchars($this->mLicense) . "\" />\n\t\t<input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars($this->mDestName) . "\" />\n\t\t<input type='hidden' name='wpWatchthis' value=\"" . htmlspecialchars(intval($this->mWatchthis)) . "\" />\n\t{$copyright}\n\t<table border='0'>\n\t\t<tr>\n\t\t\t<tr>\n\t\t\t\t<td align='right'>\n\t\t\t\t\t<input tabindex='2' type='submit' name='wpUpload' value='{$save}' />\n\t\t\t\t</td>\n\t\t\t\t<td align='left'>{$iw}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align='right'>\n\t\t\t\t\t<input tabindex='2' type='submit' name='wpReUpload' value='{$reupload}' />\n\t\t\t\t</td>\n\t\t\t\t<td align='left'>{$reup}</td>\n\t\t\t</tr>\n\t\t</tr>\n\t</table></form>\n"); }
/** * Replace entire showEditForm, need to add our own textbox and stuff */ function showEditForm($formCallback = null) { global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest; # If $wgTitle is null, that means we're in API mode. # Some hook probably called this function without checking # for is_null($wgTitle) first. Bail out right here so we don't # do lots of work just to discard it right after. if (is_null($wgTitle)) { return; } $fname = 'EditPage::showEditForm'; wfProfileIn($fname); $sk = $wgUser->getSkin(); wfRunHooks('EditPage::showEditForm:initial', array(&$this)); #need to parse the preview early so that we know which templates are used, #otherwise users with "show preview after edit box" will get a blank list #we parse this near the beginning so that setHeaders can do the title #setting work instead of leaving it in getPreviewText $previewOutput = ''; if ($this->formtype == 'preview') { $previewOutput = $this->getPreviewText(); } $this->setHeaders(); # Enabled article-related sidebar, toplinks, etc. $wgOut->setArticleRelated(true); if ($this->isConflict) { $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1</div>", 'explainconflict'); $this->textbox2 = $this->textbox1; $this->textbox1 = $this->getContent(); $this->edittime = $this->mArticle->getTimestamp(); # MeanEditor: too complicated for visual editing $this->noVisualEditor = false; } else { if ($this->section != '' && $this->section != 'new') { $matches = array(); if (!$this->summary && !$this->preview && !$this->diff) { preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches); if (!empty($matches[2])) { global $wgParser; $this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ "; } } } if ($this->missingComment) { $wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext'); } if ($this->missingSummary && $this->section != 'new') { $wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary'); } if ($this->missingSummary && $this->section == 'new') { $wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader'); } if ($this->hookError !== '') { $wgOut->addWikiText($this->hookError); } if (!$this->checkUnicodeCompliantBrowser()) { $wgOut->addWikiMsg('nonunicodebrowser'); } if (isset($this->mArticle) && isset($this->mArticle->mRevision)) { // Let sysop know that this will make private content public if saved if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission'); } else { if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view'); } } if (!$this->mArticle->mRevision->isCurrent()) { $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId()); $wgOut->addWikiMsg('editingold'); } } } if (wfReadOnly()) { $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason())); # MeanEditor: visual editing makes no sense here $this->noVisualEditor = true; } elseif ($wgUser->isAnon() && $this->formtype != 'preview') { $wgOut->wrapWikiMsg('<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning'); } else { if ($this->isCssJsSubpage) { # Check the skin exists if ($this->isValidCssJsSubpage) { if ($this->formtype !== 'preview') { $wgOut->addWikiMsg('usercssjsyoucanpreview'); } } else { $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage()); } } } $classes = array(); // Textarea CSS if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { } elseif ($this->mTitle->isProtected('edit')) { # Is the title semi-protected? if ($this->mTitle->isSemiProtected()) { $noticeMsg = 'semiprotectedpagewarning'; $classes[] = 'mw-textarea-sprotected'; } else { # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; $classes[] = 'mw-textarea-protected'; } $wgOut->addHTML("<div class='mw-warning-with-logexcerpt'>\n"); $wgOut->addWikiMsg($noticeMsg); LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1); $wgOut->addHTML("</div>\n"); } if ($this->mTitle->isCascadeProtected()) { # Is this page under cascading protection from some source pages? list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources(); $notice = "<div class='mw-cascadeprotectedwarning'>\$1\n"; $cascadeSourcesCount = count($cascadeSources); if ($cascadeSourcesCount > 0) { # Explain, and list the titles responsible foreach ($cascadeSources as $page) { $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; } } $notice .= '</div>'; $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount)); } if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) { $wgOut->wrapWikiMsg('<div class="mw-titleprotectedwarning">$1</div>', 'titleprotectedwarning'); } if ($this->kblength === false) { # MeanEditor: the length will probably be different in HTML $this->kblength = (int) (strlen($this->textbox1) / 1024); } if ($this->tooBig || $this->kblength > $wgMaxArticleSize) { $wgOut->addHTML("<div class='error' id='mw-edit-longpageerror'>\n"); $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize)); $wgOut->addHTML("</div>\n"); } elseif ($this->kblength > 29) { $wgOut->addHTML("<div id='mw-edit-longpagewarning'>\n"); $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength)); $wgOut->addHTML("</div>\n"); } $q = 'action=' . $this->action; #if ( "no" == $redirect ) { $q .= "&redirect=no"; } $action = $wgTitle->escapeLocalURL($q); $summary = wfMsg('summary'); $subject = wfMsg('subject'); $cancel = $sk->makeKnownLink($wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline'))); $separator = wfMsgExt('pipe-separator', 'escapenoentities'); $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage')); $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow')); global $wgRightsText; if ($wgRightsText) { $copywarnMsg = array('copyrightwarning', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText); } else { $copywarnMsg = array('copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]'); } /* MeanEditor: always disable the toolbar */ if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) { # prepare toolbar for edit buttons $toolbar = ''; } else { $toolbar = ''; } // activate checkboxes if user wants them to be always active if (!$this->preview && !$this->diff) { # Sort out the "watch" checkbox if ($wgUser->getOption('watchdefault')) { # Watch all edits $this->watchthis = true; } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) { # Watch creations $this->watchthis = true; } elseif ($this->mTitle->userIsWatching()) { # Already watched $this->watchthis = true; } # May be overriden by request parameters if ($wgRequest->getBool('watchthis')) { $this->watchthis = true; } if ($wgUser->getOption('minordefault')) { $this->minoredit = true; } # MeanEditor: User preference if ($wgUser->getOption('prefer_traditional_editor')) { $this->userWantsTraditionalEditor = true; } } $wgOut->addHTML($this->editFormPageTop); if ($wgUser->getOption('previewontop')) { $this->displayPreviewArea($previewOutput, true); } $wgOut->addHTML($this->editFormTextTop); # if this is a comment, show a subject line at the top, which is also the edit summary. # Otherwise, show a summary field at the bottom $summarytext = $wgContLang->recodeForEdit($this->summary); # If a blank edit summary was previously provided, and the appropriate # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the # user being bounced back more than once in the event that a summary # is not required. ##### # For a bit more sophisticated detection of blank summaries, hash the # automatic one and pass that in the hidden field wpAutoSummary. $summaryhiddens = ''; if ($this->missingSummary) { $summaryhiddens .= Xml::hidden('wpIgnoreBlankSummary', true); } $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary); $summaryhiddens .= Xml::hidden('wpAutoSummary', $autosumm); if ($this->section == 'new') { $commentsubject = ''; if (!$wgRequest->getBool('nosummary')) { # Add a class if 'missingsummary' is triggered to allow styling of the summary line $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary'; $commentsubject = Xml::tags('label', array('for' => 'wpSummary'), $subject); $commentsubject = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $commentsubject); $commentsubject .= ' '; $commentsubject .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1')); } $editsummary = "<div class='editOptions'>\n"; global $wgParser; $formattedSummary = wfMsgForContent('newsectionsummary', $wgParser->stripSectionName($this->summary)); $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . $sk->commentBlock($formattedSummary, $this->mTitle, true) . "</div>\n" : ''; $summarypreview = ''; } else { $commentsubject = ''; # Add a class if 'missingsummary' is triggered to allow styling of the summary line $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary'; $editsummary = Xml::tags('label', array('for' => 'wpSummary'), $summary); $editsummary = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $editsummary) . ' '; $editsummary .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1')); // No idea where this is closed. $editsummary = Xml::openElement('div', array('class' => 'editOptions')) . $editsummary . '<br/>'; $summarypreview = ''; if ($summarytext && $this->preview) { $summarypreview = Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsg('summary-preview') . $sk->commentBlock($this->summary, $this->mTitle)); } $subjectpreview = ''; } $commentsubject .= $summaryhiddens; # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display if (!$this->preview && !$this->diff) { $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()'); } $templates = $this->getTemplates(); $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != ''); $hiddencats = $this->mArticle->getHiddenCategories(); $formattedhiddencats = $sk->formatHiddenCategories($hiddencats); global $wgUseMetadataEdit; if ($wgUseMetadataEdit) { $metadata = $this->mMetaData; $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata)); $top = wfMsgWikiHtml('metadata_help'); /* ToDo: Replace with clean code */ $ew = $wgUser->getOption('editwidth'); if ($ew) { $ew = " style=\"width:100%\""; } else { $ew = ''; } $cols = $wgUser->getIntOption('cols'); /* /ToDo */ $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>"; } else { $metadata = ""; } $recreate = ''; if ($this->wasDeletedSinceLastEdit()) { if ('save' != $this->formtype) { $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1</div>", 'deletedwhileediting'); } else { // Hide the toolbar and edit area, user can click preview to get it back // Add an confirmation checkbox and explanation. $toolbar = ''; $recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>'; } } $tabindex = 2; $checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor)); $checkboxhtml = implode($checkboxes, "\n"); $buttons = $this->getEditButtons($tabindex); $buttonshtml = implode($buttons, "\n"); $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1'); $wgOut->addHTML(<<<END {$toolbar} <form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data"> END ); if (is_callable($formCallback)) { call_user_func_array($formCallback, array(&$wgOut)); } wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut)); // Put these up at the top to ensure they aren't lost on early form submission $this->showFormBeforeText(); $wgOut->addHTML(<<<END {$recreate} {$commentsubject} {$subjectpreview} {$this->editFormTextBeforeContent} END ); if ($this->isConflict || $this->diff) { # MeanEditor: should be redundant, but let's be sure $this->noVisualEditor = true; } # MeanEditor: also apply htmlspecialchars? See $encodedtext $html_text = $this->safeUnicodeOutput($this->textbox1); if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) { $this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text)); } if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) { $this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew)); } if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) { $wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n"); } else { $wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n"); $this->showTextbox1($classes); } $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg); $wgOut->addHTML(<<<END {$this->editFormTextAfterWarn} {$metadata} {$editsummary} {$summarypreview} {$checkboxhtml} {$safemodehtml} END ); $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->"); /** * To make it harder for someone to slip a user a page * which submits an edit form to the wiki without their * knowledge, a random token is associated with the login * session. If it's not passed back with the submission, * we won't save the page, or render user JavaScript and * CSS previews. * * For anon editors, who may not have a session, we just * include the constant suffix to prevent editing from * broken text-mangling proxies. */ $token = htmlspecialchars($wgUser->editToken()); $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n"); $this->showEditTools(); $wgOut->addHTML(<<<END {$this->editFormTextAfterTools} <div class='templatesUsed'> {$formattedtemplates} </div> <div class='hiddencats'> {$formattedhiddencats} </div> END ); if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) { $wgOut->wrapWikiMsg('==$1==', "yourdiff"); $de = new DifferenceEngine($this->mTitle); $de->setText($this->textbox2, $this->textbox1); $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion")); $wgOut->wrapWikiMsg('==$1==', "yourtext"); $this->showTextbox2(); } $wgOut->addHTML($this->editFormTextBottom); $wgOut->addHTML("</form>\n"); if (!$wgUser->getOption('previewontop')) { $this->displayPreviewArea($previewOutput, false); } wfProfileOut($fname); }
/** * Displays the main upload form, optionally with a highlighted * error message up at the top. * * @param string $msg as HTML * @access private */ function mainUploadForm($msg = '') { global $wgOut, $wgUser; global $wgUseCopyrightUpload; $cols = intval($wgUser->getOption('cols')); $ew = $wgUser->getOption('editwidth'); if ($ew) { $ew = " style=\"width:100%\""; } else { $ew = ''; } if ('' != $msg) { $sub = wfMsgHtml('uploaderror'); $wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n"); } $wgOut->addHTML('<div id="uploadtext">'); $wgOut->addWikiText(wfMsg('uploadtext')); $wgOut->addHTML('</div>'); $sk = $wgUser->getSkin(); $sourcefilename = wfMsgHtml('sourcefilename'); $destfilename = wfMsgHtml('destfilename'); $summary = wfMsgWikiHtml('fileuploadsummary'); $licenses = new Licenses(); $license = wfMsgHtml('license'); $nolicense = wfMsgHtml('nolicense'); $licenseshtml = $licenses->getHtml(); // WERELATE - added licenseHelp $licenseHelpUrl = $sk->makeInternalOrExternalUrl(wfMsgForContent('licensehelppage')); $licenseHelp = '<a target="helpwindow" href="' . $licenseHelpUrl . '">' . htmlspecialchars(wfMsg('licensehelp')) . '</a>'; // WERELATE - added code to select proper license if ($this->mLicense) { $protectedLicense = str_replace(array('\\', '$', '^', '.', '[', ']', '|', '(', ')', '?', '*', '+', '{', '}', '-'), array('\\\\', '\\$', '\\^', '\\.', '\\[', '\\]', '\\|', '\\(', '\\)', '\\?', '\\*', '\\+', '\\{', '\\}', '\\-'), $this->mLicense); $licenseshtml = preg_replace('$value="(' . $protectedLicense . ')"$', 'value="$1" selected="selected"', $licenseshtml); } $ulb = wfMsgHtml('uploadbtn'); $titleObj = Title::makeTitle(NS_SPECIAL, 'Upload'); // WERELATE: added target and id $query = ''; if ($this->mTarget) { $query = 'target=' . urlencode($this->mTarget) . '&id=' . urlencode($this->mId); } $action = $titleObj->escapeLocalURL($query); $encDestFile = htmlspecialchars($this->mDestFile); //WERELATE - added watchcreations $watchChecked = $wgUser->getOption('watchdefault') || $wgUser->getOption('watchcreations') ? 'checked="checked"' : ''; // WERELATE - add scripts global $wgScriptPath; $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/image.1.js\"></script>"); // WERELATE: removed tabindexes; added id to table $wgOut->addHTML("\n\t<form id='upload' method='post' enctype='multipart/form-data' action=\"{$action}\">\n\t\t<table id='image_form_table' border='0'>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile ? "" : "onchange='fillDestFilename()' ") . "size='40' />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpDestFile'>{$destfilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wpDestFile' id='wpDestFile' size='40' value=\"{$encDestFile}\" />\n\t\t\t</td>\n\t\t</tr>"); // WERELATE - added check to omit fields in case of a re-upload, since they're ignored $treecheckboxeshtml = ''; if (!$this->mReUploading) { $wgOut->addHTML("\n\t\t<tr><td> </td><td> </td></tr>\n\t\t<tr><td> </td><td align='left'><b>License and copyright</b></td></tr>\n\t\t<tr>"); if ($licenseshtml != '') { global $wgStylePath; $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wpLicense'>{$license} ( {$licenseHelp} ):</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<script type='text/javascript' src=\"{$wgStylePath}/common/upload.2.js\"></script>\n\t\t\t\t<select name='wpLicense' id='wpLicense' \n\t\t\t\t\tonchange='licenseSelectorCheck()'>\n\t\t\t\t\t<option value=''>{$nolicense}</option>\n\t\t\t\t\t{$licenseshtml}\n\t\t\t\t</select>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t"); } if ($wgUseCopyrightUpload) { $filestatus = wfMsgHtml('filestatus'); $copystatus = htmlspecialchars($this->mUploadCopyStatus); $filesource = wfMsgHtml('filesource'); $uploadsource = htmlspecialchars($this->mUploadSource); $wgOut->addHTML("\n\t\t\t <td align='right' nowrap='nowrap'><label for='wpUploadCopyStatus'>{$filestatus}:</label></td>\n\t\t\t <td><input type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus' value=\"{$copystatus}\" size='40' /></td>\n\t\t </tr>\n\t\t\t<tr>\n\t\t \t<td align='right'><label for='wpUploadCopyStatus'>{$filesource}:</label></td>\n\t\t\t <td><input type='text' name='wpUploadSource' id='wpUploadCopyStatus' value=\"{$uploadsource}\" size='40' /></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t"); } // WERELATE: added fields $personTbl = $this->toForm($this->mPeople, 'person', NS_PERSON, true); $familyTbl = $this->toForm($this->mFamilies, 'family', NS_FAMILY, true); $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wrCopyright'>Copyright holder:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrCopyright' id='wrCopyright' size='30' value=\"" . htmlspecialchars($this->mCopyright) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr><td> </td><td> </td></tr>\n\t\t<tr><td> </td><td align='left'><b>Time place and people</b></td></tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrDate'>Image date:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrDate' id='wrDate' size='15' value=\"" . htmlspecialchars($this->mDate) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrPlace'>Place:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input class='place_input' type='text' name='wrPlace' id='wrDate' size='30' value=\"" . htmlspecialchars($this->mPlace) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Person page:</td>\n\t\t\t<td align='left'>{$personTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td> </td>\n\t\t\t<td align='left'><a id='person_link' href='javascript:void(0)' onClick='addImagePage(\"person\"); return preventDefaultAction(event);'>Add another person</a></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Family page:</td>\n\t\t\t<td align='left'>{$familyTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td> </td>\n\t\t\t<td align='left'><a id='family_link' href='javascript:void(0)' onClick='addImagePage(\"family\"); return preventDefaultAction(event);'>Add another family</a></td>\n\t\t</tr>\n\t\t"); // WERELATE - move description from above; end reUploading if statement; moved summary label // add id for wpUpload; added tree checkboxes //!!! remove this code dependency before sharing require_once "extensions/familytree/FamilyTreeUtil.php"; $t = null; if ($this->mDestFile) { $t = Title::newFromText($this->mDestFile, NS_IMAGE); } $treecheckboxeshtml = FamilyTreeUtil::generateTreeCheckboxes($wgUser, $t, true); $wgOut->addHtml("\n\t\t\t<tr><td> </td><td> </td></tr>\n\t\t\t<tr><td></td><td align='left'><b>{$summary}</b></td></tr>\n\t\t\t<tr><td></td><td align='left'>\n\t\t\t\t<textarea name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars($this->mUploadDescription) . "</textarea>\n\t\t\t</td>\n\t\t</tr> "); } $wgOut->addHTML("\n\t\t<tr>\n\t\t<td></td>\n\t\t<td>\n\t\t\t<input type='checkbox' name='wpWatchthis' id='wpWatchthis' {$watchChecked} value='true' />\n\t\t\t<label for='wpWatchthis'>" . wfMsgHtml('watchthis') . "</label>\n\t\t\t<input type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' />\n\t\t\t<label for='wpIgnoreWarning'>" . wfMsgHtml('ignorewarnings') . "</label>" . $treecheckboxeshtml . "\n\t\t</td>\n\t</tr>\n\t<tr>\n\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'><input type='submit' id='wpUpload' name='wpUpload' value=\"{$ulb}\" /></td>\n\t</tr>\n\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'>\n\t\t"); $wgOut->addWikiText(wfMsgForContent('edittools')); $wgOut->addHTML("\n\t\t</td>\n\t</tr>\n\n\t</table>\n\t</form>"); }
/** * This will be called if the user did not exist locally and userExists returned true * Using &$errormsg requires a patch, otherwise it'll always be "bad password" * See Extension:MediaWikiAuth for this patch * * @param $username Mixed: username * @param $password Mixed: password to the above username * @param $errormsg Mixed: error message or null */ function authenticate($username, $password, &$errormsg = null) { if ($username == 'FIXUPREV') { $dbw = wfGetDB(DB_MASTER); $dbw->query('UPDATE revision,user SET revision.rev_user=user.user_id WHERE revision.rev_user=0 AND revision.rev_user_text=user.user_name', __METHOD__); $errormsg = 'Fixed records.'; return false; } global $wgMediaWikiAuthAPIURL; # This is loaded here so it isn't loaded needlessly if (!class_exists('Snoopy', false)) { require_once dirname(__FILE__) . '/Snoopy.class.php'; } $this->snoopy = new Snoopy(); $this->snoopy->agent = 'Mozilla/5.0 Snoopy/1.2.4'; # The user should exist remotely. Let's try to login. $login_vars = array('action' => 'login', 'lgname' => $username, 'lgpassword' => $password, 'format' => 'php'); do { $this->snoopy->submit($wgMediaWikiAuthAPIURL, $login_vars); # Did we get in? Look for result: 'Success' $results = unserialize($this->snoopy->results); wfDebugLog('MediaWikiAuth', 'Login result:' . print_r($results, true)); wfLoadExtensionMessages('MediaWikiAuth'); $errormsg = wfMsg('mwa-error-unknown'); if (isset($results['login'])) { $login = $results['login']; # This ignores the NoName option as it will be filtered out before now switch ($login['result']) { case 'Success': # Set cookies from the successful login $this->snoopy->setcookies(); # Did we not have an ID from earlier? Use the one we're given now if (!isset($this->old_user_id)) { $this->old_user_id = $login['lguserid']; } $this->old_user_name = $login['lgusername']; return true; case 'NotExists': global $wgUser; if ($wgUser->isAllowed('createaccount')) { $errormsg = wfMsgWikiHtml('nosuchuser', htmlspecialchars($username)); } else { $errormsg = wfMsg('nosuchusershort', htmlspecialchars($username)); } break; case 'NeedToken': # Set cookies and break out to resubmit $this->snoopy->setcookies(); $login_vars['lgtoken'] = $login['token']; break; case 'WrongToken': $errormsg = wfMsg('mwa-error-wrong-token'); break; case 'EmptyPass': $errormsg = wfMsg('wrongpasswordempty'); break; case 'WrongPass': case 'WrongPluginPass': $errormsg = wfMsg('wrongpassword'); break; case 'CreateBlocked': $errormsg = wfMsg('mwa-autocreate-blocked'); break; case 'Throttled': $errormsg = wfMsg('login-throttled'); break; case 'ResetPass': $errormsg = wfMsg('mwa-resetpass'); break; } if (isset($login['wait'])) { $errormsg .= ' ' . wfMsg('mwa-wait', $login['wait']); } } } while (isset($results['login']) && $login['result'] == 'NeedToken'); # Login failed! Display a message return false; }