View previous topic :: View next topic |
Author |
Message |
Saus
Joined: 29 Mar 2002 Posts: 25
|
Posted: Sat Apr 19, 2003 2:58 pm Post subject: Last 20 referrers? |
|
|
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 |
|
 |
Saus
Joined: 29 Mar 2002 Posts: 25
|
Posted: Sun Apr 20, 2003 1:12 pm Post subject: |
|
|
Anyone at all? |
|
Back to top |
|
 |
cjc
Joined: 24 Dec 2002 Posts: 146 Location: New York
|
Posted: Sun Apr 20, 2003 1:27 pm Post subject: |
|
|
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 |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Apr 20, 2003 3:04 pm Post subject: |
|
|
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 |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Sun May 11, 2003 6:20 am Post subject: |
|
|
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 |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun May 11, 2003 10:24 pm Post subject: |
|
|
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 |
|
 |
donncha
Joined: 18 Feb 2003 Posts: 43 Location: Cork, Ireland
|
|
Back to top |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Tue May 13, 2003 10:32 am Post subject: |
|
|
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 |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Tue May 13, 2003 11:19 am Post subject: |
|
|
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 |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Tue May 13, 2003 12:00 pm Post subject: |
|
|
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 |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Tue May 13, 2003 4:59 pm Post subject: |
|
|
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 |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Tue May 13, 2003 9:11 pm Post subject: |
|
|
Got it to go..
that bit was causing the problem. |
|
Back to top |
|
 |
amities
Joined: 25 Jul 2002 Posts: 5
|
Posted: Thu Jun 26, 2003 11:29 pm Post subject: |
|
|
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 |
|
 |
flowerglen
Joined: 27 May 2003 Posts: 24
|
Posted: Thu Jul 10, 2003 8:09 pm Post subject: |
|
|
where do i put the db connection variables? |
|
Back to top |
|
 |
jhesch
Joined: 16 Jun 2003 Posts: 6
|
Posted: Fri Jul 25, 2003 4:37 am Post subject: |
|
|
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 |
|
 |
|