Reply
Loggin Referers
Old 03-26-2006, 06:13 AM Loggin Referers
Skilled Talker

Posts: 68
Hi, i'm makeing a script that logs reffered links and desplys them on the website.
Conditions,
* It only desplys the last 5 reffers.
* it dosent desply referers from my domain.
* It dosent desply domains already on the list

Now that last part is wer it's going wrong, i dont want it to desply domains alredy in the current 5 being desplyed but i do want it to desply them if ther not already being desplyed.
Heres my code.
PHP Code:
<?
$filename 
"referers.txt"
$lines = array(); 
$filecheck fopen($filename"r"); 
$getcontents=file_get_contents($filename);
$referer $_SERVER['HTTP_REFERER'];
$short_referer preg_replace('/^http:\/\/(www\.)?([^\/]+).*$/i''\2'$_SERVER['HTTP_REFERER']);
$HTTP "http://";
$write "<a href=$referer><li>$short_referer</a>";
while(!
feof($filecheck)) { 



    
$lines[] = fgets($filecheck4096); 
 

  
fclose ($filecheck); 



if (
preg_match("/http/i""$referer")) {


echo 
"";




if ( 
$short_referer == "my domain")
{
echo 
"";
} elseif (
preg_match("/$short_referer/""$getcontents")) {
echo 
"";

} else {


$addref "referers.txt";
$file fopen $addref"a+") ;
fwrite $file"
$write" 
) ;
fclose $file ) ;




}

 



} else { echo 
""; }






$lines array_reverse($lines);

echo 
"
<ul>
$lines[0]
$lines[1]
$lines[2]
$lines[3]
$lines[4]
</ul>




"
;

?>

Now to desply th last 5 written is easy i jsut use
PHP Code:
$lines array_reverse($lines);

echo 
"
<ul>
$lines[0]
$lines[1]
$lines[2]
$lines[3]
$lines[4]
</ul> 
However when it check to see if the domain is already on the list.
PHP Code:
elseif (preg_match("/$short_referer/""$getcontents")) 
it looks at the hole file, how do i get it to look at the last 5 referers??
__________________
Need PHP Help? Got Skype?
Call me!
mrpaul is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-26-2006, 05:34 PM Re: Loggin Referers
Skilled Talker

Posts: 68
is it possible to do something like,
PHP Code:
elseif (preg_match("/$short_referer/""$line[0], $line[1], $line[2], $line[3], $line[4],  ")) 
I'd test it but i dont have access to a php server.
__________________
Need PHP Help? Got Skype?
Call me!
mrpaul is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Loggin Referers
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12621 seconds with 12 queries