Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Register your account to receive email notifications when new services and mods are added.


This forum is now closed and has moved to a new location! Click here to find out why.
Pages: 1 [2]

AuthorTopic: Anti-SQL injection function  (Read 3842 times)

Karlos

  • Basic Member
  • *
  • Reputation Power: 0
  • Karlos is looked down upon.
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Anti-SQL injection function
« Reply #15 on: May 14, 2009, 11:49:54 AM »
function Clean($Var) {
 if (
get_magic_globals_gpc() == 1) {
  
$Var stripslashes($Var);
 }
 
$Var mysql_real_escape_string(htmlentities($Var));
 return 
$Var;
}


Simple yet effective
Logged

Drizzah

  • Basic Member
  • *
  • Reputation Power: 4
  • Drizzah has no influence.
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Anti-SQL injection function
« Reply #16 on: April 05, 2010, 01:34:53 AM »
What is the downfall of using this code below. This is basically the code above, but played with some.

function anti_inject($campo)
{
    foreach($campo as $key => $val)
    {
        $val = mysql_real_escape_string(trim(strip_tags($val)));
        $campo[$key] = $val;
    }
    return $campo;
}

$_POST = anti_inject($_POST);
$_POST = str_ireplace("script", "blocked", $_POST);
$_POST = str_ireplace("xss", "blocked", $_POST);
$_GET = anti_inject($_GET);
$_GET = str_ireplace("script", "blocked", $_GET);
$_GET = str_ireplace("xss", "blocked", $_GET);
}
Logged
Good Info and Help with Securing
Strip HTML Tags - PHP Filtering

rpmb

  • Basic Member
  • *
  • Reputation Power: 0
  • rpmb is looked down upon.rpmb is looked down upon.rpmb is looked down upon.rpmb is looked down upon.rpmb is looked down upon.
  • Offline Offline
  • Posts: 6
    • View Profile
    • Email
Re: Anti-SQL injection function
« Reply #17 on: April 09, 2010, 03:09:38 AM »
the downfall is in you using it.
Logged

Drizzah

  • Basic Member
  • *
  • Reputation Power: 4
  • Drizzah has no influence.
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Anti-SQL injection function
« Reply #18 on: April 11, 2010, 12:03:17 AM »
the downfall is in you using it.

It's doing what I want it to do so far. I am just asking as alot of people here come up with some good techniques of making it just a little bit better. Also, I am not slow or anything. I do know you are being a smart a$$ about it.

If you do not have a tip to give on a code, a compliment to give on a code or a reason and example of why not to use a code. Then don't bother replying to the post. (Meaningless Posting just to get your reputation higher)! :o
Logged
Good Info and Help with Securing
Strip HTML Tags - PHP Filtering
Pages: 1 [2]
« previous next »
 


This forum is now closed and has moved to a new location! Click here to find out why.