2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/30/2005 *
4 * =================== Last change: 05/19/2008 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Sponsor can manage his account *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Der Sponsor kann sein Account verwalten *
12 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2016 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
36 } elseif (!isExtensionActive('sponsor')) {
37 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=sponsor%}');
39 } elseif (!isSponsor()) {
41 addFatalMessage(__FILE__, __LINE__, '{--SPONSOR_ONLY_AREA_ENTERED--}');
45 // Data for the formular
46 $result = sqlQueryEscaped("SELECT
47 `id`, `company`, `position`, `tax_ident`,
48 `sex`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
49 `phone`, `fax`, `cell`, `email`, `url`,
50 `status`, `receive_warnings`
52 `{?_MYSQL_PREFIX?}_sponsor_data`
58 bigintval(getSession('sponsor_id')),
59 getSession('sponsorpass')
60 ), __FILE__, __LINE__);
63 if (sqlNumRows($result) == 1) {
65 $content = sqlFetchArray($result);
66 if ($content['status'] == 'CONFIRMED') {
67 // Check if form was submitted or not
70 if (!isPostRequestElementSet('pass_old')) {
71 // No current password entered
72 $message = '{--SPONSOR_NO_CURRENT_PASSWORD_ENTERED--}';
73 } elseif (md5(postRequestElement('pass_old')) != getSession('sponsorpass')) {
74 // Entered password didn't match password in DB
75 $message = '{--SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB--}';
76 } elseif ((isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2')) && (postRequestElement('password1') != postRequestElement('password2'))) {
77 // Both new passwords did not match
78 $message = '{--SPONSOR_BOTH_NEW_PASSWORDS_DIDNOT_MATCH--}';
79 } elseif ((!isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2'))) {
80 // No password one entered
81 $message = '{--SPONSOR_PASSWORD_ONE_EMPTY--}';
82 } elseif ((isPostRequestElementSet('password1')) && (!isPostRequestElementSet('password2'))) {
83 // No password two entered
84 $message = '{--SPONSOR_PASSWORD_TWO_EMPTY--}';
85 } elseif ((isPostRequestElementSet('password1')) && (strlen(postRequestElement('password1')) < getMinPasswordLength())) {
87 $message = '{--SPONSOR_PASSWORD_TOO_SHORT--}';
89 // Default is we don't want to change password!
90 $PASS_AND = ''; $PASS_DATA = '';
92 // Check if the sponsor wants to change his/her password
93 if ((postRequestElement('password1') == postRequestElement('password2')) && (isPostRequestElementSet('password1')) && (postRequestElement('password1') != postRequestElement('pass_old'))) {
94 // Change current password
95 $PASS_AND = ",`password`='%s'";
96 $PASS_DATA = md5(postRequestElement('password1'));
99 // Unsecure data which we don't want here
100 $UNSAFE = array('receive_warnings', 'warning_interval');
102 // Remove all (maybe spoofed) unsafe data from array
103 foreach ($UNSAFE as $remove) {
104 unsetPostRequestElement($remove);
107 // Set last change timestamp
108 setPostRequestElement('last_change', 'UNIX_TIMESTAMP()');
111 $message = saveSponsorData(postRequestArray(), $content);
114 if (!empty($message)) {
116 $GLOBALS['sponsor_output'] = returnMessage($message);
118 // No message generated
119 $GLOBALS['sponsor_output'] = returnMessage('{--SPONSOR_NO_MESSAGE_GENERATED--}');
123 $GLOBALS['sponsor_output'] = loadTemplate('sponsor_account_form', TRUE, $content);
127 $GLOBALS['sponsor_output'] = returnMessage('{%message,SPONSOR_ACCOUNT_FAILED=' . $content['status'] . '%}');
130 // Sponsor account not found
131 $GLOBALS['sponsor_output'] = returnMessage('{%message,SPONSOR_ACCOUNT_404=' . getSession('sponsor_id') . '%}');
135 sqlFreeResult($result);