Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Referrers Script tiny problem

    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)
    }
    ?>

    I've tried adding as many lines as I could like this:

    Code:
    $mydomain = 'site1.com';
    $mydomain2 = 'site2.com';
    $mydomain3 = 'site3.com';
    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))) {
    But that doesn't seem to work. Any ideas?

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Problem is in flock when it first meet condition it locks file and execute commands, but after that you forgot to unlock file and because of that it just add one url.
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you but that did not make one bit of sense. What I need is someone to fix the problem. Not forgetting to speak in lehman terms. Thanks.

  • #4
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is everyone dead on bere because I'm getting no answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •