]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/display.php
Minor security bug fix.
[SourceForge/phpwiki.git] / lib / display.php
1 <?php
2    // display.php: fetch page or get default content
3    // calls transform.php for actual transformation of wiki markup to HTML
4    rcs_id('$Id: display.php,v 1.6 2001-02-07 21:11:46 dairiki Exp $');
5  
6    // if we got GET data, the first item is always a page name
7    // if it wasn't this file would not have been included
8
9    if (empty($QUERY_STRING) && isset($argv[0]))
10       $QUERY_STRING = $argv[0];
11   
12    if (isset($QUERY_STRING) && preg_match('/^[-+%\w]+$/', $QUERY_STRING)) {
13       $pagename = urldecode($QUERY_STRING);
14    } else { 
15       $pagename = gettext("FrontPage");
16
17       // if there is no FrontPage, create a basic set of Wiki pages
18       if (! IsWikiPage($dbi, $pagename)) {
19          include "lib/setupwiki.php";
20       }
21    }
22
23    $html = "";
24    $enc_name = rawurlencode($pagename);
25    $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
26
27    // we render the page if it exists, else ask the user to write one.
28    if (is_array($pagehash)) {
29       // transform.php returns $html containing all the HTML markup
30       include("lib/transform.php");
31    } else {
32       $html .= sprintf(gettext("Describe %s here."),
33                        "$pagename<a href='$ScriptUrl?edit=$enc_name'>?</a>");
34    }
35
36    GeneratePage('BROWSE', $html, $pagename, $pagehash);
37    flush();
38
39    IncreaseHitCount($dbi, $pagename);
40 ?>