![]() |
|
#1
|
|||
|
|||
Problem with a small piece of referrer code.referrers.php
PHP Code:
Ignore the $mydomain at the top, I was going to add some kind of filtering for referrers from the same domain, but couldn't even get this to work yet. If I echo it, instead of writing it to a file it seems to work. I made sure that referrers.php was CHMOD'd to 666, but it still didn't write it to a file. I'm not sure what I am doing wrong, as I said I tried echoing it and it worked fine. But writing to a file wont, even if I use a literal string for the first argument or fopen() instead of a variable. Or if I use single quotes for the second parameter 'a' or double quotes "a". I even tried creating the text file and placing it in the directory incase the problem was creating the file. Any help would be great. Last edited by LuciWiz : 19-May-2006 at 01:57.
Reason: Please insert your PHP code between [php] & [/php] tags
|
|
#2
|
||||
|
||||
Re: Problem with a small piece of referrer code.This is definitely a permission issue. Is this script on a Linux/Unix machine?
Are you sure the script (referrers.php) has the required permission to create / write to the LOG file? When I write scripts that create or write to a text file, I usually create a directory just to store these log / data / text files and assign the web server (e.g. nobody or apache) read, write and execute permissions for that folder. |
|
#3
|
|||
|
|||
Re: Problem with a small piece of referrer code.It is in a separate folder (it was before) but I chmod'd the folder and all subfolders/files to 777. It is now working as it should be. Thank you very much
|
|
#4
|
||||
|
||||
Re: Problem with a small piece of referrer code.I am glad...
I am curious now. Are you only interested in the referrers for your web pages or is this script part of a larger data gathering script? The reason I ask: if you're only interested in the referrer information, you should really consider parsing your web server's log file for the information instead. |
|
#5
|
|||
|
|||
Re: Problem with a small piece of referrer code.Just referrer data, IP isn't really important but I put it there incase at a future date I decide I want it. I was just thinking along the lines of referring site (url to be specific) current url it directs to, and the number of hits. So if the same referring url directs to the same page 2 times it would have a little 2 in brackets maybe next to it. But then what if it is the same referring page but a different page it directs to? Would I class that as a separate hit or the same because it is from the same referrer. Also I would need to add some kind of filtering to stop referrals from my own domain.
So I want to keep it quite basic but do it in a certain way so it is quite precise. I couldn't see the access log files on the FTP, but in the control panel there was a log manager. I took a little look and could see access_log which was 98mb, I downloaded it and it contained: IP -- [Date/Time (what seems to be timezone info like -0700)] The type of request like POST or GET HTTP etc and user agent. This seems to be for other websites not just mine though, perhaps the log is shared between the other sites that are hosted on this server as it is shared hosting. There was also a access_log.processed which was only about 2KB xferlog_regular.processed and non processed, which just contains details of what I have been transfering through FTP. And an error_log. I couldn't see any details of referrers in any of the files that I looked in |
|
#6
|
||||
|
||||
Re: Problem with a small piece of referrer code.If you can get the correct information from your web host, I can help you write a simple script that you can use to extract the referrer information from the log file.
The correct information required is:
You could have a cronjob run the script every few minutes and update a database or something. This should be a fun little project for the weekend! |
|
#7
|
|||
|
|||
Re: Problem with a small piece of referrer code.I don't know the location of the file, but I can always download the file to my PC from the control panel. I was thinking I could filter the file for my domain so I don't get any of the data from the other sites sharing the server. That doesn't seem possible now though because the only places my domain appears are when it is the referrer.
IP - - [Date/Time -/+TimeZone] "GET/POST /webpage.extension HTTP/1.1" 200 (OK reply?) (not sure what the next number is) "http://website.com/page.php" <<--Referring page. "user agent browser info" Code:
Even though I'm not very good at data parsing in any language, I don't think that would be the biggest problem right now. It would probably be the access_log because it is mixed. Maybe I should continue work on the referrer logging script, as I could do with learning PHP anyway. What are your thoughts? -EDIT- If I don't reply right away, I'm not ignoring you, it is 9:48 am and I haven't slept yet, so I may be off to bed, and view this when I wake up, just so you know |
|
#8
|
||||
|
||||
Re: Problem with a small piece of referrer code.One log file for all the domains? How odd!
Did you ask your web host if one exists just for your domain? I am almost certain this is available somewhere. But in case it's not, you may consider moving when you can afford to move because that's just plain weird. Back to the script you are writing: Sure, you can and should proceed with your work on this script if you only want to learn. I will not discourage you. And if we wrote the script to parse your log file, you will also learn quite a bit about PHP (and the added bonus of having them work in the command line, i.e. not via a browser). |
|
#9
|
|||
|
|||
Re: Problem with a small piece of referrer code.That would be great to learn how to run PHP files from the command line, I was thinking of setting up a HTTPD with PHP on my PC just to learn that before. I wouldn't be able to do it with my host though I don't think as I don't have shell/ssh access. Unless it can be executed via another PHP file through the browser hehe, but that kind of takes the point away I guess.
I have wanted to learn PHP for a while, it seems such a powerful language, and so versatile. |
|
#10
|
||||
|
||||
Re: Problem with a small piece of referrer code.It's not necessary for you to have (remote) access to your server. You can set it up as a cronjob and it will be run every few minutes.
You can set up a cronjob, can't you? |
Recent GIDBlog
Last Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Here it is again! 35% - 40% off For Life! | my-e-space | Web Hosting Advertisements & Offers | 0 | 20-Apr-2006 14:48 |
| Problem with porting of Linux code to Windows, FORTRAN/C. | stormlab | C Programming Language | 2 | 15-Oct-2005 03:53 |
| Problem with porting of Linux code to Windows, FORTRAN/C. | stormlab | Computer Software Forum - Linux | 0 | 14-Oct-2005 12:25 |
| Problem with int mixed with char,... | leitz | CPP / C++ Forum | 17 | 07-Dec-2004 20:56 |
| This is a small snippet from a much larger piece. | Tang_Quester | Open Discussion Forum | 1 | 19-Mar-2004 01:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The