diff options
Diffstat (limited to 'series/trunk/admin')
-rw-r--r-- | series/trunk/admin/addsub.php | 4 | ||||
-rw-r--r-- | series/trunk/admin/adduser.php | 110 | ||||
-rw-r--r-- | series/trunk/admin/chpwd.php | 2 | ||||
-rw-r--r-- | series/trunk/admin/deletesub.php | 1 | ||||
-rw-r--r-- | series/trunk/admin/deleteuser.php | 49 | ||||
-rw-r--r-- | series/trunk/admin/main.php | 1 | ||||
-rw-r--r-- | series/trunk/admin/mansub.php | 1 | ||||
-rw-r--r-- | series/trunk/admin/manuser.php | 46 |
8 files changed, 212 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 | */ | ||
14 | require_once('includes/instadisc.php'); | ||
15 | |||
16 | if (!isset($_SESSION['username'])) | ||
17 | { | ||
18 | header('Location: index.php'); | ||
19 | exit; | ||
20 | } | ||
21 | |||
22 | if (!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 | |||
51 | function 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 | |||
79 | function 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 | |||
92 | function 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 | |||
104 | function 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'); | |||
16 | if (!isset($_SESSION['username'])) | 16 | if (!isset($_SESSION['username'])) |
17 | { | 17 | { |
18 | header('Location: index.php'); | 18 | header('Location: index.php'); |
19 | exit; | ||
19 | } | 20 | } |
20 | 21 | ||
21 | if (isset($_SESSION['username'])) | 22 | if (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 | ||
70 | function showForm($old, $new, $confirm, $errors) | 72 | 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'); | |||
16 | if (!isset($_SESSION['username'])) | 16 | if (!isset($_SESSION['username'])) |
17 | { | 17 | { |
18 | header('Location: index.php'); | 18 | header('Location: index.php'); |
19 | exit; | ||
19 | } | 20 | } |
20 | 21 | ||
21 | if (!instaDisc_isAdmin($_SESSION['username'])) | 22 | 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 @@ | |||
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 | */ | ||
14 | require_once('includes/instadisc.php'); | ||
15 | |||
16 | if (!isset($_SESSION['username'])) | ||
17 | { | ||
18 | header('Location: index.php'); | ||
19 | exit; | ||
20 | } | ||
21 | |||
22 | if (!instaDisc_isAdmin($_SESSION['username'])) | ||
23 | { | ||
24 | header('Location: index.php'); | ||
25 | exit; | ||
26 | } | ||
27 | |||
28 | if (!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'); | |||
16 | if (!isset($_SESSION['username'])) | 16 | if (!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'); | |||
16 | if (!isset($_SESSION['username'])) | 16 | if (!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 | */ | ||
14 | require_once('includes/instadisc.php'); | ||
15 | |||
16 | if (!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 | |||
25 | if (instaDisc_isAdmin($_SESSION['username'])) | ||
26 | { | ||
27 | $users = instaDisc_getAllUsers(); | ||
28 | } else { | ||
29 | header('Location: index.php'); | ||
30 | exit; | ||
31 | } | ||
32 | $i=0; $j=0; | ||
33 | for ($i=0;isset($users[$i]);$i++) | ||
34 | { | ||
35 | $j++; | ||
36 | } | ||
37 | $j--; | ||
38 | for ($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 | ?> | ||