summaryrefslogtreecommitdiff
path: root/register.php
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-25 15:57:29 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-25 15:57:29 +0000
commit15b91c7e661d928d8b125ec9cfbda1702319c8b4 (patch)
tree092d474c05e414bb04a8c428b8ff6cb9ccab765d /register.php
parent9aafe7551eb5a73739709e72465031db7a1531b4 (diff)
downloadsemanticscuttle-15b91c7e661d928d8b125ec9cfbda1702319c8b4.tar.gz
semanticscuttle-15b91c7e661d928d8b125ec9cfbda1702319c8b4.tar.bz2
Major refactoring: transform user into object, define parameters used into each file, ...
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@173 b3834d28-1941-0410-a4f8-b48e95affb8f
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));
}