-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.php
201 lines (197 loc) · 7.95 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?PHP
require_once('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ChiliStats - OneWiev</title>
<link href="chilistats.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="logo">
<h1>ChiliStats</h1>
</div>
<div id="menu">
<ul>
<li><a href="stats.php">OneView</a></li>
<li><a href="visitors.php">Visitors</a></li>
<li><a href="history.php">History</a></li>
</ul>
</div>
<div class="middle">
<h3>One View</h3>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="oneview">
<tr valign="top">
<?PHP
// Gesamt Besucher ermitteln
$abfrage=mysql_query("select sum(user),sum(view) from ".$db_prefix."Day");
$visitors=mysql_result($abfrage,0,0);
$visits=mysql_result($abfrage,0,1);
mysql_free_result($abfrage);
echo "<td width=\"30%\">Visitors</td><td width=\"20%\">$visitors</td>\n";
echo "<td width=\"30%\">Visits</td><td width=\"20%\">$visits</td>\n";
?>
</tr>
<tr valign="top">
<?PHP
// Online
$time = time();
$isonline=$time-(3*60); // 3 Minuten Online Zeit
$abfrage=mysql_query("select count(id) from ".$db_prefix."IPs where online>='$isonline'");
$online=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
echo "<td>Online</td><td>$online</td>\n";
echo "<td> </td><td> </td>\n";
?>
</tr>
<tr valign="top">
<td> </td><td> </td><td> </td><td> </td>
</tr>
<tr valign="top">
<?PHP
// Bounce
$abfrage=mysql_query("select count(id) from ".$db_prefix."IPs");
$total=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
$abfrage=mysql_query("select count(id) from ".$db_prefix."IPs where online=time");
$onepage=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
echo "<td>Bounce</td><td>".round(($onepage/$total)*100,2)."%</td>\n";
// Page/User and 7 days averange
$from_day=date("Y.m.d",$time -(7*24*60*60));
$to_day=date("Y.m.d",$time - (24*60*60)); // <= ohne heute
$abfrage=mysql_query("select AVG(user),(sum(view)/sum(user)) from ".$db_prefix."Day where day>='$from_day' AND day<='$to_day'");
$avg_7=round(mysql_result($abfrage,0,0),2);
$page_user=round(mysql_result($abfrage,0,1),1);
mysql_free_result($abfrage);
echo "<td>Page/Visitor</td><td>$page_user</td>\n";
?>
</tr>
<tr valign="top">
<td> </td><td> </td><td> </td><td> </td>
</tr>
<tr valign="top">
<?PHP
echo" <td>Ø 7 days</td>\n";
echo" <td>$avg_7</td>\n";
// 30 days averange
$from_day=date("Y.m.d",$time -(30*24*60*60));
$to_day=date("Y.m.d",$time - (24*60*60)); // <= ohne heute
$abfrage=mysql_query("select AVG(user) from ".$db_prefix."Day where day>='$from_day' AND day<='$to_day'");
$avg_30=round(mysql_result($abfrage,0,0),2);
mysql_free_result($abfrage);
echo" <td>Ø 30 days</td>\n";
echo" <td>$avg_30</td>\n";
?>
</tr>
<tr valign="top">
<?PHP
// Gesamt User Heute
$sel_timestamp = mktime(0, 0, 0, date("n"), date("j"), date("Y"));
$sel_tag = date("Y.m.d",$sel_timestamp);
$abfrage=mysql_query("select sum(user) from ".$db_prefix."Day where day='$sel_tag'");
$today=mysql_result($abfrage,0,0);
if ($today=="") $today=0;
mysql_free_result($abfrage);
echo "<td>Today</td><td>$today</td>\n";
// gestern zur gleichen Zeit
$anfangTag = mktime(0, 0, 0, date(n), date(j), date(Y)) - 24*60*60 ;
$endeTag = $time - 24*60*60 ;
$abfrage=mysql_query("select count(id) from ".$db_prefix."IPs where time>='$anfangTag' AND time<=$endeTag");
$yesterday=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
echo "<td>Yesterday (".date("G:i",$time).")</td><td>$yesterday</td>\n";
?>
</tr>
</table>
</div>
<div class="middle">
<h3>Last 24 hours </h3>
<table height="200" width="100%" cellpadding="0" cellspacing="0" align="right">
<tr valign="bottom" height="180">
<?PHP
// User der letzten 24 Stunden abfragen
$bar_nr=0;
$bar_mark="";
for($Stunde=23; $Stunde>=0; $Stunde--)
{
$anfangStunde = mktime(date("H")-$Stunde, 0, 0, date("n"), date("j"), date("Y")) ;
$endeStunde = mktime(date("H")-$Stunde, 59, 59, date("n"), date("j"), date("Y")) ;
$abfrage=mysql_query("select count(id) from ".$db_prefix."IPs where time>='$anfangStunde' AND time<=$endeStunde");
$User=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
// Diagramm vorbereiten, Array erstellen
$bar[$bar_nr] = $User;
$bar_title[$bar_nr] = date("G:i",$anfangStunde)." - ".date("G:i",$endeStunde);
if (date("H")-$Stunde == 0) $bar_mark = $bar_nr;
$bar_nr++;
}
// Diagramm
for($i=0; $i<$bar_nr; $i++)
{
$value=$bar[$i];
if ($value == "") $value = 0;
if (max($bar) > 0) {$bar_hight=round((170/max($bar))*$value);} else $bar_hight = 0;
if ($bar_hight == 0) $bar_hight = 1;
if ($bar_mark == "$i" ) { echo "<td style=\"border-left: #FF0000 1px dotted;\" width=\"19\">";}
else echo "<td width=\"19\">";
echo "<div class=\"bar\" style=\"height:".$bar_hight."px;\" title=\"".$bar_title[$i]." - $value Visitors\"></div></td>\n";
}
?>
</tr><tr height="20">
<td colspan="6" width="25%" class="timeline"><?PHP echo date("G:i",mktime(date("H")-23, 0, 0, date("n"), date("j"), date("Y"))); ?></td>
<td colspan="6" width="25%" class="timeline"><?PHP echo date("G:i",mktime(date("H")-17, 0, 0, date("n"), date("j"), date("Y"))); ?></td>
<td colspan="6" width="25%" class="timeline"><?PHP echo date("G:i",mktime(date("H")-11, 0, 0, date("n"), date("j"), date("Y"))); ?></td>
<td colspan="6" width="25%" class="timeline"><?PHP echo date("G:i",mktime(date("H")-5, 0, 0, date("n"), date("j"), date("Y"))); ?></td>
</tr></table>
</div>
<div style="clear:both"></div>
<div class="full">
<h3>Last 30 days </h3>
<table height="230" width="100%" cellpadding="0" cellspacing="0" align="right">
<tr valign="bottom" height="210">
<?PHP
// User der letzten 30 Tage abfragen
$bar_nr=0;
$bar_mark="";
for($day=29; $day>=0; $day--)
{
$sel_timestamp = mktime(0, 0, 0, date("n"), date("j")-$day, date("Y"));
$sel_tag = date("Y.m.d",$sel_timestamp);
$abfrage=mysql_query("select sum(user) from ".$db_prefix."Day where day='$sel_tag'");
$User=mysql_result($abfrage,0,0);
mysql_free_result($abfrage);
$bar[$bar_nr]=$User; // Im Array Speichern
$bar_title[$bar_nr] = date("j.M.Y",$sel_timestamp);
if (date("j")-$day == 1) $bar_mark = $bar_nr;
if ( date("w", $sel_timestamp) == 6 OR date("w", $sel_timestamp)== 0) {$weekend[$bar_nr]=true;}
else {$weekend[$bar_nr]=false;}
$bar_nr++;
}
// Diagramm
for($i=0; $i<$bar_nr; $i++)
{
$value=$bar[$i];
if ($value == "") $value = 0;
if (max($bar) > 0) {$bar_hight=round((200/max($bar))*$value);} else $bar_hight = 0;
if ($bar_hight == 0) $bar_hight = 1;
if ($bar_mark == "$i" ) { echo "<td style=\"border-left: #FF0000 1px dotted;\" width=\"31\">";}
else echo "<td width=\"31\">";
echo "<div class=\"bar\" style=\"height:".$bar_hight."px;\" title=\"".$bar_title[$i]." - $value Visitors\"></div></td>\n";
}
?>
</tr><tr height="20">
<td colspan="6" class="timeline"><?PHP echo date("j.M",mktime(0, 0, 0, date("n"), date("j")-29, date("Y"))); ?></td>
<td colspan="6" class="timeline"><?PHP echo date("j.M",mktime(0, 0, 0, date("n"), date("j")-23, date("Y"))); ?></td>
<td colspan="6" class="timeline"><?PHP echo date("j.M",mktime(0, 0, 0, date("n"), date("j")-17, date("Y"))); ?></td>
<td colspan="6" class="timeline"><?PHP echo date("j.M",mktime(0, 0, 0, date("n"), date("j")-11, date("Y"))); ?></td>
<td colspan="6" class="timeline"><?PHP echo date("j.M",mktime(0, 0, 0, date("n"), date("j")-5, date("Y"))); ?></td>
</tr></table>
</div>
<div style="clear:both"></div>
<div id="footer">ChiliStats by <a href="http://www.chiliscripts.com" target="_blank" >ChiliScripts.com</a></div>
</div>
</body>
</html>