Forum Moderators: coopster

Message Too Old, No Replies

call to undefined method

need fresh eyes

         

henry0

4:49 pm on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did not test the nested foreach yet, I need to deal with that error first

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

eelixduppy

5:39 pm on Feb 5, 2009 (gmt 0)



First off try this:

$check = new test();

And secondly, did you define the class before you tried to instantiate it?

henry0

6:22 pm on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, class and functions are defined
(you have the class and a file sample, corresponding to the error generated)
I forgot ()
but it does not matter for all other class function are properly doing the job
what am I missing that's got to be obvious

henry0

8:43 pm on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK fixed!
here it is, use it comment, make better...

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