-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetUserStats.php
66 lines (53 loc) · 1.93 KB
/
getUserStats.php
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
56
57
58
59
60
61
62
63
64
65
66
<?php
getUserDetails();
function getUserDetails()
{
$dir = "data/";
$activity_file = "data/userdetails.txt";
$lines = array();
if (file_exists($activity_file)) {
$no_of_entries = 2000;
$fp = fopen($activity_file, "r");
$activities;
while (!feof($fp)) {
$row;
$line = fgets($fp, 4096);
$line = str_replace("\n", "", $line);
if (true) {
$line = explode(",", $line);
if (isset($line[0]) && isset($line[1]) && isset($line[2]))
$row['browser'] = $line[0] . " " . $line[1] . " " . $line[2];
if (isset($line[4])) {
if (stripos($line[4], "windows") > -1)
$row['os'] = "windows";
if (stripos($line[4], "linux") > -1)
$row['os'] = "linux";
if (stripos($line[4], "mac") > -1)
$row['os'] = "Mac";
else
$row['os'] = $line[4];
}
if (isset($line[5])) {
$user="NA";
$action = explode(":",$line[5])[0];
if(stripos($line[5],":")>-1){
$user = explode(":",$line[5])[1];
}
$row['action'] = $action;
$row['user'] = $user;
}
if (isset($line[6])) {
$time = explode("GMT", $line[7])[0];
$row['time'] = $time;
}
array_push($lines, $row);
if (count($lines) > $no_of_entries) {
break;
}
}
}//end while f!=null
}//end if activity_file exists
$reversed = array_reverse($lines);
echo json_encode($reversed);
}
?>