plugin:referrers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:referrers [2009-10-10 18:18] – tag cleanup laynee | plugin:referrers [2020-09-19 10:22] (current) – [Automatic commit of referrers page versions] tjgrant@tatewake.com | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Referrers | + | ====== Referrers |
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
author | author | ||
email : tjgrant@tatewake.com | email : tjgrant@tatewake.com | ||
type : action | type : action | ||
- | lastupdate : 2009-05-26 | + | lastupdate : 2020-09-19 |
- | compatible : (current version) | + | compatible : 2020-07-29 " |
depends | depends | ||
conflicts | conflicts | ||
- | similar | + | similar |
tags : statistics, logging | tags : statistics, logging | ||
+ | |||
+ | downloadurl: | ||
+ | bugtracker : https:// | ||
+ | sourcerepo : https:// | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
---- | ---- | ||
- | [[http:// | + | ===== License ===== |
+ | |||
+ | * **Author:** [[tjgrant@tatewake.com|Terence J. Grant]] | ||
+ | * **License: | ||
+ | * **Donate:** [[https:// | ||
+ | |||
+ | ===== Download ===== | ||
+ | |||
+ | Before downloading or using this product, make sure you __**understand and accept**__ the terms of the [[# | ||
+ | |||
+ | After downloading, | ||
+ | |||
+ | * This is the **latest version**, compatible with **The Latest DokuWiki**: | ||
+ | * Latest Version: [[https:// | ||
+ | * GitHub URL: [[https:// | ||
+ | * Older downloads are available on request only. | ||
+ | |||
+ | **Note: https:// | ||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | Use the plugin manager to install, or... | ||
+ | |||
+ | - [[# | ||
+ | - unpack it into ''< | ||
+ | - login as admin and change the plugin in the configuration manager | ||
+ | |||
+ | **using git:** | ||
+ | < | ||
+ | % cd < | ||
+ | % git clone git:// | ||
+ | </ | ||
+ | |||
+ | **Note: https:// | ||
+ | |||
+ | ===== About ===== | ||
+ | |||
+ | This plugin logs referrers for your site, so you can see where your traffic comes from. | ||
+ | |||
+ | Set the options for this plugin via the **Configuration Settings** menu from the DokuWiki admin menu. (It will be near the bottom of the page.) | ||
+ | |||
+ | |{{http:// | ||
+ | |||
+ | ===== Install ===== | ||
+ | |||
+ | As a plugin all you need to do is unpack the file into the lib/plugins/ directory (you should end up with a lib/ | ||
+ | |||
+ | Remember to create a page in the **wiki** namespace called **referrers**. | ||
+ | |||
+ | ===== Upgrading ===== | ||
+ | |||
+ | To upgrade, remove the original lib/ | ||
+ | |||
+ | ===== What's New ===== | ||
+ | ==== Sep 19, 2020 ==== | ||
+ | * Updated release with nicer documentation and code cleanup | ||
+ | |||
+ | ==== May 26, 2009 ==== | ||
+ | * Plugin is now an **action plugin** that requires no additional PHP code modification. | ||
+ | * Referrer spam blocking has been removed in order to simplify the code. | ||
+ | |||
+ | ==== April 29, 2007 ==== | ||
+ | * More referrer spam blocking is in place. | ||
+ | * Better support for not logging spiders and search engines. | ||
+ | * Non-standard browser/ | ||
+ | |||
+ | ==== September 3, 2006 ==== | ||
+ | * Initial release | ||
+ | |||
+ | ====== Discussion ====== | ||
+ | |||
+ | * Start all subtopics using H2. (Heading 2.) | ||
+ | |||
+ | ===== Adding username to referrers output ===== | ||
+ | |||
+ | For anyone finding this plug-in as useful as I am, here's a mod to code.php that will add the user's DokuWiki username as the third column of the wiki: | ||
+ | |||
+ | < | ||
+ | function re_log_referrers_3($refignore) | ||
+ | { | ||
+ | ... | ||
+ | # | ||
+ | fwrite($fp, "^ hostname ^ ip address ^ username ^ referrer ^\n" | ||
+ | } | ||
+ | #write new ref | ||
+ | #$rh = getenv(" | ||
+ | $rh = $_SERVER[REMOTE_ADDR]; | ||
+ | $ru = $_SERVER[REMOTE_USER]; | ||
+ | if (strcmp($ru, | ||
+ | |||
+ | fwrite($fp, "| %%" | ||
+ | # | ||
+ | fwrite($fp, $rh . " | " . $ru); | ||
+ | </ | ||
+ | |||
+ | // Bobby Metz 07/25/2007 // | ||
+ | |||
+ | ===== Disabling Null entries ===== | ||
+ | |||
+ | Though rare, some servers don't provide an HTTP_REFERER value and the plug-in will record NULL in the referrer column. | ||
+ | |||
+ | < | ||
+ | # HTTP_REFERRER is blank when user directly requests the page | ||
+ | # or remote server does not provide it's address | ||
+ | if (strcmp($refhi, | ||
+ | if (re_contains($ref, | ||
+ | if (re_contains($ref,' | ||
+ | </ | ||
+ | |||
+ | // Bobby Metz 07/25/2007 // | ||
+ | |||
+ | ===== Referrer script is slow ===== | ||
+ | |||
+ | //Moved from monobook for dokuwiki.// | ||
+ | |||
+ | //Hi I have a quite serious issue with using the template, let me give a few information on my configuration first | ||
+ | * Fedora core 5 with Xampp | ||
+ | * I switched my website root from / | ||
+ | The problem is that everything is working just fine with the default template but that the wiki turns very slow when using monobook except if browsing on the server using the localhost address. To be clear, with monobook : | ||
+ | * using http:// | ||
+ | * using http:// | ||
+ | * using http:// | ||
+ | Anybody got this problem before ? | ||
+ | Thx in advance// | ||
+ | ---- | ||
+ | |||
+ | Did you for some reason include other.php in main.php? If so, this would be the reason for the slow down. (Its an experimental disabled module for the time being.) If not, the only other thing I can think of is this... | ||
+ | |||
+ | From my experience, slow downs in php are mostly due to file system related activity; I use a fair amount of " | ||
+ | |||
+ | Beyond this, in my opinion, there are probably a few things in the apache config that might improve your performance. (Though I don't know what it would be.) I'd suggest investingating PHP speed problems with Apache and your machine config; it'll probably boil down to that. | ||
+ | --- // | ||
+ | ---- | ||
+ | |||
+ | Hi, and thank you for your answer. This morning, I debugged main.php and I found out that it was this part of the code that was slowing down the page generation : | ||
+ | |||
+ | < | ||
+ | |||
+ | I just removed it this way and it's working fine now | ||
+ | |||
+ | < | ||
+ | </ | ||
+ | |||
+ | Is it safe to just comment it ? I'm not interested in the feature anyway. | ||
+ | Thanks again | ||
+ | ---- | ||
+ | |||
+ | I had originally thought that might be the case as well, but for whatever reason I forgot to mention that possibility. If anything, I would imagine the reverse lookups in referrers.php would be the slowdown, but again it could be due to the file system calls. You can comment that out and everything will work just fine. --- // | ||
+ | |||
+ | ---- | ||
+ | |||
+ | The root cause of this problem is that machine with local, fake NAT IP addresses (192.168.X.Y) don't have reverse IP maps. That means that anytime the server tries to find out the name of a system on that subnet to generate the referrer info, it's going to try to find it via DNS, which will take a few seconds to time-out before returning nothing useful. | ||
+ | |||
+ | This sort of problem is always coming up with using gethostbyaddr in any programming language. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Thanks for the information and tips, I'll look at making this better for the next release. | ||
+ | |||
+ | ===== Modifying for https sites ===== | ||
+ | |||
+ | I needed to block refs for my site which does https only. This takes a simple change to code.php. | ||
+ | |||
+ | < | ||
+ | $a = ' | ||
+ | $b = ' | ||
+ | $c = ' | ||
+ | ... | ||
+ | if (re_beginsWith($ref, | ||
+ | if (re_beginsWith($ref, | ||
+ | if (re_beginsWith($ref, | ||
+ | </ | ||
+ | |||
+ | However, it seemed that the author added this as an afterthought and since most of the traffic will be interanl linking, I thought a couple of slight modifications to the original code was better, i.e. no more $a, $b, etc. | ||
+ | |||
+ | < | ||
+ | #$a = ' | ||
+ | #$b = ' | ||
+ | if (re_contains($ref, | ||
+ | if (re_contains($ref,' | ||
+ | </ | ||
+ | |||
+ | The first line will match any ref url including your page. Using the re_beginsWith just makes extra comparisons, | ||
+ | |||
+ | // Bobby Metz 07/25/2007 // | ||
+ | |||
+ | Well, I'm going to go for $a, $b, $c rather than just do a contains. If someone does a " | ||
+ | |||
+ | ===== Manually Create Preferences File ===== | ||
+ | |||
+ | After installing this plug-in I was surprised to find that the local preferences for it are not loaded from the main DokuWiki local.php file. There is a nice configuration page, but for high security sites which don't allow web-based admin changes this is a problem. | ||
+ | |||
+ | File name: lib/ | ||
+ | Default settings to add: | ||
+ | < | ||
+ | <?php | ||
+ | $re_settings[' | ||
+ | $re_settings[' | ||
+ | $re_settings[' | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | // Bobby Metz 07/25/2007 // | ||
+ | |||
+ | Whoops, ok this' | ||
+ | |||
+ | ===== Speedier Exec - Getting rid of getenv lag ===== | ||
+ | |||
+ | With dicussions of file system slowness above, I too began digging for ways to use this very useful plug-in while minimize user impact. | ||
+ | |||
+ | < | ||
+ | function re_log_referrers_3($refignore) | ||
+ | { | ||
+ | ... | ||
+ | #$refhi = getenv(" | ||
+ | $refhi = $_SERVER[HTTP_REFERER]; | ||
+ | ... | ||
+ | #$rh = getenv(" | ||
+ | $rh = $_SERVER[REMOTE_ADDR]; | ||
+ | ... | ||
+ | #if (re_beginsWith(getenv(HTTP_USER_AGENT), | ||
+ | #if (re_beginsWith(getenv(HTTP_USER_AGENT), | ||
+ | if (re_beginsWith($_SERVER[HTTP_USER_AGENT], | ||
+ | if (re_beginsWith($_SERVER[HTTP_USER_AGENT], | ||
+ | ... | ||
+ | function re_log_referrers_2($refignore) | ||
+ | { | ||
+ | global $_SERVER; | ||
+ | #$x = gethostbyaddr(getenv(" | ||
+ | $x = gethostbyaddr($_SERVER[REMOTE_ADDR]); | ||
+ | ... | ||
+ | #if (!re_contains(strtolower(getenv(HTTP_USER_AGENT)), | ||
+ | #if (!re_contains(strtolower(getenv(HTTP_USER_AGENT)), | ||
+ | #if (!re_contains(strtolower(getenv(HTTP_USER_AGENT)), | ||
+ | #if (!re_contains(strtolower(getenv(HTTP_USER_AGENT)), | ||
+ | if (!re_contains(strtolower($_SERVER[HTTP_USER_AGENT]), | ||
+ | if (!re_contains(strtolower($_SERVER[HTTP_USER_AGENT]), | ||
+ | if (!re_contains(strtolower($_SERVER[HTTP_USER_AGENT]), | ||
+ | if (!re_contains(strtolower($_SERVER[HTTP_USER_AGENT]), | ||
+ | </ | ||
+ | |||
+ | // Bobby Metz 07/25/2007 // | ||
+ | |||
+ | Ok, this will be in for the next version, thanks. | ||
+ | |||
+ | =====Question===== | ||
+ | |||
+ | >The instructions say to insert a couple of php code lines in "your template... between < | ||
+ | a file, or even a file type. A typical template has like two dozen files in there. Are we talking about some css file? | ||
+ | |||
+ | Typically you'll want to do this for any PHP (or HTML) files containing the string "< | ||
+ | |||
+ | If you only do main.php though you'll miss some hits to certain types of pages, so I suggest searching for head tags through all the php files in a template to make sure you get them all. --- // | ||
+ | |||
+ | ===== All referrers are NULL? ===== | ||
+ | |||
+ | Hi -\\ I had been running a fairly old version of Dokuwiki/ | ||
+ | --- // | ||
+ | |||
+ | **// | ||
+ | $a = ' | ||
+ | $b = ' | ||
+ | </ | ||
+ | if (re_beginsWith($ref, | ||
+ | if (re_beginsWith($ref, | ||
+ | </ | ||
+ | So I manually created '' | ||
+ | Now, with the value of '' | ||
+ | --- // | ||
+ | |||
+ | ===== Automatic commit of referrers page versions ===== | ||
- | ===== Discussion ===== | + | Just a tip...\\ |
+ | I thought it was a shame to see the referral information disappear at midnight, when the referrers.txt is reset. The DokuWiki has a few php scripts useful for automation, //'' | ||
+ | # Archival of the wiki referrers page (otherwise all data is lost at day change) | ||
+ | 0 0 * * * / | ||
+ | </ | ||
+ | --- // | ||
- | Please use the [[http:// |
plugin/referrers.1255191484.txt.gz · Last modified: 2009-10-10 18:18 by laynee