]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - admin.php
PhpWiki 1.2.7 backport cvs release-1_2-branch enhancements never released with 1...
[SourceForge/phpwiki.git] / admin.php
1 <?php // $Id: admin.php,v 1.5.2.3 2005-01-07 14:23:04 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    if (!ini_get('register_globals')) {
7        extract($HTTP_SERVER_VARS);
8    }
9
10    include("lib/config.php");
11    include("lib/stdlib.php");
12    if (!ini_get('register_globals')) {
13        import_request_variables('gps');
14    }
15
16    // set these to your preferences. For heaven's sake
17    // pick a good password!
18    $wikiadmin   = "";
19    $adminpasswd = "";
20
21    // Do not tolerate sloppy systems administration
22    if (empty($wikiadmin) || empty($adminpasswd)) {
23       echo "Set the administrator account and password first.\n";
24       exit;
25    }
26
27    // from the manual, Chapter 16
28    if (($PHP_AUTH_USER != $wikiadmin  )  ||
29        ($PHP_AUTH_PW   != $adminpasswd)) {
30       Header("WWW-Authenticate: Basic realm=\"PhpWiki\"");
31       Header("HTTP/1.0 401 Unauthorized");
32       echo gettext ("You entered an invalid login or password.");
33       exit;
34    }
35
36    // All requests require the database
37    $dbi = OpenDataBase($WikiPageStore);
38
39    if (isset($lock) || isset($unlock)) {
40       include ('admin/lockpage.php');
41       $QUERY_STRING = $pagename;
42    } elseif (isset($zip)) {
43       include ('lib/ziplib.php');
44       include ('admin/zip.php');
45       ExitWiki('');
46    } elseif (isset($dumpserial)) {
47       include ('admin/dumpserial.php');
48    } elseif (isset($loadserial)) {
49       include ('admin/loadserial.php');
50    } elseif (isset($remove)) {
51       if (get_magic_quotes_gpc())
52          $remove = stripslashes($remove);
53       if (function_exists('RemovePage')) {
54          $html .= sprintf(gettext ("You are about to remove '%s' permanently!"), htmlspecialchars($remove));
55          $html .= "\n<P>";
56          $url = rawurlencode($remove);
57          $html .= sprintf(gettext ("Click %shere%s to remove the page now."),
58                   "<A HREF=\"$ScriptUrl?removeok=$url\">", "</A>");
59          $html .= "\n<P>";
60          $html .= gettext ("Otherwise press the \"Back\" button of your browser.");
61       } else {
62          $html = gettext ("Function not yet implemented.");
63       }
64       GeneratePage('MESSAGE', $html, gettext ("Remove page"), 0);
65       ExitWiki('');
66    } elseif (isset($removeok)) {
67       if (get_magic_quotes_gpc())
68          $removeok = stripslashes($removeok);
69       RemovePage($dbi, $removeok);
70       $html = sprintf(gettext ("Removed page '%s' succesfully."),
71                       htmlspecialchars($removeok));
72       GeneratePage('MESSAGE', $html, gettext ("Remove page"), 0);
73       ExitWiki('');
74    }
75
76    include('index.php');
77 ?>