moving stuff from index.php to includes/Wiki.php
[lhc/web/wiklou.git] / index.php
1 <?php
2 /**
3 * Main wiki script; see docs/design.txt
4 * @package MediaWiki
5 */
6 $wgRequestTime = microtime();
7
8 unset( $IP );
9 @ini_set( 'allow_url_fopen', 0 ); # For security...
10
11 if ( isset( $_REQUEST['GLOBALS'] ) ) {
12 die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
13 }
14
15 # Valid web server entry point, enable includes.
16 # Please don't move this line to includes/Defines.php. This line essentially defines
17 # a valid entry point. If you put it in includes/Defines.php, then any script that includes
18 # it becomes an entry point, thereby defeating its purpose.
19 define( 'MEDIAWIKI', true );
20 require_once( './includes/Defines.php' );
21
22 if( !file_exists( 'LocalSettings.php' ) ) {
23 $IP = "." ;
24 require_once( 'includes/DefaultSettings.php' ); # used for printing the version
25 ?>
26 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
27 <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
28 <head>
29 <title>MediaWiki <?php echo $wgVersion ?></title>
30 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
31 <style type='text/css' media='screen, projection'>
32 html, body {
33 color: #000;
34 background-color: #fff;
35 font-family: sans-serif;
36 text-align: center;
37 }
38
39 h1 {
40 font-size: 150%;
41 }
42 </style>
43 </head>
44 <body>
45 <img src='skins/common/images/mediawiki.png' alt='The MediaWiki logo' />
46
47 <h1>MediaWiki <?php echo $wgVersion ?></h1>
48 <div class='error'>
49 <?php
50 if ( file_exists( 'config/LocalSettings.php' ) ) {
51 echo( "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory." );
52 } else {
53 echo( "Please <a href='config/index.php' title='setup'>setup the wiki</a> first." );
54 }
55 ?>
56
57 </div>
58 </body>
59 </html>
60 <?php
61 die();
62 }
63
64 require_once( './LocalSettings.php' );
65 require_once( 'includes/Setup.php' );
66
67 wfProfileIn( 'main-misc-setup' );
68 OutputPage::setEncodings(); # Not really used yet
69
70
71 # The wiki action class
72 require_once ( "includes/Wiki.php" ) ;
73 $wgTheWiki = new MediaWikiType ;
74
75
76 # Query string fields
77 $action = $wgRequest->getVal( 'action', 'view' );
78 $title = $wgRequest->getVal( 'title' );
79
80 if ($wgRequest->getVal( 'printable' ) == 'yes') {
81 $wgOut->setPrintable();
82 }
83
84 if ( '' == $title && 'delete' != $action ) {
85 $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
86 } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
87 # URLs like this are generated by RC, because rc_title isn't always accurate
88 $wgTitle = Title::newFromID( $curid );
89 } else {
90 $wgTitle = Title::newFromURL( $title );
91 /* check variant links so that interwiki links don't have to worry about
92 the possible different language variants
93 */
94 if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
95 $wgContLang->findVariantLink( $title, $wgTitle );
96
97 }
98 wfProfileOut( 'main-misc-setup' );
99
100 # Debug statement for user levels
101 // print_r($wgUser);
102
103 $search = $wgRequest->getText( 'search' );
104 if( !is_null( $search ) && $search !== '' ) {
105 // Compatibility with old search URLs which didn't use Special:Search
106 // Do this above the read whitelist check for security...
107 $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
108 }
109
110 # If the user is not logged in, the Namespace:title of the article must be in
111 # the Read array in order for the user to see it. (We have to check here to
112 # catch special pages etc. We check again in Article::view())
113 if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
114 $wgOut->loginToUse();
115 $wgOut->output();
116 exit;
117 }
118
119
120 $wgTheWiki->mSearch = $search ;
121 $wgTheWiki->main_action () ;
122 # $search = $wgTheWiki->mSearch ; # Not needed
123
124
125 # Deferred updates aren't really deferred anymore. It's important to report errors to the
126 # user, and that means doing this before OutputPage::output(). Note that for page saves,
127 # the client will wait until the script exits anyway before following the redirect.
128 wfProfileIn( 'main-updates' );
129 foreach ( $wgDeferredUpdateList as $up ) {
130 $up->doUpdate();
131 }
132 wfProfileOut( 'main-updates' );
133
134 wfProfileIn( 'main-cleanup' );
135 $wgLoadBalancer->saveMasterPos();
136
137 # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
138 $wgLoadBalancer->commitAll();
139
140 $wgOut->output();
141
142 foreach ( $wgPostCommitUpdateList as $up ) {
143 $up->doUpdate();
144 }
145
146 wfProfileOut( 'main-cleanup' );
147
148 logProfilingData();
149 $wgLoadBalancer->closeAll();
150 wfDebug( "Request ended normally\n" );
151 ?>