summary refs log tree commit diff stats
path: root/admin
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2009-02-21 18:05:42 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2009-02-21 18:05:42 -0500
commitd0601a55010cd9fe2f2587ce157ce059e5da732e (patch)
tree6c56f73f6d2dfa1bbaab5c053321458014709377 /admin
parent877fa5a38fefe2bdd0e00768b6ec4b52a81d7a69 (diff)
downloadpillowcase-d0601a55010cd9fe2f2587ce157ce059e5da732e.tar.gz
pillowcase-d0601a55010cd9fe2f2587ce157ce059e5da732e.tar.bz2
pillowcase-d0601a55010cd9fe2f2587ce157ce059e5da732e.zip
Started admin panel
Diffstat (limited to 'admin')
-rwxr-xr-xadmin/.htaccess4
-rw-r--r--admin/add.php30
-rwxr-xr-xadmin/index.php27
-rw-r--r--admin/login.php30
-rw-r--r--admin/logout.php7
-rw-r--r--admin/main.php8
-rw-r--r--admin/manage.php15
-rw-r--r--admin/remove.php8
-rw-r--r--admin/update.php5
9 files changed, 134 insertions, 0 deletions
diff --git a/admin/.htaccess b/admin/.htaccess new file mode 100755 index 0000000..d590e40 --- /dev/null +++ b/admin/.htaccess
@@ -0,0 +1,4 @@
1RewriteEngine On
2RewriteCond %{REQUEST_FILENAME} !index.php
3RewriteCond %{REQUEST_FILENAME} !-d
4RewriteRule (.*).php /admin/index.php?file=$1 [QSA,L]
diff --git a/admin/add.php b/admin/add.php new file mode 100644 index 0000000..96a9219 --- /dev/null +++ b/admin/add.php
@@ -0,0 +1,30 @@
1<?php
2
3$getimage = "SELECT * FROM moderation WHERE id = " . $_GET['id'];
4$getimage2 = mysql_query($getimage);
5$getimage3 = mysql_fetch_array($getimage2);
6
7$title = $getimage3['title'];
8$title = preg_replace('/[^A-Za-z0-9 ]/','',$title);
9$title = str_replace(' ', '-', $title);
10$title = preg_replace('/-{2,}/','-',$title);
11if (substr($title,0,1) == '-')
12{
13 $title = substr($title,1);
14}
15if (substr($title,strlen($title)-1,1) == '-')
16{
17 $title = substr($title,0,strlen($title)-1);
18}
19$title = strtolower($title);
20rename($_SERVER['DOCUMENT_ROOT'] . '/moderation/' . $getimage3['id'] . '.png', $_SERVER['DOCUMENT_ROOT'] . '/images/' . $title . '.png');
21
22$insimage = "INSERT INTO pending (title,filename,text,author) VALUES (\"" . $getimage3['title'] . "\",\"" . $title . "\",\"" . $getimage3['text'] . "\",\"" . $getimage3['author'] . "\")";
23$insimage2 = mysql_query($insimage);
24
25$delimage = "DELETE FROM moderation WHERE id = " . $_GET['id'];
26$delimage2 = mysql_query($delimage);
27
28?>
29
30Added comic <?php echo($getimage3['title']); ?>!
diff --git a/admin/index.php b/admin/index.php new file mode 100755 index 0000000..3a5f6be --- /dev/null +++ b/admin/index.php
@@ -0,0 +1,27 @@
1<?php
2
3session_start();
4
5ob_start();
6
7include('../header.php');
8
9if (!isset($_SESSION['username']))
10{
11 include('login.php');
12} else {
13 if (!isset($_GET['file']))
14 {
15 $file = 'main.php';
16 } else {
17 $file = basename($_GET['file'] . '.php');
18 }
19
20 include($file);
21}
22
23include('../footer.php');
24
25ob_end_flush();
26
27?>
diff --git a/admin/login.php b/admin/login.php new file mode 100644 index 0000000..f938664 --- /dev/null +++ b/admin/login.php
@@ -0,0 +1,30 @@
1<?php
2
3if (!isset($_GET['submit']))
4{
5
6?>
7<FORM ACTION="/admin/login.php?submit=" METHOD="POST">
8Username: <INPUT TYPE="text" NAME="user"><BR>
9Password: <INPUT TYPE="password" NAME="pass"><BR>
10<INPUT TYPE="submit"></FORM>
11<?php
12
13} else {
14 $getconfig = "SELECT * FROM config WHERE name = \"username\" OR name = \"password\" ORDER BY name DESC";
15 $getconfig2 = mysql_query($getconfig) or die($getconfig);
16 $username = mysql_fetch_array($getconfig2);
17 $password = mysql_fetch_array($getconfig2);
18
19 if (($username['value'] == $_POST['user']) && ($password['value'] == md5($_POST['pass'])))
20 {
21 $_SESSION['username'] = $_POST['user'];
22
23 header('Location: /admin/');
24 exit;
25 } else {
26?><H2>Incorrect login</H2><?php
27 }
28}
29
30?>
diff --git a/admin/logout.php b/admin/logout.php new file mode 100644 index 0000000..639e045 --- /dev/null +++ b/admin/logout.php
@@ -0,0 +1,7 @@
1<?php
2
3unset($_SESSION['username']);
4
5header('Location: /');
6
7?>
diff --git a/admin/main.php b/admin/main.php new file mode 100644 index 0000000..aa01262 --- /dev/null +++ b/admin/main.php
@@ -0,0 +1,8 @@
1<H2>Admin Panel</H2>
2
3<UL>
4 <LI><A HREF="/admin/post.php">Upload a comic</A></LI>
5 <LI><A HREF="/admin/manage.php">Manage moderation queue</A></LI>
6 <LI><A HREF="/admin/update.php">HG Update</A></LI>
7 <LI><A HREF="/admin/logout.php">Logout</A></LI>
8</UL>
diff --git a/admin/manage.php b/admin/manage.php new file mode 100644 index 0000000..2485520 --- /dev/null +++ b/admin/manage.php
@@ -0,0 +1,15 @@
1<UL><?php
2
3$getimages = "SELECT * FROM moderation";
4$getimages2 = mysql_query($getimages);
5while ($getimages3 = mysql_fetch_array($getimages2))
6{
7?><LI><?php echo($getimages3['title']); ?> -
8<IMG SRC="/moderation/<?php echo($getimages3['id']); ?>.png" ALT="<?php echo($getimages3['text']); ?>" TITLE="<?php echo($getimages3['text']); ?>"> -
9<A HREF="/admin/add.php?id=<?php echo($getimages3['id']); ?>">Add to Pending Queue</A> -
10<A HREF="/admin/remove.php?id=<?php echo($getimages3['id']); ?>">Remove</A></LI><?php
11}
12
13?></UL>
14
15<A HREF="/admin/">Back to Admin</A>
diff --git a/admin/remove.php b/admin/remove.php new file mode 100644 index 0000000..bf8e565 --- /dev/null +++ b/admin/remove.php
@@ -0,0 +1,8 @@
1<?php
2
3$delimage = "DELETE FROM moderation WHERE id = " . $_GET['id'];
4$delimage2 = mysql_query($delimage);
5
6?>
7
8Removed comic <?php echo($_GET['id']); ?>!
diff --git a/admin/update.php b/admin/update.php new file mode 100644 index 0000000..c84c2c4 --- /dev/null +++ b/admin/update.php
@@ -0,0 +1,5 @@
1<?php
2
3system('hg update');
4
5?>