mysql escaping and admin authentication
Hello.
I'm writing a plugin that logs admin activity to a mysql database table. I have a few problems so far: I use the client_putinserver and client_disconnect functions to log when somebody joins and leaves. then inside each one i check to see if the user has admin rights using is_user_admin. The problem is if someone joins as a simple player and then authenticates as an admin and leaves, i only log the disconnection, so i see someone leaving without joining, same goes if someone joins authed and leaves unauthed, i only see him joining and not leaving, worst case if someone joins unauthed , auths, then changes name and becomes a normal player and leaves, i dont log anything. So id like to know what i should use to detect when someone gains admin privileges and also when someone loses admin privileges. One other matter is, when i log the joins/parts the admin's name gets logged, so ppl can have all sorts of names, this is vulerable to sql injection, and id like to prevent that. From what i've seen on php's mysql_real_escape_string function Code:
mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.This is so far the code i use to log joins/parts (the client_disconnect is similar, except that i log as "left" instead of "joined") : Code:
|
Re: mysql escaping and admin authentication
see:
http://www.amxmodx.org/funcwiki.php?go=func&id=1182 http://www.amxmodx.org/funcwiki.php?go=func&id=1183 maybe you can catch the amx log: Login: <.....> became an admin <.....>..... or catch the name change with client_infochanged |
Re: mysql escaping and admin authentication
thank you for the info, i have some problems using those however:
I'm having a hard time figuring out how to use SQL_QuoteStringFmt, it returns the length of the new string or -1 on failure. so in my example i tried to escape g_admin_joined but i got all sorts of errors such as : Code:
[SQLERROR]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'\' , NOW( ) , \'g#\' , \'STEAM_ID_PENDING\' , \'zzz.zzz.zzz.zzz:27005\', \'joine' at line 1as you can see it escapes everything. its not really what i wanted, and i dont quite understand how it works, wouldnt it be easier to have smth like this Code:
Code:
\x00, \n, \r, \, ', " and \x1a |
Re: mysql escaping and admin authentication
Quote:
|
| All times are GMT -4. The time now is 03:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.