XpertWorlock Posted January 12, 2009 Share Posted January 12, 2009 using AJAX to compare data with the database, $playerID and $ip may be able to be configured in the PHP script though. example of how they start out. $playerID = guest####; (# being random numbers) $ip = ###.###.### (user IP) //CHECKS TO SEE IF PLAYERID IS LEGITIMATE if (preg_match('/^\w{6,12}$/',$playerID)) { echo ''; } else { echo 'not legit'; } //CHECKS TO SEE IF IT'S AN IP ADDRESS if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip)){ echo''; } else { echo 'invalid characters for ip'; }; If either of them fail, than it won't connect to database. If it comes back true, is there still risk of hacking? Link to comment https://forums.phpfreaks.com/topic/140531-solved-is-this-safe/ Share on other sites More sharing options...
.josh Posted January 12, 2009 Share Posted January 12, 2009 If you are validating the strings with those regexes, returning info whether it passes or not, and then sending another request to the server to query the db with the info, you are still open for attack. Why? Because you validated the info for that first request. But you are sending a different request when you are querying the database. Someone could just bypass this validation altogether. The db query should be in the same script/request as your validation. Link to comment https://forums.phpfreaks.com/topic/140531-solved-is-this-safe/#findComment-735440 Share on other sites More sharing options...
XpertWorlock Posted January 12, 2009 Author Share Posted January 12, 2009 Well yes, this script would be on the same PHP script as the query? example. 1. javascript page($ip and $playerID are cookies retrieved from javascript) 2. use ajax to go through to PHP page 3. PHP gets $ip and $playerID(using POST method), than takes both variables, makes sure they fit the preg_match, and if true, queries it on same page, than sends back results. That would be safe? Link to comment https://forums.phpfreaks.com/topic/140531-solved-is-this-safe/#findComment-735471 Share on other sites More sharing options...
.josh Posted January 12, 2009 Share Posted January 12, 2009 yes. Link to comment https://forums.phpfreaks.com/topic/140531-solved-is-this-safe/#findComment-735477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.