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 

Last 20 referrers?

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
Saus



Joined: 29 Mar 2002
Posts: 25

PostPosted: Sat Apr 19, 2003 2:58 pm    Post subject: Last 20 referrers? Reply with quote

Just saw this on Journalized at http://zed1.com/b2/,

it's a 'last 20 referrers' column. How can I include one of these on my site?
Back to top
View user's profile Send private message
Saus



Joined: 29 Mar 2002
Posts: 25

PostPosted: Sun Apr 20, 2003 1:12 pm    Post subject: Reply with quote

Anyone at all?
Back to top
View user's profile Send private message
cjc



Joined: 24 Dec 2002
Posts: 146
Location: New York

PostPosted: Sun Apr 20, 2003 1:27 pm    Post subject: Reply with quote

I do something where I run a perl script that parses out the Apache log file for search engine referrals, but this presumes access to log files and the ability to run perl scripts by cron.
Back to top
View user's profile Send private message Visit poster's website
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Sun Apr 20, 2003 3:04 pm    Post subject: Reply with quote

Hi Saus,
Just above the list of referers, are the words Script from N.C.Young. That is a link to NC Young's site where I got the script.

Click on that link and you can download the script from that page.

Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Tanman



Joined: 28 Nov 2002
Posts: 36

PostPosted: Sun May 11, 2003 6:20 am    Post subject: Reply with quote

How diud you get it to call the script? like my one includes it, but it doesn't display anything. Even after I tried to link froim another site.

I suspect that it has something todo with the <b>logreferer()</b> function, because I donno where to put that one...Its not very clear.
Back to top
View user's profile Send private message
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Sun May 11, 2003 10:24 pm    Post subject: Reply with quote

Hi Tanman,
I just followed the instructions with the script.

I'm presuming you accessed the script firstly to create the database table:
http://yourdomain/refererLib.php?createTable=1

Then in your index page add
Code:

<?php include_once('refererLib.php'); ?>
<?php logReferer(); ?>


This will log all referers to your page.

Then where you want the list referer list to appear
Code:

<?php
      $list = refererList(20);
      foreach ($list as $link){
        print "$link<br />\n";
      }
?>


Also don't forget to set your own url in the file so you don't count your own site.

Nathan also gives an example of logging individual stories.

Hope this helps,
Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
donncha



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

PostPosted: Sun May 11, 2003 10:29 pm    Post subject: Reply with quote

I'm working on an integrated b2++ plugin for this -> http://tidakada.com/board/viewtopic.php?t=879
It uses Nathan's code too Smile See it working at http://blogs.linux.ie/xeer/
Back to top
View user's profile Send private message Visit poster's website
Tanman



Joined: 28 Nov 2002
Posts: 36

PostPosted: Tue May 13, 2003 10:32 am    Post subject: Reply with quote

Mike,

When I add in those entries, I get a parse error. It seems to occur on the $list variable part.

Also, how do you change it so that it doesn't refer to your own url?
I tried looking in the readme, but it is a bit obscure... [/b]
Back to top
View user's profile Send private message
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Tue May 13, 2003 11:19 am    Post subject: Reply with quote

Tanman,

what error do you get? can you post it here please?

To exclude your own urls. you need to add them to the $ignore array in refererLib.php
Code:

    $ignore = Array(
                    'zed1.com',
                   );


Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Tanman



Joined: 28 Nov 2002
Posts: 36

PostPosted: Tue May 13, 2003 12:00 pm    Post subject: Reply with quote

Parse error: parse error in /usr/www/weiyenweb/index.php on line 307
and this is the code i put in:

Code:

<?php include("refererLib.php"); ?>
<?php logReferer(); ?>
<?php
      $list = refererList(20);
      foreach ($list as $link){
        print "$link<br />\n";
      }?>

Back to top
View user's profile Send private message
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Tue May 13, 2003 4:59 pm    Post subject: Reply with quote

I'm going to presume that line 307 is one of those lines.

However, I cannot see anything wrong with the code you have pasted in.
Unless you are running under php3 which didn't have foreach, BUT not much else would work if that was the case.

So, I can only fdeduce that line 307 is not one of these and that you have an error in a different place.

Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Tanman



Joined: 28 Nov 2002
Posts: 36

PostPosted: Tue May 13, 2003 9:11 pm    Post subject: Reply with quote

Got it to go..

Code:

br />\n";

that bit was causing the problem.
Back to top
View user's profile Send private message
amities



Joined: 25 Jul 2002
Posts: 5

PostPosted: Thu Jun 26, 2003 11:29 pm    Post subject: Reply with quote

my page gives me the following error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/amities/public_html/blog/refererLib.php on line 130

on line 130 of referlib.php, i have the following line of code

while ($result_row = mysql_fetch_array("$sqr_recentReferer")) {

any ideas what could be the problem?
Back to top
View user's profile Send private message AIM Address
flowerglen



Joined: 27 May 2003
Posts: 24

PostPosted: Thu Jul 10, 2003 8:09 pm    Post subject: Reply with quote

where do i put the db connection variables?
Back to top
View user's profile Send private message
jhesch



Joined: 16 Jun 2003
Posts: 6

PostPosted: Fri Jul 25, 2003 4:37 am    Post subject: Reply with quote

Any chance someone could hack this script to truncate the string if it's a particular number of characters or above?

Some referrer names are too long and mess up my page. I'd like the refferer to look like this if it's more than say 12 characters

thisisarefferr...

Here's the code in the library that I think needs hacked

Code:
while($result_row = mysql_fetch_array($sqr_recentReferer)){

      $count = $result_row['totalHits'];
      $domain = $result_row['baseDomain'];

      $uSet = mysql_query("select * from referer_visitLog where baseDomain = '$domain' order by visitID desc");
      $uRow = mysql_fetch_array($uSet);
      $latestUrl = $uRow["referingURL"];

      $temp = "<a href=\"$latestUrl\" target=\"_blank\">$domain</a> ($count)";

      array_push($ret,$temp);

      if ($i++ > $howMany){
         break;
      }

   }
   return $ret;
}


Thanks,

John
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