-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatcher.php
More file actions
55 lines (48 loc) · 1.92 KB
/
Copy pathwatcher.php
File metadata and controls
55 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once 'includes/common_log_parser.php';
require_once 'includes/class.gzObject.php';
require_once 'includes/class.request.php';
require_once 'includes/class.user.php';
require_once 'includes/class.users.php';
require_once 'vendor/autoload.php';
$clients = '';
$count = 0;
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array(
//'cache' => 'compilation_cache',
));
//darkestpowers.mobi.access.log.1
//lacandy.mobi.access.log
$start = microtime(true);
$parser = new CommonLogParser('/var/vhosts/sandbox/watcher/logs/linkme/apache2/lacandy.mobi.access.log');
$parse = microtime(true);
//$parser->move_pointer_to_time(time() - 36000);
$users = new Users;
// retrieve one line at a time from the new location of the pointer
while (false !== ($line = $parser->get_next_line())) {
$match = preg_match("/\.(jpg|jpeg|gif|bmp|png|css|ico|js|json|txt)/i",$line['path']);
if($match === false){
$content .= '<br>preg_match error: '.__LINE__;
}
elseif($match === 0){
$request = new Request($line);
$users->addRequest($request);
// $pages->addpage($request);
}
$count++;
}
$gzObject = new gzObject();
$gzObject->write($users);
$time = microtime(true) - $start;
$status = $count.' lines in '.round($time,3).'(s) for '.round($count/$time).' lines/s<br />';
$users->orderByHits();
foreach ($users->getUsers() as $user){
$clients .= '<a href title="'.$user->get('userAgent').'">'.$user->get('ipAddress').'</a>
';
$clients .= ' (<a href="" title="">'. $user->countRequests().'
<div class="paths">'.implode("\n<br />",$user->getRequests()).'</div>
</a>)<br />
';
}
echo $twig->render('watcher.twig', array('clients' => $clients, 'status' => $status));
?>