diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-07 14:55:06 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-07 14:55:06 +0000 |
commit | 5e84520b571eda5f69ce907aa838820533fd0737 (patch) | |
tree | 5cc2dca6dcbf4fe72c4d4a720ddd7f0c582006ea | |
parent | 866a1d8567457b451d61339064b52973419b2b0b (diff) | |
download | instadisc-5e84520b571eda5f69ce907aa838820533fd0737.tar.gz instadisc-5e84520b571eda5f69ce907aa838820533fd0737.tar.bz2 instadisc-5e84520b571eda5f69ce907aa838820533fd0737.zip |
Series: Started ACP
Refs #53
-rw-r--r-- | series/core/trunk/admin.php | 21 | ||||
-rw-r--r-- | series/core/trunk/admin/login.php | 95 | ||||
-rw-r--r-- | series/core/trunk/admin/main.php | 25 | ||||
-rw-r--r-- | series/core/trunk/includes/instadisc.php | 5 | ||||
-rw-r--r-- | series/core/trunk/theme/loggedin.tpl | 14 | ||||
-rw-r--r-- | series/core/trunk/theme/login.tpl | 61 | ||||
-rw-r--r-- | series/core/trunk/theme/main.tpl | 13 |
7 files changed, 234 insertions, 0 deletions
diff --git a/series/core/trunk/admin.php b/series/core/trunk/admin.php new file mode 100644 index 0000000..db637bd --- /dev/null +++ b/series/core/trunk/admin.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /* InstaDisc Series - A Four Island Project */ | ||
4 | |||
5 | session_start(); | ||
6 | |||
7 | include('includes/instadisc.php'); | ||
8 | |||
9 | if (!isset($_GET['id']) || !isset($_SESSION['username'])) | ||
10 | { | ||
11 | if (!isset($_SESSION['username'])) | ||
12 | { | ||
13 | include('admin/login.php'); | ||
14 | } else { | ||
15 | include('admin/main.php'); | ||
16 | } | ||
17 | } else { | ||
18 | include('admin/' . basename($_GET['id']) . '.php'); | ||
19 | } | ||
20 | |||
21 | ?> | ||
diff --git a/series/core/trunk/admin/login.php b/series/core/trunk/admin/login.php new file mode 100644 index 0000000..fe394a1 --- /dev/null +++ b/series/core/trunk/admin/login.php | |||
@@ -0,0 +1,95 @@ | |||
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($_GET['submit'])) | ||
17 | { | ||
18 | showForm('','',array()); | ||
19 | } else { | ||
20 | $numOfErrors = 0; | ||
21 | $errors = array(); | ||
22 | |||
23 | if (instaDisc_verifyUser($_POST['username'], $_POST['password'])) | ||
24 | { | ||
25 | $_SESSION['username'] = $_POST['username']; | ||
26 | |||
27 | $template = new FITemplate('loggedin'); | ||
28 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
29 | $template->display(); | ||
30 | } else { | ||
31 | addError($numOfErrors, $errors, '', 'Account could not be found'); | ||
32 | showForm($_POST['username'], $_POST['password'], $errors); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | function showForm($username, $password, $errors) | ||
37 | { | ||
38 | $template = new FITemplate('login'); | ||
39 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
40 | |||
41 | if (isset($errors[1])) | ||
42 | { | ||
43 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
44 | |||
45 | foreach ($errors as $name => $value) | ||
46 | { | ||
47 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
48 | 'MSG' => $value['msg'])); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | $template->add('USERNAME_ERR', ifErrors($errors, 'username')); | ||
53 | $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); | ||
54 | |||
55 | doErrors($template, $errors, 'username'); | ||
56 | doErrors($template, $errors, 'password'); | ||
57 | |||
58 | $template->add('USERNAME', $username); | ||
59 | $template->add('PASSWORD', $password); | ||
60 | |||
61 | $template->display(); | ||
62 | } | ||
63 | |||
64 | function ifErrors($errors, $id) | ||
65 | { | ||
66 | foreach ($errors as $name => $value) | ||
67 | { | ||
68 | if ($value['field'] == $id) | ||
69 | { | ||
70 | return ' error'; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | return ''; | ||
75 | } | ||
76 | |||
77 | function doErrors($template, $errors, $id) | ||
78 | { | ||
79 | foreach ($errors as $name => $value) | ||
80 | { | ||
81 | if ($value['field'] == $id) | ||
82 | { | ||
83 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
84 | 'VALUE' => $value['msg'])); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
90 | { | ||
91 | $numOfErrors++; | ||
92 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
93 | } | ||
94 | |||
95 | ?> | ||
diff --git a/series/core/trunk/admin/main.php b/series/core/trunk/admin/main.php new file mode 100644 index 0000000..eb0e35b --- /dev/null +++ b/series/core/trunk/admin/main.php | |||
@@ -0,0 +1,25 @@ | |||
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 | } | ||
20 | |||
21 | $template = new FITemplate('main'); | ||
22 | $template->add('SITENAME',instaDisc_getConfig('siteName')); | ||
23 | $template->display(); | ||
24 | |||
25 | ?> | ||
diff --git a/series/core/trunk/includes/instadisc.php b/series/core/trunk/includes/instadisc.php index 3e0ff32..e044cdc 100644 --- a/series/core/trunk/includes/instadisc.php +++ b/series/core/trunk/includes/instadisc.php | |||
@@ -51,4 +51,9 @@ function instaDisc_getConfig($name) | |||
51 | return $getconfig3['value']; | 51 | return $getconfig3['value']; |
52 | } | 52 | } |
53 | 53 | ||
54 | function instaDisc_verifyUser($username, $password) | ||
55 | { | ||
56 | return (($username == instaDisc_getConfig('adminUser')) && (md5($password) == instaDisc_getConfig('adminPass'))); | ||
57 | } | ||
58 | |||
54 | ?> | 59 | ?> |
diff --git a/series/core/trunk/theme/loggedin.tpl b/series/core/trunk/theme/loggedin.tpl new file mode 100644 index 0000000..b5e317a --- /dev/null +++ b/series/core/trunk/theme/loggedin.tpl | |||
@@ -0,0 +1,14 @@ | |||
1 | <HTML> | ||
2 | <HEAD> | ||
3 | <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE> | ||
4 | </HEAD> | ||
5 | |||
6 | <BODY> | ||
7 | <CENTER> | ||
8 | <H1>InstaDisc Sign-in</H1> | ||
9 | |||
10 | <P>Thank you for logging in. <A HREF="admin.php">You may now procede to the ACP</A> | ||
11 | </CENTER> | ||
12 | </BODY> | ||
13 | </HTML> | ||
14 | |||
diff --git a/series/core/trunk/theme/login.tpl b/series/core/trunk/theme/login.tpl new file mode 100644 index 0000000..2cc2a82 --- /dev/null +++ b/series/core/trunk/theme/login.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 Sign-in</H1> | ||
10 | |||
11 | <P>If you are the administrator of this Series Control, feel free to login here. | ||
12 | </CENTER> | ||
13 | |||
14 | <FORM CLASS="uniform" ACTION="./admin.php?id=login&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 Details</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"><EM>*</EM> 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/core/trunk/theme/main.tpl b/series/core/trunk/theme/main.tpl new file mode 100644 index 0000000..982be74 --- /dev/null +++ b/series/core/trunk/theme/main.tpl | |||
@@ -0,0 +1,13 @@ | |||
1 | <CENTER> | ||
2 | <H1><!--SITENAME--></H2><P> | ||
3 | <H2>Series Control ACP</H2><P> | ||
4 | |||
5 | Here are some actions you can preform: | ||
6 | |||
7 | <UL> | ||
8 | <LI><A HREF="admin.php?id=chpwd">Change your Password</A></LI> | ||
9 | <LI><A HREF="admin.php?id=addsub">Add a new Subscription</A></LI> | ||
10 | <LI><A HREF="admin.php?id=mansub">Manage subscriptions</A></LI> | ||
11 | <LI><A HREF="admin.php?id=logout">Log out</A></LI> | ||
12 | </UL> | ||
13 | </CENTER> | ||