]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-sponsor_login.php
Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / modules / guest / what-sponsor_login.php
index df5fd3e162f47ec355a568ed6e3b8194d4806a8b..a9e1c850c633c80e99846938f44a29c1290c430a 100644 (file)
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -50,16 +51,16 @@ if ((!isExtensionActive('sponsor'))) {
 } // END - if
 
 $mode = '';
-if (isGetRequestElementSet('mode')) {
+if (isGetRequestParameterSet('mode')) {
        // A "special" mode of the login system was requested
-       switch (getRequestElement('mode')) {
+       switch (getRequestParameter('mode')) {
                case 'activate' : $mode = 'activate';  break; // Activation link requested
                case 'lost_pass': $mode = 'lost_pass'; break; // Request new password
        } // END - switch
 } // END - if
 
 // Check if hash for confirmation of email address is given...
-if (isGetRequestElementSet('hash')) {
+if (isGetRequestParameterSet('hash')) {
        // Lookup sponsor
        $result = SQL_QUERY_ESC("SELECT
        `id`, `status`, `gender`, `surname`, `family`,
@@ -70,31 +71,36 @@ FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
        `hash='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL')
-LIMIT 1", array(getRequestElement('hash')), __FILE__, __LINE__);
+LIMIT 1", array(getRequestParameter('hash')), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Sponsor found, load his data...
-               $SPONSOR = SQL_FETCHARRAY($result);
-
-               // Translate gender and comma
-               $SPONSOR['gender']  = translateGender($SPONSOR['gender']);
-               $SPONSOR['points'] = translateComma($SPONSOR['points']);
-               $SPONSOR['pay']    = translateComma($SPONSOR['pay']);
+               $data = SQL_FETCHARRAY($result);
 
                // Unconfirmed account or changed email address?
-               if ($SPONSOR['status'] == 'UNCONFIRMED') {
+               if ($data['status'] == 'UNCONFIRMED') {
                        // Set account to pending
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='PENDING'
-WHERE `id`='%s' AND hash='%s' AND `status`='UNCONFIRMED' LIMIT 1",
-                       array(bigintval($SPONSOR['id']), getRequestElement('hash')), __FILE__, __LINE__);
+                       SQL_QUERY_ESC("UPDATE
+       `{?_MYSQL_PREFIX?}_sponsor_data`
+SET
+       `status`='PENDING'
+WHERE
+       `id`=%s AND
+       hash='%s' AND
+       `status`='UNCONFIRMED'
+LIMIT 1",
+                               array(
+                                       bigintval($data['id']),
+                                       getRequestParameter('hash')
+                               ), __FILE__, __LINE__);
 
                        // Check on success
                        if (SQL_AFFECTEDROWS() == 1) {
                                // Prepare mail and send it to the sponsor
-                               $message = loadEmailTemplate('sponsor_pending', $SPONSOR);
-                               sendEmail($SPONSOR['email'], getMessage('SPONSOR_ACCOUNT_PENDING_SUBJ'), $message);
+                               $message = loadEmailTemplate('sponsor_pending', $data);
+                               sendEmail($data['email'], getMessage('SPONSOR_ACCOUNT_PENDING_SUBJ'), $message);
 
                                // Send email to admin
-                               sendAdminNotification(getMessage('ADMIN_NEW_SPONSOR'), 'admin_sponsor_pending', $SPONSOR);
+                               sendAdminNotification(getMessage('ADMIN_NEW_SPONSOR'), 'admin_sponsor_pending', $data);
 
                                // Sponsor account set to pending
                                loadTemplate('admin_settings_saved', false, getMessage('SPONSOR_ACCOUNT_IS_PENDING'));
@@ -102,11 +108,18 @@ WHERE `id`='%s' AND hash='%s' AND `status`='UNCONFIRMED' LIMIT 1",
                                // Could not unlock account!
                                loadTemplate('admin_settings_saved', false, getMessage('SPONSOR_ACCOUNT_PENDING_FAILED'));
                        }
-               } elseif ($SPONSOR['status'] == 'EMAIL') {
+               } elseif ($data['status'] == 'EMAIL') {
                        // Changed email adress need to be confirmed
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='CONFIRMED'
-WHERE `id`='%s' AND hash='%s' AND `status`='EMAIL' LIMIT 1",
-                       array(bigintval($SPONSOR['id']), getRequestElement('hash')), __FILE__, __LINE__);
+                       SQL_QUERY_ESC("UPDATE
+       `{?_MYSQL_PREFIX?}_sponsor_data`
+SET
+       `status`='CONFIRMED'
+WHERE
+       `id`='%s' AND
+       `hash`='%s' AND
+       `status`='EMAIL'
+LIMIT 1",
+                               array(bigintval($data['id']), getRequestParameter('hash')), __FILE__, __LINE__);
 
                        // Check on success
                        if (SQL_AFFECTEDROWS() == 1) {
@@ -122,7 +135,7 @@ WHERE `id`='%s' AND hash='%s' AND `status`='EMAIL' LIMIT 1",
                }
        } else {
                // No sponsor found
-               loadTemplate('admin_settings_saved', false, sprintf(getMessage('SPONSOR_ACCOUNT_404'), getRequestElement('hash')));
+               loadTemplate('admin_settings_saved', false, sprintf(getMessage('SPONSOR_ACCOUNT_404'), getRequestParameter('hash')));
        }
 
        // Free memory
@@ -131,7 +144,7 @@ WHERE `id`='%s' AND hash='%s' AND `status`='EMAIL' LIMIT 1",
        // Send activation link again
        if (isFormSent()) {
                // Check submitted data
-               if (!isPostRequestElementSet('email')) unsetPostRequestElement('ok');
+               if (!isPostRequestParameterSet('email')) unsetPostRequestParameter('ok');
        }
 
        if (isFormSent()) {
@@ -139,26 +152,25 @@ WHERE `id`='%s' AND hash='%s' AND `status`='EMAIL' LIMIT 1",
                $result = SQL_QUERY_ESC("SELECT id, hash, status, remote_addr, gender, surname, family, sponsor_created
 FROM `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1",
-               array(postRequestElement('email')), __FILE__, __LINE__);
+               array(postRequestParameter('email')), __FILE__, __LINE__);
 
                // Entry found?
                if (SQL_NUMROWS($result) == 1) {
                        // Unconfirmed sponsor account found so let's load the requested data
-                       $SPONSOR = SQL_FETCHARRAY($result);
+                       $data = SQL_FETCHARRAY($result);
 
                        // Translate some data
-                       $SPONSOR['gender']           = translateGender($SPONSOR['gender']);
-                       $SPONSOR['sponsor_created'] = generateDateTime($SPONSOR['sponsor_created']);
+                       $data['sponsor_created'] = generateDateTime($data['sponsor_created']);
 
                        // Prepare email and send it to the sponsor
-                       if ($SPONSOR['status'] == 'UNCONFIRMED') {
+                       if ($data['status'] == 'UNCONFIRMED') {
                                // Unconfirmed accounts
-                               $message_sponsor = loadEmailTemplate('sponsor_activate', $SPONSOR);
+                               $message_sponsor = loadEmailTemplate('sponsor_activate', $data);
                        } else {
                                // Confirmed email address
-                               $message_sponsor = loadEmailTemplate('sponsor_email', $SPONSOR);
+                               $message_sponsor = loadEmailTemplate('sponsor_email', $data);
                        }
-                       sendEmail(postRequestElement('email'), getMessage('SPONSOR_ACTIVATION_LINK_SUBJ'), $message_sponsor);
+                       sendEmail(postRequestParameter('email'), getMessage('SPONSOR_ACTIVATION_LINK_SUBJ'), $message_sponsor);
 
                        // Output message
                        loadTemplate('admin_settings_saved', false, getMessage('SPONSOR_ACTIVATION_LINK_SENT'));
@@ -177,7 +189,7 @@ WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1",
        // Send new password
        if (isFormSent()) {
                // Check submitted data
-               if (!isPostRequestElementSet('email')) unsetPostRequestElement('ok');
+               if (!isPostRequestParameterSet('email')) unsetPostRequestParameter('ok');
        } // END - if
 
        if (isFormSent()) {
@@ -185,7 +197,7 @@ WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1",
                $result = SQL_QUERY_ESC("SELECT `id`, `hash`, `remote_addr`, `gender`, `surname`, `family`, `sponsor_created`
 FROM `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE `email`='%s' AND `id`='%s' AND `status`='CONFIRMED' LIMIT 1",
-               array(postRequestElement('email'), bigintval(postRequestElement('id'))), __FILE__, __LINE__);
+               array(postRequestParameter('email'), bigintval(postRequestParameter('id'))), __FILE__, __LINE__);
 
                // Entry found?
                if (SQL_NUMROWS($result) == 1) {
@@ -193,7 +205,7 @@ WHERE `email`='%s' AND `id`='%s' AND `status`='CONFIRMED' LIMIT 1",
                        $DATA = SQL_FETCHARRAY($result);
 
                        // Translate some data
-                       $DATA['gender']           = translateGender($DATA['gender']);
+                       $DATA['gender']          = translateGender($DATA['gender']);
                        $DATA['sponsor_created'] = generateDateTime($DATA['sponsor_created']);
 
                        // Generate password
@@ -201,7 +213,7 @@ WHERE `email`='%s' AND `id`='%s' AND `status`='CONFIRMED' LIMIT 1",
 
                        // Prepare email and send it to the sponsor
                        $message_sponsor = loadEmailTemplate('sponsor_lost', $DATA);
-                       sendEmail(postRequestElement('email'), getMessage('SPONSOR_LOST_PASSWORD_SUBJ'), $message_sponsor);
+                       sendEmail(postRequestParameter('email'), getMessage('SPONSOR_LOST_PASSWORD_SUBJ'), $message_sponsor);
 
                        // Update password
                        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `password`='%s'
@@ -225,15 +237,15 @@ WHERE `id`='%s' LIMIT 1",
        // Check status and login data ...
        $result = SQL_QUERY_ESC("SELECT status FROM `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE `id`='%s' AND password='%s' LIMIT 1",
-       array(bigintval(postRequestElement('sponsorid')), md5(postRequestElement('pass'))), __FILE__, __LINE__);
+       array(bigintval(postRequestParameter('sponsorid')), md5(postRequestParameter('pass'))), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result) == 1) {
                // Okay, first login data check passed, now has he/she an approved (CONFIRMED) account?
                list($status) = SQL_FETCHROW($result);
                if ($status == 'CONFIRMED') {
                        // Is confirmed so both is fine and we can continue with login procedure
-                       $login = ((setSession('sponsorid'  , bigintval(postRequestElement('sponsorid')))) &&
-                       (setSession('sponsorpass', md5(postRequestElement('pass'))           ))
+                       $login = ((setSession('sponsorid'  , bigintval(postRequestParameter('sponsorid')))) &&
+                       (setSession('sponsorpass', md5(postRequestParameter('pass'))           ))
                        );
 
                        if ($login === true) {