From aa8219c03996d7ba325d71857bb34270a993d3f6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 14 Sep 2008 16:35:31 +0000 Subject: Series: Added user management Refs #53 --- series/trunk/admin/addsub.php | 4 +- series/trunk/admin/adduser.php | 110 ++++++++++++++++++++++++++++++++++++ series/trunk/admin/chpwd.php | 2 + series/trunk/admin/deletesub.php | 1 + series/trunk/admin/deleteuser.php | 49 ++++++++++++++++ series/trunk/admin/main.php | 1 + series/trunk/admin/mansub.php | 1 + series/trunk/admin/manuser.php | 46 +++++++++++++++ series/trunk/includes/instadisc.php | 25 ++++++++ series/trunk/theme/addeduser.tpl | 13 +++++ series/trunk/theme/adduser.tpl | 61 ++++++++++++++++++++ series/trunk/theme/deleteduser.tpl | 15 +++++ series/trunk/theme/deleteuser.tpl | 21 +++++++ series/trunk/theme/manuser.tpl | 32 +++++++++++ 14 files changed, 379 insertions(+), 2 deletions(-) create mode 100644 series/trunk/admin/adduser.php create mode 100644 series/trunk/admin/deleteuser.php create mode 100644 series/trunk/admin/manuser.php create mode 100644 series/trunk/theme/addeduser.tpl create mode 100644 series/trunk/theme/adduser.tpl create mode 100644 series/trunk/theme/deleteduser.tpl create mode 100644 series/trunk/theme/deleteuser.tpl create mode 100644 series/trunk/theme/manuser.tpl (limited to 'series/trunk') 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) $template->add('ID_ERR', ifErrors($errors, 'id')); $template->add('TITLE_ERR', ifErrors($errors, 'title')); $template->add('URL_ERR', ifErrors($errors, 'url')); - $template->add('CATEGORY_ERR', ifErrors($errors, 'url')); - $template->add('PASSWORD_ERR', ifErrors($errors, 'url')); + $template->add('CATEGORY_ERR', ifErrors($errors, 'category')); + $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); doErrors($template, $errors, 'id'); 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 @@ + 0) + { + showForm($_POST['username'], $_POST['password'], $errors); + } else { + instaDisc_addUser($_POST['username'], $_POST['password']); + + $template = new FITemplate('addeduser'); + $template->add('SITENAME', instaDisc_getConfig('siteName')); + $template->display(); + } +} + +function showForm($username, $password, $errors) +{ + $template = new FITemplate('adduser'); + $template->add('SITENAME', instaDisc_getConfig('siteName')); + + if (isset($errors[1])) + { + $template->adds_block('ERROR', array('ex'=>'1')); + + foreach ($errors as $name => $value) + { + $template->adds_block('ERRORS', array( 'NAME' => $name, + 'MSG' => $value['msg'])); + } + } + + $template->add('USERNAME_ERR', ifErrors($errors, 'username')); + $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); + + doErrors($template, $errors, 'username'); + doErrors($template, $errors, 'password'); + + $template->add('USERNAME', $username); + $template->add('PASSWORD', $password); + + $template->display(); +} + +function ifErrors($errors, $id) +{ + foreach ($errors as $name => $value) + { + if ($value['field'] == $id) + { + return ' error'; + } + } + + return ''; +} + +function doErrors($template, $errors, $id) +{ + foreach ($errors as $name => $value) + { + if ($value['field'] == $id) + { + $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, + 'VALUE' => $value['msg'])); + } + } +} + +function addError(&$numOfErrors, &$errors, $field, $msg) +{ + $numOfErrors++; + $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); +} + +?> 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'); if (!isset($_SESSION['username'])) { header('Location: index.php'); + exit; } if (isset($_SESSION['username'])) @@ -65,6 +66,7 @@ if (isset($_SESSION['username'])) } } else { header('Location: index.php'); + exit; } function 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'); if (!isset($_SESSION['username'])) { header('Location: index.php'); + exit; } if (!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 @@ +add('SITENAME',instaDisc_getConfig('siteName')); + $template->add('ID',$_GET['userid']); + + $sub = instaDisc_getUserByID($_GET['userid']); + $template->add('USERNAME',$sub['username']); + $template->display(); +} else { + if ($_POST['submit'] == 'Yes') + { + instaDisc_deleteUser($_POST['id']); + + $template = new FITemplate('deleteduser'); + $template->display(); + } else { + header('Location: admin.php?id=main'); + } +} + +?> 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'); if (!isset($_SESSION['username'])) { header('Location: index.php'); + exit; } $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'); if (!isset($_SESSION['username'])) { header('Location: index.php'); + exit; } $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 @@ +add('SITENAME', instaDisc_getConfig('siteName')); + +if (instaDisc_isAdmin($_SESSION['username'])) +{ + $users = instaDisc_getAllUsers(); +} else { + header('Location: index.php'); + exit; +} +$i=0; $j=0; +for ($i=0;isset($users[$i]);$i++) +{ + $j++; +} +$j--; +for ($i=0;$i<$j;$i++) +{ + $template->adds_block('USERS', array( 'USERNAME' => $users[$i]['username'], + 'ID' => $users[$i]['id'])); +} + +$template->display(); + +?> 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) return $getsub3; } +function instaDisc_addUser($username, $password) +{ + $insuser = "INSERT INTO users (username,password) VALUES (\"" . mysql_real_escape_string($username) . "\",\"" . mysql_real_escape_string(md5($password)) . "\")"; + $insuser2 = mysql_query($insuser); +} + +function instaDisc_deleteUser($id) +{ + $deluser = "DELETE FROM users WHERE id = " . $id; + $deluser2 = mysql_query($deluser); +} + +function instaDisc_getAllUsers() +{ + $getusers = "SELECT * FROM users"; + $getusers2 = mysql_query($getusers); + $i=0; + while ($getusers3[$i] = mysql_fetch_array($getusers2)) + { + $i++; + } + + return $getusers3; +} + ?> 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 @@ + + + <!--SITENAME--> InstaDisc Series Control + + + +
+

InstaDisc Add User

+ +

You've successfully added a user! Back to the ACP +

+ + 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 @@ + + + <!--SITENAME--> InstaDisc Series Control + + + + +
+

InstaDisc Add User

+ +

If you would like to add a new user to Series Control, please fill out the form below. +

+ +
+ + +
Uh oh! Validation errors!

+

    + + + +
  1. + + + +
+
+ + +
+ User Info + +
+ +

* + +

+ + + + +
+ +
+ +

* + +

+ + + + +
+
+ +
+ +
+
+ + 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 @@ + + + <!--SITENAME--> InstaDisc Series Control + + + +
+

InstaDisc User Deletion

+ +

You have successfully deleted your user! + +

Back to User Panel +

+ + 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 @@ + + + <!--SITENAME--> InstaDisc Series Control + + + +
+

InstaDisc User Deletion

+ +

Are you sure you would like to delete ? + +

+ + + +
+
+ + + + 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 @@ + + + <!--SITENAME--> InstaDisc Series Control + + + + +
+

InstaDisc User Management

+ +

You can manage your users here. + + + + + + + + + + + + + +
UsernameActions
+ Delete +
+ +

Back to User Panel +

+ + -- cgit 1.4.1