(no commit message)
[mailer.git] / 0.2.1 / inc / modules / admin / what-edit_user.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 09/28/2003 *\r
4  * ===============                              Last change: 06/10/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-edit_user.php                               *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Edit member's profiles                           *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Mitgliederprofile ändern                         *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 // Add description as navigation point\r
41 ADD_DESCR("admin", basename(__FILE__));\r
42 \r
43 OPEN_TABLE("100%", "admin_content admin_content_align", "");\r
44 \r
45 // Fix a notice\r
46 $result_main = false;\r
47 if (isset($_GET['u_id'])) {\r
48         //                                    0      1        2         3      4     5      6       7         8          9           10         11\r
49         $result_main = SQL_QUERY_ESC("SELECT sex, surname, family, street_nr, zip, city, country, email, birth_day, birth_month, birth_year, max_mails FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",\r
50          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);\r
51 }\r
52 \r
53 if ((SQL_NUMROWS($result_main) == 1) || (empty($_GET['u_id'])))\r
54 {\r
55         // User found\r
56         if (empty($_GET['u_id']))\r
57         {\r
58                 // Output selection form with all confirmed user accounts listed\r
59                 ADD_MEMBER_SELECTION_BOX();\r
60         }\r
61          elseif (isset($_POST['edit']))\r
62         {\r
63                 // Ok, change the account...\r
64                 $PASS = false; $ADD = "";\r
65                 if ((empty($_POST['pass1'])) && (empty($_POST['pass2'])))\r
66                 {\r
67                         // Don't change the password\r
68                         $PASS = true;\r
69                 }\r
70                  elseif (($_POST['pass1'] == $_POST['pass2']))\r
71                 {\r
72                         // Change the password\r
73                         $PASS = true;\r
74                         $ADD = ", password='".generateHash($_POST['pass1'])."'";\r
75                 }\r
76                 if ($PASS)\r
77                 {\r
78                         // We have to add the following things: birthday and max receive mails\r
79                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET\r
80 sex='%s',\r
81 surname='%s',\r
82 family='%s',\r
83 street_nr='%s',\r
84 country='%s',\r
85 zip=%d,\r
86 city='%s',\r
87 email='%s'\r
88 ".$ADD."\r
89 WHERE userid=%d LIMIT 1",\r
90  array(\r
91         substr($_POST['salut'], 0, 1),\r
92         $_POST['surname'],\r
93         $_POST['family_name'],\r
94         $_POST['street_nr'],\r
95         $_POST['country'],\r
96         bigintval($_POST['zip']),\r
97         $_POST['city'],\r
98         $_POST['email'],\r
99         bigintval($_GET['u_id']),\r
100 ), __FILE__, __LINE__);\r
101                         $content = USER_ACCOUNT_SAVED;\r
102                 }\r
103                  else\r
104                 {\r
105                         // Problem while saving data\r
106                         $content = USER_ACCOUNT_NOT_SAVED;\r
107                 }\r
108 \r
109                 // Load template\r
110                 LOAD_TEMPLATE("admin_settings_saved", false, $content);\r
111         }\r
112          else\r
113         {\r
114                 // Display form to edit\r
115                 list($sex, $surname, $family, $street, $zip, $city, $country, $email, $bday, $bmonth, $byear, $max) = SQL_FETCHROW($result_main);\r
116                 SQL_FREERESULT($result_main);\r
117 \r
118                 // Transfer data to constants for the template\r
119                 switch ($sex)\r
120                 {\r
121                 case "M":\r
122                         define('_SEX_M', " selected=\"selected\"");\r
123                         define('_SEX_F', "");\r
124                         define('_SEX_C', "");\r
125                         break;\r
126 \r
127                 case "F":\r
128                         define('_SEX_M', "");\r
129                         define('_SEX_F', " selected=\"selected\"");\r
130                         define('_SEX_C', "");\r
131                         break;\r
132 \r
133                 case "C":\r
134                         define('_SEX_M', "");\r
135                         define('_SEX_F', "");\r
136                         define('_SEX_C', " selected=\"selected\"");\r
137                         break;\r
138                 }\r
139 \r
140                 define('_SURNAME', $surname); define('_FAMILY', $family); define('_CITY'     , $city);\r
141                 define('_STREET' , $street);  define('_ZIP'   , $zip);    define('_MAX_MAILS', $max);\r
142                 define('_COUNTRY', $country); define('_EMAIL' , $email);\r
143 \r
144                 // Load template\r
145                 LOAD_TEMPLATE("admin_edit_user", false, bigintval($_GET['u_id']));\r
146         }\r
147 }\r
148  else\r
149 {\r
150         // Account does not exists!\r
151         OUTPUT_HTML ("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");\r
152 }\r
153 CLOSE_TABLE();\r
154 //\r
155 ?>\r