Possible further fix for #128
[mailer.git] / inc / modules / admin / what-edit_user.php
index e8d3fbd..683a836 100644 (file)
@@ -53,7 +53,7 @@ if (REQUEST_ISSET_GET('uid')) {
 FROM `{!_MYSQL_PREFIX!}_user_data`
 WHERE userid=%s
 LIMIT 1",
-       array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
+               array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
 }
 
 if ((SQL_NUMROWS($result_main) == 1) || (!REQUEST_ISSET_GET('uid')))
@@ -68,75 +68,66 @@ if ((SQL_NUMROWS($result_main) == 1) || (!REQUEST_ISSET_GET('uid')))
        {
                // Ok, change the account...
                $PASS = false; $add = '';
-               if ((!REQUEST_ISSET_POST(('pass1'))) && (!REQUEST_ISSET_POST(('pass2'))))
-               {
+               if ((!REQUEST_ISSET_POST('pass1')) && (!REQUEST_ISSET_POST('pass2'))) {
                        // Don't change the password
                        $PASS = true;
-               }
-               elseif ((REQUEST_POST('pass1') == REQUEST_POST('pass2')))
-               {
+               } elseif ((REQUEST_POST('pass1') == REQUEST_POST('pass2'))) {
                        // Change the password
                        $PASS = true;
-                       $add = ", password='".generateHash(REQUEST_POST('pass1'))."'";
+                       $add = ", `password`='" . generateHash(REQUEST_POST('pass1')) . "'";
                }
-               if ($PASS)
-               {
+
+               if ($PASS) {
                        // We have to add the following things: birthday and max receive mails
                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET
-gender='%s',
-surname='%s',
-family='%s',
-street_nr='%s',
-country='%s',
-zip=%s,
-city='%s',
-email='%s'
+`gender`='%s',
+`surname`='%s',
+`family`='%s',
+`street_nr`='%s',
+`country`='%s',
+`zip`=%s,
+`city`='%s',
+`email`='%s'
 ".$add."
 WHERE userid=%s LIMIT 1",
                        array(
-                       substr(REQUEST_POST('gender'), 0, 1),
-                       REQUEST_POST('surname'),
-                       REQUEST_POST('family'),
-                       REQUEST_POST('street_nr'),
-                       REQUEST_POST('country'),
-                       bigintval(REQUEST_POST('zip')),
-                       REQUEST_POST('city'),
-                       REQUEST_POST('email'),
-                       bigintval(REQUEST_GET('uid')),
+                               substr(REQUEST_POST('gender'), 0, 1),
+                               REQUEST_POST('surname'),
+                               REQUEST_POST('family'),
+                               REQUEST_POST('street_nr'),
+                               REQUEST_POST('country'),
+                               bigintval(REQUEST_POST('zip')),
+                               REQUEST_POST('city'),
+                               REQUEST_POST('email'),
+                               bigintval(REQUEST_GET('uid')),
                        ), __FILE__, __LINE__);
-                       $content = USER_ACCOUNT_SAVED;
-               }
-               else
-               {
+                       $content = getMessage('USER_ACCOUNT_SAVED');
+               } else {
                        // Problem while saving data
-                       $content = USER_ACCOUNT_NOT_SAVED;
+                       $content = getMessage('USER_ACCOUNT_NOT_SAVED');
                }
 
                // Load template
                LOAD_TEMPLATE('admin_settings_saved', false, $content);
-       }
-       else
-       {
+       } else {
                // Display form to edit
                list($gender, $surname, $family, $street, $zip, $city, $country, $email, $bday, $bmonth, $byear, $max) = SQL_FETCHROW($result_main);
-               SQL_FREERESULT($result_main);
 
                // Transfer data to constants for the template
-               switch ($gender)
-               {
-                       case "M":
+               switch ($gender) {
+                       case 'M':
                                define('_GENDER_M', ' selected="selected"');
                                define('_GENDER_F', '');
                                define('_GENDER_C', '');
                                break;
 
-                       case "F":
+                       case 'F':
                                define('_GENDER_M', '');
                                define('_GENDER_F', ' selected="selected"');
                                define('_GENDER_C', '');
                                break;
 
-                       case "C":
+                       case 'C':
                                define('_GENDER_M', '');
                                define('_GENDER_F', '');
                                define('_GENDER_C', ' selected="selected"');
@@ -148,12 +139,15 @@ WHERE userid=%s LIMIT 1",
                define('_COUNTRY', $country); define('_EMAIL' , $email);
 
                // Load template
-               LOAD_TEMPLATE("admin_edit_user", false, bigintval(REQUEST_GET('uid')));
+               LOAD_TEMPLATE('admin_edit_user', false, bigintval(REQUEST_GET('uid')));
        }
 } else {
        // Account does not exists!
        LOAD_TEMPLATE('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."</div>");
 }
 
+// Free the result
+SQL_FREERESULT($result_main);
+
 //
 ?>