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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (!isExtensionActive('sponsor')) {
42 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=sponsor%}');
44 } elseif (!isSponsor()) {
46 addFatalMessage(__FILE__, __LINE__, '{--SPONSOR_ONLY_AREA_ENTERED--}');
50 // Data for the formular
51 $result = SQL_QUERY_ESC("SELECT
52 `id`,`company`,`position`,`tax_ident`,
53 `gender`,`surname`,`family`,`street_nr1`,`street_nr2`,`zip`,`city`,`country`,
54 `phone`,`fax`,`cell`,`email`,`url`,
55 `status`,`receive_warnings`
57 `{?_MYSQL_PREFIX?}_sponsor_data`
63 bigintval(getSession('sponsor_id')),
64 getSession('sponsorpass')
65 ), __FILE__, __LINE__);
68 if (SQL_NUMROWS($result) == 1) {
70 $content = SQL_FETCHARRAY($result);
71 if ($content['status'] == 'CONFIRMED') {
72 // Check if form was submitted or not
75 if (!isPostRequestParameterSet('pass_old')) {
76 // No current password entered
77 $message = '{--SPONSOR_NO_CURRENT_PASSWORD_ENTERED--}';
78 } elseif (md5(postRequestParameter('pass_old')) != getSession('sponsorpass')) {
79 // Entered password didn't match password in DB
80 $message = '{--SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB--}';
81 } elseif ((isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2')) && (postRequestParameter('pass1') != postRequestParameter('pass2'))) {
82 // Both new passwords did not match
83 $message = '{--SPONSOR_BOTH_NEW_PASSWORDS_DIDNOT_MATCH--}';
84 } elseif ((!isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2'))) {
85 // No password one entered
86 $message = '{--SPONSOR_PASSWORD_ONE_EMPTY--}';
87 } elseif ((isPostRequestParameterSet('pass1')) && (!isPostRequestParameterSet('pass2'))) {
88 // No password two entered
89 $message = '{--SPONSOR_PASSWORD_TWO_EMPTY--}';
90 } elseif ((isPostRequestParameterSet('pass1')) && (strlen(postRequestParameter('pass1')) < getPassLen())) {
92 $message = '{--SPONSOR_PASSWORD_TOO_SHORT--}';
94 // Default is we don't want to change password!
95 $PASS_AND = ''; $PASS_DATA = '';
97 // Check if we want to change password or not
98 if ((postRequestParameter('pass1') == postRequestParameter('pass2')) && (isPostRequestParameterSet('pass1')) && (postRequestParameter('pass1') != postRequestParameter('pass_old'))) {
99 // Change current password
100 $PASS_AND = ", `password`='%s'";
101 $PASS_DATA = md5(postRequestParameter('pass1'));
104 // Unsecure data which we don't want here
105 $UNSAFE = array('receive_warnings', 'warning_interval');
107 // Remove all (maybe spoofed) unsafe data from array
108 foreach ($UNSAFE as $remove) {
109 unsetPostRequestParameter($remove);
112 // Set last change timestamp
113 setPostRequestParameter('last_change', 'UNIX_TIMESTAMP()');
116 $message = saveSponsorData(postRequestArray(), $content);
119 if (!empty($message)) {
121 $GLOBALS['sponsor_output'] = displayMessage($message, true);
123 // No message generated
124 $GLOBALS['sponsor_output'] = displayMessage('{--SPONSOR_NO_MESSAGE_GENERATED--}', true);
128 $GLOBALS['sponsor_output'] = loadTemplate('sponsor_account_form', true, $content);
132 $GLOBALS['sponsor_output'] = displayMessage('{%message,SPONSOR_ACCOUNT_FAILED=' . $content['status'] . '%}', true);
135 // Sponsor account not found
136 $GLOBALS['sponsor_output'] = displayMessage('{%message,SPONSOR_ACCOUNT_404=' . getSession('sponsor_id') . '%}', true);
140 SQL_FREERESULT($result);