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 ++++++++++++++++ 8 files changed, 212 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 (limited to 'series/trunk/admin') 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(); + +?> -- cgit 1.4.1