2 /************************************************************************
3 * MXChange v0.2.1 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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software. You can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License. *
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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
35 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
37 } elseif ((!EXT_IS_ACTIVE("sponsor")) && (!IS_ADMIN())) {
38 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE);
40 } elseif (!IS_SPONSOR()) {
42 ADD_FATAL(SPONSOR_ONLY_AREA_ENTERED);
46 // Data for the formular
47 $result = SQL_QUERY_ESC("SELECT company, position, tax_ident,
48 salut, surname, family, street_nr1, street_nr2, zip, city, country,
49 phone, fax, cell, email, url,
50 status, receive_warnings
51 FROM "._MYSQL_PREFIX."_sponsor_data
52 WHERE id='%s' AND password='%s' LIMIT 1",
53 array(bigintval($_COOKIE['sponsorid']), $_COOKIE['sponsorpass']), __FILE__, __LINE__);
54 if (SQL_NUMROWS($result) == 1) {
56 $content = SQL_FETCHARRAY($result);
57 if ($content['status'] == "CONFIRMED") {
58 // Check if form was submitted or not
59 if (!empty($_POST['ok'])) {
61 if (empty($_POST['pass_old'])) {
62 // No current password entered
63 $MSG = SPONSOR_NO_CURRENT_PASSWORD_ENTERED;
64 } elseif (md5($_POST['pass_old']) != $_COOKIE['sponsorpass']) {
65 // Entered password didn't match password in DB
66 $MSG = SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB;
67 } elseif ((!empty($_POST['pass1'])) && (!empty($_POST['pass2'])) && ($_POST['pass1'] != $_POST['pass2'])) {
68 // Both new passwords did not match
69 $MSG = SPONSOR_BOTH_NEW_PASSWORDS_DIDNOT_MATCH;
70 } elseif ((empty($_POST['pass1'])) && (!empty($_POST['pass2']))) {
71 // No password one entered
72 $MSG = SPONSOR_PASSWORD_ONE_EMPTY;
73 } elseif ((!empty($_POST['pass1'])) && (empty($_POST['pass2']))) {
74 // No password two entered
75 $MSG = SPONSOR_PASSWORD_TWO_EMPTY;
76 } elseif ((!empty($_POST['pass1'])) && (strlen($_POST['pass1']) < $CONFIG['pass_len'])) {
78 $MSG = SPONSOR_PASSWORD_TOO_SHORT_1.$CONFIG['pass_len'].SPONSOR_PASSWORD_TOO_SHORT_2;
80 // Default is we don't want to change password!
81 $PASS_AND = ""; $PASS_DATA = "";
83 // Check if we want to change password or not
84 if (($_POST['pass1'] == $_POST['pass2']) && (!empty($_POST['pass1'])) && ($_POST['pass1'] != $_POST['pass_old'])) {
85 // Change current password
86 $PASS_AND = ", password='%s'";
87 $PASS_DATA = md5($_POST['pass1']);
90 // Unsecure data which we don't want here
91 $UNSAFE = array('receive_warnings', 'warning_interval');
93 // Remove all (maybe spoofed) unsafe data from array
94 foreach ($UNSAFE as $remove) {
95 unset($_POST[$remove]);
98 // Set last change timestamp
99 $_POST['last_change'] = time();
102 $MSG = SPONSOR_SAVE_DATA($_POST, $content);
107 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, $MSG);
109 // No message generated
110 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_MESSAGE_GENERATED);
113 // Check for salutation selection
114 switch ($content['salut'])
117 define('__SALUT_M', " selected");
118 define('__SALUT_F', "");
119 define('__SALUT_C', "");
123 define('__SALUT_M', "");
124 define('__SALUT_F', " selected");
125 define('__SALUT_C', "");
129 define('__SALUT_M', "");
130 define('__SALUT_F', "");
131 define('__SALUT_C', " selected");
136 $OUT = LOAD_TEMPLATE("sponsor_account_form", true, $content);
140 $STATUS = SPONSOR_TRANSLATE_STATUS($content['status']);
141 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_ACCOUNT_FAILED_1.$STATUS.SPONSOR_ACCOUNT_FAILED_2);
144 // Sponsor account not found!
145 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_ACCOUNT_404_1.$_COOKIE['sponsorid'].SPONSOR_ACCOUNT_404_2);
149 SQL_FREERESULT($result);