2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 include_once( "./LocalSettings.php" );
10 if( $wgSitename == "MediaWiki" ) {
11 die( "You must set the site name in \$wgSitename before installation.\n\n" );
14 # Windows requires ';' as separator, ':' for Unix
15 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ?
";" : ":";
16 ini_set( "include_path", "$IP$sep$include_path" );
18 include_once( "Setup.php" );
20 wfProfileIn( "main-misc-setup" );
21 OutputPage
::setEncodings(); # Not really used yet
25 global $action, $title, $search, $go, $target, $printable;
26 global $returnto, $diff, $oldid, $curid;
28 # Placeholders in case of DB error
29 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
30 $wgArticle = new Article($wgTitle);
32 $action = strtolower( trim( $action ) );
33 if ( "" == $action ) { $action = "view"; }
34 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
36 if ( "" == $title && "delete" != $action ) {
37 $wgTitle = Title
::newFromText( wfMsg( "mainpage" ) );
39 # URLs like this are generated by RC, because rc_title isn't always accurate
40 $wgTitle = Title
::newFromID( $curid );
42 $wgTitle = Title
::newFromURL( $title );
44 wfProfileOut( "main-misc-setup" );
46 if ( "" != $search ) {
47 if( isset($_REQUEST['fulltext']) ) {
52 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
53 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
54 $wgOut->errorpage( "badtitle", "badtitletext" );
55 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
56 /* redirect to canonical url */
57 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) );
58 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
61 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
62 $wgTitle = Title
::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
65 switch( $wgTitle->getNamespace() ) {
67 include_once( "ImagePage.php" );
68 $wgArticle = new ImagePage( $wgTitle );
71 $wgArticle = new Article( $wgTitle );
74 wfQuery("BEGIN", DB_WRITE
);
84 $wgArticle->$action();
91 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
94 include_once( "EditPage.php" );
95 $editor = new EditPage( $wgArticle );
99 include_once( "PageHistory.php" );
100 $history = new PageHistory( $wgArticle );
104 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
106 wfQuery("COMMIT", DB_WRITE
);
110 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
112 wfDebug( "Request ended normally\n" );