root/admin.php

Revision 153, 4.7 kB (checked in by rollercow, 3 years ago)

Lots of little changes, mostly checking input and new comments
Goes some way to dealing with #27

  • Property svn:executable set to *
Line 
1 <?php
2     //include our admin functions
3     include("admin.lib.php");
4     $admin = new admin();
5
6     //make our command list from the path
7     $request=explode('/',substr($_SERVER[PATH_INFO], 1));
8
9     // Check if we're logging in or out - must be done before any HTML is displayed
10     switch ($request[0]) {
11         case "login":
12             //if login was suscessfull..
13             if ($admin->login()) {
14                 //Reinitalise the admin variable now the user is logged in, thus setting up the stuff thats dependent on having a username
15                 $admin = new admin();
16             }
17             //otherwise dont mess with it, so we dont lose the error
18             break;
19         case "logout":
20             $admin->logout();
21             break;
22     }
23
24 ?>
25 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
27 <head>
28     <title>Blog Admin</title>
29     <link rel="stylesheet" href="<? echo $admin->httpPath; ?>blog.css" type="text/css" />
30 <?php
31     //No point loading all that java script gubbins if its not going to be used
32     if ($admin->blog->editor && ($request[0] == "newentry" || $request[0] == "update" || $request[0] == "postupdate" || $request[0] == "postentry")) {
33 ?>
34     <script language="javascript" type="text/javascript" src="<?php echo $admin->httpPath; ?>tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
35     <script language="javascript" type="text/javascript" src="<?php echo $admin->httpPath; ?>tinymce-config.js"></script>
36 <?php
37     }
38 ?>
39 </head>
40 <body>
41 <div id="toptop"></div>
42 <div id="container">
43     <div id="toppanel">
44     <h1><a href="<? echo $admin->adminPath;?>"><? echo _("SUCS Blogs"); ?></a></h1>
45         <h2>Blog management</h2>
46     <h3> </h3>
47     </div>
48     <div id="content">
49     <div id="sidepanel">
50     <? if($_SESSION['userName']) $admin->menu(); else echo "<ul class=\"side-menu\">\n<li><a href=\"{$admin->basePath}\">".("View blogs")."</a></li>\n</ul>" ?><br />
51         <p class="sideblurb">
52         <a href="http://sucs.org"><img src="<? echo $admin->httpPath."img/sucspow.png"; ?>" alt="Powered by SUCS" height="13" width="80" /></a>
53         </p>
54     </div>
55     <div id="maincontent"><?
56         //alter the debuging state on request
57         if ($request[0] == "debug") {
58             $_SESSION[debug] = $request[1];
59         }
60         //if logged in
61         if($_SESSION['userName']) {
62                 echo "<div class=\"login\"><h3>"._("Hello")." {$admin->realName} (<a href=\"{$admin->adminPath}logout\">"._("Log out")."</a>)</h3></div>";
63                 //call appropriate functions..
64                 switch (array_shift($request)) {
65                     case "newentry":
66                         $admin->printEntryForm() ;
67                         break;
68                     case "settings":
69                         $admin->printSettingsForm() ;
70                         break;
71                     case "postentry":
72                         $admin->postEntry() ;
73                         break;
74                     case "postupdate":
75                         $admin->updateEntry(array_shift($request)) ;
76                         break;
77                     case "update":
78                         $admin->updateForm(array_shift($request)) ;
79                         break;
80                     case "postsettings":
81                         $admin->updateSettings() ;
82                         break;
83                     case "showentries":
84                         $admin->printEntries() ;
85                         break;
86                     case "deleteentry":
87                         $admin->deleteEntry(array_shift($request)) ;
88                         break;
89                     case "confirmdeleteentries":
90                         $admin->confirmDeleteEntries();
91                         break;
92                     case "deleteentries":
93                         $admin->deleteEntries();
94                         break;
95                     case "moderatecomments":
96                         $admin->printComments();
97                         $admin->printAuthorisedUsers();
98                         break;
99                     case "updatecomments":
100                         $admin->updateComments();
101                         break;
102                     case "deletecomments":
103                         $admin->deleteComments(array_shift($request));
104                         break;
105                     case "updateauthusers":
106                         $admin->updateAuthorisedUsers();
107                         break;
108                     default:
109                         $admin->mainPage();
110                 }
111         }
112         else {
113             //run appropriate functions
114             switch (array_shift($request)) {
115                 case "signup":
116                     echo "<div class=\"login\"><h3><a href=\"{$admin->adminPath}\">"._("Not logged in")."</a></h3></div>\n";
117                     $admin->addUserForm();
118                     break;
119                 case "adduser":
120                     echo "<div class=\"login\"><h3><a href=\"{$admin->adminPath}\">"._("Not logged in")."</a></h3>\n";
121                     $admin->addUser();
122                     break;
123                 //or offer login box
124                 default:
125                     echo "<div class=\"login\"><h3>"._("Not logged in")."</h3>\n";
126                     $admin->printLoginForm();
127             }
128         }
129
130     ?></div>
131     </div>
132     <div id="bottompanel">
133     <p><? echo _("Validate"); ?> : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a></p>
134     </div>
135 </div>
136 <div id="botbot"></div>
137 <?php
138     //if we are in debug mode display a bunch of stuff
139     if($_SESSION[debug]){
140         echo "<div class=\"debug\"><h2>"._("Debug Info")."</h2><pre>\n";
141         echo "**"._("Session")."**\n";
142         print_r($_SESSION);
143         echo "**"._("Request")."**\n";
144         print_r($_REQUEST);
145         echo "**"._("Class")."**\n";
146         print_r($admin);
147         echo "</pre></div>";
148     }
149 ?>
150 </body>
151 </html>
152
Note: See TracBrowser for help on using the browser.