Strange url track suppression logic

Found a bug? Tell us!!
Post Reply
Rasmus
Regular
Posts: 7
Joined: Sun Nov 09, 2003 6:35 pm

Strange url track suppression logic

Post by Rasmus »

My referrer tracking isn't working (current CVS) and I tracked it down to some iffy logic in the suppression-related code. The query that checks the suppression table looks like this:

Code: Select all

        $suppressq = "SELECT count(1)
                      FROM $serendipity[dbPrefix]suppress
                      WHERE ip = '$_SERVER[REMOTE_ADDR]'
                      AND scheme = '$url_parts[scheme]'
                      AND port = '$url_parts[port]'
                      AND host = '$url_parts[host]'
                      AND path = '$url_parts[path]'
                      AND query = '$url_parts[query]'
                      AND last > now() - $interval";
Then it gets executed and checked:

Code: Select all

        $count = serendipity_db_query($suppressq, true);
        if ($count[0] == 0) {
            serendipity_db_query($suppressu);
            return;
        }
Now, to me this reads:
If a referring url has been seen in the past $interval seconds then log it. That confuses the heck out of me. Isn't that completely reversed? I don't really see the point of the supression table to begin with, but if you are going to have it, shouldn't you be discarding the referrers that are seen in the past $interval seconds and not the other way around?

I think someone may have overloaded this logic checking for 0 to insert the url the first time it is seen, but once the url is in the table this logic is backwards. Or perhaps I am misunderstanding the point of this code. I have commented out the whole mess on my server now and it is working just fine.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

Ehhh, I think you missed the point
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
Rasmus
Regular
Posts: 7
Joined: Sun Nov 09, 2003 6:35 pm

Post by Rasmus »

tomsommer wrote:Ehhh, I think you missed the point
Well, what is the point of this code then? What is it guarding against? Whatever the point is, it didn't work at all. I never got any referrers listed before I got rid of that code.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

hmm, did you try and hack your way out of this? to fix it? (without commenting it out)

After re-reading your post this seems strange to me to, but nothing... AFAIK... has been changed in this code since 0.2
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
Rasmus
Regular
Posts: 7
Joined: Sun Nov 09, 2003 6:35 pm

Post by Rasmus »

I'd have to understand what exactly the code was supposed to do before I could go and write a version that works.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

I didn't write the code but I guess it to prevent flood of referrers, if the same person clicks a link like 4 times in a row it's only counted as 1 click
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
Post Reply