about summary refs log tree commit diff stats
path: root/series/trunk
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 16:35:31 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 16:35:31 +0000
commitaa8219c03996d7ba325d71857bb34270a993d3f6 (patch)
treec90692fa1692f86237986843c561b935fb809858 /series/trunk
parent6b6e632d858d2371525242e394e692da291c7502 (diff)
downloadinstadisc-aa8219c03996d7ba325d71857bb34270a993d3f6.tar.gz
instadisc-aa8219c03996d7ba325d71857bb34270a993d3f6.tar.bz2
instadisc-aa8219c03996d7ba325d71857bb34270a993d3f6.zip
Series: Added user management
Refs #53
Diffstat (limited to 'series/trunk')
-rw-r--r--series/trunk/admin/addsub.php4
-rw-r--r--series/trunk/admin/adduser.php110
-rw-r--r--series/trunk/admin/chpwd.php2
-rw-r--r--series/trunk/admin/deletesub.php1
-rw-r--r--series/trunk/admin/deleteuser.php49
-rw-r--r--series/trunk/admin/main.php1
-rw-r--r--series/trunk/admin/mansub.php1
-rw-r--r--series/trunk/admin/manuser.php46
-rw-r--r--series/trunk/includes/instadisc.php25
-rw-r--r--series/trunk/theme/addeduser.tpl13
-rw-r--r--series/trunk/theme/adduser.tpl61
-rw-r--r--series/trunk/theme/deleteduser.tpl15
-rw-r--r--series/trunk/theme/deleteuser.tpl21
-rw-r--r--series/trunk/theme/manuser.tpl32
14 files changed, 379 insertions, 2 deletions
diff --git a/series/trunk/admin/addsub.php b/series/trunk/admin/addsub.php index 0b6ff3f..2ba2bb5 100644 --- a/series/trunk/admin/addsub.php +++ b/series/trunk/admin/addsub.php
@@ -77,8 +77,8 @@ function showForm($id, $title, $url, $category, $password, $errors)
77 $template->add('ID_ERR', ifErrors($errors, 'id')); 77 $template->add('ID_ERR', ifErrors($errors, 'id'));
78 $template->add('TITLE_ERR', ifErrors($errors, 'title')); 78 $template->add('TITLE_ERR', ifErrors($errors, 'title'));
79 $template->add('URL_ERR', ifErrors($errors, 'url')); 79 $template->add('URL_ERR', ifErrors($errors, 'url'));
80 $template->add('CATEGORY_ERR', ifErrors($errors, 'url')); 80 $template->add('CATEGORY_ERR', ifErrors($errors, 'category'));
81 $template->add('PASSWORD_ERR', ifErrors($errors, 'url')); 81 $template->add('PASSWORD_ERR', ifErrors($errors, 'password'));
82 82
83 doErrors($template, $errors, 'id'); 83 doErrors($template, $errors, 'id');
84 doErrors($template, $errors, 'title'); 84 doErrors($template, $errors, 'title');
diff --git a/series/trunk/admin/adduser.php b/series/trunk/admin/adduser.php new file mode 100644 index 0000000..dcad5d5 --- /dev/null +++ b/series/trunk/admin/adduser.php
@@ -0,0 +1,110 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22if (!isset($_GET['submit']))
23{
24 showForm('','',array());
25} else {
26 $numOfErrors = 0;
27 $errors = array();
28
29 if ($_POST['username'] == '')
30 {
31 addError($numOfErrors, $errors, 'username', 'Username is a required field');
32 }
33
34 if ($_POST['password'] == '')
35 {
36 addError($numOfErrors, $errors, 'password', 'Password is a required field');
37 }
38
39 if ($numOfErrors > 0)
40 {
41 showForm($_POST['username'], $_POST['password'], $errors);
42 } else {
43 instaDisc_addUser($_POST['username'], $_POST['password']);
44
45 $template = new FITemplate('addeduser');
46 $template->add('SITENAME', instaDisc_getConfig('siteName'));
47 $template->display();
48 }
49}
50
51function showForm($username, $password, $errors)
52{
53 $template = new FITemplate('adduser');
54 $template->add('SITENAME', instaDisc_getConfig('siteName'));
55
56 if (isset($errors[1]))
57 {
58 $template->adds_block('ERROR', array('ex'=>'1'));
59
60 foreach ($errors as $name => $value)
61 {
62 $template->adds_block('ERRORS', array( 'NAME' => $name,
63 'MSG' => $value['msg']));
64 }
65 }
66
67 $template->add('USERNAME_ERR', ifErrors($errors, 'username'));
68 $template->add('PASSWORD_ERR', ifErrors($errors, 'password'));
69
70 doErrors($template, $errors, 'username');
71 doErrors($template, $errors, 'password');
72
73 $template->add('USERNAME', $username);
74 $template->add('PASSWORD', $password);
75
76 $template->display();
77}
78
79function ifErrors($errors, $id)
80{
81 foreach ($errors as $name => $value)
82 {
83 if ($value['field'] == $id)
84 {
85 return ' error';
86 }
87 }
88
89 return '';
90}
91
92function doErrors($template, $errors, $id)
93{
94 foreach ($errors as $name => $value)
95 {
96 if ($value['field'] == $id)
97 {
98 $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name,
99 'VALUE' => $value['msg']));
100 }
101 }
102}
103
104function addError(&$numOfErrors, &$errors, $field, $msg)
105{
106 $numOfErrors++;
107 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
108}
109
110?>
diff --git a/series/trunk/admin/chpwd.php b/series/trunk/admin/chpwd.php index abd6d97..12eff53 100644 --- a/series/trunk/admin/chpwd.php +++ b/series/trunk/admin/chpwd.php
@@ -16,6 +16,7 @@ require_once('includes/instadisc.php');
16if (!isset($_SESSION['username'])) 16if (!isset($_SESSION['username']))
17{ 17{
18 header('Location: index.php'); 18 header('Location: index.php');
19 exit;
19} 20}
20 21
21if (isset($_SESSION['username'])) 22if (isset($_SESSION['username']))
@@ -65,6 +66,7 @@ if (isset($_SESSION['username']))
65 } 66 }
66} else { 67} else {
67 header('Location: index.php'); 68 header('Location: index.php');
69 exit;
68} 70}
69 71
70function showForm($old, $new, $confirm, $errors) 72function showForm($old, $new, $confirm, $errors)
diff --git a/series/trunk/admin/deletesub.php b/series/trunk/admin/deletesub.php index ac22ef3..102a6a3 100644 --- a/series/trunk/admin/deletesub.php +++ b/series/trunk/admin/deletesub.php
@@ -16,6 +16,7 @@ require_once('includes/instadisc.php');
16if (!isset($_SESSION['username'])) 16if (!isset($_SESSION['username']))
17{ 17{
18 header('Location: index.php'); 18 header('Location: index.php');
19 exit;
19} 20}
20 21
21if (!instaDisc_isAdmin($_SESSION['username'])) 22if (!instaDisc_isAdmin($_SESSION['username']))
diff --git a/series/trunk/admin/deleteuser.php b/series/trunk/admin/deleteuser.php new file mode 100644 index 0000000..7d1b0a0 --- /dev/null +++ b/series/trunk/admin/deleteuser.php
@@ -0,0 +1,49 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22if (!instaDisc_isAdmin($_SESSION['username']))
23{
24 header('Location: index.php');
25 exit;
26}
27
28if (!isset($_GET['submit']))
29{
30 $template = new FITemplate('deleteuser');
31 $template->add('SITENAME',instaDisc_getConfig('siteName'));
32 $template->add('ID',$_GET['userid']);
33
34 $sub = instaDisc_getUserByID($_GET['userid']);
35 $template->add('USERNAME',$sub['username']);
36 $template->display();
37} else {
38 if ($_POST['submit'] == 'Yes')
39 {
40 instaDisc_deleteUser($_POST['id']);
41
42 $template = new FITemplate('deleteduser');
43 $template->display();
44 } else {
45 header('Location: admin.php?id=main');
46 }
47}
48
49?>
diff --git a/series/trunk/admin/main.php b/series/trunk/admin/main.php index 2bb80f3..9318a5d 100644 --- a/series/trunk/admin/main.php +++ b/series/trunk/admin/main.php
@@ -16,6 +16,7 @@ require_once('includes/instadisc.php');
16if (!isset($_SESSION['username'])) 16if (!isset($_SESSION['username']))
17{ 17{
18 header('Location: index.php'); 18 header('Location: index.php');
19 exit;
19} 20}
20 21
21$template = new FITemplate('main'); 22$template = new FITemplate('main');
diff --git a/series/trunk/admin/mansub.php b/series/trunk/admin/mansub.php index 88bed6e..6ad04ac 100644 --- a/series/trunk/admin/mansub.php +++ b/series/trunk/admin/mansub.php
@@ -16,6 +16,7 @@ require_once('includes/instadisc.php');
16if (!isset($_SESSION['username'])) 16if (!isset($_SESSION['username']))
17{ 17{
18 header('Location: index.php'); 18 header('Location: index.php');
19 exit;
19} 20}
20 21
21$template = new FITemplate('mansub'); 22$template = new FITemplate('mansub');
diff --git a/series/trunk/admin/manuser.php b/series/trunk/admin/manuser.php new file mode 100644 index 0000000..4228a36 --- /dev/null +++ b/series/trunk/admin/manuser.php
@@ -0,0 +1,46 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22$template = new FITemplate('manuser');
23$template->add('SITENAME', instaDisc_getConfig('siteName'));
24
25if (instaDisc_isAdmin($_SESSION['username']))
26{
27 $users = instaDisc_getAllUsers();
28} else {
29 header('Location: index.php');
30 exit;
31}
32$i=0; $j=0;
33for ($i=0;isset($users[$i]);$i++)
34{
35 $j++;
36}
37$j--;
38for ($i=0;$i<$j;$i++)
39{
40 $template->adds_block('USERS', array( 'USERNAME' => $users[$i]['username'],
41 'ID' => $users[$i]['id']));
42}
43
44$template->display();
45
46?>
diff --git a/series/trunk/includes/instadisc.php b/series/trunk/includes/instadisc.php index b7b5ed0..18d40ef 100644 --- a/series/trunk/includes/instadisc.php +++ b/series/trunk/includes/instadisc.php
@@ -130,4 +130,29 @@ function instaDisc_getSubscriptionByID($id)
130 return $getsub3; 130 return $getsub3;
131} 131}
132 132
133function instaDisc_addUser($username, $password)
134{
135 $insuser = "INSERT INTO users (username,password) VALUES (\"" . mysql_real_escape_string($username) . "\",\"" . mysql_real_escape_string(md5($password)) . "\")";
136 $insuser2 = mysql_query($insuser);
137}
138
139function instaDisc_deleteUser($id)
140{
141 $deluser = "DELETE FROM users WHERE id = " . $id;
142 $deluser2 = mysql_query($deluser);
143}
144
145function instaDisc_getAllUsers()
146{
147 $getusers = "SELECT * FROM users";
148 $getusers2 = mysql_query($getusers);
149 $i=0;
150 while ($getusers3[$i] = mysql_fetch_array($getusers2))
151 {
152 $i++;
153 }
154
155 return $getusers3;
156}
157
133?> 158?>
diff --git a/series/trunk/theme/addeduser.tpl b/series/trunk/theme/addeduser.tpl new file mode 100644 index 0000000..3b4be9c --- /dev/null +++ b/series/trunk/theme/addeduser.tpl
@@ -0,0 +1,13 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc Add User</H1>
9
10 <P>You've successfully added a user! <A HREF="admin.php">Back to the ACP</A>
11 </CENTER>
12 </BODY>
13</HTML>
diff --git a/series/trunk/theme/adduser.tpl b/series/trunk/theme/adduser.tpl new file mode 100644 index 0000000..a051c24 --- /dev/null +++ b/series/trunk/theme/adduser.tpl
@@ -0,0 +1,61 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 <LINK REL="stylesheet" TYPE="text/css" HREF="theme/uniform.css">
5 </HEAD>
6
7 <BODY>
8 <CENTER>
9 <H1>InstaDisc Add User</H1>
10
11 <P>If you would like to add a new user to Series Control, please fill out the form below.
12 </CENTER>
13
14 <FORM CLASS="uniform" ACTION="./admin.php?id=adduser&amp;submit=" METHOD="POST">
15
16 <!--BEGIN ERROR-->
17 <DIV ID="errorMsg">Uh oh! Validation errors!<P>
18 <OL>
19 <!--END ERROR-->
20
21 <!--BEGIN ERRORS-->
22 <LI><A HREF="#error<!--ERRORS.NAME-->"><!--ERRORS.MSG--></A></LI>
23 <!--END ERRORS-->
24
25 <!--BEGIN ERROR-->
26 </OL>
27 </DIV>
28 <!--END ERROR-->
29
30 <FIELDSET CLASS="inlineLabels">
31 <LEGEND>User Info</LEGEND>
32
33 <DIV CLASS="ctrlHolder<!--USERNAME_ERR-->">
34 <!--BEGIN USERNAME_ERRS-->
35 <P ID="error<!--USERNAME_ERRS.NAME-->" CLASS="errorField"><EM>*</EM>
36 <!--USERNAME_ERRS.MSG-->
37 </P>
38 <!--END USERNAME_ERRS-->
39
40 <LABEL FOR="username"><EM>*</EM> Username: </LABEL>
41 <INPUT TYPE="text" ID="username" NAME="username" CLASS="textInput" VALUE="<!--USERNAME-->">
42 </DIV>
43
44 <DIV CLASS="ctrlHolder<!--PASSWORD_ERR-->">
45 <!--BEGIN PASSWORD_ERRS-->
46 <P ID="error<!--PASSWORD_ERRS.NAME-->" CLASS="errorField"><EM>*</EM>
47 <!--PASSWORD_ERRS.MSG-->
48 </P>
49 <!--END PASSWORD_ERRS-->
50
51 <LABEL FOR="password">Password: </LABEL>
52 <INPUT TYPE="password" ID="password" NAME="password" CLASS="textInput" VALUE="<!--PASSWORD-->">
53 </DIV>
54 </FIELDSET>
55
56 <DIV CLASS="buttonHolder">
57 <INPUT TYPE="submit" NAME="submit" VALUE="Submit">
58 </DIV>
59 </FORM>
60 </BODY>
61</HTML>
diff --git a/series/trunk/theme/deleteduser.tpl b/series/trunk/theme/deleteduser.tpl new file mode 100644 index 0000000..a6c4f9b --- /dev/null +++ b/series/trunk/theme/deleteduser.tpl
@@ -0,0 +1,15 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc User Deletion</H1>
9
10 <P>You have successfully deleted your user!
11
12 <P><A HREF="admin.php?id=main">Back to User Panel</A>
13 </CENTER>
14 </BODY>
15</HTML>
diff --git a/series/trunk/theme/deleteuser.tpl b/series/trunk/theme/deleteuser.tpl new file mode 100644 index 0000000..d3af600 --- /dev/null +++ b/series/trunk/theme/deleteuser.tpl
@@ -0,0 +1,21 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc User Deletion</H1>
9
10 <P>Are you sure you would like to delete <!--USERNAME-->?
11
12 <FORM ACTION="./admin.php?id=deleteuser&amp;submit=" METHOD="POST">
13 <INPUT TYPE="hidden" NAME="id" VALUE="<!--ID-->">
14 <INPUT TYPE="submit" NAME="submit" VALUE="Yes">
15 <INPUT TYPE="submit" NAME="submit" VALUE="No">
16 </FORM>
17 </CENTER>
18 </BODY>
19</HTML>
20
21
diff --git a/series/trunk/theme/manuser.tpl b/series/trunk/theme/manuser.tpl new file mode 100644 index 0000000..28f69d0 --- /dev/null +++ b/series/trunk/theme/manuser.tpl
@@ -0,0 +1,32 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 <LINK REL="stylesheet" HREF="theme/table.css">
5 </HEAD>
6
7 <BODY>
8 <CENTER>
9 <H1>InstaDisc User Management</H1>
10
11 <P>You can manage your users here.
12
13 <TABLE>
14 <TR>
15 <TH>Username</TH>
16 <TH>Actions</TH>
17 </TR>
18
19 <!--BEGIN USERS-->
20 <TR>
21 <TD><!--USERS.USERNAME--></TD>
22 <TD>
23 <A HREF="admin.php?id=deleteuser&amp;userid=<!--USERS.ID-->">Delete</A>
24 </TD>
25 </TR>
26 <!--END USERS-->
27 </TABLE>
28
29 <P><A HREF="admin.php?id=main">Back to User Panel</A>
30 </CENTER>
31 </BODY>
32</HTML>