php-statistieken
show_stats.php
Code (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?
//--- check for posted date
if (!$_POST['dag'])
$datum = date("d.m.Y");
else
$datum = $_POST['dag'] . "." . $_POST['maand'] . "." . $_POST['jaar'];
//--- show date selection form
echo "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<b>Selecteer een datum</b><br />";
// dag
echo "<select name=\"dag\">";
for ($i = 1; $i <= 31; $i++)
{
if ($i < 10)
$num = "0" . $i;
else
$num = $i;
unset($selected);
if ($num == $_POST['dag'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('d') && !$select)
$selected = "selected";
echo "<option value=\"" . $num . "\" $selected>" . $num . "</option>";
}
echo "</select> . ";
// maand
echo "<select name=\"maand\">";
for ($i = 1; $i <= 12; $i++)
{
if ($i < 10)
$num = "0" . $i;
else
$num = $i;
unset($selected);
if ($num == $_POST['maand'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('m') && !$select)
$selected = "selected";
echo "<option value=\"" . $num . "\" $selected>" . $num . "</option>";
}
echo "</select> . ";
// jaar
echo "<select name=\"jaar\">";
for ($i = date('Y'); $i >= date('Y')-3; $i--)
{
unset($selected);
if ($num == $_POST['jaar'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('Y') && !$select)
$selected = "selected";
echo "<option value=\"" . $i . "\" $selected>" . $i . "</option>";
}
echo "</select> <input type=\"submit\" value=\"Toon statistieken\" name=\"submit\"><p>";
//--- receive statics from database
$sql = "SELECT uniek,views,refs FROM php_statics WHERE datum = '" . $datum . "'";
$res = mysql_query($sql);
//--- check if static results are available
if (mysql_num_rows($res) >= 1)
{
//--- unset browser_id cuz it's getting used by register of statics
unset($browser_id);
unset($browser_ids);
unset($browser);
//--- put received data in array
$row = mysql_fetch_array($res);
//--- explode referers
$refs = explode(",", $row['refs']);
//--- check for totals
$max = $row['views'];
$views = ceil($row['views'] / ($row['views'] / 400));
$uniek = ceil($row['uniek'] / ($row['views'] / 400));
$verwijzingen = ceil(count($refs) / ($row['views'] / 400));
$browser_types = ceil(count($browser) / ($row['views'] / 400));
//--- print statics
echo "<p>De volgende statistieken zijn bekend:</p>";
//--- uniek
echo "<p><b>Uniek</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $uniek . "\" alt=\"" . $row['uniek'] . " unieke bezoeken\"> ";
echo $row['uniek'] . "</p>";
//--- views
echo "<p><b>Views</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $views . "\" alt=\"" . $row['views'] . " totale bezoeken\"> ";
echo $row['views'] . "</p>";
//--- get referers
echo "<p><b>Verwijzingen</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $verwijzingen . "\" alt=\"" . count($refs) . " totale bezoeken\"> ";
echo count($refs) . "</p>";
echo "<h3 class=\"reactions\"><span class=\"smalln\">Links naar deze website</span></h3>";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" width=\"492\">";
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"392\"><b>Verwijzende websites</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
//----
// zoekmachines & verwijzende pagina's
//---
//--- get all search engines from database
$ssql = "SELECT browser,browser_icon FROM php_statics_browsers WHERE search_engine = 1";
$sres = mysql_query($ssql);
for ($i = 0; $srow = mysql_fetch_array($sres); $i++)
{
$engines[$i] = $srow['browser'];
$engine_icons[$i] = $srow['browser_icon'];
}
$res = $refs;
sort($res);
reset($res);
//--- set search engines and other linking websites
for ($i = 0; $i < count($res); $i++)
{
$url = $res[$i];
$parseurl = parse_url($url); // normaal parse_url($res[$i]);
$url_slizes = explode(".", $parseurl['host']);
$domain_nr = count($url_slizes) - 2;
$domainname = $url_slizes[$domain_nr];
if (array_search(ucfirst($domainname), $engines) && $search_engine != ucfirst($domainname))
{
if (!$k)
$k = 1;
else
$k++;
$searched_key = array_search(ucfirst($domainname), $engines);
$search_engine = $engines[$searched_key];
$set_engine[$k] = $engines[$searched_key];
$set_icon[$k] = $engine_icons[$searched_key];
$set_count[$k] = 1;
}
elseif (array_search(ucfirst($domainname), $engines))
{
$set_count[$k]++;
}
else
{
$linkname = $res[$i];
if (!$link || $link != $res[$i])
{
if (!$l)
$l = 1;
else
$l++;
$link = $res[$i];
$set_link[$linkname] = 1;
}
else
$set_link[$linkname]++;
}
}
arsort($set_link);
reset($set_link);
unset($aantal);
//--- show linking websites
foreach ($set_link as $link => $count)
{
if (strlen($link) >= 40)
$urladdr = substr($link, 0, 40) . "..";
else
$urladdr = $link;
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\"><a href=\"" . $link . "\" target=\"_blank\" title=\"" . $link . "\">" . $urladdr . "</a></td><td width=\"50\">" . $count . "</td><td width=\"50\"> </td></tr>";
$aantal = $aantal + $count;
}
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($set_link) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "<tr class=\"grey_bg\"><td colspan=\"4\"> </td></tr>";
unset($k);
//--- show linking search engines
for ($i = 1; $i <= count($set_engine); $i++)
{
$naam = $set_engine[$i];
$count = $set_count[$i];
$zoekmachine_pic[$naam] = $set_icon[$i];
if (!$zoekmachine[$naam])
$zoekmachine[$naam] = $count;
else
$zoekmachine[$naam] = $zoekmachine[$naam] + $count;
}
arsort($zoekmachine);
unset($aantal);
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"390\"><b>Verwijzende zoekmachines</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
foreach ($zoekmachine as $naam => $count)
{
if ($zoekmachine_pic[$naam])
$icon = "<img src=\"" . $zoekmachine_pic[$naam] . "\" alt=\"\" />";
else
$icon = " ";
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\">" . $naam . "</td><td width=\"50\">" . $count . "</td><td width=\"50\">" . $icon . "</td></tr>";
$aantal = $aantal + $count;
}
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($zoekmachine) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "</table>";
echo "</p>";
//--- browsers
$bsql = "SELECT browser_ids FROM php_statics_agents WHERE datum = '" . $datum . "'";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
$browser_ids = explode(",", mysql_result($bres, 0));
sort($browser_ids);
reset($browser_ids);
$res = array_count_values($browser_ids);
arsort($res);
}
echo "<h3 class=\"reactions\"><span class=\"smalln\">Verschillende browsers</span></h3>";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" width=\"492\">";
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"392\"><b>Gebruikte browsers</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
//--- loop trough $res browsers
foreach ($res as $browserid => $count)
{
//--- get browser name (by browser id)
$bsql = "SELECT browser,search_engine,browser_icon FROM php_statics_browsers WHERE id = '" . $browserid . "'";
$bres = mysql_query($bsql);
//--- check if browser was found in database or if the browser is 'unknown'
if (@mysql_num_rows($bres) >= 1)
$browser_name = mysql_result($bres, 0);
else
$browser_name = "unknown";
//--- check if user agent was search engine
unset($zoek);
if (@mysql_result($bres, 0, 1) && !$zoek)
$zoek = "(zoekmachine)";
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\">";
//--- check if icon exists
unset($icon);
if (@mysql_result($bres, 0, 2))
$icon = "<img src=\"" . mysql_result($bres, 0, 2) . "\" alt=\"\">";
else
$icon = " ";
//--- print that sjit
echo $browser_name . " " . $zoek . "</td><td width=\"50\">" . $count . "</td><td width=\"50\">" . $icon . "</td>";
echo "</tr>";
$aantal = $aantal + $count;
}
//--- print totals
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($res) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "</table>";
}
else
{
echo "<p>Er zijn geen statistieken bekend voor " . $datum . "</p>";
}
?>
//--- check for posted date
if (!$_POST['dag'])
$datum = date("d.m.Y");
else
$datum = $_POST['dag'] . "." . $_POST['maand'] . "." . $_POST['jaar'];
//--- show date selection form
echo "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<b>Selecteer een datum</b><br />";
// dag
echo "<select name=\"dag\">";
for ($i = 1; $i <= 31; $i++)
{
if ($i < 10)
$num = "0" . $i;
else
$num = $i;
unset($selected);
if ($num == $_POST['dag'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('d') && !$select)
$selected = "selected";
echo "<option value=\"" . $num . "\" $selected>" . $num . "</option>";
}
echo "</select> . ";
// maand
echo "<select name=\"maand\">";
for ($i = 1; $i <= 12; $i++)
{
if ($i < 10)
$num = "0" . $i;
else
$num = $i;
unset($selected);
if ($num == $_POST['maand'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('m') && !$select)
$selected = "selected";
echo "<option value=\"" . $num . "\" $selected>" . $num . "</option>";
}
echo "</select> . ";
// jaar
echo "<select name=\"jaar\">";
for ($i = date('Y'); $i >= date('Y')-3; $i--)
{
unset($selected);
if ($num == $_POST['jaar'])
{
$selected = "selected";
$select = 1;
}
elseif ($num == date('Y') && !$select)
$selected = "selected";
echo "<option value=\"" . $i . "\" $selected>" . $i . "</option>";
}
echo "</select> <input type=\"submit\" value=\"Toon statistieken\" name=\"submit\"><p>";
//--- receive statics from database
$sql = "SELECT uniek,views,refs FROM php_statics WHERE datum = '" . $datum . "'";
$res = mysql_query($sql);
//--- check if static results are available
if (mysql_num_rows($res) >= 1)
{
//--- unset browser_id cuz it's getting used by register of statics
unset($browser_id);
unset($browser_ids);
unset($browser);
//--- put received data in array
$row = mysql_fetch_array($res);
//--- explode referers
$refs = explode(",", $row['refs']);
//--- check for totals
$max = $row['views'];
$views = ceil($row['views'] / ($row['views'] / 400));
$uniek = ceil($row['uniek'] / ($row['views'] / 400));
$verwijzingen = ceil(count($refs) / ($row['views'] / 400));
$browser_types = ceil(count($browser) / ($row['views'] / 400));
//--- print statics
echo "<p>De volgende statistieken zijn bekend:</p>";
//--- uniek
echo "<p><b>Uniek</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $uniek . "\" alt=\"" . $row['uniek'] . " unieke bezoeken\"> ";
echo $row['uniek'] . "</p>";
//--- views
echo "<p><b>Views</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $views . "\" alt=\"" . $row['views'] . " totale bezoeken\"> ";
echo $row['views'] . "</p>";
//--- get referers
echo "<p><b>Verwijzingen</b><br />";
echo "<img src=\"/images/icons/balk.gif\" height=\"13\" width=\"" . $verwijzingen . "\" alt=\"" . count($refs) . " totale bezoeken\"> ";
echo count($refs) . "</p>";
echo "<h3 class=\"reactions\"><span class=\"smalln\">Links naar deze website</span></h3>";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" width=\"492\">";
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"392\"><b>Verwijzende websites</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
//----
// zoekmachines & verwijzende pagina's
//---
//--- get all search engines from database
$ssql = "SELECT browser,browser_icon FROM php_statics_browsers WHERE search_engine = 1";
$sres = mysql_query($ssql);
for ($i = 0; $srow = mysql_fetch_array($sres); $i++)
{
$engines[$i] = $srow['browser'];
$engine_icons[$i] = $srow['browser_icon'];
}
$res = $refs;
sort($res);
reset($res);
//--- set search engines and other linking websites
for ($i = 0; $i < count($res); $i++)
{
$url = $res[$i];
$parseurl = parse_url($url); // normaal parse_url($res[$i]);
$url_slizes = explode(".", $parseurl['host']);
$domain_nr = count($url_slizes) - 2;
$domainname = $url_slizes[$domain_nr];
if (array_search(ucfirst($domainname), $engines) && $search_engine != ucfirst($domainname))
{
if (!$k)
$k = 1;
else
$k++;
$searched_key = array_search(ucfirst($domainname), $engines);
$search_engine = $engines[$searched_key];
$set_engine[$k] = $engines[$searched_key];
$set_icon[$k] = $engine_icons[$searched_key];
$set_count[$k] = 1;
}
elseif (array_search(ucfirst($domainname), $engines))
{
$set_count[$k]++;
}
else
{
$linkname = $res[$i];
if (!$link || $link != $res[$i])
{
if (!$l)
$l = 1;
else
$l++;
$link = $res[$i];
$set_link[$linkname] = 1;
}
else
$set_link[$linkname]++;
}
}
arsort($set_link);
reset($set_link);
unset($aantal);
//--- show linking websites
foreach ($set_link as $link => $count)
{
if (strlen($link) >= 40)
$urladdr = substr($link, 0, 40) . "..";
else
$urladdr = $link;
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\"><a href=\"" . $link . "\" target=\"_blank\" title=\"" . $link . "\">" . $urladdr . "</a></td><td width=\"50\">" . $count . "</td><td width=\"50\"> </td></tr>";
$aantal = $aantal + $count;
}
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($set_link) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "<tr class=\"grey_bg\"><td colspan=\"4\"> </td></tr>";
unset($k);
//--- show linking search engines
for ($i = 1; $i <= count($set_engine); $i++)
{
$naam = $set_engine[$i];
$count = $set_count[$i];
$zoekmachine_pic[$naam] = $set_icon[$i];
if (!$zoekmachine[$naam])
$zoekmachine[$naam] = $count;
else
$zoekmachine[$naam] = $zoekmachine[$naam] + $count;
}
arsort($zoekmachine);
unset($aantal);
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"390\"><b>Verwijzende zoekmachines</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
foreach ($zoekmachine as $naam => $count)
{
if ($zoekmachine_pic[$naam])
$icon = "<img src=\"" . $zoekmachine_pic[$naam] . "\" alt=\"\" />";
else
$icon = " ";
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\">" . $naam . "</td><td width=\"50\">" . $count . "</td><td width=\"50\">" . $icon . "</td></tr>";
$aantal = $aantal + $count;
}
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($zoekmachine) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "</table>";
echo "</p>";
//--- browsers
$bsql = "SELECT browser_ids FROM php_statics_agents WHERE datum = '" . $datum . "'";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
$browser_ids = explode(",", mysql_result($bres, 0));
sort($browser_ids);
reset($browser_ids);
$res = array_count_values($browser_ids);
arsort($res);
}
echo "<h3 class=\"reactions\"><span class=\"smalln\">Verschillende browsers</span></h3>";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" width=\"492\">";
echo "<tr class=\"grey_bg\"><td colspan=\"2\" width=\"392\"><b>Gebruikte browsers</b></td><td width=\"50\"><b>Aantal</b></td><td width=\"50\"><b>Icon</b></td></tr>";
//--- loop trough $res browsers
foreach ($res as $browserid => $count)
{
//--- get browser name (by browser id)
$bsql = "SELECT browser,search_engine,browser_icon FROM php_statics_browsers WHERE id = '" . $browserid . "'";
$bres = mysql_query($bsql);
//--- check if browser was found in database or if the browser is 'unknown'
if (@mysql_num_rows($bres) >= 1)
$browser_name = mysql_result($bres, 0);
else
$browser_name = "unknown";
//--- check if user agent was search engine
unset($zoek);
if (@mysql_result($bres, 0, 1) && !$zoek)
$zoek = "(zoekmachine)";
echo "<tr class=\"grey_bg\"><td width=\"92\"> </td><td width=\"300\">";
//--- check if icon exists
unset($icon);
if (@mysql_result($bres, 0, 2))
$icon = "<img src=\"" . mysql_result($bres, 0, 2) . "\" alt=\"\">";
else
$icon = " ";
//--- print that sjit
echo $browser_name . " " . $zoek . "</td><td width=\"50\">" . $count . "</td><td width=\"50\">" . $icon . "</td>";
echo "</tr>";
$aantal = $aantal + $count;
}
//--- print totals
echo "<tr class=\"grey_bg\"><td><b>Totaal</b></td><td><b>" . count($res) . "</b></td><td><b>" . $aantal . "</b></td><td> </td></tr>";
echo "</table>";
}
else
{
echo "<p>Er zijn geen statistieken bekend voor " . $datum . "</p>";
}
?>
reg_stats.php
Code (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
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
<?
//--- statics stuff
$this_domain = "http://www.jouwebsite.nl"; // using for own referers
$ssql = "SELECT ips FROM php_statics WHERE datum = '" . date('d.m.Y') . "'";
$sres = mysql_query($ssql);
//--- statics exist!
if (mysql_num_rows($sres) >= 1)
{
//--- get each ip addr
$ips = explode(",", mysql_result($sres, 0));
//--- check for ip match
unset($not_uniek);
for ($i = 0; $i < count($ips); $i++)
{
if ($_SERVER['REMOTE_ADDR'] == $ips[$i])
{
$not_uniek = 1;
$i = count($ips) + 5;
}
}
//------------------------//
// \\ start browser // \\ //
//------------------------//
//--- set browser, but only if the IP address is not registered yet!
if (!$not_uniek)
{
//--- get all browsers
$bsql = "SELECT id,browser FROM php_statics_browsers ORDER BY browser";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
for ($i = 0; $brow = mysql_fetch_array($bres); $i++)
{
$browser_id[$i] = $brow['id'];
$browser[$i] = $brow['browser'];
}
}
//--- get user agent
$user_agent = $_SERVER['HTTP_USER_AGENT'];
//--- check for browser match
$bsql = "SELECT id FROM php_statics_agents WHERE datum = '" . date('d.m.Y') . "'";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
//--- match it
for ($i = 0; $i < count($browser); $i++)
{
if (strstr($user_agent, $browser[$i]) && $browser[$i] && $user_agent)
{
$bsql = "UPDATE php_statics_agents SET browser_ids = CONCAT(browser_ids, '," . $browser_id[$i] . "') WHERE datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
$i = count($browser) + 1;
$match = 1;
}
}
//--- no match => unknown
if (!$match)
{
$bsql = "UPDATE php_statics_agents SET browser_id = CONCAT(browser_ids, ',unknown') WHERE datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
}
}
//--- nothing in db of this date yet, attempt to create one
else
{
for ($i = 0; $i < count($browser); $i++)
{
if (strstr($user_agent, $browser[$i]) && $user_agent && $browser[$i])
{
$bsql = "INSERT INTO php_statics_agents SET id = '', browser_ids = '" . $browser_id[$i] . "', datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
$i = count($browser) + 1;
}
}
}
}
//----------------------//
// \\ end browser // \\ //
//----------------------//
//--- make sure it's not a referer of its own
if (substr($_SERVER['HTTP_REFERER'], 0, 21) == $this_domain)
$not_referer = 1;
$ssql = "UPDATE php_statics SET ";
//--- update statics with referer (if $not_referer & $not_uniek are empty)
if (!$not_referer && !$not_uniek)
{
$ssql .= " uniek = uniek+1, ";
if ($_SERVER['HTTP_REFERER'])
$ssql .= "refs = CONCAT(refs, '," . $_SERVER['HTTP_REFERER'] . "'), ";
$ssql .= "ips = CONCAT(ips, '," . $_SERVER['REMOTE_ADDR'] . "'), ";
}
//--- only update the ip addresses
elseif (!$not_uniek)
$ssql .= "uniek = uniek+1, ";
//--- only update the referers
elseif (!$not_referer && $_SERVER['HTTP_REFERER'] && !$not_uniek)
$ssql .= "refs = CONCAT(refs, '," . $_SERVER['HTTP_REFERER'] . "'), ";
//--- always count views with 1
$ssql .= "views = views+1 WHERE datum = '" . date("d.m.Y") . "'";
$rres = mysql_query($ssql);
}
//--- no statics exist for this day! make them!
else
{
$ssql = "INSERT INTO php_statics ";
$ssql .= "SET id = '', ";
$ssql .= "uniek = 1, ";
$ssql .= "views = 1, ";
//--- if a referer's been set and it's not it's own, set it
if ($_SERVER['HTTP_REFERER'] && substr($_SERVER['HTTP_REFERER'], 0, 21) != $this_domain)
$ssql .= "refs = '" . $_SERVER['HTTP_REFERER'] . "', ";
//--- if no referer make first 'fake' referer 'X' (for first,)
else
$ssql .= "refs = 'X', ";
//--- set ip address and date
$ssql .= "ips = '" . $_SERVER['REMOTE_ADDR'] . "', ";
$ssql .= "datum = '" . date("d.m.Y") . "'";
$rres = mysql_query($ssql);
}
?>
//--- statics stuff
$this_domain = "http://www.jouwebsite.nl"; // using for own referers
$ssql = "SELECT ips FROM php_statics WHERE datum = '" . date('d.m.Y') . "'";
$sres = mysql_query($ssql);
//--- statics exist!
if (mysql_num_rows($sres) >= 1)
{
//--- get each ip addr
$ips = explode(",", mysql_result($sres, 0));
//--- check for ip match
unset($not_uniek);
for ($i = 0; $i < count($ips); $i++)
{
if ($_SERVER['REMOTE_ADDR'] == $ips[$i])
{
$not_uniek = 1;
$i = count($ips) + 5;
}
}
//------------------------//
// \\ start browser // \\ //
//------------------------//
//--- set browser, but only if the IP address is not registered yet!
if (!$not_uniek)
{
//--- get all browsers
$bsql = "SELECT id,browser FROM php_statics_browsers ORDER BY browser";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
for ($i = 0; $brow = mysql_fetch_array($bres); $i++)
{
$browser_id[$i] = $brow['id'];
$browser[$i] = $brow['browser'];
}
}
//--- get user agent
$user_agent = $_SERVER['HTTP_USER_AGENT'];
//--- check for browser match
$bsql = "SELECT id FROM php_statics_agents WHERE datum = '" . date('d.m.Y') . "'";
$bres = mysql_query($bsql);
if (mysql_num_rows($bres) >= 1)
{
//--- match it
for ($i = 0; $i < count($browser); $i++)
{
if (strstr($user_agent, $browser[$i]) && $browser[$i] && $user_agent)
{
$bsql = "UPDATE php_statics_agents SET browser_ids = CONCAT(browser_ids, '," . $browser_id[$i] . "') WHERE datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
$i = count($browser) + 1;
$match = 1;
}
}
//--- no match => unknown
if (!$match)
{
$bsql = "UPDATE php_statics_agents SET browser_id = CONCAT(browser_ids, ',unknown') WHERE datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
}
}
//--- nothing in db of this date yet, attempt to create one
else
{
for ($i = 0; $i < count($browser); $i++)
{
if (strstr($user_agent, $browser[$i]) && $user_agent && $browser[$i])
{
$bsql = "INSERT INTO php_statics_agents SET id = '', browser_ids = '" . $browser_id[$i] . "', datum = '" . date('d.m.Y') . "'";
mysql_query($bsql);
$i = count($browser) + 1;
}
}
}
}
//----------------------//
// \\ end browser // \\ //
//----------------------//
//--- make sure it's not a referer of its own
if (substr($_SERVER['HTTP_REFERER'], 0, 21) == $this_domain)
$not_referer = 1;
$ssql = "UPDATE php_statics SET ";
//--- update statics with referer (if $not_referer & $not_uniek are empty)
if (!$not_referer && !$not_uniek)
{
$ssql .= " uniek = uniek+1, ";
if ($_SERVER['HTTP_REFERER'])
$ssql .= "refs = CONCAT(refs, '," . $_SERVER['HTTP_REFERER'] . "'), ";
$ssql .= "ips = CONCAT(ips, '," . $_SERVER['REMOTE_ADDR'] . "'), ";
}
//--- only update the ip addresses
elseif (!$not_uniek)
$ssql .= "uniek = uniek+1, ";
//--- only update the referers
elseif (!$not_referer && $_SERVER['HTTP_REFERER'] && !$not_uniek)
$ssql .= "refs = CONCAT(refs, '," . $_SERVER['HTTP_REFERER'] . "'), ";
//--- always count views with 1
$ssql .= "views = views+1 WHERE datum = '" . date("d.m.Y") . "'";
$rres = mysql_query($ssql);
}
//--- no statics exist for this day! make them!
else
{
$ssql = "INSERT INTO php_statics ";
$ssql .= "SET id = '', ";
$ssql .= "uniek = 1, ";
$ssql .= "views = 1, ";
//--- if a referer's been set and it's not it's own, set it
if ($_SERVER['HTTP_REFERER'] && substr($_SERVER['HTTP_REFERER'], 0, 21) != $this_domain)
$ssql .= "refs = '" . $_SERVER['HTTP_REFERER'] . "', ";
//--- if no referer make first 'fake' referer 'X' (for first,)
else
$ssql .= "refs = 'X', ";
//--- set ip address and date
$ssql .= "ips = '" . $_SERVER['REMOTE_ADDR'] . "', ";
$ssql .= "datum = '" . date("d.m.Y") . "'";
$rres = mysql_query($ssql);
}
?>