<?php
//
// MODULE FOR xmlWeblication
//
// Count greped lines from logfile
// $logfile has to be defined in config.php or provide it als &logfile=....
// in your URL.
//
// 2003-12-18 <hide@address.com>
//
function module_downloadcounter() {
global $aid, $cfg, $app, $logfile;
if ( ! isset( $logfile ) ) {
$logfile = $cfg["logfile"];
}
if ( $logfile == "" ) return("");
if ( ! file_exists($logfile)) {
return( $logfile . " not exists");
}
$f = popen( "grep ". date("d.M.Y") .".*weblication-.*tgz $logfile | wc -l" , "r" );
if ( ! $f ) {
return( "Couldn't tail $logfile" );
}
else {
$rc .= "";
$l = trim(fgets( $f, 1024 ));
pclose($f);
$rc = $l . " downloads today<br>";
$l = "";
}
$f = popen( "grep weblication-.*tgz $logfile | wc -l" , "r" );
if ( ! $f ) {
return( "Couldn't tail $logfile" );
}
else {
$rc .= "";
$l = trim(fgets( $f, 1024 ));
pclose($f);
$rc .= $l . " downloads since Dec 17th, 2003";
}
return( $rc );
}
?>