boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Referers, or "pages that link to this page"

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
[email protected]



Joined: 16 Jul 2002
Posts: 9

PostPosted: Mon Jul 22, 2002 9:07 pm    Post subject: Referers, or "pages that link to this page" Reply with quote

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
View user's profile Send private message Visit poster's website
[email protected]



Joined: 16 Jul 2002
Posts: 9

PostPosted: Fri Nov 08, 2002 6:22 pm    Post subject: updated refererLib Reply with quote

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
View user's profile Send private message Visit poster's website
Joseph



Joined: 28 Oct 2002
Posts: 27
Location: Waterloo, Canada

PostPosted: Sun Nov 10, 2002 5:28 pm    Post subject: Many Thanks Reply with quote

Thanks a lot for a great hack. Running it on my site now.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
donncha



Joined: 18 Feb 2003
Posts: 43
Location: Cork, Ireland

PostPosted: Sun May 11, 2003 4:59 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
evelyne



Joined: 12 Dec 2002
Posts: 17
Location: Delft - The Netherlands

PostPosted: Sat May 31, 2003 8:36 pm    Post subject: request Reply with quote

I tried to use this at my site. I would like to count people linking to http://www.veel-in-een.nl/index.php as well as people linking to http://www.veel-in-een.nl How can I make this work?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
eadz



Joined: 06 Apr 2003
Posts: 28
Location: Auckland, New Zealand

PostPosted: Sun Jun 01, 2003 7:32 am    Post subject: Reply with quote

Nice script.

It is now a bBlog pluggin Smile demo
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
evelyne



Joined: 12 Dec 2002
Posts: 17
Location: Delft - The Netherlands

PostPosted: Sun Jun 01, 2003 11:35 am    Post subject: bblog plugin Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
eadz



Joined: 06 Apr 2003
Posts: 28
Location: Auckland, New Zealand

PostPosted: Thu Jun 05, 2003 4:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Ciury



Joined: 02 Sep 2003
Posts: 1
Location: Barcelona

PostPosted: Tue Sep 02, 2003 7:16 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
sabotage



Joined: 15 Jul 2003
Posts: 36

PostPosted: Tue Sep 02, 2003 12:17 pm    Post subject: Reply with quote

looks great....

but er.... *stoopid question alert*

(why) isn't it possible to retrieve the database-connection variables from b2config.php?
Back to top
View user's profile Send private message
Viper007Bond



Joined: 15 Aug 2003
Posts: 266
Location: Portland, Oregon, USA

PostPosted: Sat Oct 04, 2003 6:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Viper007Bond



Joined: 15 Aug 2003
Posts: 266
Location: Portland, Oregon, USA

PostPosted: Sat Oct 04, 2003 7:19 am    Post subject: Reply with quote

evelyne wrote:
I tried to use this at my site. I would like to count people linking to http://www.veel-in-een.nl/index.php as well as people linking to http://www.veel-in-een.nl How can I make this work?


That is the same thing. If someone links to http://www.veel-in-een.nl , that is the same thing as if they were to link to http://www.veel-in-een.nl/index.php .
_________________
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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Viper007Bond



Joined: 15 Aug 2003
Posts: 266
Location: Portland, Oregon, USA

PostPosted: Sat Oct 04, 2003 1:05 pm    Post subject: Reply with quote

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. Smile

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 Smile).

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. Smile

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. Smile
_________________
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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Viper007Bond



Joined: 15 Aug 2003
Posts: 266
Location: Portland, Oregon, USA

PostPosted: Wed Oct 08, 2003 12:18 am    Post subject: Reply with quote

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. Smile
_________________
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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
sabotage



Joined: 15 Jul 2003
Posts: 36

PostPosted: Wed Oct 08, 2003 1:45 pm    Post subject: Reply with quote

cool, i'm loking forward to it Viper Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group