diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-18 21:59:23 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-18 21:59:23 +0000 |
commit | fd3f2cbdaa1e3c160727c3cf09ef03d06174c114 (patch) | |
tree | 12ea30a00c68891f2fbc01f5b2730bc6edc153aa /series/trunk/admin/editsub.php | |
parent | d2a7b26e98569624347d717d7fdfe6c3074658a9 (diff) | |
download | instadisc-fd3f2cbdaa1e3c160727c3cf09ef03d06174c114.tar.gz instadisc-fd3f2cbdaa1e3c160727c3cf09ef03d06174c114.tar.bz2 instadisc-fd3f2cbdaa1e3c160727c3cf09ef03d06174c114.zip |
Series: Removed Series component
Refs #57
Diffstat (limited to 'series/trunk/admin/editsub.php')
-rw-r--r-- | series/trunk/admin/editsub.php | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/series/trunk/admin/editsub.php b/series/trunk/admin/editsub.php deleted file mode 100644 index e49a971..0000000 --- a/series/trunk/admin/editsub.php +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
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 | $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 | |||
50 | if (!isset($_GET['submit'])) | ||
51 | { | ||
52 | $sub = instaDisc_getSubscriptionByID($_GET['subid']); | ||
53 | showForm($sub['identity'],$sub['title'],$sub['url'],$sub['category'],$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['password']); | ||
78 | |||
79 | $template = new FITemplate('editedsub'); | ||
80 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
81 | $template->display(); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | function 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 | |||
120 | function 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 | |||
133 | function 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 | |||
145 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
146 | { | ||
147 | $numOfErrors++; | ||
148 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
149 | } | ||
150 | |||
151 | ?> | ||