]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/pageinfo.php
2004-11-28 19:19 rurban
[SourceForge/phpwiki.git] / lib / pageinfo.php
1 <!-- $Id: pageinfo.php,v 1.5.4.2 2005-01-07 13:59:58 rurban Exp $ -->
2 <!-- Display the internal structure of a page. Steve Wainstead, June 2000 -->
3 <?php
4    if (get_magic_quotes_gpc()) {
5       $info = stripslashes($info);
6    }
7
8    $encname = htmlspecialchars($info);
9    $enter = gettext ("Enter a page name");
10    $go = gettext ("Go");
11    $html = "<form action=\"$ScriptUrl\" METHOD=GET>\n" .
12            "<input name=\"info\" value=\"$encname\">" .
13            " $enter\n" .
14            "<input type=submit value=$go><br>\n" .
15            "<input type=checkbox name=showpagesource";
16
17    if (isset($showpagesource) && ($showpagesource == "on")) {
18       $html .= " checked";
19    }
20    $html .= "> ";
21    $html .= gettext ("Show the page source and references");
22    $html .= "\n</form>\n";
23
24    // don't bother unless we were asked
25    if (! $info) {
26       GeneratePage('MESSAGE', $html, gettext("PageInfo"), 0);
27       exit;
28    }
29
30    function ViewpageProps($name, $pagestore)
31    {
32       global $dbi, $showpagesource, $datetimeformat, $FieldSeparator;
33
34       $pagehash = RetrievePage($dbi, $name, $pagestore);
35       if ($pagehash == -1) {
36          $table = sprintf (gettext ("Page name '%s' is not in the database"),
37                 $name) . "\n";
38       }
39       else {
40          $table = "<table border=1 bgcolor=white>\n";
41
42          while (list($key, $val) = each($pagehash)) {
43             if ($key > 0 || !$key) #key is an array index
44                continue;
45             if ((gettype($val) == "array") && ($showpagesource == "on")) {
46                $val = implode($val, "$FieldSeparator#BR#$FieldSeparator\n");
47                $val = htmlspecialchars($val);
48                $val = str_replace("$FieldSeparator#BR#$FieldSeparator", "<br>", $val);
49             }
50             elseif (($key == 'lastmodified') || ($key == 'created'))
51                $val = date($datetimeformat, $val);
52             elseif (gettype($val) != "array")
53                $val = htmlspecialchars($val);
54
55             $table .= "<tr><td>$key</td><td>$val</td></tr>\n";
56          }
57
58          $table .= "</table>";
59       }
60       return $table;
61    }
62
63    $html .= "<P><B>";
64    $html .= gettext ("Current version");
65    $html .= "</B></p>";
66    // $dbi = OpenDataBase($WikiPageStore);   --- done by index.php
67    $html .= ViewPageProps($info, $WikiPageStore);
68
69    $html .= "<P><B>";
70    $html .= gettext ("Archived version");
71    $html .= "</B></p>";
72    // $dbi = OpenDataBase($ArchivePageStore);
73    $html .= ViewPageProps($info, $ArchivePageStore);
74
75    GeneratePage('MESSAGE', $html, gettext("PageInfo").": '$info'", 0);
76 ?>