Skip to content
WJunction - Webmaster Forum

PHP Error in 1 Line

Status
Not open for further replies.
Hello maybe someone can help here............

I have a DDL CMS Script if i Delete in Admin Panel a Post its showing this Warning:

Warning: eregi() expects parameter 2 to be string, array given in /home/username/public_html/Domain/File.php on line 74

Line 74 is This:

Code:
if (eregi('<[^>]*' . $tag, $varname))
Is it Possible to Fix this?!

Regards
 

4 comments

This is Complete File:

Code:
<?php
    $disalowedtags = array
    (
        'script',
        'object',
        'iframe',
        'image',
        'applet',
        'meta',
        'form',
        'onmouseover',
        'onmouseout'
    );
    foreach($_GET as $varname)
    {
        foreach($disalowedtags as $tag)
        {
            if(eregi('<[^>]*' . $tag, $varname))
            {
                #header("Location: $site_url");
                #die();
                $threat = TRUE;
            }
        }
    }
    foreach($_POST as $varname)
    {
        foreach($disalowedtags as $tag)
        {
            if (eregi('<[^>]*' . $tag, $varname))
            {
                #header("Location: $site_url");
                #die();
                $threat = TRUE;
            }
        }
    }
?>
 
I think what you want to achieve needs a recursive function.

I'm not going to bitch about how what you want to achieve could be done better.
I'm simply handing you a solution.

Voila;
PHP:
<?php
//So I can find this later:
//Robin Houtevelts

//The code:
function isAThreat($array){
	$disalowedtags = array
    (
        'script',
        'object',
        'iframe',
        'image',
        'applet',
        'meta',
        'form',
        'onmouseover',
        'onmouseout'
    );

	foreach($array as $string){
		if(is_array($string)){
			if(isAThreat($array)){
				return true;
			}
		}elseif(is_string($string)){
			
			foreach($disalowedtags as $tag)
			{
				if(eregi('<[^>]*' . $tag, $string))
				{
					#header("Location: $site_url");
					#die();
					return true;
				}
			}
			
		}
	}
	
	return false;
}

if(isAThreat($_GET) OR isAThreat($_POST)){
	$threat = TRUE;
}else{
	$threat = FALSE;
}

?>

In case I messed up on this simple function:
I'm sorry.. I haven't touched PHP in quite a while.
 
Status
Not open for further replies.

About the author

D
Active Member · Joined
1,525
Messages
298
Reactions
83
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom