Page 1 of 1

Strange url track suppression logic

Posted: Sun Nov 09, 2003 11:23 pm
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.

Posted: Mon Nov 10, 2003 10:20 pm
by tomsommer
Ehhh, I think you missed the point

Posted: Mon Nov 10, 2003 10:43 pm
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.

Posted: Tue Nov 18, 2003 12:34 am
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

Posted: Tue Nov 18, 2003 12:42 am
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.

Posted: Tue Nov 18, 2003 6:37 pm
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