Exemple #1
0
 function execute($par)
 {
     global $wgRequest, $wgUser, $wgOut;
     wfLoadExtensionMessages('RequestTopic');
     $pass_captcha = true;
     if ($wgRequest->wasPosted()) {
         $fc = new FancyCaptcha();
         $pass_captcha = $fc->passCaptcha();
     }
     $wgOut->setPageTitle(wfMsg('suggest_header'));
     if ($wgRequest->wasPosted() && $pass_captcha) {
         $dbr = wfGetDB(DB_SLAVE);
         require_once 'EditPageWrapper.php';
         $title = EditPageWrapper::formatTitle($wgRequest->getVal('suggest_topic'));
         $s = Title::newFromText($title);
         if (!$s) {
             $wgOut->addHTML("There was an error creating this title.");
             return;
         }
         // does the request exist as an article?
         if ($s->getArticleiD()) {
             $wgOut->addHTML(wfMsg('suggested_article_exists_title'));
             $wgOut->addHTML(wfMsg('suggested_article_exists_info', $s->getText(), $s->getFullURL()));
             return;
         }
         // does the request exist in the list of suggested titles?
         $email = $wgRequest->getVal('suggest_email');
         if (!$wgRequest->getCheck('suggest_email_me_check')) {
             $email = '';
         }
         $count = $dbr->selectField('suggested_titles', array('count(*)'), array('st_title' => $s->getDBKey()));
         $dbw = wfGetDB(DB_MASTER);
         if ($count == 0) {
             $dbw->insert('suggested_titles', array('st_title' => $s->getDBKey(), 'st_user' => $wgUser->getID(), 'st_user_text' => $wgUser->getName(), 'st_isrequest' => 1, 'st_category' => $wgRequest->getVal('suggest_category'), 'st_suggested' => wfTimestampNow(), 'st_notify' => $email, 'st_source' => 'req', 'st_key' => generateSearchKey($title), 'st_group' => rand(0, 4)));
         } elseif ($email) {
             // request exists lets add the user's email to the list of notifications
             $existing = $dbr->selectField('suggested_titles', array('st_notify'), array('st_title' => $s->getDBKey()));
             if ($existing) {
                 $email = "{$existing}, {$email}";
             }
             $dbw->update('suggested_titles', array('st_notify' => $email), array('st_title' => $s->getDBKey()));
         }
         $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.css?rev=') . WH_SITEREV . '"; /*]]>*/</style>');
         $wgOut->addHTML(wfMsg("suggest_confirmation_owl", $s->getFullURL(), $s->getText()));
         return;
     }
     $wgOut->setHTMLTitle('Requested Topics - wikiHow');
     $wgOut->setRobotPolicy('noindex,nofollow');
     $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.css?rev=') . WH_SITEREV . '"; /*]]>*/</style>');
     $wgOut->addHTML(wfMsg('suggest_sub_header'));
     $wgOut->addHTML("<form action='/Special:RequestTopic' method='POST' onSubmit='return checkSTForm();' name='suggest_topic_form'>");
     $wgOut->addScript('<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.js?rev=') . WH_SITEREV . '"></script>');
     $wgOut->addScript("<script type='text/javascript'/>var gSelectCat = '" . wfMsg('suggest_please_select_cat') . "';\n\t\tvar gEnterTitle = '" . wfMsg('suggest_please_enter_title') . "';\n\t\tvar gEnterEmail  = '" . wfMsg('suggest_please_enter_email') . "';\n\t</script>");
     $fc = new FancyCaptcha();
     $cats = $this->getCategoryOptions();
     $wgOut->addHTML(wfMsg('suggest_input_form', $cats, $fc->getForm(), $pass_captcha ? "" : wfMsg('suggest_captcha_failed'), $wgUser->getEmail()));
     //$wgOut->addHTML(wfMsg('suggest_notifications_form', $wgUser->getEmail()));
     //$wgOut->addHTML(wfMsg('suggest_submit_buttons'));
     $wgOut->addHTML("</form>");
 }
 public function execute()
 {
     # Get a new FancyCaptcha form data
     $captcha = new FancyCaptcha();
     $captchaIndex = $captcha->getCaptchaIndex();
     $result = $this->getResult();
     $result->addValue(null, $this->getModuleName(), array('index' => $captchaIndex));
     return true;
 }
Exemple #3
0
 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>&nbsp;</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>&nbsp;</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();
     }
 }
 function writeOutput($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
     global $wgRequest, $wgSitename, $wgLanguageCode;
     global $wgFeedClasses, $wgFilterCallback, $wgWhitelistEdit, $wgParser;
     wfLoadExtensionMessages('Postcomment');
     $wgOut->setRobotpolicy("noindex,nofollow");
     $fname = "wfSpecialPostcomment";
     //echo "topic: " . $wgRequest->getVal("topic_name") . "<BR>";
     //echo "title: " . $wgRequest->getVal("title") . "<BR>";
     //echo "comment: " . $wgRequest->getVal("comment_text") . "<BR>";
     //echo "new_topic id " . $wgRequest->getVal("new_topic") . "<BR>";
     $target = !empty($par) ? $par : $wgRequest->getVal("target");
     $t = Title::newFromDBKey($target);
     $update = true;
     if (!$t || !$t->userCanEdit()) {
         return;
     }
     if (!$wgUser->isAllowed('edit')) {
         return;
     }
     if ($t == null) {
         $wgOut->errorPage('postcomment', 'postcomment_invalidrequest');
         return;
     }
     $article = new Article($t);
     $user = $wgUser->getName();
     $real_name = User::whoIsReal($wgUser->getID());
     if ($real_name == "") {
         $real_name = $user;
     }
     $dateStr = $wgLang->timeanddate(wfTimestampNow());
     $comment = $wgRequest->getVal("comment_text");
     foreach ($wgRequest->getValues() as $key => $value) {
         if (strpos($key, "comment_text") === 0) {
             $comment = $value;
             break;
         }
     }
     $topic = $wgRequest->getVal("topic_name");
     //echo "$dateStr<br/>";
     // remove leading space, tends to be a problem with a lot of talk page comments as it breaks the
     // HTML on the page
     $comment = preg_replace('/\\n[ ]*/', "\n", trim($comment));
     // Check to see if the user is also getting a thumbs up. If so, append the thumbs message and give a thumbs up
     if ($wgRequest->getVal('thumb')) {
         $comment .= "\n\n" . wfMsg('qn_thumbs_up');
         $userName = explode(":", $wgRequest->getVal('target'));
         ThumbsUp::quickNoteThumb($wgRequest->getVal('revold'), $wgRequest->getVal('revnew'), $wgRequest->getVal('pageid'), $userName[1]);
     }
     $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, $comment);
     if ($wgRequest->getVal('fromajax') == 'true') {
         $wgOut->setArticleBodyOnly(true);
     }
     $text = "";
     $r = Revision::newFromTitle($t);
     if ($r) {
         $text = $r->getText();
     }
     $text .= "\n\n{$formattedComment}\n\n";
     $wgOut->setStatusCode(500);
     //echo "updating with text:<br/> $text";
     //exit;
     $tmp = "";
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!$wgUser->getID() && $wgWhitelistEdit) {
         $this->userNotLoggedInPage();
         return;
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($target == "Spam-Blacklist") {
         $wgOut->readOnlyPage();
         return;
     }
     if ($wgUser->pingLimiter()) {
         $wgOut->rateLimited();
         return;
     }
     if ($wgFilterCallback && $wgFilterCallback($t, $text, $tmp)) {
         # Error messages or other handling should be performed by the filter function
         return;
     }
     $matches = array();
     $preg = "/http:\\/\\/[^] \n'\">]*/";
     $mod = str_ireplace('http://www.wikihow.com', '', $comment);
     preg_match_all($preg, $mod, $matches);
     if (sizeof($matches[0]) > 2) {
         $wgOut->errorPage("postcomment", "postcomment_urls_limit");
         return;
     }
     if (trim(strip_tags($comment)) == "") {
         $wgOut->errorpage("postcomment", "postcomment_nopostingtoadd");
         return;
     }
     if (!$t->userCanEdit()) {
         $wgOut->errorpage("postcomment", "postcomment_discussionprotected");
         return;
     }
     $watch = false;
     if ($wgUser->getID() > 0) {
         $watch = $wgUser->isWatched($t);
     }
     $fc = new FancyCaptcha();
     $pass_captcha = $fc->passCaptcha();
     if (!$pass_captcha && $wgUser->getID() == 0) {
         $wgOut->addHTML("Sorry, please enter the correct word. Click <a onclick='window.location.reload(true);'>here</a> to get a new one.<br/><br/>");
         return;
     }
     $article->doEdit($text, "");
     if ($wgRequest->getVal('jsonresponse') == 'true') {
         $article->loadLastEdit(true);
         $this->revId = $article->getRevIdFetched();
     }
     //XX Vu added to notify users of usertalk updates
     if ($t->getNamespace() == NS_USER_TALK) {
         AuthorEmailNotification::notifyUserTalk($t->getArticleID(), $wgUser->getID(), $comment);
     }
     $wgOut->setStatusCode(200);
     if ($wgRequest->getVal('fromajax') == 'true') {
         $wgOut->redirect('');
         $wgTitle = $t;
         $formattedComment = $wgParser->preSaveTransform($formattedComment, $t, $wgUser, new ParserOptions());
         $wgOut->addHTML($wgOut->parse("\n" . $formattedComment));
         return;
     }
 }
function createUserLogin()
{
    global $wgRequest, $wgUser, $wgExternalSharedDB, $wgWikiaEnableConfirmEditExt, $wgEnableCOPPA, $wgDefaultSkin;
    // Init session if necessary
    if (session_id() == '') {
        wfSetupSession();
    }
    $response = new AjaxResponse();
    $response->setCacheDuration(3600 * 24 * 365);
    if (!(($wgRequest->getCheck("wpCreateaccountMail") || $wgRequest->getCheck("wpCreateaccount")) && $wgRequest->wasPosted())) {
        $response->addText(json_encode(array('status' => "ERROR", 'msg' => wfMsgExt('comboajaxlogin-post-not-understood', array('parseinline')), 'type' => 'error')));
        return $response;
    }
    if ($wgRequest->getVal('type', '') == '') {
        $wgRequest->setVal('type', 'signup');
    }
    $form = new AjaxLoginForm($wgRequest);
    $form->load();
    if ($wgEnableCOPPA && !$form->checkDate()) {
        // If the users is too young to legally register.
        $response->addText(json_encode(array('status' => "ERROR", 'msg' => wfMsg('userlogin-unable-info'), 'type' => 'error')));
        return $response;
    }
    $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
    $dbl = wfGetDB(DB_MASTER);
    $dbw->begin();
    $dbl->begin();
    $form->execute('signup');
    $dbw->commit();
    $dbl->commit();
    if ($form->msgtype == "error") {
        if (!$wgWikiaEnableConfirmEditExt) {
            /*theoretically impossible because the only possible error is captcha error*/
            $response->addText(json_encode(array('status' => "ERROR", 'msg' => $form->msg, 'type' => $form->msgtype, 'captchaUrl' => '', 'captcha' => '')));
            return $response;
        }
        $captchaObj = new FancyCaptcha();
        $captcha = $captchaObj->pickImage();
        $captchaIndex = $captchaObj->storeCaptcha($captcha);
        $titleObj = SpecialPage::getTitleFor('Captcha/image');
        $captchaUrl = $titleObj->getLocalUrl('wpCaptchaId=' . urlencode($captchaIndex));
        $response->addText(json_encode(array('status' => "ERROR", 'msg' => $form->msg, 'type' => $form->msgtype, 'captchaUrl' => $captchaUrl, 'captcha' => $captchaIndex)));
        return $response;
    }
    $response->addText(json_encode(array('status' => "OK")));
    return $response;
}
 function writeOutput($par)
 {
     global $wgLang, $wgMemc, $wgDBname, $wgUser;
     global $wgSitename, $wgLanguageCode;
     global $wgFeedClasses, $wgFilterCallback, $wgWhitelistEdit, $wgParser;
     $this->getOutput()->setRobotpolicy("noindex,nofollow");
     $target = !empty($par) ? $par : $this->getRequest()->getVal("target");
     $t = Title::newFromDBKey($target);
     $update = true;
     if (!$t || !$t->userCan('edit')) {
         return;
     }
     if (!$this->getUser()->isAllowed('edit')) {
         return;
     }
     $article = new Article($t);
     $user = $this->getUser()->getName();
     $real_name = User::whoIsReal($this->getUser()->getID());
     if ($real_name == "") {
         $real_name = $user;
     }
     $dateStr = $wgLang->timeanddate(wfTimestampNow());
     $comment = $this->getRequest()->getVal("comment_text");
     foreach ($this->getRequest()->getValues() as $key => $value) {
         if (strpos($key, "comment_text") === 0) {
             $comment = $value;
             break;
         }
     }
     $topic = $this->getRequest()->getVal("topic_name");
     //echo "$dateStr<br/>";
     // remove leading space, tends to be a problem with a lot of talk page comments as it breaks the
     // HTML on the page
     $comment = preg_replace('/\\n[ ]*/', "\n", trim($comment));
     // Check to see if the user is also getting a thumbs up. If so, append the thumbs message and give a thumbs up
     if ($this->getRequest()->getVal('thumb')) {
         $comment .= "\n\n" . wfMsg('qn_thumbs_up');
         $userName = explode(":", $this->getRequest()->getVal('target'));
         ThumbsUp::quickNoteThumb($this->getRequest()->getVal('revold'), $this->getRequest()->getVal('revnew'), $this->getRequest()->getVal('pageid'), $userName[1]);
     }
     $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, $comment);
     if ($this->getRequest()->getVal('fromajax') == 'true') {
         $this->getOutput()->setArticleBodyOnly(true);
     }
     $text = "";
     $r = Revision::newFromTitle($t);
     if ($r) {
         $text = $r->getText();
     }
     $text .= "\n\n{$formattedComment}\n\n";
     $this->getOutput()->setStatusCode(409);
     //echo "updating with text:<br/> $text";
     //exit;
     $tmp = "";
     if ($this->getUser()->isBlocked()) {
         $this->getOutput()->blockedPage();
         return;
     }
     if (!$this->getUser()->getID() && $wgWhitelistEdit) {
         $this->userNotLoggedInPage();
         return;
     }
     if (wfReadOnly()) {
         $this->getOutput()->readOnlyPage();
         return;
     }
     if ($target == "Spam-Blacklist") {
         $this->getOutput()->readOnlyPage();
         return;
     }
     if ($this->getUser()->pingLimiter()) {
         $this->getOutput()->rateLimited();
         return;
     }
     $editPage = new EditPage($article);
     $contentModel = $t->getContentModel();
     $handler = ContentHandler::getForModelID($contentModel);
     $contentFormat = $handler->getDefaultFormat();
     $content = ContentHandler::makeContent($text, $t, $contentModel, $contentFormat);
     $status = Status::newGood();
     if (!wfRunHooks('EditFilterMergedContent', array($this->getContext(), $content, &$status, '', $wgUser, false))) {
         return;
     }
     if (!$status->isGood()) {
         $errors = $status->getErrorsArray(true);
         foreach ($errors as $error) {
             if (is_array($error)) {
                 $error = count($error) ? $error[0] : '';
             }
             if (preg_match('@^spamprotection@', $error)) {
                 $message = 'Error: found spam link';
                 $this->getOutput()->addHTML($message);
                 return;
             }
         }
         $message = 'EditFilterMergedContent returned an error -- cannot post comment';
         return;
     }
     $matches = array();
     $preg = "/http:\\/\\/[^] \n'\">]*/";
     $mod = str_ireplace('http://www.wikihow.com', '', $comment);
     preg_match_all($preg, $mod, $matches);
     if (sizeof($matches[0]) > 2) {
         $this->getOutput()->showErrorPage("postcomment", "postcomment_urls_limit");
         return;
     }
     if (trim(strip_tags($comment)) == "") {
         $this->getOutput()->showErrorPage("postcomment", "postcomment_nopostingtoadd");
         return;
     }
     if (!$t->userCan('edit')) {
         $this->getOutput()->showErrorPage("postcomment", "postcomment_discussionprotected");
         return;
     }
     $watch = false;
     if ($this->getUser()->getID() > 0) {
         $watch = $this->getUser()->isWatched($t);
     }
     $fc = new FancyCaptcha();
     $pass_captcha = $fc->passCaptcha();
     if (!$pass_captcha && $this->getUser()->getID() == 0) {
         $this->getOutput()->addHTML("Sorry, please enter the correct word. Click <a onclick='window.location.reload(true);'>here</a> to get a new one.<br/><br/>");
         return;
     }
     $article->doEdit($text, "");
     if ($this->getRequest()->getVal('jsonresponse') == 'true') {
         $this->revId = $article->getRevIdFetched();
     }
     // Notify users of usertalk updates
     if ($t->getNamespace() == NS_USER_TALK) {
         AuthorEmailNotification::notifyUserTalk($t->getArticleID(), $this->getUser()->getID(), $comment);
     }
     $this->getOutput()->setStatusCode(200);
     if ($this->getRequest()->getVal('fromajax') == 'true') {
         $this->getOutput()->redirect('');
         $this->getContext()->setTitle($t);
         $formattedComment = $wgParser->preSaveTransform($formattedComment, $t, $this->getUser(), new ParserOptions());
         $this->getOutput()->addHTML($this->getOutput()->parse("\n" . $formattedComment));
         return;
     }
 }
 /**
  * create wiki form
  *
  * @access public
  *
  * @param $subpage Mixed: subpage of SpecialPage
  */
 public function createWikiForm()
 {
     global $wgOut, $wgUser, $wgExtensionsPath, $wgScriptPath, $wgStylePath;
     global $wgRequest, $wgDBname, $wgMemc;
     wfProfileIn(__METHOD__);
     #-
     $aTopLanguages = explode(',', wfMsg('autocreatewiki-language-top-list'));
     $aLanguages = wfGetFixedLanguageNames();
     asort($aLanguages);
     #-
     $hubs = WikiFactoryHub::getInstance();
     $aCategories = $hubs->getCategories();
     #--
     $params = $this->fixSessionKeys();
     if (empty($params) && empty($this->mPosted)) {
         $ip = $wgRequest->getIP();
         $key = wfMemcKey(self::CACHE_LOGIN_KEY, $wgDBname, $ip);
         $params = $wgMemc->get($key);
     }
     $fancyCaptcha = new FancyCaptcha();
     $wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"{$wgStylePath}/common/form.css\" />");
     $wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"{$wgStylePath}/common/wikia_ui/tabs.css\" />");
     // RT #19245
     $wgOut->addStyle("common/form.ie7.css", '', 'IE 7');
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgStylePath}/common/form.js\"></script>");
     /**
      * run template
      */
     $this->mAction = $wgRequest->getVal("action", false);
     if ($this->mAction == "reload") {
         $params['wiki-name'] = $wgRequest->getVal('wiki-name', false);
         $params['wiki-domain'] = $wgRequest->getVal('wiki-domain', false);
         $params['wiki-category'] = $wgRequest->getVal('wiki-category', false);
         $params['wiki-language'] = $wgRequest->getVal('wiki-language', $wgUser->getOption('language'));
         $params['wiki-type'] = $wgRequest->getVal('wiki-type', false);
     }
     $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $oTmpl->set_vars(array("subDomain" => $this->mDefSubdomain, "wgUser" => $wgUser, "wgExtensionsPath" => $wgExtensionsPath, "aLanguages" => $aLanguages, "aTopLanguages" => $aTopLanguages, "aCategories" => $aCategories, "wgScriptPath" => $wgScriptPath, "mTitle" => $this->mTitle, "mType" => $this->mType, "mLanguage" => $this->mLang, "mPostedErrors" => $this->mPostedErrors, "wgStylePath" => $wgStylePath, "captchaForm" => $fancyCaptcha->getForm(), "params" => $params, "subName" => $this->mDefSitename, "defaultDomain" => self::DEFAULT_DOMAIN, "mDomains" => $this->mDomains, "mSitenames" => $this->mSitenames));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->addHtml($oTmpl->render("create-wiki-form"));
     wfProfileOut(__METHOD__);
     return;
 }