-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
113 lines (89 loc) · 2.44 KB
/
stats.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
Text Counter by http://www.free-php-counter.com
You are allowed to remove advertising after you purchased a licence
*/
// settings
// ip-protection in seconds
$counter_expire = 600;
$counter_filename = "counter.txt";
// ignore agent list
$counter_ignore_agents = array('bot', 'bot1', 'bot3');
// ignore ip list
$counter_ignore_ips = array('127.0.0.2', '127.0.0.3');
// get basic information
$counter_agent = $_SERVER['HTTP_USER_AGENT'];
$counter_ip = $_SERVER['REMOTE_ADDR'];
$counter_time = time();
if (file_exists($counter_filename))
{
// check ignore lists
$ignore = false;
$length = sizeof($counter_ignore_agents);
for ($i = 0; $i < $length; $i++)
{
if (substr_count($counter_agent, strtolower($counter_ignore_agents[$i])))
{
$ignore = true;
break;
}
}
$length = sizeof($counter_ignore_ips);
for ($i = 0; $i < $length; $i++)
{
if ($counter_ip == $counter_ignore_ips[$i])
{
$ignore = true;
break;
}
}
// get current counter state
$c_file = array();
$fp = fopen($counter_filename, "r");
if ($fp)
{
//flock($fp, LOCK_EX);
$canWrite = false;
while (!$canWrite)
$canWrite = flock($fp, LOCK_EX);
while (!feof($fp))
{
$line = trim(fgets($fp, 1024));
if ($line != "")
$c_file[] = $line;
}
flock($fp, LOCK_UN);
fclose ($fp);
}
else
{
$ignore = true;
}
{
// get data for reading only
if (sizeof($c_file) > 0)
list($day_arr, $yesterday_arr, $week_arr, $month_arr, $year_arr, $all, $record, $record_time) = explode("||", $c_file[0]);
else
list($day_arr, $yesterday_arr, $week_arr, $month_arr, $year_arr, $all, $record, $record_time) = explode("||", date("z") . ":1||" . (date("z")-1) . ":0||" . date("W") . ":1||" . date("n") . ":1||" . date("Y") . ":1||1||1||" . $counter_time);
// day
$day_data = explode(":", $day_arr);
$day = $day_data[1];
// yesterday
$yesterday_data = explode(":", $yesterday_arr);
$yesterday = $yesterday_data[1];
// week
$week_data = explode(":", $week_arr);
$week = $week_data[1];
// month
$month_data = explode(":", $month_arr);
$month = $month_data[1];
// year
$year_data = explode(":", $year_arr);
$year = $year_data[1];
$record_time = trim($record_time);
$online = sizeof($c_file) - 1;
if ($online <= 0)
$online = 1;
}
}
?>