21 $this->statdir = $this->statconfig->getValue(
'statdir');
22 $this->inputfile = $this->statconfig->getValue(
'inputfile');
23 $this->statrules = $this->statconfig->getValue(
'statrules');
24 $this->offset = $this->statconfig->getValue(
'offset', 0);
36 echo 'Statistics directory : ' . $this->statdir .
"\n";
37 echo 'Input file : ' . $this->inputfile .
"\n";
38 echo 'Offset : ' . $this->offset .
"\n";
48 if (!is_dir($this->statdir)) {
49 throw new Exception(
'Statistics module: output dir do not exists [' . $this->statdir .
']');
52 if (!file_exists($this->inputfile)) {
53 throw new Exception(
'Statistics module: input file do not exists [' . $this->inputfile .
']');
56 $file =
fopen($this->inputfile,
'r');
59 $this->statconfig->getValue(
'datestart', 0), $this->statconfig->getValue(
'datelength', 15), $this->statconfig->getValue(
'offsetspan', 44)
62 $sessioncounter = array();
66 while (!feof($file)) {
67 $logline = fgets($file, 4096);
70 if (!preg_match(
'/STAT/', $logline)) {
76 $epoch = $logparser->parseEpoch($logline);
77 $content = $logparser->parseContent($logline);
79 if ((
$i % 10000) == 0) {
80 echo(
"Read line " .
$i .
"\n");
83 $trackid = $content[4];
85 if (!isset($sessioncounter[$trackid])) {
86 $sessioncounter[$trackid] = 0;
88 $sessioncounter[$trackid]++;
91 echo(
"----------------------------------------\n");
92 echo(
'Log line: ' . $logline .
"\n");
93 echo(
'Date parse [' . substr($logline, 0, $this->statconfig->getValue(
'datelength', 15)) .
'] to [' . date(DATE_RFC822, $epoch) .
']' .
"\n");
94 echo htmlentities(print_r($content,
true));
101 $histogram = array();
102 foreach ($sessioncounter as $trackid =>
$sc) {
103 if (!isset($histogram[
$sc])) {
111 foreach ($sessioncounter as $trackid =>
$sc) {
128 echo "Preparing to delete [" .count(
$todelete) .
"] trackids\n";
130 if (!is_dir($this->statdir)) {
131 throw new Exception(
'Statistics module: output dir do not exists [' . $this->statdir .
']');
134 if (!file_exists($this->inputfile)) {
135 throw new Exception(
'Statistics module: input file do not exists [' . $this->inputfile .
']');
138 $file =
fopen($this->inputfile,
'r');
141 if (file_exists($outputfile)) {
145 $outfile =
fopen($outputfile,
'x');
148 $this->statconfig->getValue(
'datestart', 0), $this->statconfig->getValue(
'datelength', 15), $this->statconfig->getValue(
'offsetspan', 44)
153 while (!feof($file)) {
154 $logline = fgets($file, 4096);
157 if (!preg_match(
'/STAT/', $logline)) {
164 if (($i % 10000) == 0) {
165 echo(
"Read line " . $i .
"\n");
168 $trackid = $content[4];
169 if (in_array($trackid,
$todelete,
true)) {
173 fputs($outfile, $logline);
store($todelete, $outputfile)
__construct($inputfile=null)
Constructor.
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.