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__, '{--SPONSOR_ONLY_AREA_ENTERED--}');
52 // Data for the formular
53 $result = SQL_QUERY_ESC("SELECT
54 `id`, `company`, `position`, `tax_ident`,
55 `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
56 `phone`, `fax`, `cell`, `email`, `url`,
57 `status`, `receive_warnings`
59 `{?_MYSQL_PREFIX?}_sponsor_data`
65 bigintval(getSession('sponsor_id')),
66 getSession('sponsorpass')
67 ), __FILE__, __LINE__);
70 if (SQL_NUMROWS($result) == 1) {
72 $content = SQL_FETCHARRAY($result);
73 if ($content['status'] == 'CONFIRMED') {
74 // Check if form was submitted or not
77 if (!isPostRequestParameterSet('pass_old')) {
78 // No current password entered
79 $message = '{--SPONSOR_NO_CURRENT_PASSWORD_ENTERED--}';
80 } elseif (md5(postRequestParameter('pass_old')) != getSession('sponsorpass')) {
81 // Entered password didn't match password in DB
82 $message = '{--SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB--}';
83 } elseif ((isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2')) && (postRequestParameter('pass1') != postRequestParameter('pass2'))) {
84 // Both new passwords did not match
85 $message = '{--SPONSOR_BOTH_NEW_PASSWORDS_DIDNOT_MATCH--}';
86 } elseif ((!isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2'))) {
87 // No password one entered
88 $message = '{--SPONSOR_PASSWORD_ONE_EMPTY--}';
89 } elseif ((isPostRequestParameterSet('pass1')) && (!isPostRequestParameterSet('pass2'))) {
90 // No password two entered
91 $message = '{--SPONSOR_PASSWORD_TWO_EMPTY--}';
92 } elseif ((isPostRequestParameterSet('pass1')) && (strlen(postRequestParameter('pass1')) < getConfig('pass_len'))) {
94 $message = '{--SPONSOR_PASSWORD_TOO_SHORT--}';
96 // Default is we don't want to change password!
97 $PASS_AND = ''; $PASS_DATA = '';
99 // Check if we want to change password or not
100 if ((postRequestParameter('pass1') == postRequestParameter('pass2')) && (isPostRequestParameterSet('pass1')) && (postRequestParameter('pass1') != postRequestParameter('pass_old'))) {
101 // Change current password
102 $PASS_AND = ", `password`='%s'";
103 $PASS_DATA = md5(postRequestParameter('pass1'));
106 // Unsecure data which we don't want here
107 $UNSAFE = array('receive_warnings', 'warning_interval');
109 // Remove all (maybe spoofed) unsafe data from array
110 foreach ($UNSAFE as $remove) {
111 unsetPostRequestParameter($remove);
114 // Set last change timestamp
115 setPostRequestParameter('last_change', 'UNIX_TIMESTAMP()');
118 $message = saveSponsorData(postRequestArray(), $content);
121 if (!empty($message)) {
123 $GLOBALS['sponsor_output'] = loadTemplate('admin_settings_saved', true, $message);
125 // No message generated
126 $GLOBALS['sponsor_output'] = loadTemplate('admin_settings_saved', true, '{--SPONSOR_NO_MESSAGE_GENERATED--}');
130 foreach (array('m', 'f', 'c') as $gender) {
131 $content['gender_' . $gender] = '';
134 // Check for gender selection
135 $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
138 $GLOBALS['sponsor_output'] = loadTemplate('sponsor_account_form', true, $content);
142 $STATUS = sponsorTranslateUserStatus($content['status']);
143 $GLOBALS['sponsor_output'] = loadTemplate('admin_settings_saved', true, getMaskedMessage('SPONSOR_ACCOUNT_FAILED', $STATUS));
146 // Sponsor account not found!
147 $GLOBALS['sponsor_output'] = loadTemplate('admin_settings_saved', true, getMaskedMessage('SPONSOR_ACCOUNT_404', getSession('sponsor_id')));
151 SQL_FREERESULT($result);