about summary refs log tree commit diff stats
path: root/central/trunk/addsub.php
diff options
context:
space:
mode:
Diffstat (limited to 'central/trunk/addsub.php')
-rw-r--r--central/trunk/addsub.php94
1 files changed, 0 insertions, 94 deletions
diff --git a/central/trunk/addsub.php b/central/trunk/addsub.php deleted file mode 100644 index fd46234..0000000 --- a/central/trunk/addsub.php +++ /dev/null
@@ -1,94 +0,0 @@
1<?php
2
3/* InstaDisc Server - A Four Island Project */
4
5include('includes/instadisc.php');
6include('includes/template.php');
7
8if (!isset($_GET['submit']))
9{
10 showForm('',array());
11} else {
12 $numOfErrors = 0;
13 $errors = array();
14
15 if ($_POST['url'] == '')
16 {
17 addError($numOfErrors, $errors, 'url', 'URL is a required field');
18 }
19
20 if ($numOfErrors > 0)
21 {
22 showForm($_POST['url'], $errors);
23 } else {
24 $key = instaDisc_generateSubscriptionActivation($_SESSION['username'], $_POST['url']);
25 if ($key !== FALSE)
26 {
27 $template = new FITemplate('addedsub');
28 $template->add('SITENAME', instaDisc_getConfig('siteName'));
29 $template->add('KEY', $key);
30 $template->display();
31 } else {
32 addError($numOfErrors, $errors, '', 'Unknown error');
33 showForm($_POST['url'], $errors);
34 }
35 }
36}
37
38function showForm($url, $errors)
39{
40 $template = new FITemplate('addsub');
41 $template->add('SITENAME', instaDisc_getConfig('siteName'));
42
43 if (isset($errors[1]))
44 {
45 $template->adds_block('ERROR', array('ex'=>'1'));
46
47 foreach ($errors as $name => $value)
48 {
49 $template->adds_block('ERRORS', array( 'NAME' => $name,
50 'MSG' => $value['msg']));
51 }
52 }
53
54 $template->add('URL_ERR', ifErrors($errors, 'url'));
55
56 doErrors($template, $errors, 'url');
57
58 $template->add('URL', $url);
59
60 $template->display();
61}
62
63function ifErrors($errors, $id)
64{
65 foreach ($errors as $name => $value)
66 {
67 if ($value['field'] == $id)
68 {
69 return ' error';
70 }
71 }
72
73 return '';
74}
75
76function doErrors($template, $errors, $id)
77{
78 foreach ($errors as $name => $value)
79 {
80 if ($value['field'] == $id)
81 {
82 $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name,
83 'VALUE' => $value['msg']));
84 }
85 }
86}
87
88function addError(&$numOfErrors, &$errors, $field, $msg)
89{
90 $numOfErrors++;
91 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
92}
93
94?>