Jump to content

Archived

This topic is now archived and is closed to further replies.

Rancid

Top Referers List

Recommended Posts

I was wondering if anyone could tell me how to make a list of top Referers so when somone visits my site by clicking a link on somone elses it counts it and puts it on a list. i would be greatful for help.

Share this post


Link to post
Share on other sites
oke, first: this isn't such a big script but I'm not going to make it for you!
Let's start:

As first you need a database, in this database you put 'id, name, link, in, out'

Then you make the main page, here you select the database stuff and use the 'while' thing to make a list of all the referers. You sort them on links "hits in-out" (that's the credit they have, so they can be in min...).
Then in the while you pute their name with a link around it. This link must be [a href=\"http://www.yoursite.com/out.php?id=$id\" target=\"_blank\"]http://www.yoursite.com/out.php?id=$id[/a]. (The out page comes later)

Then ofcource the referers must be able to make hits in:
You give them a link: [a href=\"http://www.yoursite.com/in.php?id=theirid\" target=\"_blank\"]http://www.yoursite.com/in.php?id=theirid[/a]
Then you make the in.php page:
You can select their id from the url so you select his data from your database. Then you say update hits in + 1, oke :)
If you want that they can only click once per IP you must put this in the If-Else structure...

Then the out.php page.

You select de data from the database with the id in the link. Then you update the out hits + 1. And you riderect the visitor to the url of the referer!!



So that was all :p
If you have questions you may ask them :D (if you are just a noob in php, I could understand that ... )

Greets,
klaroen

Share this post


Link to post
Share on other sites
[!--quoteo(post=385089:date=Jun 17 2006, 03:49 PM:name=klaroen)--][div class=\'quotetop\']QUOTE(klaroen @ Jun 17 2006, 03:49 PM) [snapback]385089[/snapback][/div][div class=\'quotemain\'][!--quotec--]
oke, first: this isn't such a big script but I'm not going to make it for you!
Let's start:

As first you need a database, in this database you put 'id, name, link, in, out'

Then you make the main page, here you select the database stuff and use the 'while' thing to make a list of all the referers. You sort them on links "hits in-out" (that's the credit they have, so they can be in min...).
Then in the while you pute their name with a link around it. This link must be [a href=\"http://www.yoursite.com/out.php?id=$id\" target=\"_blank\"]http://www.yoursite.com/out.php?id=$id[/a]. (The out page comes later)

Then ofcource the referers must be able to make hits in:
You give them a link: [a href=\"http://www.yoursite.com/in.php?id=theirid\" target=\"_blank\"]http://www.yoursite.com/in.php?id=theirid[/a]
Then you make the in.php page:
You can select their id from the url so you select his data from your database. Then you say update hits in + 1, oke :)
If you want that they can only click once per IP you must put this in the If-Else structure...

Then the out.php page.

You select de data from the database with the id in the link. Then you update the out hits + 1. And you riderect the visitor to the url of the referer!!
So that was all :p
If you have questions you may ask them :D (if you are just a noob in php, I could understand that ... )

Greets,
klaroen
[/quote]

I'm not sure that's what he was asking for... and besides, using any kind of blah.php?id=$variable is very insecure as people can change it to whatever they want.

What you need is a script at the top of your main page (or every page if you want those hits counted) that checks the refered server variable (I can't remember what it is off the top of my head but I'll look if you want) and then makes sure the link wasn't from within your own site. Then you need to do a check on the database to check whether a row for that referrer already exists. If it does then increment the count value by one and update the database, if it doesn't then insert a new row. Then on your top referrers page you can simply pull the rows out of the database and sort them by count.

If you were using a more informative stats system you'd probably have a new row for each visit but for what you want, the above method should work fine (and is a lot less database-intensive).

Hope that helped, if you need actual code, I'd be happy to write some out for you.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.