예제 #1
0
파일: Wiki.php 프로젝트: ErdemA/wikihow
 /**
  * Initialize the object to be known as $wgArticle for special cases
  */
 function initializeSpecialCases(&$title, &$output, $request)
 {
     global $wgRequest, $wgUseGoogleMini, $IP;
     wfProfileIn('MediaWiki::initializeSpecialCases');
     $action = $this->getVal('Action');
     $search = $request->getVal('search');
     if ($this->getVal('Server') != "http://" . $_SERVER['HTTP_HOST'] && !preg_match("@[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+@", $_SERVER['HTTP_HOST']) && !IS_SPARE_HOST && !IS_CLOUD_SITE) {
         $output->redirect($this->getVal('Server') . $_SERVER['REQUEST_URI'], 301);
         return;
     }
     if (!$title or $title->getDBkey() == '') {
         $title = SpecialPage::getTitleFor('Badtitle');
         # Die now before we mess up $wgArticle and the skin stops working
         throw new ErrorPageError('badtitle', 'badtitletext');
     } else {
         if (!is_null($search) && $search !== '' && $wgUseGoogleMini) {
             //XXCHANGED
             if ($wgRequest->getVal('advanced', null) == null && $wgUseGoogleMini) {
                 $title = Title::makeTitle(NS_SPECIAL, 'LSearch');
                 require_once "{$IP}/extensions/wikihow/LSearch.body.php";
                 $s = new LSearch();
                 $s->execute('');
             } else {
                 require_once "{$IP}/includes/SpecialSearch.php";
                 $title = Title::makeTitle(NS_SPECIAL, 'Search');
                 #$s = new SpecialSearch();
                 #$s->execute('');
                 wfSpecialSearch();
             }
         } else {
             if ($title->getInterwiki() != '') {
                 if ($rdfrom = $request->getVal('rdfrom')) {
                     $url = $title->getFullURL('rdfrom=' . urlencode($rdfrom));
                 } else {
                     $url = $title->getFullURL();
                 }
                 /* Check for a redirect loop */
                 if (!preg_match('/^' . preg_quote($this->getVal('Server'), '/') . '/', $url) && $title->isLocal()) {
                     $output->redirect($url);
                 } else {
                     $title = SpecialPage::getTitleFor('Badtitle');
                     throw new ErrorPageError('badtitle', 'badtitletext');
                 }
             } else {
                 if ($action == 'view' && !$wgRequest->wasPosted() && (!isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title']) && !count(array_diff(array_keys($this->GET), array('action', 'title')))) {
                     $targetUrl = $title->getFullURL();
                     // Redirect to canonical url, make it a 301 to allow caching
                     global $wgUsePathInfo;
                     if ($targetUrl == $wgRequest->getFullRequestURL()) {
                         $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
                         if ($wgUsePathInfo) {
                             $message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
                         } else {
                             $message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
                         }
                         wfHttpError(500, "Internal error", $message);
                         return false;
                     } else {
                         $output->setSquidMaxage(1200);
                         $output->redirect($targetUrl, '301');
                     }
                 } else {
                     if (NS_SPECIAL == $title->getNamespace()) {
                         /* actions that need to be made when we have a special pages */
                         SpecialPage::executePath($title);
                     } else {
                         /* No match to special cases */
                         wfProfileOut('MediaWiki::initializeSpecialCases');
                         return false;
                     }
                 }
             }
         }
     }
     /* Did match a special case */
     wfProfileOut('MediaWiki::initializeSpecialCases');
     return true;
 }