]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - admin.php
rel1.2.8: fix broken register_globals = off logic. centralize logic in lib/config...
[SourceForge/phpwiki.git] / admin.php
1 <?php // $Id: admin.php,v 1.5.2.4 2005-07-23 11:13:03 rurban Exp $
2
3    function rcs_id($id) {}   // otherwise this gets in the way
4
5    define('WIKI_ADMIN', true);  // has to be before includes
6
7    include("lib/config.php");
8    include("lib/stdlib.php");
9
10    // Set these to your preferences. 
11    // For heaven's sake pick a good password!
12    $wikiadmin   = "";
13    $adminpasswd = "";
14
15    // Do not tolerate sloppy systems administration
16    if (empty($wikiadmin) || empty($adminpasswd)) {
17        echo gettext("Set the administrator account and password first.\n");
18       exit;
19    }
20
21    // From the manual, Chapter 16
22    if (($PHP_AUTH_USER != $wikiadmin  )  ||
23        ($PHP_AUTH_PW   != $adminpasswd)) {
24       Header("WWW-Authenticate: Basic realm=\"PhpWiki\"");
25       Header("HTTP/1.0 401 Unauthorized");
26       echo gettext("You entered an invalid login or password.");
27       exit;
28    }
29
30    // All requests require the database
31    $dbi = OpenDataBase($WikiPageStore);
32
33    if (isset($lock) || isset($unlock)) {
34       include ('admin/lockpage.php');
35       $QUERY_STRING = $pagename;
36    } elseif (isset($zip)) {
37       include ('lib/ziplib.php');
38       include ('admin/zip.php');
39       ExitWiki('');
40    } elseif (isset($dumpserial)) {
41       include ('admin/dumpserial.php');
42    } elseif (isset($loadserial)) {
43       include ('admin/loadserial.php');
44    } elseif (isset($remove)) {
45       if (get_magic_quotes_gpc())
46          $remove = stripslashes($remove);
47       if (function_exists('RemovePage')) {
48          $html .= sprintf(gettext ("You are about to remove '%s' permanently!"), htmlspecialchars($remove));
49          $html .= "\n<P>";
50          $url = rawurlencode($remove);
51          $html .= sprintf(gettext ("Click %shere%s to remove the page now."),
52                   "<A HREF=\"$ScriptUrl?removeok=$url\">", "</A>");
53          $html .= "\n<P>";
54          $html .= gettext ("Otherwise press the \"Back\" button of your browser.");
55       } else {
56          $html = gettext ("Function not yet implemented.");
57       }
58       GeneratePage('MESSAGE', $html, gettext ("Remove page"), 0);
59       ExitWiki('');
60    } elseif (isset($removeok)) {
61       if (get_magic_quotes_gpc())
62          $removeok = stripslashes($removeok);
63       RemovePage($dbi, $removeok);
64       $html = sprintf(gettext ("Removed page '%s' succesfully."),
65                       htmlspecialchars($removeok));
66       GeneratePage('MESSAGE', $html, gettext ("Remove page"), 0);
67       ExitWiki('');
68    }
69
70    include('index.php');
71 ?>