c286b065bc29054e8634cd02c4e47765ec719bc0
[lhc/web/wiklou.git] / wiki.phtml
1 <?
2 # Main wiki script; see design.doc
3 #
4 $wgRequestTime = microtime();
5
6 session_cache_limiter( "private, must-revalidate" );
7 session_start();
8 session_register( "wsUserID" );
9 session_register( "wsUserName" );
10 session_register( "wsUserPassword" );
11 session_register( "wsUploadFiles" );
12
13 unset( $IP );
14 ini_set( "allow_url_fopen", 0 ); # For security...
15 include_once( "./LocalSettings.php" );
16
17 # Windows requires ';' as separator, ':' for Unix
18 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
19 ini_set( "include_path", "$IP$sep$include_path" );
20
21 include_once( "Setup.php" );
22
23 wfProfileIn( "main-misc-setup" );
24 OutputPage::setEncodings(); # Not really used yet
25
26 # Useful debug output
27 wfDebug( "\nStart request\n" );
28 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
29 $headers = getallheaders();
30 foreach ($headers as $name => $value) {
31 wfDebug( "$name: $value\n" );
32 }
33 wfDebug( "\n" );
34
35 # Query string fields
36 #
37 global $action, $title, $search, $go, $target, $printable;
38 global $returnto, $diff, $oldid;
39
40 $action = strtolower( trim( $action ) );
41 if ( "" == $action ) { $action = "view"; }
42 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
43
44 if ( "" == $title && "delete" != $action ) {
45 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
46 } else {
47 $wgTitle = Title::newFromURL( $title );
48 # if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
49 if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
50 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
51 $wgOut->errorpage( "badtitle", "badtitletext" );
52 $wgOut->output();
53 exit;
54 }
55 }
56 wfProfileOut( "main-misc-setup" );
57
58 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 }
79
80 switch( $action ) {
81 case "view":
82 case "watch":
83 case "unwatch":
84 case "history":
85 case "delete":
86 case "revert":
87 case "rollback":
88 case "protect":
89 case "unprotect":
90 $wgArticle->$action();
91 break;
92 case "print":
93 $wgArticle->view();
94 break;
95 case "edit":
96 case "submit":
97 include_once( "EditPage.php" );
98 $editor = new EditPage( $wgArticle );
99 $editor->$action();
100 break;
101 default:
102 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
103 }
104 }
105
106 $wgOut->output();
107 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
108
109 ?>