-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphp.php
More file actions
34 lines (29 loc) · 781 Bytes
/
php.php
File metadata and controls
34 lines (29 loc) · 781 Bytes
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
<?php
function runLogViewer(){
date_default_timezone_set('AMERICA/NEW_YORK');
$log = file_get_contents('');
$logArrPre = explode("\n",$log);
$logArr = array();
for($i = 0; $i < count($logArrPre); $i++){
preg_match('/^[^\s]*/', $logArrPre[$i], $newIp);
$newIp = $newIp[0];
preg_match('/\[(.*)\]/', $logArrPre[$i], $newTime);
$newTime = $newTime[1];
preg_match('/"(.*)"/', $logArrPre[$i], $pageNType);
$pageNType = $pageNType[1];
preg_match('/([^\s]*)\s([^\s]*)\s([^"])/', $pageNType, $newPageNType);
$newType = $newPageNType[1];
$newPage = $newPageNType[2];
$newProt = $newPageNType[3];
$newRow = array(
"ip"=>$newIp,
"time"=>strtotime($newTime),
"file"=>$newPage,
"reqType"=>$newType,
"reqProt"=>$newProt,
);
$logArr[] = $newRow;
}
return $logArr;
}
?>