// note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); // straight replacements, the user should never need these since they're normal characters // this prevents like Image $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { // ;? matches the ;, which is optional // 0{0,7} matches any padded zeros, which are optional and go up to 8 chars // @ @ search for the hex values $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ; // @ @ 0{0,7} matches '0' zero to seven times $val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ; } // now the only remaining whitespace attacks are \t, \n, and \r $ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); $ra = array_merge($ra1, $ra2); $found = true; // keep replacing as long as the previous round replaced something while ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(�{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2).''.substr($ra[$i], 2); // add in <> to nerf the tag $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags if ($val_before == $val) { // no replacements were made, so exit the loop $found = false; } } } return $val; } foreach($_GET as $key=>$value) { $$key = RemoveXSS($value); } foreach($_POST as $key=>$value) { $$key = RemoveXSS($value); } /* * VARIABILE *****************************************************************************/ $path_site = "."; include ($path_site."/configurari/config_db.php"); //include ($path_site."/configurari/conect_db.php"); include ($path_site."/configurari/config_generale.php"); include ($path_site."/configurari/config_functii.php"); //include ($path_site."/configurari/config_forum.php"); include ($path_site."/limba/Romana.php"); include ($path_site."/configurari/variabile.php"); if (isset($u_tip_utilizator) AND $u_tip_utilizator > 5) { include ($path_site."/configurari/config_generale_admin.php"); include ($path_site."/configurari/config_functii_admin.php"); include ($path_site."/limba/Romana_admin.php"); } if ($conf_revizie == "1" AND $user_ip != "82.76.81.15") { include ($path_site."/navigare/sus.php"); include ($path_site."/navigare/stanga_revizie.php"); include ($path_site."/navigare/index_1.php"); include ($path_site."/content/revizie.php"); include ($path_site."/navigare/index_2.php"); include ($path_site."/navigare/dreapta_revizie.php"); include ($path_site."/navigare/jos.php"); } else { include ($path_site."/navigare/sus.php"); include ($path_site."/navigare/stanga_".$var_site.".php"); include ($path_site."/navigare/index_1.php"); if (!isset($c) OR $c == "") { include ($path_site."/content/start_".$var_site.".php"); include ($path_site."/navigare/index_2.php"); include ($path_site."/navigare/dreapta_".$var_site.".php"); include ($path_site."/navigare/jos.php"); } else { if (file_exists($path_site."/content/".$c.".php")) { include ($path_site."/content/".$c.".php"); if (isset($var_sezon_curent) AND $c == "afisare_echipa" AND $var_sezon == $var_sezon_curent) { include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_3.php"); } else if ($c == "competitie" OR ($c == "istoric" AND isset($id_competitie) AND $id_competitie != '')) { include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_4.php"); } else if ($c == "camp_interne" OR $c == "camp_nationale" OR $c == "camp_european_prel" OR $c == "afisare_echipa" OR $c == "afisare_clasament" OR $c == "afisare_etapa" OR $c == "liga-1" OR $c == "regulament" OR ($c == "istoric" AND $id_campionat != '' AND $istoric != "cmondial")) { include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_2.php"); } else if ($c == "camp_mondial" OR ($c == "istoric" AND $istoric == "cmondial")) { include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_5.php"); } else if ($c == "cluburi_da_conducerea" OR $c == "cluburi_da_detalii" OR $c == "cluburi_da_jucatori" OR $c == "cluburi_da_stadion") { include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_cluburi_2.php"); } else { // include ($path_site."/navigare/dreapta_".$var_site.".php"); } include ($path_site."/navigare/jos.php"); } else { include ($path_site."/content/start_eroare.php"); include ($path_site."/navigare/index_3.php"); include ($path_site."/navigare/dreapta_".$var_site.".php"); include ($path_site."/navigare/jos.php"); } } } ?>