@@ -129,7 +129,7 @@ function deleteUserBlacklistRecords($id)
129129function deleteUserRecordsLeaveBlacklistRecords ($ id )
130130{
131131 global $ tables ;
132-
132+
133133 Sql_Query ('delete from ' .$ tables ['linktrack_uml_click ' ].' where userid = ' .$ id );
134134 Sql_Query ('delete from ' .$ tables ['listuser ' ].' where userid = ' .$ id );
135135 Sql_Query ('delete from ' .$ tables ['usermessage ' ].' where userid = ' .$ id );
@@ -156,7 +156,7 @@ function deleteUserLeaveBlacklist($id)
156156 */
157157function deleteUserIncludeBlacklist ($ id )
158158{
159- // Note: deleteUserBlacklistRecords() must be executed first, else the ID
159+ // Note: deleteUserBlacklistRecords() must be executed first, else the ID
160160 // to email lookup fails due to the missing record
161161 deleteUserBlacklistRecords ($ id );
162162 deleteUserRecordsLeaveBlacklistRecords ($ id );
@@ -206,7 +206,7 @@ function addNewUser($email, $password = '')
206206 entered = now(),modified = now(),password = "%s",
207207 passwordchanged = now(),disabled = 0,
208208 uniqid = "%s",htmlemail = 1, uuid = "%s"
209- ' , $ GLOBALS ['tables ' ]['user ' ], $ email , $ blacklist , $ passwordEnc , getUniqid (), (string ) uuid::generate (4 )));
209+ ' , $ GLOBALS ['tables ' ]['user ' ], sql_escape ( $ email) , $ blacklist , $ passwordEnc , getUniqid (), (string ) uuid::generate (4 )));
210210
211211 $ id = Sql_Insert_Id ();
212212
@@ -312,8 +312,8 @@ function AttributeValue($table, $value)
312312function getUserEmail ($ id )
313313{
314314 global $ tables ;
315-
316- $ userid = Sql_Fetch_Row_Query ("select email from {$ tables ['user ' ]} where id = \"$ id \"" );
315+
316+ $ userid = Sql_Fetch_Row_Query ("select email from {$ tables ['user ' ]} where id = \"$ id \"" );
317317 return $ userid [0 ];
318318}
319319
@@ -416,7 +416,7 @@ function UserAttributeValue($user = 0, $attribute = 0)
416416 case 'checkboxgroup ' :
417417 // print "select value from $user_att_table where userid = $user and attributeid = $attribute";
418418 $ val_ids = Sql_Fetch_Row_Query ("select value from $ user_att_table where userid = $ user and attributeid = $ attribute " );
419- if ($ val_ids [0 ]) {
419+ if ($ val_ids && $ val_ids [0 ]) {
420420 // print '<br/>1 <b>'.$val_ids[0].'</b>';
421421 if (function_exists ('cleancommalist ' )) {
422422 $ val_ids [0 ] = cleanCommaList ($ val_ids [0 ]);
@@ -457,13 +457,13 @@ function UserAttributeValue($user = 0, $attribute = 0)
457457 $ table_prefix " .'listattr_ ' .$ att ['tablename ' ].".id = $ user_att_table " .".value and
458458 $ user_att_table " .'.attributeid = ' .$ attribute );
459459 $ row = Sql_Fetch_row ($ res );
460- $ value = $ row [0 ];
460+ $ value = $ row ? $ row [0 ] : '' ;
461461 break ;
462462 default :
463463 $ res = Sql_Query (sprintf ('select value from %s where
464464 userid = %d and attributeid = %d ' , $ user_att_table , $ user , $ attribute ));
465465 $ row = Sql_Fetch_row ($ res );
466- $ value = $ row [0 ];
466+ $ value = $ row ? $ row [0 ] : '' ;
467467 }
468468
469469 return stripslashes ($ value );
@@ -588,7 +588,7 @@ function addEmailToBlackList($email, $reason = '', $date = '')
588588 Sql_Query (sprintf ('insert ignore into %s (email,name,data) values("%s","%s","%s") ' ,
589589 $ GLOBALS ['tables ' ]['user_blacklist_data ' ], sql_escape ($ email ),
590590 'reason ' , addslashes ($ reason )));
591- foreach (array ('REMOTE_ADDR ' ) as $ item ) { // @@@do we want to know more?
591+ foreach (array ('REMOTE_ADDR ' , ' HTTP_X_FORWARDED_FOR ' ) as $ item ) { // @@@do we want to know more?
592592 if (isset ($ _SERVER [$ item ])) {
593593 Sql_Query (sprintf ('insert ignore into %s (email,name,data) values("%s","%s","%s") ' ,
594594 $ GLOBALS ['tables ' ]['user_blacklist_data ' ], addslashes ($ email ),
@@ -829,7 +829,7 @@ function addUserHistory($email, $msg, $detail)
829829 }
830830 }
831831 } else {
832- $ default = array ('HTTP_USER_AGENT ' , 'HTTP_REFERER ' , 'REMOTE_ADDR ' , 'REQUEST_URI ' );
832+ $ default = array ('HTTP_USER_AGENT ' , 'HTTP_REFERER ' , 'REMOTE_ADDR ' , 'REQUEST_URI ' , ' HTTP_X_FORWARDED_FOR ' );
833833 foreach ($ sysarrays as $ key => $ val ) {
834834 if (in_array ($ key , $ default )) {
835835 $ sysinfo .= "\n" .strip_tags ($ key ).' = ' .htmlspecialchars ($ val );
@@ -839,13 +839,8 @@ function addUserHistory($email, $msg, $detail)
839839
840840 $ userid = Sql_Fetch_Row_Query ("select id from $ user_table where email = \"$ email \"" );
841841 if ($ userid [0 ]) {
842- if (isset ($ _SERVER ['REMOTE_ADDR ' ])) {
843- $ ip = $ _SERVER ['REMOTE_ADDR ' ];
844- } else {
845- $ ip = '' ;
846- }
847842 Sql_Query (sprintf ('insert into %s (ip,userid,date,summary,detail,systeminfo)
848- values("%s",%d,now(),"%s","%s","%s") ' , $ user_his_table , $ ip , $ userid [0 ], sql_escape ($ msg ),
843+ values("%s",%d,now(),"%s","%s","%s") ' , $ user_his_table , getClientIP () , $ userid [0 ], sql_escape ($ msg ),
849844 sql_escape (htmlspecialchars ($ detail )), sql_escape ($ sysinfo )));
850845 }
851846}
0 commit comments