cd2a88066a9c634cb6e0d825818232a7a9d9d673
[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 global $IP;
14 include_once( "./LocalSettings.php" );
15 include_once( "$IP/Setup.php" );
16
17 wfProfileIn( "main-misc-setup" );
18 OutputPage::setEncodings(); # Not really used yet
19
20 # Useful debug output
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
28 # Query string fields
29 #
30 global $action, $title, $search, $go, $target, $printable;
31 global $returnto, $diff, $oldid;
32
33 $action = strtolower( trim( $action ) );
34 if ( "" == $action ) { $action = "view"; }
35 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
36
37 if ( "" == $title && "delete" != $action ) {
38 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
39 } else {
40 $wgTitle = Title::newFromURL( $title );
41 # if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
42 if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
43 $wgOut->errorpage( "badtitle", "badtitletext" );
44 $wgOut->output();
45 exit;
46 }
47 }
48 wfProfileOut();
49 if ( -1 == $wgTitle->getNamespace() ) {
50 wfSpecialPage();
51 } else if ( "" != $search ) {
52 if($go) {
53
54 wfGo ($search);
55
56 } else {
57
58 wfSearch( $search );
59
60 }
61
62 } else {
63 switch( $wgTitle->getNamespace() ) {
64 case 6:
65 include_once( "$IP/ImagePage.php" );
66 $wgArticle = new ImagePage( $wgTitle );
67 break;
68 default:
69 $wgArticle = new Article( $wgTitle );
70 }
71
72 switch( $action ) {
73 case "view":
74 case "watch":
75 case "unwatch":
76 case "history":
77 case "delete":
78 case "revert":
79 case "rollback":
80 case "protect":
81 case "unprotect":
82 $wgArticle->$action();
83 break;
84 case "print":
85 $wgArticle->view();
86 break;
87 case "edit":
88 case "submit":
89 include_once( "$IP/EditPage.php" );
90 $editor = new EditPage( $wgArticle );
91 $editor->$action();
92 break;
93 default:
94 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
95 }
96 }
97
98 $wgOut->output();
99 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
100
101 ?>