summaryrefslogtreecommitdiff
path: root/register.php
diff options
context:
space:
mode:
Diffstat (limited to 'register.php')
-rw-r--r--register.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/register.php b/register.php
index b70d724..aeaa18f 100644
--- a/register.php
+++ b/register.php
@@ -20,16 +20,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
require_once('header.inc.php');
+
+/* Service creation: only useful services are created */
$userservice =& ServiceFactory::getServiceInstance('UserService');
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+/* Managing all possible inputs */
+isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
+isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define('POST_USERNAME', '');
+isset($_POST['password']) ? define('POST_PASS', $_POST['password']): define('POST_PASS', '');
+isset($_POST['email']) ? define('POST_MAIL', $_POST['email']): define('POST_MAIL', '');
+isset($_POST['antispamAnswer']) ? define('POST_ANTISPAMANSWER', $_POST['antispamAnswer']): define('POST_ANTISPAMANSWER', '');
+
+
$tplVars = array();
-if (isset($_POST['submitted'])) {
- $posteduser = trim(utf8_strtolower($_POST['username']));
+if (POST_SUBMITTED != '') {
+ $posteduser = trim(utf8_strtolower(POST_USERNAME));
// Check if form is incomplete
- if (!($posteduser) || !($_POST['password']) || !($_POST['email'])) {
+ if (!($posteduser) || POST_PASS == '' || POST_MAIL == '') {
$tplVars['error'] = T_('You <em>must</em> enter a username, password and e-mail address.');
// Check if username is reserved
@@ -45,17 +55,17 @@ if (isset($_POST['submitted'])) {
$tplVars['error'] = T_('This username is not valid (too long, forbidden characters...), please make another choice.');
// Check if e-mail address is valid
- } elseif (!$userservice->isValidEmail($_POST['email'])) {
+ } elseif (!$userservice->isValidEmail(POST_MAIL)) {
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
// Check if antispam answer is valid
- } elseif (strcmp($_POST['antispamAnswer'], $GLOBALS['antispamAnswer']) != 0) {
+ } elseif (strcmp(POST_ANTISPAMANSWER, $GLOBALS['antispamAnswer']) != 0) {
$tplVars['error'] = T_('Antispam answer is not valid. Please try again.');
// Register details
- } elseif ($userservice->addUser($posteduser, $_POST['password'], $_POST['email'])) {
+ } elseif ($userservice->addUser($posteduser, POST_PASS, POST_MAIL)) {
// Log in with new username
- $login = $userservice->login($posteduser, $_POST['password']);
+ $login = $userservice->login($posteduser, POST_PASS);
if ($login) {
header('Location: '. createURL('bookmarks', $posteduser));
}