/** * Send the edit form and related headers to $wgOut * @param $formCallback Optional callable that takes an OutputPage * parameter; will be called during form output * near the top, for captchas and the like. */ function showEditForm($formCallback = null) { global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle; $fname = 'EditPage::showEditForm'; wfProfileIn($fname); $sk = $wgUser->getSkin(); wfRunHooks('EditPage::showEditForm:initial', array(&$this)); $wgOut->setRobotpolicy('noindex,nofollow'); # Enabled article-related sidebar, toplinks, etc. $wgOut->setArticleRelated(true); if ($this->formtype == 'preview') { $wgOut->setPageTitleActionText(wfMsg('preview')); } if ($this->isConflict) { $s = wfMsg('editconflict', $wgTitle->getPrefixedText()); $wgOut->setPageTitle($s); $wgOut->addWikiMsg('explainconflict'); $this->textbox2 = $this->textbox1; $this->textbox1 = $this->getContent(); $this->edittime = $this->mArticle->getTimestamp(); } else { if ($this->section != '') { if ($this->section == 'new') { $s = wfMsg('editingcomment', $wgTitle->getPrefixedText()); } else { $s = wfMsg('editingsection', $wgTitle->getPrefixedText()); $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])) . " */ "; } } } } else { $s = wfMsg('editing', $wgTitle->getPrefixedText()); } $wgOut->setPageTitle($s); 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->addWikiMsg('rev-deleted-text-permission'); } else { if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) { $wgOut->addWikiMsg('rev-deleted-text-view'); } } if (!$this->mArticle->mRevision->isCurrent()) { $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId()); $wgOut->addWikiMsg('editingold'); } } } if (wfReadOnly()) { $wgOut->addHTML('<div id="mw-read-only-warning">' . wfMsgWikiHTML('readonlywarning') . '</div>'); } elseif ($wgUser->isAnon() && $this->formtype != 'preview') { $wgOut->addHTML('<div id="mw-anon-edit-warning">' . wfMsgWikiHTML('anoneditwarning') . '</div>'); } else { if ($this->isCssJsSubpage && $this->formtype != 'preview') { # Check the skin exists if ($this->isValidCssJsSubpage) { $wgOut->addWikiMsg('usercssjsyoucanpreview'); } else { $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage()); } } } if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { # Show a warning if editing an interface message $wgOut->addWikiMsg('editinginterface'); } elseif ($this->mTitle->isProtected('edit')) { # Is the title semi-protected? if ($this->mTitle->isSemiProtected()) { $noticeMsg = 'semiprotectedpagewarning'; } else { # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; } $wgOut->addWikiMsg($noticeMsg); } if ($this->mTitle->isCascadeProtected()) { # Is this page under cascading protection from some source pages? list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources(); $notice = "\$1\n"; if (count($cascadeSources) > 0) { # Explain, and list the titles responsible foreach ($cascadeSources as $page) { $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; } } $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', count($cascadeSources))); } if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create') != array()) { $wgOut->addWikiMsg('titleprotectedwarning'); } if ($this->kblength === false) { $this->kblength = (int) (strlen($this->textbox1) / 1024); } if ($this->tooBig || $this->kblength > $wgMaxArticleSize) { $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize); } elseif ($this->kblength > 29) { $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength)); } #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 if ($this->formtype == 'preview') { $previewOutput = $this->getPreviewText(); } $rows = $wgUser->getIntOption('rows'); $cols = $wgUser->getIntOption('cols'); $ew = $wgUser->getOption('editwidth'); if ($ew) { $ew = " style=\"width:100%\""; } else { $ew = ''; } $q = 'action=submit'; #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'))); $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') . ']]'); } if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) { # prepare toolbar for edit buttons $toolbar = $this->getEditToolbar(); } 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; } if ($wgUser->getOption('minordefault')) { $this->minoredit = true; } } $wgOut->addHTML($this->editFormPageTop); if ($wgUser->getOption('previewontop')) { if ('preview' == $this->formtype) { $this->showPreview($previewOutput); } else { $wgOut->addHTML('<div id="wikiPreview"></div>'); } if ('diff' == $this->formtype) { $this->showDiff(); } } $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 = htmlspecialchars($wgContLang->recodeForEdit($this->summary)); # FIXME if ($this->section == 'new') { $commentsubject = "<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />"; $editsummary = ''; $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : ''; $summarypreview = ''; } else { $commentsubject = ''; $editsummary = "<span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />"; $summarypreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('summary-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : ''; $subjectpreview = ''; } # 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->preview || $this->section != '' ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates(); $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != ''); global $wgUseMetadataEdit; if ($wgUseMetadataEdit) { $metadata = $this->mMetaData; $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata)); $top = wfMsgWikiHtml('metadata_help'); $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>"; } else { $metadata = ""; } $hidden = ''; $recreate = ''; if ($this->deletedSinceEdit) { if ('save' != $this->formtype) { $wgOut->addWikiMsg('deletedwhileediting'); } else { // Hide the toolbar and edit area, use can click preview to get it back // Add an confirmation checkbox and explanation. $toolbar = ''; $hidden = 'type="hidden" style="display:none;"'; $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)); $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>"; } } $tabindex = 2; $checkboxes = self::getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis)); $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 $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n"); $wgOut->addHTML(<<<END {$recreate} {$commentsubject} {$subjectpreview} {$this->editFormTextBeforeContent} <textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}' cols='{$cols}'{$ew} {$hidden}> END . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t"); $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg); $wgOut->addHTML($this->editFormTextAfterWarn); $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$summarypreview}\n{$checkboxhtml}\n{$safemodehtml}\n"); $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->"); $wgOut->addHtml('<div class="mw-editTools">'); $wgOut->addWikiMsgArray('edittools', array(), array('content')); $wgOut->addHtml('</div>'); $wgOut->addHTML($this->editFormTextAfterTools); $wgOut->addHTML("\n<div class='templatesUsed'>\n{$formattedtemplates}\n</div>\n"); /** * 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"); # If a blank edit summary was previously provided, and the appropriate # user preference is active, pass a hidden tag here. This will stop the # user being bounced back more than once in the event that a summary # is not required. if ($this->missingSummary) { $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n"); } # For a bit more sophisticated detection of blank summaries, hash the # automatic one and pass that in a hidden field. $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary); $wgOut->addHtml(wfHidden('wpAutoSummary', $autosumm)); if ($this->isConflict) { $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"); $wgOut->addHTML("<textarea tabindex='6' id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>"); } $wgOut->addHTML($this->editFormTextBottom); $wgOut->addHTML("</form>\n"); if (!$wgUser->getOption('previewontop')) { if ($this->formtype == 'preview') { $this->showPreview($previewOutput); } else { $wgOut->addHTML('<div id="wikiPreview"></div>'); } if ($this->formtype == 'diff') { $this->showDiff(); } } wfProfileOut($fname); }
function execute($par) { global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname, $wgScriptPath; global $wgRequest, $wgSitename, $wgLanguageCode; global $wgScript; $fname = "wfSpecialEmailLink"; if ($wgRequest->getVal('fromajax')) { $wgOut->setArticleBodyOnly(true); } $this->setHeaders(); $me = Title::makeTitle(NS_SPECIAL, "EmailLink"); $action = $me->getFullURL(); $fc = new FancyCaptcha(); $pass_captcha = true; $name = $from = $r1 = $r2 = $r3 = $m = ""; if ($wgRequest->wasPosted()) { $pass_captcha = $fc->passCaptcha(); $email = $wgRequest->getVal("email"); $name = $wgRequest->getVal("name"); $recipient1 = $wgRequest->getVal('recipient1'); $recipient2 = $wgRequest->getVal('recipient2'); $recipient3 = $wgRequest->getVal('recipient3'); if (preg_match("@kittens683\\@aol.com@", $recipient1) || preg_match("@kittens683\\@aol.com@", $recipient2) || preg_match("@kittens683\\@aol.com@", $recipient3)) { return; } $message = $wgRequest->getVal('message'); } if (!$wgRequest->wasPosted() || !$pass_captcha) { if ($wgUser->getID() > 0 && !$wgUser->canSendEmail()) { $userEmail = $wgUser->getEmail(); // If there is no verification time stamp and no email on record, show initial message to have a user input a valid email address if (empty($userEmail)) { wfDebug("User can't send.\n"); $wgOut->errorpage("mailnologin", "mailnologintext"); } else { // When user does have an email on record, but has not verified it yet wfDebug("User can't send without verification.\n"); $wgOut->errorpage("mailnologin", "mailnotverified"); } return; } $titleKey = isset($par) ? $par : $wgRequest->getVal('target'); if ($titleKey == "") { $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-no-title') . "</font>"); return; } $titleObj = Title::newFromURL($titleKey); if (!$titleObj) { $titleObj = Title::newFromURL(urldecode($titleKey)); } if (!$titleObj || $titleObj->getArticleID() < 0) { $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-article-not-found') . "</font>"); return; } else { $titleKey = $titleObj->getDBKey(); } $articleObj = new Article($titleObj); $subject = $titleObj->getText(); $titleText = $titleObj->getText(); if (WikihowArticleEditor::articleIsWikiHow($articleObj)) { $subject = wfMsg('howto', $subject); $titleText = wfMsg('howto', $titleText); } $subject = wfMsg('wikihow-article-subject', $subject); if ($titleObj->getText() == wfMsg('mainpage')) { $subject = wfMsg('wikihow-article-subject-main-page'); } // add the form HTML $article_title = wfMsg('article') . ":"; if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $wgOut->addHTML("<br/><br/>" . wfMsg('know-someone-answer-topic-request')); $article_title = wfMsg('topic-requested') . ":"; } if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) { $wgOut->errorPage('emaillink', 'emaillink_invalidpage'); return; } if ($titleObj->getText() == "Books For Africa") { $message = wfMsg('friend-sends-article-email-africa-body'); } $titleKey = urlencode($titleKey); $token = $this->getToken1(); $wgOut->addHTML("\n<link type='text/css' rel='stylesheet' href='" . wfGetPad('/extensions/wikihow/common/jquery-ui-themes/jquery-ui.css?rev=' . WH_SITEREV) . "' />\n<form id=\"emaillink\" method=\"post\" action=\"{$action}\">\n<input type=\"hidden\" name=\"target\" value=\"{$titleKey}\">\n<input type=\"hidden\" name=\"token\" value=\"{$token}\">\n<table border=\"0\">\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>{$article_title}</td>\n<td valign=\"top\" colspan=\"2\">{$titleText}</td>\n</tr>\n"); if ($wgUser->getID() <= 0) { $wgOut->addHTML("\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-name') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"name\" value=\"{$name}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-email') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"email\" value=\"{$email}\" class='input_med'></td>\n</tr>"); } $wgOut->addHTML("\n<tr>\n<td valign=\"top\" width=\"300px\" colspan=\"1\" rowspan='3' class='mw-label'>" . wfMsg('recipient-emails') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient1\" value=\"{$recipient1}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient2\" value=\"{$recipient2}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient3\" value=\"{$recipient3}\" class='input_med'></td>\n</tr>\n<!--<tr>\n<td valign=\"top\" colspan=\"1\">" . wfMsg('emailsubject') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"subject\" value=\"{$subject}\" class='input_med'></td>\n</tr>-->\n<tr>\n<td colspan=\"1\" valign=\"top\" class='mw-label'>" . wfMsg('emailmessage') . ":</td>\n<td colspan=\"2\"><TEXTAREA rows=\"5\" cols=\"55\" name=\"message\">{$message}</TEXTAREA></td>\n</tr>\n<tr>\n<TD> </TD>\n<TD colspan=\"2\"><br/>\n" . wfMsgWikiHTML('emaillink_captcha') . "\n" . ($pass_captcha ? "" : "<br><br/><font color='red'>Sorry, that phrase was incorrect, try again.</font><br/><br/>") . "\n" . $fc->getForm('') . "\n</TD>\n</tr>\n<tr>\n<TD> </TD>\n<TD colspan=\"2\"><br/>\n<input type='submit' name=\"wpEmaiLinkSubmit\" value=\"" . wfMsg('submit') . "\" class=\"button primary\" />\n</td>\n</tr>\n<tr>\n<TD colspan=\"3\">\n<br/><br/>\n" . wfMsg('share-message-three-friends') . "\n</TD>\n</TR>\n\n"); // do this if the user isn't logged in $wgOut->addHTML("</table> </form>"); } else { if ($wgUser->pingLimiter('emailfriend')) { $wgOut->rateLimited(); wfProfileOut("{$fname}-checks"); wfProfileOut($fname); return false; } $usertoken = $wgRequest->getVal('token'); $token1 = $this->getToken1(); $token2 = $this->getToken2(); if ($usertoken != $token1 && $usertoken != $token2) { $this->reject(); echo "token {$usertoken} {$token1} {$token2}\n"; exit; return; } // check referrer $good_referer = Title::makeTitle(NS_SPECIAL, "EmailLink")->getFullURL(); $referer = $_SERVER["HTTP_REFERER"]; if (strpos($refer, $good_referer) != 0) { $this->reject(); echo "referrer bad\n"; exit; } // this is a post, accept the POST data and create the Request article $recipient1 = $_POST['recipient1']; $recipient2 = $_POST['recipient2']; $recipient3 = $_POST['recipient3']; $titleKey = $_POST['target']; $message = $_POST['message']; if ($titleKey == "Books-For-Africa") { $titleKey = "wikiHow:" . $titleKey; } $titleKey = urldecode($titleKey); $titleObj = Title::newFromDBKey($titleKey); if ($titleObj->getArticleID() <= 0) { $this->reject(); echo "no article id\n"; exit; } $dbkey = $titleObj->getDBKey(); $articleObj = new Article($titleObj); $subject = $titleObj->getText(); $how_to = $subject; if (WikihowArticleEditor::articleIsWikiHow($articleObj)) { $subject = wfMsg("howto", $subject); } $how_to = $subject; if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $subject = wfMsg('subject-requested-howto') . ": " . wfMsg("howto", $subject); } else { if ($titleObj->getNamespace() == NS_PROJECT) { $subject = wfMsg('friend-sends-article-email-africa-subject'); } else { $subject = wfMsg('wikihow-article-subject', $subject); } } if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) { $wgOut->errorPage('emaillink', 'emaillink_invalidpage'); return; } // for the body of the email $titleText = $titleObj->getText(); if ($titleText != wfMsg('mainpage')) { $summary = Article::getSection($articleObj->getContent(true), 0); // trip out all MW and HTML tags $summary = ereg_replace("<.*>", "", $summary); $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary); $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary); } $url = $titleObj->getFullURL(); $from_name = ""; $validEmail = ""; if ($wgUser->getID() > 0) { $from_name = $wgUser->getName(); $real_name = $wgUser->getRealName(); if ($real_name != "") { $from_name = $real_name; } $email = $wgUser->getEmail(); if ($email != "") { $validEmail = $email; $from_name .= "<{$email}>"; } else { $from_name .= "<*****@*****.**>"; } } else { $email = $wgRequest->getVal("email"); $name = $wgRequest->getVal("name"); if ($email == "") { $email = "*****@*****.**"; } else { $validEmail = $email; } $from_name = "{$name} <{$email}>"; } if (strpos($email, "\n") !== false || strpos($recipient1, "\n") !== false || strpos($recipient2, "\n") !== false || strpos($recipient3, "\n") !== false || strpos($title, "\n") !== false) { echo "reciep\n"; exit; $this->reject(); return; } $r_array = array(); $num_recipients = 0; if ($recipient1 != "") { $num_recipients++; $x = split(";", $recipient1); $r_array[] = $x[0]; } if ($recipient2 != "") { $num_recipients++; $x = split(";", $recipient2); $r_array[] = $x[0]; } if ($recipient3 != "") { $num_recipients++; $x = split(";", $recipient3); $r_array[] = $x[0]; } if ($titleObj->getNamespace() == NS_PROJECT) { $r_array[] = '*****@*****.**'; } if ($validEmail != "" && !in_array($validEmail, $r_array)) { $num_recipients++; $r_array[] = $validEmail; } if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $body = "{$message}\n\n----------------\n\n\t" . wfMsg('article-request-email', $how_to, "http://www.wikihow.com/index.php?title2={$dbkey}&action=easy&requested={$dbkey}", "http://www.wikihow.com/Request:{$dbkey}", "http://www.wikihow.com/" . wfMsg('writers-guide-url'), "http://www.wikihow.com/" . wfMsg('about-wikihow-url') . ""); } else { if ($titleObj->getText() == wfMsg('mainpage')) { $body = "{$message}\n\n----------------\n\n\t" . wfMsg('friend-sends-article-email-main-page') . "\n\n\t"; } else { if ($titleObj->getNamespace() == NS_PROJECT) { $body = "{$message}"; } else { $body = "{$message}\n\n----------------\n\n" . wfMsg('friend-sends-article-email', $how_to, $summary, $url) . "\n\n\t"; } } } $from = new MailAddress($email); foreach ($r_array as $address) { $address = preg_replace("@,.*@", "", $address); $to = new MailAddress($address); $sbody = $body; if ($address == $validEmail) { $sbody = wfMsg('copy-email-from-yourself') . "\n\n" . $sbody; } if (!userMailer($to, $from, $subject, $sbody, false)) { //echo "got an en error\n"; } } SiteStatsUpdate::addLinksEmailed($num_recipients); $this->thanks(); } }
private function getContribs() { global $wgUser; $skin =& $wgUser->getSkin(); $numContribs = 0; // get timestamp as of 90 days ago $numDays = 90; $timestamp = wfTimestamp(TS_MW, time() - $numDays * 24 * 60 * 60); $dbr =& wfGetDB(DB_SLAVE); $sql = 'select COUNT(*) from revision where rev_user='******' and rev_timestamp >= ' . $dbr->addQuotes($timestamp); $res = $dbr->query($sql, 'wfSpecialMyRelate'); if ($res !== false) { $row = $dbr->fetchRow($res); if ($row !== false) { $numContribs = $row[0]; } $dbr->freeResult($res); } $ret = '<div class="myrelate-header">Contributions</div>'; $ret .= '<dl><dd>' . wfMsgWikiHTML('NumberOfContributions', $numContribs, $numDays) . '</dd></dl>'; $tip = wfMsgHTML('contributionstip'); $ret .= $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Contributions/' . $wgUser->getName()), 'View contributions', '', '', '', '', " title=\"{$tip}\""); return $ret; }