i need this script working to monitor bandwidth of a folder/subdomain this script basically grabs the stats from cpanel. should be easy for knowledgeable coder. paying $5 for this quick job! pm me if you can do it <? function cpanel_logs( $username, $password, $domain, $searchpath ) { $bw = 0 ; $logs = file( sprintf( 'http://%s:%s@%s:2082/getlogarchive/%s', $username, $password, $domain, $domain )); if( $logs ) { foreach( $logs as $line ) { preg_match( '~"([A-Z]+) (.*?[^ ]) HTTP/1\.[1|0]" ([0-9]+) ([0-9]+) "(.*?[^"])" "(.*?[^"])"~si', $line, $matches ); if( ereg( $searchpath, $matches[2] ) ) { $bw += $matches[4]; } } } return $bw ; } $username = 'username'; $password = 'password'; $hostname = 'hostname.com'; printf( 'Images on %s have taken up a total of %01.2fMB bandwidth today<br />', $hostname, cpanel_logs( $username, $password, $hostname, 'images' ) / 1048576 ); printf( '%s has taken up a total of %01.2fMB bandwidth today<br />', $hostname, cpanel_logs( $username, $password, $hostname, '/' ) / 1048576 ); ?> PHP:
log file usually returned as gzipped archive. before you regex-it, you should open it as gz file. So, instead of: $logs = file( sprintf( 'http://%s:%s@%s:2082/getlogarchive/%s', $username, $password, $domain, $domain )); PHP: You should use: $logs = readgzfile( sprintf( 'http://%s:%s@%s:2082/getlogarchive/%s', $username, $password, $domain, $domain )); PHP: just my two cents.