diff options
Diffstat (limited to 'central/trunk/activate.php')
| -rw-r--r-- | central/trunk/activate.php | 126 |
1 files changed, 126 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 | |||
| 5 | include('instadisc.php'); | ||
| 6 | |||
| 7 | if (!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 | |||
| 55 | function 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 | |||
| 99 | function 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 | |||
| 111 | function 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 | |||
| 122 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 123 | { | ||
| 124 | $numOfErrors++; | ||
| 125 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 126 | } | ||
