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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
43 } elseif (!isExtensionActive('sponsor')) {
44 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('sponsor'));
46 } elseif (!isSponsor()) {
48 addFatalMessage(__FILE__, __LINE__, getMessage('SPONSOR_ONLY_AREA_ENTERED'));
52 // Data for the formular
53 $result = SQL_QUERY_ESC("SELECT `company`, `position`, `tax_ident`,
54 `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
55 `phone`, `fax`, `cell`, `email`, `url`,
56 `status`, `receive_warnings`
57 FROM `{?_MYSQL_PREFIX?}_sponsor_data`
58 WHERE `id`='%s' AND `password`='%s' LIMIT 1",
59 array(bigintval(getSession('sponsorid')), getSession('sponsorpass')), __FILE__, __LINE__);
62 if (SQL_NUMROWS($result) == 1) {
64 $content = SQL_FETCHARRAY($result);
65 if ($content['status'] == 'CONFIRMED') {
66 // Check if form was submitted or not
69 if (!isPostRequestParameterSet('pass_old')) {
70 // No current password entered
71 $message = getMessage('SPONSOR_NO_CURRENT_PASSWORD_ENTERED');
72 } elseif (md5(postRequestParameter('pass_old')) != getSession('sponsorpass')) {
73 // Entered password didn't match password in DB
74 $message = getMessage('SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB');
75 } elseif ((isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2')) && (postRequestParameter('pass1') != postRequestParameter('pass2'))) {
76 // Both new passwords did not match
77 $message = getMessage('SPONSOR_BOTH_NEW_PASSWORDS_DIDNOT_MATCH');
78 } elseif ((!isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2'))) {
79 // No password one entered
80 $message = getMessage('SPONSOR_PASSWORD_ONE_EMPTY');
81 } elseif ((isPostRequestParameterSet('pass1')) && (!isPostRequestParameterSet('pass2'))) {
82 // No password two entered
83 $message = getMessage('SPONSOR_PASSWORD_TWO_EMPTY');
84 } elseif ((isPostRequestParameterSet('pass1')) && (strlen(postRequestParameter('pass1')) < getConfig('pass_len'))) {
86 $message = getMessage('SPONSOR_PASSWORD_TOO_SHORT');
88 // Default is we don't want to change password!
89 $PASS_AND = ''; $PASS_DATA = '';
91 // Check if we want to change password or not
92 if ((postRequestParameter('pass1') == postRequestParameter('pass2')) && (isPostRequestParameterSet('pass1')) && (postRequestParameter('pass1') != postRequestParameter('pass_old'))) {
93 // Change current password
94 $PASS_AND = ", `password`='%s'";
95 $PASS_DATA = md5(postRequestParameter('pass1'));
98 // Unsecure data which we don't want here
99 $UNSAFE = array('receive_warnings', 'warning_interval');
101 // Remove all (maybe spoofed) unsafe data from array
102 foreach ($UNSAFE as $remove) {
103 unsetPostRequestParameter($remove);
106 // Set last change timestamp
107 setPostRequestParameter('last_change', 'UNIX_TIMESTAMP()');
110 $message = saveSponsorData(postRequestArray(), $content);
113 if (!empty($message)) {
115 $OUT = loadTemplate('admin_settings_saved', true, $message);
117 // No message generated
118 $OUT = loadTemplate('admin_settings_saved', true, getMessage('SPONSOR_NO_MESSAGE_GENERATED'));
122 foreach (array('m', 'f', 'c') as $gender) {
123 $content['gender_' . $gender] = '';
126 // Check for gender selection
127 $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
130 $OUT = loadTemplate('sponsor_account_form', true, $content);
134 $STATUS = sponsorTranslateUserStatus($content['status']);
135 $OUT = loadTemplate('admin_settings_saved', true, getMaskedMessage('SPONSOR_ACCOUNT_FAILED', $STATUS));
138 // Sponsor account not found!
139 $OUT = loadTemplate('admin_settings_saved', true, getMaskedMessage('SPONSOR_ACCOUNT_404', getSession('sponsorid')));
143 SQL_FREERESULT($result);