News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[Tip and Trick] Finding out referrer of the users coming to your site

Started by SwapsRulez, February 01, 2009, 05:46:35 AM

Previous topic - Next topic

Arantor

Alex: yes, it probably could but it's unfortunately not as simple as that. At a minimum which portal are you using?

Tiribulus

Fancy running into Arantor in this thread too after he helped me out with what turned out to be this tweak in my thread.

He can explain this better than I can, it appears that the deprecated regular expression "ereg", which is used in this tweak can quickly tally up pages and pages of errors in your log.

See HERE for more info.

Arantor

That's not actually the problem here. Adaptation to put it in a block is not trivial.

Tiribulus

Quote from: Arantor on October 16, 2009, 07:50:38 PM
That's not actually the problem here. Adaptation to put it in a block is not trivial.

Were you addressing this to me?

Arantor

Indirectly, sorry. The last problem left in this thread was putting it into a portal block, which ereg probably won't be an issue with.

ereg being deprecated is only actually a problem on hosts that bother to update. Most users that run SMF are still running earlier 5.2 or 5.1, with a not inconsiderable percentage running 4.4 and 4.3, meaning that while this will become a problem, it probably won't be a huge problem for a while.

Tiribulus

Quote from: Arantor on October 17, 2009, 06:56:55 PM
Indirectly, sorry. The last problem left in this thread was putting it into a portal block, which ereg probably won't be an issue with.

ereg being deprecated is only actually a problem on hosts that bother to update. Most users that run SMF are still running earlier 5.2 or 5.1, with a not inconsiderable percentage running 4.4 and 4.3, meaning that while this will become a problem, it probably won't be a huge problem for a while.

Oh I see. I just was doing what Mr. Phil asked by putting the info from the other thread in here where the referrer thing got started. Sorry, I should have been clearer too. Nothing to do with the block question.

- danny

Quote from: Arantor on October 11, 2009, 06:00:35 AM
Alex: yes, it probably could but it's unfortunately not as simple as that. At a minimum which portal are you using?

TinyPortal v0.9.8

JulesW

I had to put in the code above the template_main_above for it to work, however, it also logs referrers which are coming from our own site. Also I replaced the ereg with preg_match. Could that be the cause? If not, any idea what could be?

(ereg gives me errors in the log: function ereg() is deprecated)

edit: Forgot to mention: I did escape the slashes with \/ but with or without, does not make a difference and every time its accompanied by the following error:
2: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Delimiter must not be alphanumeric or backslash
forumurl/Sources/Load.php(1999) : eval()'d code
64
And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17

Tiribulus

Quote from: JulesW on October 30, 2009, 03:15:32 PM
<<< I had to put in the code above the template_main_above for it to work, however, it also logs referrers which are coming from our own site. >>>

I also am this way. On both counts. It seems like it didn't used to log hits from my own site though at first. I think, if I remember correctly.

I said on the previous page:
QuoteFor some reason adding the code after template_main_above() broke my site in a hideous way, but adding it before works jist peachy.

Tiribulus

Quote from: MrPhil on October 16, 2009, 05:36:48 PM
Trivial.

if (empty($referrer) || preg_match("/slurp/", $agent) || preg_match("/bot/", $agent) || preg_match("/spider/", $agent) || preg_match("/crawler/", $agent) || preg_match("/http:\/\/gregnmary\.gotdns\.com:8080\//", $referrer)) {

I haven't tried it myself, but you may be able to simplify it to

if (empty($referrer) || preg_match("/slurp|bot|spider|crawler/", $agent) || preg_match("/http:\/\/gregnmary\.gotdns\.com:8080\//", $referrer)) {


JulesW

Thanks Tiribulus, that solved my problem! I have been reading that other thread you quote, but I probably missed the fact you were talking about the refferer tip!

Also in case ppl are wondering. The if (empty($referrer) || preg_match("/slurp|bot|spider|crawler/", $agent) || preg_match("/http:\/\/gregnmary\.gotdns\.com:8080\//", $referrer)) {
works!

And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17

Tiribulus

Quote from: JulesW on November 03, 2009, 01:35:17 PM
Thanks Tiribulus, that solved my problem! I have been reading that other thread you quote, but I probably missed the fact you were talking about the refferer tip!

Also in case ppl are wondering. The if (empty($referrer) || preg_match("/slurp|bot|spider|crawler/", $agent) || preg_match("/http:\/\/gregnmary\.gotdns\.com:8080\//", $referrer)) {
works!

No trouble.

Except people should take note to change the URL to their own. I should have said that too.

Tiribulus

Does anybody know why I'm getting this error
http://gregnmary.gotdns.com:8080/forum1/index.php?action=admin;area=logs;sa=errorlog;desc;start=0
2: preg_match(): Unknown modifier '/'
File: /srv/www/htdocs/forum1/Themes/brightforest_22/index.template.php
Line: 72
Repeatedly?

Here is the Code: Lines 72 and 73:
if (empty($referrer) || preg_match("/slurp/", $agent) || preg_match("/bot/", $agent) || preg_match("/spider/", $agent) || preg_match("/crawler/", $agent) || preg_match("/http:\/\/gregnmary\.gotdns\.com:8080\forum1//", $referrer)) {
}
Thank you very much

Arantor


Tiribulus

Thank you Arantor my old friend. Would it be that double // after forum1 at the end?

Also while were at it, did anybody ever figure out how to have this tweak not report internal hits from ip addresses on your own lan?
Thanks again

Arantor

Yup; the last / marked the end of the regular expression, but the extra one before it wasn't escaped properly. Either escape the second to last one (as \//) or remove it, it wouldn't hurt to leave it as a single one there.

pearpandas

Thanks, this will be very useful in order to really understand your analytics and how to improve them!

Advertisement: