<?php
//=====================================================================================
//Apply real_escape_string to strip out SQL injection
function makeSafe($value){
//if (isset($value)){
$value = $this->clean_html($value);
$value = strip_tags(trim($value));
//}
return $value;
//return mysql_real_escape_string($value);
}
//=====================================================================================
//Clean out html code. From html2txt() in http://us2.php.net/manual/en/function.strip-tags.php
function clean_html($document){
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
);
//Replace any of the patterns listed above
$text = preg_replace($search, '', $document);
//Replace or remove any illegal characters
$text = preg_replace('/;/', ' ', $text); //semicolons
$text = preg_replace('/"/', "'", $text); //double quotations
$text = preg_replace('/[\%\?\*]/', ' ', $text); //wildcards
$text = preg_replace('/[\:\`\$\/\\\=\~\<\>\|\!\^]/', ' ', $text); //other uneeded symbols
$text = preg_replace('/[-]{2,}/', '-', $text); //more than 1 dash in a row
$text = preg_replace("/[\']{2,}/", "'", $text); //more than 1 single quotation in a row
$text = preg_replace("/[\&]{2,}/", '&', $text); //more than 1 ampersand in a row
$text = preg_replace("/[ ]{2,}/", ' ', $text); //more than 1 space in a row
//And replace any leftover special characters
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
//Return the value
return $text;
}
$mystring = "
rcooper@c2ti.com test 456
Famed California pollster Joe Shumate was found dead in his home one month before Election Day 2010, surrounded by sheets of polling data he labored over for the flailing Senate bid of Carly Fiorina. Upon his death, Fiorina praised Shumate as 'the heart and sou f her team. She issued a news release praising him as a person who believed in inves";
$mystring2 = makeSafe($mystring);
echo $mystring2;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Using $this when not in object context in /in/Z7Tmm:9
Stack trace:
#0 /in/Z7Tmm(58): makeSafe('\nrcooper@c2ti.c...')
#1 {main}
thrown in /in/Z7Tmm on line 9
Process exited with code 255.
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.