18-12-2007, 12:45
|
#26 (permalink)
|
|
Designers are strange :)
Join Date: Jan 2007
Location: Shrewsbury, UK
Posts: 1,703
|
PHP Code:
function make_safe($make_safe)
{
if(get_magic_quotes_gpc())// If magic quotes is enabled
{
$string = stripslashes($string);//Remove slashes from the string
}
else //If not {
$make_safe = addslashes(trim($make_safe));
}
$make_safe = escapeshellcmd($make_safe); //Remove all SHELL commands
$make_safe = escapeshellarg($make_safe); //Remove all SHELL commands to be run as an argument
$make_safe = mysql_real_escape_string($make_safe); //Stop MOST MySQL injections
$make_safe = stripslashes(strip_tags(htmlspecialchars($make_safe, ENT_QUOTES))); //Remove XHTML, remove slashes
return $make_safe; // Return the safe string
} // End make safe functions
PHP Code:
// This function encrypts users passwords 3 times.
function encrypt($encrypt)
{
$encrypt = md5($encrypt); // Encrypt the string to MD5
$encrypt = sha1($encrypt); // Encrypt the MD5 string to SHA1
$encrypt = md5($encrypt); // Encrypt the SHA1 string to MD5 AGAIN!!
return $encrypt; // Return the encrypted string.
} // End encryption function
PHP Code:
// This function check if a user has used a correct email, if not, it dies.
function check_email($check_email)
{
$_name = "/^[-!#$%&'*+./0-9=?A-Z^_`{|}~]+"; // Name check, bit before @
$_host = "([-0-9A-Z]+.)+"; // Host check, bit after @
$_tlds = "([0-9A-Z]){2,4}$/i"; // TLD check, bit after .
if(!preg_match($_name."@".$_host .$_tlds,$email)) // If the email isn't valid..
{
die("Please enter a valid email address"); // Kill the function
}
else // if email is valid
{
return $check_email; // Return the email string
}
} // End check email function
}
These aren't too complex, but they work, so yeah. Happy XMAS!!!!!!
I love using die(); in my scripts. XD
__________________
If it works, it's valid.
Last edited by RaelRode : 18-12-2007 at 15:59.
|
|
|
|