fixed a few minor bugs and misc. notices
[mediawiki.git] / wiki.phtml
blobadcfe63f451dd3004792c5178b1391531679da51
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;
37 $action = strtolower( trim( $action ) );
38 if ( "" == $action ) { $action = "view"; }
39 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
41 if ( "" == $title && "delete" != $action ) {
42         $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
43 } else {
44         $wgTitle = Title::newFromURL( $title );
45 #       if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
46         if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
47                 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
48                 $wgOut->errorpage( "badtitle", "badtitletext" );
49                 $wgOut->output();
50                 exit;
51         }
53 wfProfileOut( "main-misc-setup" );
55 if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
56         wfSpecialPage();
57 } else if ( "" != $search ) {
58         if($go) {
59                 wfGo( $search );
60         } else {
61                 wfSearch( $search );
62         }
63 } else {
64         if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
65                 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
66         }       
67         
68         switch( $wgTitle->getNamespace() ) {
69         case 6:
70                 include_once( "ImagePage.php" );
71                 $wgArticle = new ImagePage( $wgTitle );
72                 break;
73         default:
74                 $wgArticle = new Article( $wgTitle );
75         }
77         switch( $action ) {
78                 case "view":
79                 case "watch":
80                 case "unwatch":
81                 case "delete":
82                 case "revert":
83                 case "rollback":
84                 case "protect":
85                 case "unprotect":
86                         $wgArticle->$action();
87                         break;
88                 case "print":
89                         $wgArticle->view();
90                         break;
91                 case "edit":
92                 case "submit":
93                         include_once( "EditPage.php" );
94                         $editor = new EditPage( $wgArticle );
95                         $editor->$action();
96                         break;
97                 case "history":
98                         include_once( "PageHistory.php" );
99                         $history = new PageHistory( $wgArticle );
100                         $history->history();
101                         break;
102                 default:
103                         $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
104         }
107 $wgOut->output();
108 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
109 logProfilingData();
110 wfDebug( "Request ended normally\n" );