PHP Traffic accounting

340 views Asked by At

we're calculating the traffic usage of customers with access logs of NGINX / apache. Now a big question came to my mind.

What if I do this:

<?php
    file_get_contents( "http://www.speedtest.qsc.de/1GB.qsc" );
?>

The call itself would be a simple GET with just a few bytes / kilobytes, but assuming we have enough memory_limit and max_execution_time, the script would download a 1GB file. This wouldn't be logged at all, right?

Is there any way to track something like I mentioned above?

Thanks in advance

1

There are 1 answers

3
exussum On

for apache the default log is

LogFormat "%h %l %u %t \"%r\" %>s %b"

the %b represents the Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '-' rather than a 0 when no bytes are sent

You could probably use that

http://httpd.apache.org/docs/2.2/mod/mod_log_config.html

for nginx its also default

log_format compression '$remote_addr - $remote_user [$time_local] '
                       '"$request" $status $bytes_sent '
                       '"$http_referer" "$http_user_agent" "$gzip_ratio"';

http://nginx.org/en/docs/http/ngx_http_log_module.html