2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/11/2005 *
4 * =============== Last change: 05/19/2008 *
6 * -------------------------------------------------------------------- *
7 * File : settings.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Sponsor can manage his settings *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Der Sponsor kann seine Einstellungen aendern *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyleft (c) 2003, 2004, 2005 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 $FATAL[] = EXTENSION_PROBLEM_EXT_INACTIVE;
40 } elseif (!IS_SPONSOR()) {
42 $FATAL[] = SPONSOR_ONLY_AREA_ENTERED;
46 // Data for the formular
47 $result = SQL_QUERY_ESC("SELECT status, receive_warnings, warning_interval, email, surname, family, salut
48 FROM "._MYSQL_PREFIX."_sponsor_data
49 WHERE id='%s' AND password='%s' LIMIT 1",
50 array(bigintval($_COOKIE['sponsorid']), $_COOKIE['sponsorpass']), __FILE__, __LINE__);
51 if (SQL_NUMROWS($result) == 1) {
53 $content = SQL_FETCHARRAY($result);
54 if ($content['status'] == "CONFIRMED") {
55 // Check if form was submitted or not
56 if (!empty($_POST['ok'])) {
58 if (empty($_POST['password'])) {
59 // No current password entered
60 $MSG = SPONSOR_NO_CURRENT_PASSWORD_ENTERED;
61 } elseif (md5($_POST['password']) != $_COOKIE['sponsorpass']) {
62 // Entered password didn't match password in DB
63 $MSG = SPONSOR_CURRENT_PASSWORD_DIDNOT_MATCH_DB;
65 // Unsecure data which we don't want here
66 $UNSAFE = array('company', 'position', 'tax_ident', 'salut', 'surname', 'family',
67 'street_nr1', 'street_nr2', 'zip', 'city', 'country', 'phone', 'fax', 'cell',
70 // Remove all (maybe spoofed) unsafe data from array
71 foreach ($UNSAFE as $remove) {
72 unset($_POST[$remove]);
75 // Set last change timestamp
76 $_POST['last_change'] = time();
79 $MSG = SPONSOR_SAVE_DATA($_POST, $content);
84 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, $MSG);
86 // No message generated
87 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_MESSAGE_GENERATED);
90 // Make yes/no selection
91 switch ($content['receive_warnings']) {
92 case "Y": define('__YES', " checked"); define('__NO', ""); break;
93 case "N": define('__YES', ""); define('__NO', " checked"); break;
96 // Translate current interval into fancy string
97 define('__CURRENT', CREATE_FANCY_TIME($content['warning_interval']));
100 $OUT = LOAD_TEMPLATE("sponsor_settings_form", true, $content);
104 $STATUS = SPONSOR_TRANSLATE_STATUS($content['status']);
105 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_ACCOUNT_FAILED_1.$STATUS.SPONSOR_ACCOUNT_FAILED_2);
108 // Sponsor account not found!
109 $OUT = LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_ACCOUNT_404_1.$_COOKIE['sponsorid'].SPONSOR_ACCOUNT_404_2);
113 SQL_FREERESULT($result);