diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-08 12:26:08 +0000 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-08 12:26:08 +0000 |
| commit | 4116da2199a163a72860f6265d52a2ae0b860967 (patch) | |
| tree | 0e850bcbf770d50f8de04b1ae537d9c30c8bd1e5 /central/trunk/register.php | |
| parent | 70f4caa35e06a9607b942cddfe9f3f9d6a0078d5 (diff) | |
| download | instadisc-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/trunk/register.php')
| -rw-r--r-- | central/trunk/register.php | 132 |
1 files changed, 132 insertions, 0 deletions
| 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 | |||
| 5 | include('instadisc.php'); | ||
| 6 | |||
| 7 | if (!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 | |||
| 58 | function 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 | |||
| 105 | function 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 | |||
| 117 | function 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 | |||
| 128 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 129 | { | ||
| 130 | $numOfErrors++; | ||
| 131 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 132 | } | ||
