PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Kriek
Forum Contributor
Posts: 238 Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:
Post
by Kriek » Thu Dec 12, 2002 11:00 pm
Ok this is driving me nuts.
Wrong parameter count for strstr() on line 8
Code: Select all
<?php
$log = 'log.txt';
$exit = 'exit.ref';
$max = 20;
$dom = 'home.com';
$dig = 'something.net';
$ref = getenv("HTTP_REFERER");
if (($ref) and (!strstr($ref, $dig, $dom))) {
$ref .= "\n";
$sp = fopen($exit, "w");
if (flock($sp, 2)) {
$rfile = file($log);
if ($ref <> $rfile[0]) {
if (count($rfile) == $max)
array_pop($rfile);
array_unshift($rfile, $ref);
$r = join("", $rfile);
$rp = fopen($flog, "w");
$status = fwrite($rp, $r);
$status = fclose($rp);
}
}
$status = fclose($sp);
}
?>
Last edited by
Kriek on Fri Dec 13, 2002 8:09 pm, edited 9 times in total.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Dec 12, 2002 11:04 pm
http://www.php.net/manual/en/function.strstr.php string strstr ( string haystack, string needle)
the parser is absolutly right about this
What do you want to achieve? testing wether $ref contains $dig or $dom?
Kriek
Forum Contributor
Posts: 238 Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:
Post
by Kriek » Thu Dec 12, 2002 11:08 pm
I'd like to check $ref for $dig and $dom
It's basically going to exclude them from the results.
Last edited by
Kriek on Thu Dec 12, 2002 11:10 pm, edited 1 time in total.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Dec 12, 2002 11:10 pm
strstr cant do it.
You might use preg_match as it can take an array of patterns. But they are tested sequencly (?).
Code: Select all
!strstr($ref, $dom) and !strstr($ref, $dig) will do.
Kriek
Forum Contributor
Posts: 238 Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:
Post
by Kriek » Thu Dec 12, 2002 11:18 pm
Thanks! That worked perfect.
I'll remember that next time.
nathus
Forum Commoner
Posts: 49 Joined: Thu Dec 12, 2002 6:23 pm
Post
by nathus » Thu Dec 12, 2002 11:30 pm
could also use ereg("($dig|$dom)", $ref)