Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Apsauga nuo SQL Injection

Parašė weberiz· 2012 Bal. 4 12:04:02
#6


// Validate numeric input
function isnum($value) {
	if (!is_array($value)) {
		return (preg_match("/^[0-9]+$/", $value));
	} else {
		return false;
	}
}
// Strip Input Function, prevents <span style="border-bottom: 1px dotted black;">HTML</span> in unwanted places
function stripinput($text) {
	if (!is_array($text)) {
		$text = stripslash(trim($text));
		//$text = preg_replace("/&[^#0-9]/", "&amp;", $text)
		$search = array("&", "\"", "'", "\\", '\"', "\'", "<", ">", "&nbsp;");
		$replace = array("&amp;", "&quot;", "'", "\", "&quot;", "'", "&lt;", "&gt;", " ");
		$text = preg_replace("/(&amp;)+(?=\#([0-9]{2,3});)/i", "&", str_replace($search, $replace, $text));
	} else {
		foreach ($text as $key => $value) {
			$text[$key] = stripinput($value);
		}
	}
	return $text;
}
 
// Prevent any possible XSS attacks via $_GET.
function stripget($check_url) {
	$return = false;
	if (is_array($check_url)) {
		foreach ($check_url as $value) {
			if (stripget($value) == true) { 
				return true;
			}
		}
	} else {
		$check_url = str_replace(array("\"", "\'"), array("", ""), urldecode($check_url));
		if (preg_match("/<[^<>]+>/i", $check_url)) { 
			return true;
		}
	}
	return $return;
}

viskas apsaugotas tik naudok šias funkcijas