Jump to content

Recommended Posts

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))

Link to comment
https://forums.phpfreaks.com/topic/178298-solved-eregi-to-preg/
Share on other sites

  • 4 years later...

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.