View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 16 Jul 2002 Posts: 9
|
Posted: Mon Jul 22, 2002 9:07 pm Post subject: Referers, or "pages that link to this page" |
|
|
Hi All.
I created a library to log and display referrers in general, and I posted instructions for an easy integration of this with b2. This means you can place a box on your page that will let you track pages that link to a given post. You can also display pages that link to the site as a whole. Choose to show most recent or most frequent referers.
http://ncyoung.com/index.php?p=57&c=1
Thanks!
------------>Nathan |
|
Back to top |
|
 |
[email protected]
Joined: 16 Jul 2002 Posts: 9
|
Posted: Fri Nov 08, 2002 6:22 pm Post subject: updated refererLib |
|
|
Hi All!
I updated my library so that if you need to you can turn on back-checking that will make sure the listed referer REALLY does link to your page. This is to block referer spam, which may become a problem.
You can see my weblog post about it and download the new version from:
http://ncyoung.com/permaLink/116
------------>Nathan |
|
Back to top |
|
 |
Joseph
Joined: 28 Oct 2002 Posts: 27 Location: Waterloo, Canada
|
Posted: Sun Nov 10, 2002 5:28 pm Post subject: Many Thanks |
|
|
Thanks a lot for a great hack. Running it on my site now. |
|
Back to top |
|
 |
donncha
Joined: 18 Feb 2003 Posts: 43 Location: Cork, Ireland
|
Posted: Sun May 11, 2003 4:59 pm Post subject: |
|
|
Thanks Nathan for posting that. I have it integrated into b2++ now, and it's feeding the db results. It's not working perfectly yet, but it's close!
You can see a demo of it running on http://blogs.linux.ie/xeer/ (look for the grey box marked "referers", there's also an external referers box with the text "Documents refering to this site.." but that's not the one your code is generating.
I posted some commentry on the plugin here: http://blogs.linux.ie/xeer/archives/p/89490336/more/1/c/1
This post will more than likely show up as a referer on that weblog entry so look at that as an example  |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 17 Location: Delft - The Netherlands
|
|
Back to top |
|
 |
eadz
Joined: 06 Apr 2003 Posts: 28 Location: Auckland, New Zealand
|
Posted: Sun Jun 01, 2003 7:32 am Post subject: |
|
|
Nice script.
It is now a bBlog pluggin demo _________________
|
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 17 Location: Delft - The Netherlands
|
Posted: Sun Jun 01, 2003 11:35 am Post subject: bblog plugin |
|
|
I don't want a completely new bloggingtool, just want the code to fix this problem. I read at your site that referer is a plugin for your bloggingtool. Where can I download this plugin? (can't find any link for downloading). And you're sure it fixes my problem? |
|
Back to top |
|
 |
eadz
Joined: 06 Apr 2003 Posts: 28 Location: Auckland, New Zealand
|
Posted: Thu Jun 05, 2003 4:03 pm Post subject: |
|
|
Ok, I have found a little bug.
Some referer spammers put this as a referer :
XXXX:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
And fully break the page. Maybe we can have a length limit on the referer? _________________
|
|
Back to top |
|
 |
Ciury
Joined: 02 Sep 2003 Posts: 1 Location: Barcelona
|
Posted: Tue Sep 02, 2003 7:16 am Post subject: |
|
|
eadz wrote: | Ok, I have found a little bug.
Some referer spammers put this as a referer :
XXXX:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
And fully break the page. Maybe we can have a length limit on the referer? |
You can add this code on refererLib.php, lines 184 and 143 (just before "$temp =...")
Code: | $length = 18; // Max url lenght
$etc = '...'; // Code 4 replacing last 3 chars
if (strlen($domain) > $length) {
$length -= strlen($etc);
$domain = substr($domain, 0, $length).$etc;
} |
|
|
Back to top |
|
 |
sabotage
Joined: 15 Jul 2003 Posts: 36
|
Posted: Tue Sep 02, 2003 12:17 pm Post subject: |
|
|
looks great....
but er.... *stoopid question alert*
(why) isn't it possible to retrieve the database-connection variables from b2config.php? |
|
Back to top |
|
 |
Viper007Bond
Joined: 15 Aug 2003 Posts: 266 Location: Portland, Oregon, USA
|
Posted: Sat Oct 04, 2003 6:41 am Post subject: |
|
|
sabotage wrote: | looks great....
but er.... *stoopid question alert*
(why) isn't it possible to retrieve the database-connection variables from b2config.php? |
I was wondering the same thing. I think I'll try including in the config file and calling the variables and see if I can get it to work. If so, I'll post the results.
*UPDATE*
Yeah, it works. Replace this code in "refererLib.php":
Code: | mysql_connect("dbHost", "dbUser", "dbPass");
mysql_select_db("dbName"); |
with this:
Code: | include ("b2config.php");
mysql_connect($dbhost,$dbusername,$dbpassword);
mysql_select_db($dbname); |
_________________ http://www.viper007bond.com
If you haven't already installed b2, I advise you look into WordPress or b2evo instead as b2 is dead. |
|
Back to top |
|
 |
Viper007Bond
Joined: 15 Aug 2003 Posts: 266 Location: Portland, Oregon, USA
|
|
Back to top |
|
 |
Viper007Bond
Joined: 15 Aug 2003 Posts: 266 Location: Portland, Oregon, USA
|
Posted: Sat Oct 04, 2003 1:05 pm Post subject: |
|
|
Yes, I know, I know, I've posted three times in a row. I'd edit my last post, but this is unrelated to my last post, so...
On my stats page, I made a few adjustments to the referrer hack. I'll explain what is different and then how to get it on your blog.
For "Last 10 Referring Pages", it lists the URL (up to 75 characters long) and does not check to see if that domain has already been used.
Why? Say people came to my site from two different threads here. It would list "tidakada.com" and the link would go to the last thread that referred the person to my site.
Instead, I edited it to show the last unique URLs (not domains) that linked to my site. If a URL shows up more than once in the list, it only shows the most recent one (that way it'll get some variety instead of a bunch of the same thing). It then displays the full URL instead of the domain, but cuts off the display of the URL at a set number (thanks to Ciury ).
How to do that -
Replace (lines 133 - 144)
Code: | $domain = $result_row['baseDomain'];
if (!$domain){
continue;
}
if ($last[$domain]){
continue;
}
$last[$domain] = 1;
$temp = "<a href=\"$fullUrl\" target=\"_blank\">$domain</a>"; |
with
Code: | if (!$fullUrl){
continue;
}
if ($last[$fullUrl]){
continue;
}
$last[$fullUrl] = 1;
$length = 75; // Max url lenght
$etc = '...'; // Code 4 replacing last 3 chars
if (strlen($fullUrl) > $length) {
$length -= strlen($etc);
$dispUrl = substr($fullUrl, 0, $length).$etc;
}
else {
$dispUrl = $fullUrl;
}
$temp = "<a href=\"$fullUrl\" target=\"_blank\">$dispUrl</a>"; |
--------------------------------------------------
Additionally, I made the "Top 10 Referring Sites" go to the domain instead of the last page at that domain that referred someone to my site. A simple variable replacement of (line 185):
Code: | $temp = "<a href=\"$latestUrl\" target=\"_blank\">$domain</a> ($count)"; |
with:
Code: | $temp = "<a href=http://$domain target=\"_blank\">$domain</a> ($count)"; |
I hope all of that is a use to someone.
NOTE: I am JUST learning PHP and picking it up as I go so I wouldn't be surprised if there was a small error or easier way of doing any of that.  _________________ http://www.viper007bond.com
If you haven't already installed b2, I advise you look into WordPress or b2evo instead as b2 is dead. |
|
Back to top |
|
 |
Viper007Bond
Joined: 15 Aug 2003 Posts: 266 Location: Portland, Oregon, USA
|
Posted: Wed Oct 08, 2003 12:18 am Post subject: |
|
|
Meh, I've added so many hacks to mine that I thought I'd just release the whole code for it. Nathan gave me permission to, so once I get done with it, I'll post the code.  _________________ http://www.viper007bond.com
If you haven't already installed b2, I advise you look into WordPress or b2evo instead as b2 is dead. |
|
Back to top |
|
 |
sabotage
Joined: 15 Jul 2003 Posts: 36
|
Posted: Wed Oct 08, 2003 1:45 pm Post subject: |
|
|
cool, i'm loking forward to it Viper  |
|
Back to top |
|
 |
|