about summary refs log tree commit diff stats
path: root/central
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-08-08 12:26:08 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-08-08 12:26:08 +0000
commit4116da2199a163a72860f6265d52a2ae0b860967 (patch)
tree0e850bcbf770d50f8de04b1ae537d9c30c8bd1e5 /central
parent70f4caa35e06a9607b942cddfe9f3f9d6a0078d5 (diff)
downloadinstadisc-4116da2199a163a72860f6265d52a2ae0b860967.tar.gz
instadisc-4116da2199a163a72860f6265d52a2ae0b860967.tar.bz2
instadisc-4116da2199a163a72860f6265d52a2ae0b860967.zip
Central: Started default frontend
The default frontend is based on Four Island's. Perhaps at some point a templating system may be introduced to make frontending
a little easier. Refs #25
Diffstat (limited to 'central')
-rw-r--r--central/trunk/activate.php126
-rw-r--r--central/trunk/index.php26
-rw-r--r--central/trunk/register.php132
3 files changed, 284 insertions, 0 deletions
diff --git a/central/trunk/activate.php b/central/trunk/activate.php new file mode 100644 index 0000000..c8d4aa0 --- /dev/null +++ b/central/trunk/activate.php
@@ -0,0 +1,126 @@
1<?php
2
3/* InstaDisc Server - A Four Island Project */
4
5include('instadisc.php');
6
7if (!isset($_GET['submit']))
8{
9 showForm('','',array());
10} else {
11 $numOfErrors = 0;
12 $errors = array();
13
14 $getpending = "SELECT * FROM pending WHERE username = \"" . mysql_real_escape_string($_POST['username']) . "\" AND code = \"" . mysql_real_escape_string($_POST['code']) . "\"";
15 $getpending2 = mysql_query($getpending);
16 $getpending3 = mysql_fetch_array($getpending2);
17 if ($getpending3['username'] != $_POST['username'])
18 {
19 addError($numOfErrors, $errors, '', 'Account could not be found');
20 }
21
22 if ($numOfErrors > 0)
23 {
24 showForm($_POST['username'], $_POST['code'], $errors);
25 } else {
26 if ($_POST['submit'] == "Verify")
27 {
28 if (instaDisc_activateAccount($_POST['username'], $_POST['code']))
29 {
30?>
31<HTML>
32 <HEAD>
33 <TITLE><?php echo(instaDisc_getConfig('siteName')); ?> InstaDisc Central Server</TITLE>
34 </HEAD>
35 <BODY>
36 <CENTER>
37 <H1>InstaDisc Activation</H1>
38
39 <P>Thank you for activating! You've now been signed up for the InstaDisc service.
40 You will recieve an email with the information to input into your InstaDisc client.
41 </CENTER>
42 </BODY>
43</HTML>
44<?php
45 } else {
46 addError($numOfErrors, $errors, '', 'The email could not be sent');
47 showForm($_POST['username'], $_POST['code'], $errors);
48 }
49 } else {
50 instaDisc_deactivateAccount($_POST['username'], $_POST['code']);
51 }
52 }
53}
54
55function showForm($username, $code, $errors)
56{
57?>
58<HTML>
59 <HEAD>
60 <TITLE><?php echo(instaDisc_getConfig('siteName')); ?> InstaDisc Central Server</TITLE>
61 <LINK REL="stylesheet" TYPE="text/css" HREF="uniform.css">
62 </HEAD>
63 <BODY>
64 <CENTER>
65 <H1>InstaDisc Activation</H1>
66
67 <P>If you've already registered and an activation email has been sent to your address, please fill in the form below.
68 </CENTER>
69
70 <FORM CLASS="uniform" ACTION="./activate.php?submit=" METHOD="POST">
71<?php
72 if (isset($errors[1]))
73 {
74?><DIV ID="errorMsg">Uh oh! Validation errors!<P>
75<OL><?php
76 foreach ($errors as $name => $value)
77 {
78?><LI><A HREF="#error<?php echo($name); ?>"><?php echo($value['msg']); ?></A></LI><?php
79 }
80?></OL></DIV><?php
81 }
82?>
83<FIELDSET CLASS="inlineLabels"><LEGEND>User Details</LEGEND>
84<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'username'); ?>">
85<?php doErrors($errors, 'username'); ?> <LABEL FOR="username"><EM>*</EM> Username: </LABEL>
86 <INPUT TYPE="text" ID="username" NAME="username" CLASS="textInput" VALUE="<?php echo($username); ?>">
87</DIV>
88<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'code'); ?>">
89<?php doErrors($errors, 'code'); ?> <LABEL FOR="code"><EM>*</EM> Activation Code: </LABEL>
90 <INPUT TYPE="text" ID="code" NAME="code" CLASS="textInput" VALUE="<?php echo($code); ?>">
91</DIV>
92</FIELDSET>
93<DIV CLASS="buttonHolder">
94 <INPUT TYPE="submit" NAME="submit" VALUE="Verify">
95 <INPUT TYPE="submit" NAME="submit" VALUE="Delete">
96</DIV></FORM><?php
97}
98
99function ifErrors($errors, $id)
100{
101 foreach ($errors as $name => $value)
102 {
103 if ($value['field'] == $id)
104 {
105 echo(' error');
106 return;
107 }
108 }
109}
110
111function doErrors($errors, $id)
112{
113 foreach ($errors as $name => $value)
114 {
115 if ($value['field'] == $id)
116 {
117?> <P ID="error<?php echo($name); ?>" CLASS="errorField"><EM>*</EM> <?php echo($value['msg']); ?></P><?php echo("\n");
118 }
119 }
120}
121
122function addError(&$numOfErrors, &$errors, $field, $msg)
123{
124 $numOfErrors++;
125 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
126}
diff --git a/central/trunk/index.php b/central/trunk/index.php new file mode 100644 index 0000000..ce71def --- /dev/null +++ b/central/trunk/index.php
@@ -0,0 +1,26 @@
1<?php
2
3/* InstaDisc Server - A Four Island Project */
4
5include('instadisc.php');
6
7?>
8<HTML>
9 <HEAD>
10 <TITLE>Four Island InstaDisc Central Server</TITLE>
11 </HEAD>
12 <BODY>
13 <CENTER>
14 <H1><?php echo(instaDisc_getConfig('siteName')); ?> InstaDisc</H1>
15
16 <P>Welcome to <?php instaDisc_getConfig('siteName')); ?>'s InstaDisc Central Server!
17 <P>InstaDisc is a wonderful productivity-increasing notification program. For more information about the project itself, see
18 <A HREF="http://fourisland.com/projects/instadisc/">its project site</A>.<P>An InstaDisc "Central Server" is where you can
19 register for the InstaDisc service. There are many Central Servers around the world, you generally pick the one that is
20 closest to you. If you would like to choose <?php echo(instaDisc_getConfig('siteName')); ?>'s, why not register now?
21 <P><A HREF="register.php">Register</A>
22 <BR><A HREF="login.php">Login</A>
23 <BR><A HREF="activate.php">Activation page</A>
24 </CENTER>
25 </BODY>
26</HTML>
diff --git a/central/trunk/register.php b/central/trunk/register.php new file mode 100644 index 0000000..8322861 --- /dev/null +++ b/central/trunk/register.php
@@ -0,0 +1,132 @@
1<?php
2
3/* InstaDisc Server - A Four Island Project */
4
5include('instadisc.php');
6
7if (!isset($_GET['submit']))
8{
9 showForm('','','',array());
10} else {
11 $numOfErrors = 0;
12 $errors = array();
13
14 if ($_POST['username'] == '')
15 {
16 addError($numOfErrors, $errors, 'username', 'Username is a required field');
17 }
18
19 if ($_POST['password'] == '')
20 {
21 addError($numOfErrors, $errors, 'password', 'Password is a required field');
22 }
23
24 if ($_POST['email'] == '')
25 {
26 addError($numOfErrors, $errors, 'email', 'Email is a required field');
27 }
28
29 if ($numOfErrors > 0)
30 {
31 showForm($_POST['username'], $_POST['password'], $_POST['email'], $errors);
32 } else {
33 $send = instaDisc_sendActivationEmail($_POST['username'], $_POST['password'], $_POST['email']);
34 if ($send === TRUE)
35 {
36?>
37<HTML>
38 <HEAD>
39 <TITLE><?php echo(instaDisc_getConfig('siteName')); ?> InstaDisc Central Server</TITLE>
40 </HEAD>
41 <BODY>
42 <CENTER>
43 <H1>InstaDisc Registration</H1>
44
45 <P>Thank you for registering! An activation email has been sent to the address you provided. When you recieve it, copy the
46 code inside to the <A HREF="activate.php">Activation page</A>.
47 </CENTER>
48 </BODY>
49</HTML>
50<?php
51 } else {
52 addError($numOfErrors, $errors, '', $send);
53 showForm($_POST['username'], $_POST['password'], $_POST['email'], $errors);
54 }
55 }
56}
57
58function showForm($username, $password, $email, $errors)
59{
60?>
61<HTML>
62 <HEAD>
63 <TITLE><?php echo(instaDisc_getConfig('siteName')); ?> InstaDisc Central Server</TITLE>
64 <LINK REL="stylesheet" TYPE="text/css" HREF="uniform.css">
65 </HEAD>
66 <BODY>
67 <CENTER>
68 <H1>InstaDisc Registration</H1>
69
70 <P>If you would like to sign up for our InstaDisc service, please fill out the form below.
71 </CENTER>
72
73 <FORM CLASS="uniform" ACTION="./register.php?submit=" METHOD="POST">
74<?php
75 if (isset($errors[1]))
76 {
77?><DIV ID="errorMsg">Uh oh! Validation errors!<P>
78<OL><?php
79 foreach ($errors as $name => $value)
80 {
81?><LI><A HREF="#error<?php echo($name); ?>"><?php echo($value['msg']); ?></A></LI><?php
82 }
83?></OL></DIV><?php
84 }
85?>
86<FIELDSET CLASS="inlineLabels"><LEGEND>User Details</LEGEND>
87<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'username'); ?>">
88<?php doErrors($errors, 'username'); ?> <LABEL FOR="username"><EM>*</EM> Username: </LABEL>
89 <INPUT TYPE="text" ID="username" NAME="username" CLASS="textInput" VALUE="<?php echo($username); ?>">
90</DIV>
91<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'password'); ?>">
92<?php doErrors($errors, 'password'); ?> <LABEL FOR="password"><EM>*</EM> Password: </LABEL>
93 <INPUT TYPE="password" ID="password" NAME="password" CLASS="textInput" VALUE="<?php echo($password); ?>">
94</DIV>
95<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'email'); ?>">
96<?php doErrors($errors, 'email'); ?> <LABEL FOR="email"><EM>*</EM> Email: </LABEL>
97 <INPUT TYPE="text" ID="email" NAME="email" CLASS="textInput" VALUE="<?php echo($email); ?>">
98</DIV>
99</FIELDSET>
100<DIV CLASS="buttonHolder">
101 <INPUT TYPE="submit" VALUE="Submit">
102</DIV></FORM><?php
103}
104
105function ifErrors($errors, $id)
106{
107 foreach ($errors as $name => $value)
108 {
109 if ($value['field'] == $id)
110 {
111 echo(' error');
112 return;
113 }
114 }
115}
116
117function doErrors($errors, $id)
118{
119 foreach ($errors as $name => $value)
120 {
121 if ($value['field'] == $id)
122 {
123?> <P ID="error<?php echo($name); ?>" CLASS="errorField"><EM>*</EM> <?php echo($value['msg']); ?></P><?php echo("\n");
124 }
125 }
126}
127
128function addError(&$numOfErrors, &$errors, $field, $msg)
129{
130 $numOfErrors++;
131 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
132}