示例#1
1
/**
 * Called to display the Special:ReviewMerge page
 *
 * @param unknown_type $par
 * @param unknown_type $specialPage
 */
function wfSpecialReviewMerge($par = NULL, $specialPage)
{
    global $wgOut, $wgScriptPath, $wgUser, $wrSidebarHtml;
    $reviewForm = new ReviewForm();
    // read query parameters into variables
    $unmerge = '';
    if (!$reviewForm->readQueryParms($par)) {
        $wgOut->setPageTitle('Review merge');
        $results = '<p>You must click on a "review" link on Recent Changes or a page history in order to review the merge.</p>';
    } else {
        if ($reviewForm->isMarkPatrolled()) {
            $wgOut->setPagetitle(wfMsg('markedaspatrolled'));
            $results = $reviewForm->markPatrolled();
        } else {
            if ($reviewForm->isUnmerge()) {
                if (!$wgUser->isLoggedIn()) {
                    if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
                        User::SetupSession();
                    }
                    $title = Title::makeTitle(NS_SPECIAL, 'ReviewMerge/' . $par);
                    $requestData = array();
                    if ($title) {
                        $requestData['returnto'] = $title->getPrefixedUrl();
                    }
                    $request = new FauxRequest($requestData);
                    require_once 'includes/SpecialUserlogin.php';
                    $form = new LoginForm($request);
                    $form->mainLoginForm("You need to sign in to unmerge pages<br/><br/>", '');
                    return;
                }
                if ($wgUser->isBlocked()) {
                    $wgOut->blockedPage();
                    return;
                } else {
                    if (wfReadOnly()) {
                        $wgOut->readOnlyPage();
                        return;
                    }
                }
                $wgOut->setPagetitle('Unmerge');
                $results = $reviewForm->unmerge();
            } else {
                $wgOut->setPageTitle('Review merge');
                $wrSidebarHtml = $reviewForm->getReviewSideText();
                $results = $reviewForm->getReviewResults();
                $unmerge = $reviewForm->getUnmergeInfo();
            }
        }
    }
    $wgOut->addHTML($unmerge . $results);
}
示例#2
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang, $wgOut, $wrAdminUserName;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($wgUser->isLoggedIn()) {
         if ($wgUser->getName() == $wrAdminUserName) {
             $user = User::newFromName($par);
         } else {
             $user = $wgUser;
         }
         $msg = '';
         if ($user->getID() > 0) {
             $user->setOption('enotifwatchlistpages', 0);
             $user->setOption('enotifusertalkpages', 0);
             $user->setOption('enotifminoredits', 0);
             $user->setOption('disablemail', 1);
             $user->saveSettings();
         } else {
             $msg = $user->getName() . ' not found';
         }
         $this->show($msg);
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('Unsubscribe')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in to unsubscribe<br/><br/>", '');
     }
 }
 function submit_OTP($user_id, $user_name)
 {
     global $wgRequest, $wgOut, $wgUser;
     $otp_DB = "";
     $attempts = 0;
     # When OTP button is pressed we we check if the OTP is set on DB.
     if ($wgRequest->getCheck('clickBotOTP')) {
         SpecialLatch::accDB_useraccid($user_id, $user_id, $acc_id, $otp_DB, $attempts);
         # CSRF protection
         if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) {
             return;
         } else {
             # If it's correct we set again the correct user name to session and redirect to the main page
             if ($otp_DB == $wgRequest->getText('txt_OTP')) {
                 $wgRequest->setSessionData('wsUserName', $user_name);
                 $fullURL = $wgRequest->getRequestURL();
                 $urlMainPage = explode("?", $fullURL);
                 $wgOut->redirect($urlMainPage[0]);
             } else {
                 if ($attempts < 2) {
                     SpecialLatch::updDB_useraccid($user_id, $acc_id, $otp_DB, $attempts + 1);
                     $wgOut->addWikiText(wfMsg('latch-OTP-error'));
                 } else {
                     $wgUser->logout();
                     $wgOut->clearHTML();
                     $specialUserlogin = new LoginForm();
                     $specialUserlogin->load();
                     $error = $specialUserlogin->mAbortLoginErrorMsg ?: 'wrongpassword';
                     $specialUserlogin->mainLoginForm($specialUserlogin->msg($error)->text());
                 }
             }
         }
     }
 }
示例#4
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang, $wgOut, $wrAdminUserName;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($wgUser->isLoggedIn() && $wgUser->getName() == $wrAdminUserName) {
         $pieces = explode('/', $par);
         if (count($pieces) > 1 && strlen($pieces[1]) == 8) {
             $pieces[1] .= '000000';
         }
         $user = User::newFromName($pieces[0]);
         $msg = '';
         if (count($pieces) == 2 && $user->getID() > 0 && strlen($pieces[1]) == 14) {
             $user->setOption('wrnoads', $pieces[1]);
             $user->saveSettings();
         } else {
             $msg = $pieces[0] . ' not found or date incorrect';
         }
         $this->show($msg);
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('NoAds')));
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in<br/><br/>", '');
     }
 }
示例#5
0
function wfSpecialAddPage($par)
{
    global $wgOut, $wgRequest, $wgUser, $wgLang, $wgCommandLineMode, $wgScriptPath;
    $error = '';
    $editParms = '';
    $title = null;
    $addPageForm = new AddPageForm();
    // read query parameters into variables
    $addPageForm->readQueryParms($par);
    if (!$wgUser->isLoggedIn()) {
        if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
            User::SetupSession();
        }
        $request = new FauxRequest(array('returnto' => $wgLang->specialPage('AddPage') . '/' . $addPageForm->namespace));
        require_once 'includes/SpecialUserlogin.php';
        $form = new LoginForm($request);
        $form->mainLoginForm("You need to log in to add pages<br/><br/>", '');
        return;
    }
    if ($wgUser->isBlocked()) {
        $wgOut->blockedPage();
        return;
    }
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    // redirect?
    list($redirTitle, $error) = $addPageForm->getRedirTitleOrError();
    if ($redirTitle != null) {
        $editParms = $addPageForm->getEditParms();
        $wgOut->redirect($redirTitle->getFullURL('action=edit' . $editParms));
        return;
    }
    // get form text
    $formHtml = $addPageForm->getFormHtml();
    $pageTitle = $addPageForm->getPageTitle();
    $pageHeading = $addPageForm->getPageHeading();
    $msgId = $addPageForm->getMessageId();
    // set up page
    $wgOut->setPagetitle($pageTitle);
    $wgOut->setArticleRelated(false);
    $wgOut->setRobotpolicy('noindex,nofollow');
    if ($addPageForm->namespace == NS_PERSON || $addPageForm->namespace == NS_FAMILY || $addPageForm->namespace == NS_SOURCE || $addPageForm->namespace == NS_PLACE) {
        $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/search.31.js\"></script>");
        $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
    }
    $wgOut->addHTML("<h2>{$pageHeading}</h2>");
    if ($error) {
        $wgOut->addHTML("<p><font color=red>{$error}</font></p>");
    }
    $wgOut->addHTML($formHtml);
    $wgOut->addWikiText("\n\n" . wfmsg($msgId));
}
示例#6
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang;
     if ($wgUser->isLoggedIn()) {
         $this->show();
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('Dashboard')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in to view your dashboard<br/><br/>", '');
     }
 }
示例#7
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang;
     if ($wgUser->isLoggedIn()) {
         switch ($this->action) {
             case 'newPage':
                 $this->newPage();
                 break;
             default:
                 $this->show();
                 break;
         }
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('MyRelate')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in before using MyRelate<br/><br/>", '');
     }
 }
示例#8
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang, $wgOut;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($wgUser->isLoggedIn()) {
         switch ($this->action) {
             case 'newTree':
                 $this->newTree();
                 break;
             case 'shareTree':
                 $this->shareTree();
                 break;
             case 'renameTree':
                 $this->renameTree();
                 break;
             case 'deleteTree':
                 $this->deleteTree();
                 break;
             default:
                 $this->show();
                 break;
         }
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('FamilyTree')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in before creating trees<br/><br/>", '');
     }
 }
示例#9
0
 public function execute()
 {
     global $wgCommandLineMode, $wgLang, $wgOut;
     if ($this->username) {
         if (!$this->user || !$this->user->getID()) {
             $wgOut->addHtml('<p><font color="red">User not found</font></p>');
             return;
         }
         if ($this->otherUsername) {
             $this->showUserNetwork();
         } else {
             $this->showFullNetwork();
         }
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('Network')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in to view your network<br/><br/>", '');
     }
 }
示例#10
0
/**
 * Called to display the Special:Merge page
 *
 * @param unknown_type $par
 * @param unknown_type $specialPage
 */
function wfSpecialMerge($par = NULL, $specialPage)
{
    global $wgOut, $wgScriptPath, $wgCommandLineMode, $wrSidebarHtml, $wgMemc, $wgUser;
    //		$sideText = '';
    $mergeForm = new MergeForm();
    // read query parameters into variables
    $mergeForm->readQueryParms($par);
    if (!$wgUser->isLoggedIn()) {
        if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
            User::SetupSession();
        }
        $mergeTargetTitle = $mergeForm->getMergeTargetTitle();
        $requestData = array();
        if ($mergeTargetTitle) {
            $requestData['returnto'] = $mergeTargetTitle->getPrefixedUrl();
        }
        $request = new FauxRequest($requestData);
        require_once 'includes/SpecialUserlogin.php';
        $form = new LoginForm($request);
        $form->mainLoginForm("You need to sign in to merge pages<br/><br/>", '');
        return;
    }
    if ($wgUser->isBlocked()) {
        $wgOut->blockedPage();
        return;
    }
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    $isGedcom = $mergeForm->isGedcom();
    $wgOut->setPageTitle($isGedcom ? 'Update pages' : 'Merge pages');
    if ($mergeForm->getFormAction() == 'Cancel') {
        $output = '<H2>Merge Cancelled</H2><p>You can use the <b>back</b> button on your browser to navigate back to where you were, or select an item from the menu.</p>';
    } else {
        if ($mergeForm->getFormAction() == 'NotMatch') {
            $output = $mergeForm->getNotMatchResults();
        } else {
            if ($mergeForm->getFormAction() != 'Merge' || !$mergeForm->preMerge()) {
                $output = '<H2>Unable to merge</H2>' . $mergeForm->getWarnings() . '<p>Press the <b>back</b> button on your browser to go back to the Compare page.</p>';
            } else {
                if ($mergeForm->isSecondPhase()) {
                    // disallow merging the same page twice in a row (result of double-click)
                    if ($mergeForm->isGedcom()) {
                        $cacheKey = 'mergekey:ged:' . $mergeForm->gedcomId . $mergeForm->gedcomKey;
                    } else {
                        $cacheKey = 'mergekey:' . $wgUser->getID() . $mergeForm->editToken;
                    }
                    if (!$wgMemc->get($cacheKey)) {
                        $wgMemc->set($cacheKey, 't', 5);
                        $output = $mergeForm->doMerge();
                    }
                } else {
                    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/merge.10.js\"></script>");
                    //		$mergeText = $isGedcom ? 'update' : 'merge';
                    //		$mergeButton = $isGedcom ? 'Update' : 'Merge';
                    //		$sideText = '<h3>Instructions</h3><p>' .
                    //						($mergeForm->getMergesCount() > 1 ? "For each set of pages to $mergeText, check" : 'Check') .
                    //						" the boxes next to the pieces of information you want included in the {$mergeText}d page.</p>" .
                    //						($isGedcom ? '<p><b>Updating pages is optional.</b>  It is not necessary or desirable to update these pages unless you have more accurate information or reliable sources to add.</b></p>'
                    //								: '<p>The <i>target</i> is the page that the other page(s) will be merged into.</p>').
                    //						'<p>The box colors are for your information only:</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>Once you have chosen which pieces of information to include, click on the \"$mergeButton\" button at the bottom of the screen to $mergeText the pages.</p>".
                    //						'<p>(<a href="/wiki/Help:Merging_pages">more help</a>)</p>';
                    $output = $mergeForm->getMergeResults();
                }
            }
        }
    }
    //   $skin = $wgUser->getSkin();
    $wrSidebarHtml = wfMsgWikiHtml('MergeHelp');
    $wgOut->addHTML($output);
}
示例#11
0
 public function getResults()
 {
     global $wgUser, $wgCommandLineMode, $wgLang;
     if ($this->userName) {
         $results = '<p>Changes made in the past 24 hours are not reflected</p>';
         $u = User::newFromName($this->userName);
         if (!$u || !$u->getID()) {
             $results .= '<font color="red">User not found</font>';
         } else {
             $sk = $wgUser->getSkin();
             // issue db query to get the family trees, sort afterward
             $dbr =& wfGetDB(DB_SLAVE);
             $res = $dbr->select(array('watchlist', 'duplicates'), array('dp_namespace', 'dp_title', 'dp_match_titles'), array('wl_user' => $u->getID(), 'wl_namespace=dp_namespace', 'wl_title=dp_title'));
             $compareTitle = Title::makeTitle(NS_SPECIAL, 'Compare');
             $searchTitle = Title::makeTitle(NS_SPECIAL, 'Search');
             $found = false;
             while ($row = $dbr->fetchObject($res)) {
                 if (!$found) {
                     $results .= '<ul>';
                     $found = true;
                 }
                 $title = Title::makeTitle($row->dp_namespace, $row->dp_title);
                 $namespace = $row->dp_namespace == NS_PERSON ? 'Person' : 'Family';
                 if ($row->dp_match_titles) {
                     $baseTitle = $compareTitle;
                     $query = 'ns=' . $namespace . '&compare=' . urlencode($row->dp_title . '|' . $row->dp_match_titles);
                 } else {
                     $baseTitle = $searchTitle;
                     $query = 'match=on&ns=' . $namespace . '&pagetitle=' . urlencode($row->dp_title);
                 }
                 $results .= '<li>' . $sk->makeKnownLinkObj($baseTitle, htmlspecialchars($title->getPrefixedText()), $query) . ' &nbsp; (<i>' . $sk->makeKnownLinkObj($baseTitle, 'open in new window', $query, '', '', 'target="_blank"') . '</i>)</li>';
             }
             $dbr->freeResult($res);
             if ($found) {
                 $results .= '</ul>';
             } else {
                 $results .= '<p>No possible duplicates found.</p>';
             }
         }
         return $results;
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('ShowDuplicates')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in to view your possible duplicates<br/><br/>", '');
         return '';
     }
 }
 public static function wfLoginHook(&$returnTo, &$returnToQuery, &$type)
 {
     global $wgUser, $wgOut, $wgRequest, $wgTitle;
     $acc_id = "";
     $msg = "";
     $app_id = "";
     $secret = "";
     $type = 'error';
     $two_factor_token = "";
     $user_id = "";
     # We remove the user's name to "freeze" the session
     $wgRequest->setSessionData('wsUserName', "");
     # If app_id, secret, user_id and the account_id are already in the DB, we take them
     SpecialLatch::accDB_appsecret($app_id, $secret);
     SpecialLatch::accDB_useraccid($wgUser->getId(), $user_id, $acc_id);
     # If the user doesn't have Latch configured we redirect him to Main Page without checking anything
     if (!empty($user_id) && !empty($acc_id)) {
         # We call the Status function from the Latch SDK
         $api = new Latch($app_id, $secret);
         $statusResponse = $api->status($acc_id);
         $responseData = $statusResponse->getData();
         $responseError = $statusResponse->getError();
         if (empty($statusResponse) || empty($responseData) && empty($responseError)) {
             return false;
         } else {
             # If everything is OK and the status is on, we redirect the user to the main page and set the user's name again
             if (!empty($responseData) && $responseData->{"operations"}->{$app_id}->{"status"} === "on") {
                 if (!empty($responseData->{"operations"}->{$app_id}->{"two_factor"})) {
                     $two_factor_token = $responseData->{"operations"}->{$app_id}->{"two_factor"}->{"token"};
                     # We have another special page for the OTP page. We insert the OTP token on DB and we redirect to that page
                     if (!empty($two_factor_token)) {
                         SpecialLatch::updDB_useraccid($user_id, $acc_id, $two_factor_token);
                         $wgOut->redirect(SpecialPage::getTitleFor('LatchOTP')->getFullURL('', false, PROTO_CURRENT));
                     }
                 } else {
                     SpecialLatch::putUserInSession();
                 }
             } else {
                 if (!empty($responseData) && $responseData->{"operations"}->{$app_id}->{"status"} === "off") {
                     $wgUser->logout();
                     $specialUserlogin = new LoginForm();
                     $specialUserlogin->load();
                     $error = $specialUserlogin->mAbortLoginErrorMsg ?: 'wrongpassword';
                     $specialUserlogin->mainLoginForm($specialUserlogin->msg($error)->text());
                 } else {
                     SpecialLatch::putUserInSession();
                 }
             }
         }
     } else {
         SpecialLatch::putUserInSession();
     }
     return true;
 }