PHPee.com PHP development forum
dlcount.php bandwidth warning

 
Post new topic   Reply to topic    phpee.com Forum Index -> PPhlogger Support
View previous topic :: View next topic  
Author Message
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Tue Jun 01, 2004 12:36 pm    Post subject: dlcount.php bandwidth warning Reply with quote
If you use dlcount.php to count downloads for files, the log files files will show TWO hits for the file, one when pphlogger checks to see if it exists and one for the download itself.

If you have a bandwidth allowance on your web hosting then this will DOUBLE the bandwidth usage for each file download!

If you wish to avoid this I suggest you delete the following lines from dlcount.php:
Code:
if (!($redir_url,"r")) {
   header("Location: $redir_url");   //file does not exist !!
   exit;
}

Of course, if you are using a counter hosted by someone else then there is nothing you can do about this.

Oliver.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 936
Location: London, UK

PostPosted: Tue Jun 01, 2004 2:01 pm    Post subject: Reply with quote
When PHP 5 is fully implemented, you will be able to use:

PHP:
if (!@file_exists($redir_url)) {
   
header("Location: $redir_url");   //file does not exist !!
   
exit;
}


file_exists should only check to see if the file actually exists and not actually open it.

That's my understanding of it any how Smile

David
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Tue Jun 01, 2004 3:15 pm    Post subject: Reply with quote
sdjl wrote:
file_exists should only check to see if the file actually exists and not actually open it.

That's my understanding of it any how Smile

Well...

I'm not sure how that works. However there is some great code at php.net which uses sockets to see if a file exists on a remote host. And it won't cause any bandwidth to be logged on the remote host because it uses a HEAD and not GET request.

http://uk.php.net/manual/en/function.file-exists.php#41580

The "file exists" code in dlcount.php could be replaced by this.

Oliver.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 936
Location: London, UK

PostPosted: Tue Jun 01, 2004 4:45 pm    Post subject: Reply with quote
Yep, that could be used.

The manual says that file_exists(); will be usable on "some" URL wrappers in PHP 5.

We shall see Smile

David
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Tue Jun 01, 2004 4:58 pm    Post subject: Reply with quote
sdjl wrote:
The manual says that file_exists(); will be usable on "some" URL wrappers in PHP 5.

Indeed. However it doesn't make it clear as to whether HEAD or GET is used to determine a remote file's existance.

Oliver.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 936
Location: London, UK

PostPosted: Tue Jun 01, 2004 7:59 pm    Post subject: Reply with quote
Very true. But at the moment, file_exists() doesn't actually open the file to check if it's there or not. So i'm going to assume it uses that same method unless told otherwise Smile

Mind you, its not likely that i'll be running PHP5 any time soon either Very Happy

David
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Tue Jun 01, 2004 8:37 pm    Post subject: Reply with quote
sdjl wrote:
Very true. But at the moment, file_exists() doesn't actually open the file to check if it's there or not. So i'm going to assume it uses that same method unless told otherwise Smile

Checking to see if a file exists on a local file system, and checking to see if a file exists on a remote file system over http are two very different things...

Oliver.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 936
Location: London, UK

PostPosted: Tue Jun 01, 2004 9:27 pm    Post subject: Reply with quote
Oliver341 wrote:

Checking to see if a file exists on a local file system, and checking to see if a file exists on a remote file system over http are two very different things...


Yes, i am aware of that Wink
Having used PHP for the past 6 years or so i've come to know how the web and its protocols/languages/methods work Smile

David
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Post new topic   Reply to topic    phpee.com Forum Index -> PPhlogger Support All times are GMT + 1 Hour
Page 1 of 1

 
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.0.11
Theme design based on Team 101 Designs, modified by Philip Iezzi