about summary refs log tree commit diff stats
path: root/series/trunk
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 15:49:20 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 15:49:20 +0000
commitabb2d3c67ddc132c4cc7ea435e13731527c32634 (patch)
tree65aa76b08708397dd79cee29f4bc09826825a1bb /series/trunk
parent7bb63b11cd21e97ddece876d46d9e06e81b95a55 (diff)
downloadinstadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.tar.gz
instadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.tar.bz2
instadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.zip
Series: Worked on ACP
Refs #53
Diffstat (limited to 'series/trunk')
-rw-r--r--series/trunk/admin/deletesub.php70
-rw-r--r--series/trunk/admin/editsub.php151
-rw-r--r--series/trunk/admin/mansub.php39
-rw-r--r--series/trunk/includes/instadisc.php13
-rw-r--r--series/trunk/install.php1
-rw-r--r--series/trunk/subscription.php15
-rw-r--r--series/trunk/theme/deletedsub.tpl15
-rw-r--r--series/trunk/theme/deletesub.tpl21
-rw-r--r--series/trunk/theme/editedsub.tpl13
-rw-r--r--series/trunk/theme/editsub.tpl104
-rw-r--r--series/trunk/theme/mansub.tpl32
-rw-r--r--series/trunk/theme/subscription.tpl8
12 files changed, 475 insertions, 7 deletions
diff --git a/series/trunk/admin/deletesub.php b/series/trunk/admin/deletesub.php new file mode 100644 index 0000000..37b0bee --- /dev/null +++ b/series/trunk/admin/deletesub.php
@@ -0,0 +1,70 @@
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 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19}
20
21if (!instaDisc_isAdmin($_SESSION['username']))
22{
23 $subs = instaDisc_listSubscriptions($_SESSION['username']);
24 $i=0;
25 $notfound=1;
26 for ($i=0;isset($subs[$i]);$i++)
27 {
28 if (!isset($_GET['submit']))
29 {
30 if ($subs[$i]['identity'] == $_POST['id'])
31 {
32 $notfound=0;
33 }
34 } else {
35 if ($subs[$i]['id'] == $_GET['subid'])
36 {
37 $notfound=0;
38 }
39 }
40 }
41
42 if ($notfound == 1)
43 {
44 header('Location: index.php');
45 exit;
46 }
47}
48
49if (!isset($_GET['submit']))
50{
51 $template = new FITemplate('deletesub');
52 $template->add('SITENAME',instaDisc_getConfig('siteName'));
53 $template->add('ID',$_GET['subid']);
54
55 $sub = instaDisc_getSubscription($_GET['subid']);
56 $template->add('IDENTITY',$sub['identity']);
57 $template->display();
58} else {
59 if ($_POST['submit'] == 'Yes')
60 {
61 instaDisc_deleteSubscription($_POST['id']);
62
63 $template = new FITemplate('deletedsub');
64 $template->display();
65 } else {
66 header('Location: admin.php?id=main');
67 }
68}
69
70?>
diff --git a/series/trunk/admin/editsub.php b/series/trunk/admin/editsub.php new file mode 100644 index 0000000..cafd217 --- /dev/null +++ b/series/trunk/admin/editsub.php
@@ -0,0 +1,151 @@
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 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22if (!instaDisc_isAdmin($_SESSION['username']))
23{
24 $subs = instaDisc_listSubscriptions($_SESSION['username']);
25 $i=0;
26 $notfound=1;
27 for ($i=0;isset($subs[$i]);$i++)
28 {
29 if (!isset($_GET['submit']))
30 {
31 if ($subs[$i]['identity'] == $_POST['id'])
32 {
33 $notfound=0;
34 }
35 } else {
36 if ($subs[$i]['id'] == $_GET['subid'])
37 {
38 $notfound=0;
39 }
40 }
41 }
42
43 if ($notfound == 1)
44 {
45 header('Location: index.php');
46 exit;
47 }
48}
49
50if (!isset($_GET['submit']))
51{
52 $sub = instaDisc_getSubscription($_GET['subid']);
53 showForm($sub['identity'],$sub['title'],$sub['category'],$sub['url'],$sub['password'],array());
54} else {
55 $numOfErrors = 0;
56 $errors = array();
57
58 if ($_POST['title'] == '')
59 {
60 addError($numOfErrors, $errors, 'title', 'Title is a required field');
61 }
62
63 if ($_POST['url'] == '')
64 {
65 addError($numOfErrors, $errors, 'url', 'Subscription URL is a required field');
66 }
67
68 if ($_POST['category'] == '')
69 {
70 addError($numOfErrors, $errors, 'category', 'Category is a required field');
71 }
72
73 if ($numOfErrors > 0)
74 {
75 showForm($_POST['id'], $_POST['title'], $_POST['url'], $_POST['category'], $_POST['password'], $errors);
76 } else {
77 instaDisc_initSubscription($_SESSION['username'], $_POST['id'], $_POST['url'], $_POST['title'], $_POST['category'], $_POST['personal'], $_POST['password']);
78
79 $template = new FITemplate('editedsub');
80 $template->add('SITENAME', instaDisc_getConfig('siteName'));
81 $template->display();
82 }
83}
84
85function showForm($id, $title, $url, $category, $password, $errors)
86{
87 $template = new FITemplate('editsub');
88 $template->add('SITENAME', instaDisc_getConfig('siteName'));
89
90 if (isset($errors[1]))
91 {
92 $template->adds_block('ERROR', array('ex'=>'1'));
93
94 foreach ($errors as $name => $value)
95 {
96 $template->adds_block('ERRORS', array( 'NAME' => $name,
97 'MSG' => $value['msg']));
98 }
99 }
100
101 $template->add('TITLE_ERR', ifErrors($errors, 'title'));
102 $template->add('URL_ERR', ifErrors($errors, 'url'));
103 $template->add('CATEGORY_ERR', ifErrors($errors, 'url'));
104 $template->add('PASSWORD_ERR', ifErrors($errors, 'url'));
105
106 doErrors($template, $errors, 'title');
107 doErrors($template, $errors, 'url');
108 doErrors($template, $errors, 'category');
109 doErrors($template, $errors, 'password');
110
111 $template->add('ID', $id);
112 $template->add('TITLE', $title);
113 $template->add('URL', $url);
114 $template->add('CATEGORY', $category);
115 $template->add('PASSWORD', $password);
116
117 $template->display();
118}
119
120function ifErrors($errors, $id)
121{
122 foreach ($errors as $name => $value)
123 {
124 if ($value['field'] == $id)
125 {
126 return ' error';
127 }
128 }
129
130 return '';
131}
132
133function doErrors($template, $errors, $id)
134{
135 foreach ($errors as $name => $value)
136 {
137 if ($value['field'] == $id)
138 {
139 $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name,
140 'VALUE' => $value['msg']));
141 }
142 }
143}
144
145function addError(&$numOfErrors, &$errors, $field, $msg)
146{
147 $numOfErrors++;
148 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
149}
150
151?>
diff --git a/series/trunk/admin/mansub.php b/series/trunk/admin/mansub.php new file mode 100644 index 0000000..358365f --- /dev/null +++ b/series/trunk/admin/mansub.php
@@ -0,0 +1,39 @@
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 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19}
20
21$template = new FITemplate('mansub');
22$template->add('SITENAME', instaDisc_getConfig('siteName'));
23
24if (instaDisc_isAdmin($_SESSION['username']))
25{
26 $subs = instaDisc_getAllSubscriptions();
27} else {
28 $subs = instaDisc_listSubscriptions($_SESSION['username']);
29}
30$i=0;
31for ($i=0;isset($subs[$i]);$i++)
32{
33 $template->adds_block('SUBSCRIPTION', array( 'IDENTITY' => $subs['identity'],
34 'ID' => $subs['id']));
35}
36
37$template->display();
38
39?>
diff --git a/series/trunk/includes/instadisc.php b/series/trunk/includes/instadisc.php index a5afb3a..54f427a 100644 --- a/series/trunk/includes/instadisc.php +++ b/series/trunk/includes/instadisc.php
@@ -97,4 +97,17 @@ function initSubscription($username, $subscriptionID, $subscriptionURL, $subscri
97 } 97 }
98} 98}
99 99
100function instaDisc_listSubscriptions($username)
101{
102 $getsubs = "SELECT * FROM subscriptions WHERE username = \"" . mysql_real_escape_string($username) . "\"";
103 $getsubs2 = mysql_query($getsubs);
104 $i=0;
105 while ($getsubs3[$i] = mysql_fetch_array($getsubs2))
106 {
107 $i++;
108 }
109
110 return $getsubs3;
111}
112
100?> 113?>
diff --git a/series/trunk/install.php b/series/trunk/install.php index 868726d..905344b 100644 --- a/series/trunk/install.php +++ b/series/trunk/install.php
@@ -208,7 +208,6 @@ function showStepTwo($siteName, $adminUser, $adminPass, $errors)
208<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'siteName'); ?>"> 208<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'siteName'); ?>">
209<?php doErrors($errors, 'siteName'); ?> <LABEL FOR="siteName"><EM>*</EM> Site Name: </LABEL> 209<?php doErrors($errors, 'siteName'); ?> <LABEL FOR="siteName"><EM>*</EM> Site Name: </LABEL>
210 <INPUT TYPE="text" ID="siteName" NAME="siteName" CLASS="textInput" VALUE="<?php echo($siteName); ?>"> 210 <INPUT TYPE="text" ID="siteName" NAME="siteName" CLASS="textInput" VALUE="<?php echo($siteName); ?>">
211 <P CLASS="formHint">Your website's name is required for a little personalization of emails.</P>
212</DIV> 211</DIV>
213</FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Administrator User Details</LEGEND> 212</FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Administrator User Details</LEGEND>
214<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminUser'); ?>"> 213<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminUser'); ?>">
diff --git a/series/trunk/subscription.php b/series/trunk/subscription.php index 81c3870..4db5736 100644 --- a/series/trunk/subscription.php +++ b/series/trunk/subscription.php
@@ -18,16 +18,19 @@ if (!instaDisc_subscriptionExists($_GET['id']))
18 18
19$sub = instaDisc_getSubscription($_GET['id']); 19$sub = instaDisc_getSubscription($_GET['id']);
20 20
21echo('Subscription: ' . $sub['url'] . "\n"); 21$template = new FITemplate('subscription');
22echo('Title: ' . $sub['title'] . "\n"); 22$template->add('SUBSCRIPTION', $sub['url']);
23echo('Category: ' . $sub['category'] . "\n"); 23$template->add('TITLE', $sub['title']);
24$template->add('CATEGORY', $sub['category']);
24 25
25if ($sub['password'] != '') 26if ($sub['password'] != '')
26{ 27{
27 echo("Password: On\n"); 28 $template->add('PASSWORD', "Password: On\n");
28} 29}
29 30
30echo('Series-Control-URL: http://' . $_SERVER['SERVER_NAME'] . str_replace(basename($_SERVER['PHP_SELF']), 'xmlrpc.php', $_SERVER['PHP_SELF']) . "\n"); 31$template->add('SERIESURL', 'http://' . $_SERVER['SERVER_NAME'] . str_replace(basename($_SERVER['PHP_SELF']), 'xmlrpc.php', $_SERVER['PHP_SELF']));
31echo('Subscription-ID: ' . $_GET['id'] . "\n"); 32$template->add('SUBID', $_GET['id']);
33
34$template->display();
32 35
33?> 36?>
diff --git a/series/trunk/theme/deletedsub.tpl b/series/trunk/theme/deletedsub.tpl new file mode 100644 index 0000000..0b7a796 --- /dev/null +++ b/series/trunk/theme/deletedsub.tpl
@@ -0,0 +1,15 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc Subscription Deletion</H1>
9
10 <P>You have successfully deleted your subscription!
11
12 <P><A HREF="admin.php?id=main">Back to User Panel</A>
13 </CENTER>
14 </BODY>
15</HTML>
diff --git a/series/trunk/theme/deletesub.tpl b/series/trunk/theme/deletesub.tpl new file mode 100644 index 0000000..af1cb6e --- /dev/null +++ b/series/trunk/theme/deletesub.tpl
@@ -0,0 +1,21 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc Subscription Deletion</H1>
9
10 <P>Are you sure you would like to delete <!--IDENTITY-->?
11
12 <FORM ACTION="./admin.php?id=deletesub&amp;submit=" METHOD="POST">
13 <INPUT TYPE="hidden" NAME="id" VALUE="<!--ID-->">
14 <INPUT TYPE="submit" NAME="submit" VALUE="Yes">
15 <INPUT TYPE="submit" NAME="submit" VALUE="No">
16 </FORM>
17 </CENTER>
18 </BODY>
19</HTML>
20
21
diff --git a/series/trunk/theme/editedsub.tpl b/series/trunk/theme/editedsub.tpl new file mode 100644 index 0000000..f0360c3 --- /dev/null +++ b/series/trunk/theme/editedsub.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 Edit Subscription</H1>
9
10 <P>You've successfully edited a subscription! <A HREF="admin.php">Back to the ACP</A>
11 </CENTER>
12 </BODY>
13</HTML>
diff --git a/series/trunk/theme/editsub.tpl b/series/trunk/theme/editsub.tpl new file mode 100644 index 0000000..7a88a81 --- /dev/null +++ b/series/trunk/theme/editsub.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 Edit Subscription</H1>
10
11 <P>You can edit a subscription here.
12 </CENTER>
13
14 <FORM CLASS="uniform" ACTION="./admin.php?id=editsub&amp;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-->" READONLY="READONLY">
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>
diff --git a/series/trunk/theme/mansub.tpl b/series/trunk/theme/mansub.tpl new file mode 100644 index 0000000..ca62d74 --- /dev/null +++ b/series/trunk/theme/mansub.tpl
@@ -0,0 +1,32 @@
1<HTML>
2 <HEAD>
3 <TITLE><!--SITENAME--> InstaDisc Series Control</TITLE>
4 </HEAD>
5
6 <BODY>
7 <CENTER>
8 <H1>InstaDisc Subscription Management</H1>
9
10 <P>You can manage your subscriptions here.
11
12 <TABLE>
13 <TR>
14 <TH>Subscription URL</TH>
15 <TH>Actions</TH>
16 </TR>
17
18 <!--BEGIN SUBSCRIPTIONS-->
19 <TR>
20 <TD><!--SUBSCRIPTIONS.IDENTITY--></TD>
21 <TD>
22 <A HREF="admin.php?id=editsub&amp;subid=<!--SUBSCRIPTIONS.ID-->">Edit</A><BR>
23 <A HREF="admin.php?id=deletesub&amp;subid=<!--SUBSCRIPTIONS.ID-->">Delete</A>
24 </TD>
25 </TR>
26 <!--END SUBSCRIPTIONS-->
27 </TABLE>
28
29 <P><A HREF="admin.php?id=main">Back to User Panel</A>
30 </CENTER>
31 </BODY>
32</HTML>
diff --git a/series/trunk/theme/subscription.tpl b/series/trunk/theme/subscription.tpl new file mode 100644 index 0000000..cd6050b --- /dev/null +++ b/series/trunk/theme/subscription.tpl
@@ -0,0 +1,8 @@
1<DIV STYLE="display: none;">:
2Subscription: <!--SUBSCRIPTION-->
3Title: <!--TITLE-->
4Category: <!--CATEGORY-->
5<!--PASSWORD-->Series-Control-URL: <!--SERIESURL-->
6Subscription-ID: <!--SUBID-->
7End: </DIV><DIV STYLE="margin: 0 auto; margin-top: 5em; width: 500px; background-color: #FBEC5D; text-align: center; padding: 4px;"><B>This is an InstaDisc Subscription file.</B><P>If you would like to subscribe to the InstaDisc subscription:<BR><I><!--TITLE--></I> (<U><!--CATEGORY--></U>)<BR>Copy the address of this file to the "Add Subscription" form on your InstaDisc client.</DIV>
8