Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Blocking referrers in .htaccess and shor urls
  • Posted: 19.07.2005, 18:08
     
    thedc
    rank:
    Helper Helper
    registered:
     March 2005
    Status:
    offline
    last visit:
    20.04.06
    Posts:
    167
    I have been trying to block referrer spam by using a mod rewrite in .htaccess but it never seems to work and always causes my site to become unreachable, but I am able to run short urls so I am a little confused.

    I anyone runnig short urls at the same time as blocking referrer spam?
  • Posted: 19.07.2005, 19:51
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    I block referers I don't want to see by adding keywords in a PNConfig value in the module_vars table and by adding this to my referer.php file :

    Code

    $writeref = true;
             $refex = pnConfigGetVar('httprefexcluded');
             //if (!empty($refex) && $refex."" != "") {
             if (!empty($refex)) {
                 $refexclusion = explode(' ', $refex);
                 $count = count($refexclusion);
                 $eregicondition = "((";
                 for ($i = 0; $i < $count; $i++) {
                     if ($i != $count-1) {
                         $eregicondition .= $refexclusion[$i] . ")|(";
                     } else {
                         $eregicondition .= $refexclusion[$i] . "))";
                     }
                 }

                 if (eregi($eregicondition, $httpreferer)) {
                     $writeref = false;
                 }
            }

    if ($writeref == true) {
    // grab a reference to our table column..............
    .......................


    }


    The list of words is separated by spaces...
    My current list but I'm adding words as they appear...

    Quote


    bookmark yahoo google xxx search msn sex poker casino texas credit 5gigs westvaley infoseek pills


    I did a hack a long time ago to have a field in the administration to use to exclude words.......

    Think I should do that again. Will ask...

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 19.07.2005, 20:00
     
    FrankDeRosa
    rank:
    Professional Professional
    registered:
     March 2002
    Status:
    offline
    last visit:
    15.04.07
    Posts:
    2489
    There's an old post about this, too. Some good code in it (not that your code isn't fly, chestnut).

    http://forums.postnuke.com/index.php?name=PNphpBB2&file=viewtopic&t=35990&highlight=block+referrer

    Frank

    --
    Serious hosting - all the features, bandwith and storage you could want without breaking the bank at DreamHost.com


    See what I do with PostNuke - http://surreal-dreams.com
  • Posted: 19.07.2005, 20:06
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    I saw it too... But having not much clue about htaccess... I chose the PHP way. :)

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 22.07.2005, 01:51
     
    thedc
    rank:
    Helper Helper
    registered:
     March 2005
    Status:
    offline
    last visit:
    20.04.06
    Posts:
    167

    Chestnut

    I block referers I don't want to see by adding keywords in a PNConfig value in the module_vars table and by adding this to my referer.php file :

    Code

    $writeref = true;
             $refex = pnConfigGetVar('httprefexcluded');
             //if (!empty($refex) && $refex."" != "") {
             if (!empty($refex)) {
                 $refexclusion = explode(' ', $refex);
                 $count = count($refexclusion);
                 $eregicondition = "((";
                 for ($i = 0; $i < $count; $i++) {
                     if ($i != $count-1) {
                         $eregicondition .= $refexclusion[$i] . ")|(";
                     } else {
                         $eregicondition .= $refexclusion[$i] . "))";
                     }
                 }

                 if (eregi($eregicondition, $httpreferer)) {
                     $writeref = false;
                 }
            }

    if ($writeref == true) {
    // grab a reference to our table column..............
    .......................


    }



    The list of words is separated by spaces...
    My current list but I'm adding words as they appear...

    Quote



    bookmark yahoo google xxx search msn sex poker casino texas credit 5gigs westvaley infoseek pills



    I did a hack a long time ago to have a field in the administration to use to exclude words.......

    Think I should do that again. Will ask...



    Does that actually stop the referers from connecting to your site? Or does it simply not show it in your referers module. Or am I missing something here and that is esentially what the htaccess method does as well.
  • Posted: 22.07.2005, 01:57
     
    FrankDeRosa
    rank:
    Professional Professional
    registered:
     March 2002
    Status:
    offline
    last visit:
    15.04.07
    Posts:
    2489
    With the .htaccess method, the referrers are redirected elsewhere. With Chestnut's PHP method, the referrers arrive at your site, but their visits are not logged by the referrals module.

    You could do both, just to be safe :) Redirect and ignore - referral spam no more.

    Frank

    --
    Serious hosting - all the features, bandwith and storage you could want without breaking the bank at DreamHost.com


    See what I do with PostNuke - http://surreal-dreams.com
  • Posted: 22.07.2005, 15:30
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    The keywords exclusion system has been included in the upcoming 0.760...

    So that is one done on 2 ! :wink:

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 22.07.2005, 18:45
     
    FrankDeRosa
    rank:
    Professional Professional
    registered:
     March 2002
    Status:
    offline
    last visit:
    15.04.07
    Posts:
    2489
    Nice. I didn't realize that I had that already - I'll have to explore it. :) Goodby poker/casino/pills sites. The best one was the unitedchurchofjebus.com (something like that) with it's poker and casino pages. SPAM!

    Frank

    --
    Serious hosting - all the features, bandwith and storage you could want without breaking the bank at DreamHost.com


    See what I do with PostNuke - http://surreal-dreams.com
  • Posted: 22.07.2005, 18:52
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    28.11.08
    Posts:
    13417

    Quote

    I didn't realize that I had that already - I'll have to explore it


    You don't, unless you have the latest CVS ;)

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 22.07.2005, 19:00
     
    FrankDeRosa
    rank:
    Professional Professional
    registered:
     March 2002
    Status:
    offline
    last visit:
    15.04.07
    Posts:
    2489
    Oh, heh. That would be no.

    Way to keep up with the times, though - Any reduction of crap on the 'net is a Good Thing (TM).

    Frank

    --
    Serious hosting - all the features, bandwith and storage you could want without breaking the bank at DreamHost.com


    See what I do with PostNuke - http://surreal-dreams.com
  • Posted: 22.07.2005, 20:49
     
    FrankDeRosa
    rank:
    Professional Professional
    registered:
     March 2002
    Status:
    offline
    last visit:
    15.04.07
    Posts:
    2489
    Looking at my referral logs I'm being bombarded by these damn casino sites. It's official - I no longer like poker. I'm eagerly awaiting the .760 release, if only to get rid of their crap. Hook me up, fellas!

    Frank

    --
    Serious hosting - all the features, bandwith and storage you could want without breaking the bank at DreamHost.com


    See what I do with PostNuke - http://surreal-dreams.com
  • Posted: 03.08.2005, 03:58
     
    SilentSpic
    rank:
    Freshman Freshman
    registered:
     August 2004
    Status:
    offline
    last visit:
    15.08.06
    Posts:
    20

    Chestnut

    I block referers I don't want to see by adding keywords in a PNConfig value in the module_vars table and by adding this to my referer.php file :

    Code

    $writeref = true;
             $refex = pnConfigGetVar('httprefexcluded');
             //if (!empty($refex) && $refex."" != "") {
             if (!empty($refex)) {
                 $refexclusion = explode(' ', $refex);
                 $count = count($refexclusion);
                 $eregicondition = "((";
                 for ($i = 0; $i < $count; $i++) {
                     if ($i != $count-1) {
                         $eregicondition .= $refexclusion[$i] . ")|(";
                     } else {
                         $eregicondition .= $refexclusion[$i] . "))";
                     }
                 }

                 if (eregi($eregicondition, $httpreferer)) {
                     $writeref = false;
                 }
            }

    if ($writeref == true) {
    // grab a reference to our table column..............
    .......................


    }


    The list of words is separated by spaces...
    My current list but I'm adding words as they appear...

    Quote


    bookmark yahoo google xxx search msn sex poker casino texas credit 5gigs westvaley infoseek pills


    I did a hack a long time ago to have a field in the administration to use to exclude words.......

    Think I should do that again. Will ask...


    Can someone give me a sample where to place the key words? I have a couple of site which gives me over 200 hits, but do not want them to show up on my referrer. If these sites are taking off, does it still count the number of pageviews? Or does it lock them out? Thank you in advance.

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula