Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.