Welcome!,
How to use AntiInject.
Antiinject is a SQL Injection Prevention Library made as a second hand meant to Be At the top of your code!
Simple code:
require('antiinject.php');
antiinject($string,true);
Lets Break this down:
require('antiinject.php');
^1 ^2
antiinject($string,true);
^3 ^4 ^5
1.Require, Add the function of antiinject in the file antiinject.php
2.antiinject.php, The file of my project
3.Antiinject, The Function Of the program
4.$string, The Variable string you wish to scan
5.true, Block the site using defined messages in the file. false will be used for defining a statement as seen below will show how to use the false string.
Advanced code, Custom code
Here`s a script to log any ip that attempts to SQL inject your site
require('antiinject.php');
if(!antiinject($string,false)){
$logfile= 'log.txt';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch? ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);
die("You tried to hack my site, i got your ip now");
}
I'm not going to go in detail on this but false will return false and is used to execute php code in a if statement