baxr6 Posted October 20, 2009 Share Posted October 20, 2009 Im converting my regex for php 5.3 and I am stuck on the following if((eregi("<[^>]script*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*object*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*iframe*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*applet*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*meta*\"?[^>]*>", $secvalue)) || (eregi("<[^>]style*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*form*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*img*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) || (eregi("<[^>]body*\"?[^>]*>", $secvalue) && !eregi("<[^>]tbody*\"?[^>]*>", $secvalue)) || (eregi("\([^>]*\"?[^)]*\)", $secvalue)) || (eregi("\"", $secvalue)) || (eregi("forum_admin", $sec_key)) || (eregi("inside_mod", $sec_key))) { block_ip($blocker_row); } anyone got any ideas on how to convert this to preg.so far I have this $html_regex = '{ ^( (?: <script\b[^>]*>.*?</script> # script block | <object\b[^>]*>.*?</object> # object block | <iframe\b[^>]*>.*?</iframe> # iframe block | <applet\b[^>]*>.*?</applet> # applet block | <meta\b[^>]*>.*?</meta> # meta block | <style\b[^>]*>.*?</style> # style block | <form\b[^>]*>.*?</form> # form block | <img\b[^>]*>.*?</img> # img block | <onmouseover\b[^>]*>.*?</onmouseover> # onmouseover block | <body\b[^>]*>.*?</body> # body block )*+ )$ }isx'; if (preg_match($html_regex, $html_string)) Quote Link to comment Share on other sites More sharing options...
Garethp Posted October 20, 2009 Share Posted October 20, 2009 Well what are you still have trouble with? Quote Link to comment Share on other sites More sharing options...
baxr6 Posted October 20, 2009 Author Share Posted October 20, 2009 specifically these (eregi("\([^>]*\"?[^)]*\)", $secvalue)) || (eregi("\"", $secvalue)) || (eregi("forum_admin", $sec_key)) || (eregi("inside_mod", $sec_key))) { and if it will function as before. Quote Link to comment Share on other sites More sharing options...
Garethp Posted October 20, 2009 Share Posted October 20, 2009 "~\([^>]*\"?[^)]*\)~i" "~\"~i" "~forum_admin~i" "~inside_mod~i" Try those in preg_match, then come back if you have some more problems Quote Link to comment Share on other sites More sharing options...
baxr6 Posted October 20, 2009 Author Share Posted October 20, 2009 might need to put it in code tags, i think its messed up Quote Link to comment Share on other sites More sharing options...
Garethp Posted October 20, 2009 Share Posted October 20, 2009 "~\([^>]*\"?[^)]*\)~i" "~\"~i" "~forum_admin~i" "~inside_mod~i" Try those in preg_match, then come back if you have some more problems Quote Link to comment Share on other sites More sharing options...
baxr6 Posted October 20, 2009 Author Share Posted October 20, 2009 yep all good, thanks m8 Quote Link to comment Share on other sites More sharing options...
alexanderpaul Posted November 12, 2013 Share Posted November 12, 2013 Can someone (experienced) advise me how to convert the following from eregi to preg* functions due I read that "eregi() gets deprecated with PHP 5.3" // begin hacker defense - Thanks Kreuznacher | wurdzwurk foreach ($_POST as $secvalue) { if ((eregi("<[^>]*script.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*object.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*iframe.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*applet.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*window.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*document.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*cookie.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*meta.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*style.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*alert.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*form.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*php.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*<?.*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*img.*\"?[^>]*>", $secvalue))) { die ("There was a problem with your post. Pleae try removing any HTML you may have in it."); } } // end hacker defense Appreciate advice here. Thanks. Quote Link to comment Share on other sites More sharing options...
.josh Posted November 12, 2013 Share Posted November 12, 2013 did you read the forum sticky about this very thing? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.