Source of trunk/controlpanel.php at revision HEAD (03/04/2009 2:03:13, 4408 bytes, 122 lines, language: php) [download]:

1
<?php
2
3
/*
4
** User Control Panel
5
** for CodewiseBlog Multi-User
6
**
7
** by William R. Fraser <wrf@codewise.org>
8
** Copyright (c) 2005-2008 Codewise.org
9
*/
10
11
/*
12
** This file is part of CodewiseBlog
13
**
14
** CodewiseBlog is free software; you can redistribute it and/or modify
15
** it under the terms of the GNU General Public License as published by
16
** the Free Software Foundation; either version 2 of the License, or
17
** (at your option) any later version.
18
**
19
** CodewiseBlog is distributed in the hope that it will be useful,
20
** but WITHOUT ANY WARRANTY; without even the implied warranty of
21
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
** GNU General Public License for more details.
23
**
24
** You should have received a copy of the GNU General Public License
25
** along with CodewiseBlog; if not, write to the Free Software
26
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27
*/
28
29
function cplogin()
30
{
31
    global $db;
32
33
    $q $db->issue_query("SELECT password FROM blogs WHERE blogid = '1'");
34
    $root_hash $db->fetch_var($q);
35
36
    $q $db->issue_query("SELECT password FROM blogs WHERE blogid = '" BLOGID "'");
37
    $hash $db->fetch_var($q);
38
39
    if($_SESSION['controlpanel'] == || md5($_POST['password']) == $root_hash)
40
    {
41
        $_SESSION['controlpanel'] = 1;
42
        $_SESSION['blogid'] = BLOGID;
43
        define('LOGGED_IN'TRUE);
44
        define('ADMIN'TRUE);
45
        return "You are now logged in as Admin. Beware that changes you make are potentially dangerous!<br />"
46
            "<a href=\"" INDEX_URL "?controlpanel\">Continue to the Control Panel</a><br />"
47
            "<a href=\"" INDEX_URL "\">Back to your blog</a>";
48
    } elseif($_SESSION['controlpanel'] == BLOGID || md5($_POST['password']) == $hash) {
49
        $_SESSION['controlpanel'] = BLOGID;
50
        define('LOGGED_IN'TRUE);
51
        define('ADMIN'FALSE);
52
        return "You are now logged in.<br />"
53
            "<a href=\"" INDEX_URL "?controlpanel\">Continue to the Control Panel</a><br />"
54
            "<a href=\"" INDEX_URL "\">Back to your blog</a>";
55
    } else {
56
        $GLOBALS['NOTIFY'] = "Incorrect password.";
57
        define('LOGGED_IN'FALSE);
58
        define('ADMIN'FALSE);
59
        return main_page(1);
60
    }
61
}
62
63
function controlpanel()
64
{
65
    global $db$BLOGINFO;
66
67
    $TITLE $BLOGINFO['title'] . " :: Control Panel";
68
69
    if($_SESSION['controlpanel'] != BLOGID && $_SESSION['controlpanel'] != 1)
70
    {
71
        header("Location: " INDEX_URL "?notloggedin");
72
        return;
73
    }
74
75
    if(isset($_GET['controlpanel:settings']))
76
    {
77
        require("cp_settings.php");
78
    } elseif(isset($_GET['controlpanel:write'])) {
79
        require("cp_write.php");
80
    } elseif(isset($_GET['controlpanel:edit'])) {
81
        require("cp_edit.php");
82
    } elseif(isset($_GET['controlpanel:userinfo'])) {
83
        require("cp_userinfo.php");
84
    } elseif(isset($_GET['controlpanel:skin'])) {
85
        require("cp_skin_multi.php");
86
    } elseif(isset($_GET['controlpanel:adduser'])) {
87
        require("cp_adduser.php");
88
    } elseif(isset($_GET['controlpanel:manage'])) {
89
        require("cp_manage.php");
90
    } else {
91
        $current "home";
92
        //$body = "<div align=\"center\">Welcome to the CodewiseBlog control panel.<br />"
93
        $body skinvoodoo("controlpanel""welcome", array())
94
          . skinvoodoo("controlpanel""versionfooter", array()) . "</div>";
95
    }
96
97
    $args = array
98
    (
99
        "root"    => (BLOGID == TRUE FALSE),
100
        "current" => $current,
101
        "cpurl"        => INDEX_URL "?controlpanel",
102
        "url_settings" => INDEX_URL "?controlpanel:settings",
103
        "url_write"    => INDEX_URL "?controlpanel:write",
104
        "url_edit"     => INDEX_URL "?controlpanel:edit",
105
        "url_userinfo" => INDEX_URL "?controlpanel:userinfo",
106
        "url_skin"     => INDEX_URL "?controlpanel:skin",
107
        "url_adduser"  => INDEX_URL "?controlpanel:adduser",
108
        "url_manage"   => INDEX_URL "?controlpanel:manage",
109
    );
110
111
    $out skinvoodoo("controlpanel"""$args);
112
113
    $out str_replace("<!-- #CWB_CP_BODY# -->"$body$out);
114
    $out str_replace("%{".UNIQ."titletag}"$BLOGINFO['title'] . " :: Control Panel"$out);
115
    $out str_replace("%{".UNIQ."querycount}"querycount(), $out);
116
    $out str_replace("%{".UNIQ."runtime}"runtime(), $out);
117
118
    return $out;
119
}
120
121
?>
122

powered by Codewise Manager v0.1-DEV :: 42.01ms, 6 ops, 3 queries