respected Posted November 14, 2006 Share Posted November 14, 2006 Hello I have a referrers script that I use on my website. The thing is, it only blocks out one URL so that it doesn't appear on the referrers list and that is ofcourse my site.I have tried lots of ways in order to allow the script to take in as many URLs because they're certain websites I do not want to be listed.Can anyone help me? The troubled php coding I have is with reflog.php:-[code]<?php/* Modified by Scott Riggs at www.cybernetec.com*/$path = '/home/blabla/public_html/';// Name of referrer log file$reflog = $path . 'reflog.txt';// Name of semaphore file$semaphore = $path . 'semaphore.ref';// Maximum number of referrers to log$maxref = 6;// Domain name of this site (minus "http://www.")$mydomain = 'site1.com';// From whence did Bunky come?$ref = getenv("HTTP_REFERER");// Cover me. I'm going in.if (($ref) and (!strstr($ref, $mydomain, $mydomain2))) { // if there's a referrer, and it's not someone bouncing around this site $ref .= "\n"; // append a line feed $sp = fopen($semaphore, "w"); // open the semaphore file if (flock($sp, 2)) { // lock the semaphore; other processes will stop and wait here $rfile = file($reflog); // read the referrer log into an array if ($ref <> $rfile[0]) { // if this referrer is different from the last one if (count($rfile) == $maxref) // if the file is full array_pop($rfile); // pop the last element array_unshift($rfile, $ref); // push the new referrer onto the front $r = join("", $rfile); // make the array into a string $rp = fopen($reflog, "w"); // open the referrer log in write mode $status = fwrite($rp, $r); // write out the referrer URLs $status = fclose($rp); // close the log } } $status = fclose($sp); // close the semaphore (and release the lock)}?>[/code]I've tried adding as many lines as I could like this:[code]$mydomain = 'site1.com';$mydomain2 = 'site2.com';$mydomain3 = 'site3.com';[/code]and adding elseifs under each line, like this:-[code]if (($ref) and (!strstr($ref, $mydomain))) {elseif if (($ref) and (!strstr($ref, $mydomain2))) {elseif (($ref) and (!strstr($ref, $mydomain3))) {[/code]But that doesn't seem to work. Any ideas? Link to comment https://forums.phpfreaks.com/topic/27241-referrers-script-tiny-problem/ Share on other sites More sharing options...
respected Posted November 15, 2006 Author Share Posted November 15, 2006 any ideas or solutions would be appreciated! Link to comment https://forums.phpfreaks.com/topic/27241-referrers-script-tiny-problem/#findComment-124933 Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 You could use an array of URI's, then use the [url=http://php.net/in_array]in_array[/url] function to see if the URI exists within the array. Link to comment https://forums.phpfreaks.com/topic/27241-referrers-script-tiny-problem/#findComment-124938 Share on other sites More sharing options...
respected Posted November 16, 2006 Author Share Posted November 16, 2006 Could someone just fix my coding instead and display it in the next reply, im not too good with php, thanks. Link to comment https://forums.phpfreaks.com/topic/27241-referrers-script-tiny-problem/#findComment-125654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.