Forum Moderators: coopster
The error:
call to undefined method test::unset_cookie()
any file:
$check = new test;
$input=array($firstName, $lastName, $username, $email, $body); //print_r($input);
if($check->unset_cookie($input) )
{
echo "<h3>Not allowed to set cookie!</h3>";
exit;
}
The class:
class test (showing only the function related to the error)
{
var $input;
//// check fot attempt cookie setting ///
function unset_cookie ($input)
{
foreach $input as $cook
{
$cook=implode("", $input);
if(count($_COOKIE))
{
foreach(array_keys($_COOKIE) as $value)
{
unset($value);
return true;
}
return false;
}
}
}
} // end class
$check = new test();
And secondly, did you define the class before you tried to instantiate it?
class test
{
var $input;
var $authHosts;
//// check for inject ////////////////////
function badStr ($input) {
$bad_strings = array(
"content-type:"
,"mime-version:"
,"multipart/mixed"
,"Content-Transfer-Encoding:"
,"bcc:"
,"cc:"
,"to:"
);
foreach($bad_strings as $bad_string) {
if(eregi($bad_string, implode("", $input)) ) return true;
}
return false;
}
//// check for invalid referrer ////////////
function valid_referrers ($validReferrers)
{
$http_ref = $_SERVER['HTTP_REFERER'];
$array = parse_url($http_ref);
$a = $array['host'];
if(!in_array($a,$validReferrers)) { return true; }
return false;
}
//// check for attempt cookie setting ///
function if_cookie ($input) {
$cook_strings = array(
"setcookie",
"$_COOKIE",
"cookie"
);
foreach($cook_strings as $bad_cook) {
if(eregi($bad_cook, implode("", $input)) ) return true;
}
return false;
}
//// check spam using php filter ///////////
function sanit_emails($emails)
{
//filter_var() sanitizes the e-mail
foreach($emails as $bad_email)
{
$emails=explode(" ", $emails);
if(filter_var($emails, FILTER_VALIDATE_EMAIL))
{
return true;
}
return false;
}
}
} // end of class