diff options
Diffstat (limited to 'series/core')
-rw-r--r-- | series/core/trunk/admin/addsub.php | 129 | ||||
-rw-r--r-- | series/core/trunk/includes/instadisc.php | 6 | ||||
-rw-r--r-- | series/core/trunk/theme/addedsub.tpl | 13 | ||||
-rw-r--r-- | series/core/trunk/theme/addsub.tpl | 104 |
4 files changed, 252 insertions, 0 deletions
diff --git a/series/core/trunk/admin/addsub.php b/series/core/trunk/admin/addsub.php new file mode 100644 index 0000000..26a8109 --- /dev/null +++ b/series/core/trunk/admin/addsub.php | |||
@@ -0,0 +1,129 @@ | |||
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['id'] == '') | ||
30 | { | ||
31 | addError($numOfErrors, $errors, 'id', 'Subscription ID is a required field'); | ||
32 | } | ||
33 | |||
34 | if ($_POST['title'] == '') | ||
35 | { | ||
36 | addError($numOfErrors, $errors, 'title', 'Title is a required field'); | ||
37 | } | ||
38 | |||
39 | if ($_POST['url'] == '') | ||
40 | { | ||
41 | addError($numOfErrors, $errors, 'url', 'Subscription URL is a required field'); | ||
42 | } | ||
43 | |||
44 | if ($_POST['category'] == '') | ||
45 | { | ||
46 | addError($numOfErrors, $errors, 'category', 'Category is a required field'); | ||
47 | } | ||
48 | |||
49 | if ($numOfErrors > 0) | ||
50 | { | ||
51 | showForm($_POST['id'], $_POST['title'], $_POST['url'], $_POST['category'], $_POST['password'], $errors); | ||
52 | } else { | ||
53 | instaDisc_addSubscription($_POST['id'], $_POST['title'], $_POST['url'], $_POST['category'], $_POST['password']); | ||
54 | |||
55 | $template = new FITemplate('addedsub'); | ||
56 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
57 | $template->display(); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | function showForm($id, $title, $url, $category, $password, $errors) | ||
62 | { | ||
63 | $template = new FITemplate('addsub'); | ||
64 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
65 | |||
66 | if (isset($errors[1])) | ||
67 | { | ||
68 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
69 | |||
70 | foreach ($errors as $name => $value) | ||
71 | { | ||
72 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
73 | 'MSG' => $value['msg'])); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | $template->add('ID_ERR', ifErrors($errors, 'id')); | ||
78 | $template->add('TITLE_ERR', ifErrors($errors, 'title')); | ||
79 | $template->add('URL_ERR', ifErrors($errors, 'url')); | ||
80 | $template->add('CATEGORY_ERR', ifErrors($category, 'url')); | ||
81 | $template->add('PASSWORD_ERR', ifErrors($password, 'url')); | ||
82 | |||
83 | doErrors($template, $errors, 'id'); | ||
84 | doErrors($template, $errors, 'title'); | ||
85 | doErrors($template, $errors, 'url'); | ||
86 | doErrors($template, $errors, 'category'); | ||
87 | doErrors($template, $errors, 'password'); | ||
88 | |||
89 | $template->add('ID', $id); | ||
90 | $template->add('TITLE', $title); | ||
91 | $template->add('URL', $url); | ||
92 | $template->add('CATEGORY', $category); | ||
93 | $template->add('PASSWORD', $password); | ||
94 | |||
95 | $template->display(); | ||
96 | } | ||
97 | |||
98 | function ifErrors($errors, $id) | ||
99 | { | ||
100 | foreach ($errors as $name => $value) | ||
101 | { | ||
102 | if ($value['field'] == $id) | ||
103 | { | ||
104 | return ' error'; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return ''; | ||
109 | } | ||
110 | |||
111 | function doErrors($template, $errors, $id) | ||
112 | { | ||
113 | foreach ($errors as $name => $value) | ||
114 | { | ||
115 | if ($value['field'] == $id) | ||
116 | { | ||
117 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
118 | 'VALUE' => $value['msg'])); | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
124 | { | ||
125 | $numOfErrors++; | ||
126 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
127 | } | ||
128 | |||
129 | ?> | ||
diff --git a/series/core/trunk/includes/instadisc.php b/series/core/trunk/includes/instadisc.php index be6fcee..6cf4657 100644 --- a/series/core/trunk/includes/instadisc.php +++ b/series/core/trunk/includes/instadisc.php | |||
@@ -63,4 +63,10 @@ function instaDisc_changePassword($password) | |||
63 | $setconfig3 = mysql_fetch_array($setconfig2); | 63 | $setconfig3 = mysql_fetch_array($setconfig2); |
64 | } | 64 | } |
65 | 65 | ||
66 | function instaDisc_addSubscription($id, $title, $url, $category, $password = '') | ||
67 | { | ||
68 | $inssub = "INSERT INTO subscriptions (identity, title, url, category, password) VALUES (\"" . mysql_real_escape_string($id) . "\",\"" . mysql_real_escape_string($title) . "\",\"" . mysql_real_escape_string($url) . "\",\"" . mysql_real_escape_string($category) . "\",\"" . mysql_real_escape_string(($password == '' ? '' : md5($password))) . "\")"; | ||
69 | $inssub2 = mysql_query($inssub); | ||
70 | } | ||
71 | |||
66 | ?> | 72 | ?> |
diff --git a/series/core/trunk/theme/addedsub.tpl b/series/core/trunk/theme/addedsub.tpl new file mode 100644 index 0000000..5bf2faa --- /dev/null +++ b/series/core/trunk/theme/addedsub.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 Subscription</H1> | ||
9 | |||
10 | <P>You've successfully added a subscription! <A HREF="admin.php">Back to the ACP</A> | ||
11 | </CENTER> | ||
12 | </BODY> | ||
13 | </HTML> | ||
diff --git a/series/core/trunk/theme/addsub.tpl b/series/core/trunk/theme/addsub.tpl new file mode 100644 index 0000000..f16cee1 --- /dev/null +++ b/series/core/trunk/theme/addsub.tpl | |||
@@ -0,0 +1,104 @@ | |||
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 Subscription</H1> | ||
10 | |||
11 | <P>If you would like to add a new subscription to Series Control, please fill out the form below. | ||
12 | </CENTER> | ||
13 | |||
14 | <FORM CLASS="uniform" ACTION="./admin.php?id=addsub&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>Series Control Info</LEGEND> | ||
32 | |||
33 | <DIV CLASS="ctrlHolder<!--ID_ERR-->"> | ||
34 | <!--BEGIN ID_ERRS--> | ||
35 | <P ID="error<!--ID_ERRS.NAME-->" CLASS="errorField"><EM>*</EM> | ||
36 | <!--ID_ERRS.MSG--> | ||
37 | </P> | ||
38 | <!--END ID_ERRS--> | ||
39 | |||
40 | <LABEL FOR="id"><EM>*</EM> Subscription ID: </LABEL> | ||
41 | <INPUT TYPE="text" ID="id" NAME="id" CLASS="textInput" VALUE="<!--ID-->"> | ||
42 | |||
43 | <P CLASS="formHint">This is a short, unique string used to identify this subscription in Series Control.</P> | ||
44 | </DIV> | ||
45 | </FIELDSET> | ||
46 | |||
47 | <FIELDSET CLASS="inlineLabels"> | ||
48 | <LEGEND>Subscription Info</LEGEND> | ||
49 | |||
50 | <DIV CLASS="ctrlHolder<!--TITLE_ERR-->"> | ||
51 | <!--BEGIN TITLE_ERRS--> | ||
52 | <P ID="error<!--TITLE_ERRS.NAME-->" CLASS="errorField"><EM>*</EM> | ||
53 | <!--TITLE_ERRS.MSG--> | ||
54 | </P> | ||
55 | <!--END TITLE_ERRS--> | ||
56 | |||
57 | <LABEL FOR="title"><EM>*</EM> Title: </LABEL> | ||
58 | <INPUT TYPE="text" ID="title" NAME="title" CLASS="textInput" VALUE="<!--TITLE-->"> | ||
59 | </DIV> | ||
60 | |||
61 | <DIV CLASS="ctrlHolder<!--URL_ERR-->"> | ||
62 | <!--BEGIN URL_ERRS--> | ||
63 | <P ID="error<!--URL_ERRS.NAME-->" CLASS="errorField"><EM>*</EM> | ||
64 | <!--URL_ERRS.MSG--> | ||
65 | </P> | ||
66 | <!--END URL_ERRS--> | ||
67 | |||
68 | <LABEL FOR="url"><EM>*</EM> Subscription URL: </LABEL> | ||
69 | <INPUT TYPE="text" ID="url" NAME="url" CLASS="textInput" VALUE="<!--URL-->"> | ||
70 | |||
71 | <P CLASS="formHint">This is a unique URL used to identify this subscription on the Client.</P> | ||
72 | </DIV> | ||
73 | |||
74 | <DIV CLASS="ctrlHolder<!--CATEGORY_ERR-->"> | ||
75 | <!--BEGIN CATEGORY_ERRS--> | ||
76 | <P ID="error<!--CATEGORY_ERRS.NAME-->" CLASS="errorField"><EM>*</EM> | ||
77 | <!--CATEGORY_ERRS.MSG--> | ||
78 | </P> | ||
79 | <!--END CATEGORY_ERRS--> | ||
80 | |||
81 | <LABEL FOR="category"><EM>*</EM> Category: </LABEL> | ||
82 | <INPUT TYPE="text" ID="category" NAME="category" CLASS="textInput" VALUE="<!--CATEGORY-->"> | ||
83 | </DIV> | ||
84 | |||
85 | <DIV CLASS="ctrlHolder<!--PASSWORD_ERR-->"> | ||
86 | <!--BEGIN PASSWORD_ERRS--> | ||
87 | <P ID="error<!--PASSWORD_ERRS.NAME-->" CLASS="errorField"><EM>*</EM> | ||
88 | <!--PASSWORD_ERRS.MSG--> | ||
89 | </P> | ||
90 | <!--END PASSWORD_ERRS--> | ||
91 | |||
92 | <LABEL FOR="password">Password: </LABEL> | ||
93 | <INPUT TYPE="password" ID="password" NAME="password" CLASS="textInput" VALUE="<!--PASSWORD-->"> | ||
94 | |||
95 | <P CLASS="formHint">If this subscription is encrypted, enter it's password here. Otherwise, leave it blank.</P> | ||
96 | </DIV> | ||
97 | </FIELDSET> | ||
98 | |||
99 | <DIV CLASS="buttonHolder"> | ||
100 | <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> | ||
101 | </DIV> | ||
102 | </FORM> | ||
103 | </BODY> | ||
104 | </HTML> | ||