Remove broken walloon link for the moment; sql error breaks imports
[mediawiki.git] / wiki.phtml
blob86605c8fb645194e1817196870ade52fd1b99b43
1 <?
2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
6 unset( $IP );
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 include_once( "./LocalSettings.php" );
10 # Windows requires ';' as separator, ':' for Unix
11 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
12 ini_set( "include_path", "$IP$sep$include_path" );
14 include_once( "Setup.php" );
16 wfProfileIn( "main-misc-setup" );
17 OutputPage::setEncodings(); # Not really used yet
19 # Useful debug output
20 if ( function_exists( "getallheaders" ) ) {
21         wfDebug( "\nStart request\n" );
22         wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
23         $headers = getallheaders();
24         foreach ($headers as $name => $value) {
25                 wfDebug( "$name: $value\n" );
26         }
27         wfDebug( "\n" );
28 } else {
29         wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
32 # Query string fields
34 global $action, $title, $search, $go, $target, $printable;
35 global $returnto, $diff, $oldid, $curid;
37 # Placeholders in case of DB error
38 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
39 $wgArticle = new Article($wgTitle);
41 $action = strtolower( trim( $action ) );
42 if ( "" == $action ) { $action = "view"; }
43 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
45 if ( "" == $title && "delete" != $action ) {
46         $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
47 } elseif ( $curid ) {
48         # URLs like this are generated by RC, because rc_title isn't always accurate
49         $wgTitle = Title::newFromID( $curid );
50 } else {
51         $wgTitle = Title::newFromURL( $title );
53 wfProfileOut( "main-misc-setup" );
55 if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
56         $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
57         $wgOut->errorpage( "badtitle", "badtitletext" );
58 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
59         wfSpecialPage();
60 } else if ( "" != $search ) {
61         if($go) {
62                 wfGo( $search );
63         } else {
64                 wfSearch( $search );
65         }
66 } else {
67         if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
68                 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
69         }       
70         
71         switch( $wgTitle->getNamespace() ) {
72         case 6:
73                 include_once( "ImagePage.php" );
74                 $wgArticle = new ImagePage( $wgTitle );
75                 break;
76         default:
77                 $wgArticle = new Article( $wgTitle );
78         }
80         switch( $action ) {
81                 case "view":
82                 case "watch":
83                 case "unwatch":
84                 case "delete":
85                 case "revert":
86                 case "rollback":
87                 case "protect":
88                 case "unprotect":
89                         $wgArticle->$action();
90                         break;
91                 case "print":
92                         $wgArticle->view();
93                         break;
94                 case "edit":
95                 case "submit":
96                         include_once( "EditPage.php" );
97                         $editor = new EditPage( $wgArticle );
98                         $editor->$action();
99                         break;
100                 case "history":
101                         include_once( "PageHistory.php" );
102                         $history = new PageHistory( $wgArticle );
103                         $history->history();
104                         break;
105                 default:
106                         $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
107         }
110 $wgOut->output();
111 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
112 logProfilingData();
113 wfDebug( "Request ended normally\n" );