statistieken script
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Stats</title>
</head>
<body>
<script language="JavaScript">
<!--
pagina = escape(document.location.href);
referrer = escape(document.referrer);
if ((referrer == "") || (referrer == "undefined")) { referrer = "bookmark"; }
ss = screen.width + "x" + screen.height;
src = "stats.php?pagina=" + pagina + "&referrer=" + referrer + "&ss=" + ss;
src = "<img src=\"" + src + "\";
document.write(src);
-->
</script>
</body>
</html>
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
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
<?
echo "<img src=\"webstats_img.jpg\">";
if(!IsSet($_GET['pagina']) || !IsSet($_GET['referrer']) || !IsSet($_GET['ss']))
{
echo "Error!- Verkeerde gegevens!";
} else
{
$http_u_a = strtolower(rawurldecode($_SERVER['HTTP_USER_AGENT']));
//browser
if(eregi('msie ([0-9]+\.[0-9]+)', $http_u_a, $regs)){
$browser = "Internet Explorer ".$regs[1];
}
elseif(eregi('mozilla/(.?)firefox/([0-9]{0,2}\.[0-9]{0,2}\.[0-9]{0,2})', $http_u_a, $regs)){
$browser = "Firefox ".$regs[1];
}
elseif((eregi('google', $http_u_a))){
$browser = "Google";
}
elseif((eregi('bot', $http_u_a)) || (eregi('slurp', $http_u_a)) || (eregi('scooter', $http_u_a)) || (eregi('spider', $http_u_a)) || (eregi('crawler', $http_u_a)) || (eregi('archiver', $http_u_a))){
$browser = 'Andere zoekmachine';
}
else{
$browser = "Anders";
}
//os
if(eregi("(win|windows)[ ]*((nt)*[ /]*([0-9]+(.?[0-9]+))*)", $http_u_a, $regs)){
if(eregi("(win|windows)[ ](95)", $http_u_a)){
$os = 'Windows 95';
}
elseif(eregi("(win|windows)[ ](98)", $http_u_a)){
$os = 'Windows 98';
}
elseif(eregi("(win|windows)[ ](me)", $http_u_a)){
$os = 'Windows ME';
}
elseif(eregi("(win|windows)[ ](nt)", $http_u_a)){
if(eregi("(win|windows)[ ](nt)[ ](5.1)", $http_u_a)){
$os = 'Windows XP';
}
elseif(eregi("(win|windows)[ ](nt)[ ](5.0)", $http_u_a)){
$os = 'Windows 2000';
}
else{
$os = 'Windows NT';
}
}
else{
$os = 'Windows';
}
}
else{
$os = 'Anders';
}
include('connect.php');
function AddStats($table, $value) {
$sql = "SELECT id FROM $table WHERE $table='$value'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
$id = mysql_result($result, 0, "id");
$sql = "UPDATE $table SET aantal=aantal+1 WHERE id='$id'";
}
else {
$sql = "INSERT INTO $table ($table, aantal) VALUES ('$value', '1')";
}
mysql_query($sql) or die("Geen verbinding met database");
return TRUE;
}
AddStats("browser", $browser);
AddStats("os", $os);
AddStats("pagina", $_GET['pagina']);
AddStats("referrer", $_GET['referrer']);
AddStats("screensize", $_GET['ss']);
}
?>
echo "<img src=\"webstats_img.jpg\">";
if(!IsSet($_GET['pagina']) || !IsSet($_GET['referrer']) || !IsSet($_GET['ss']))
{
echo "Error!- Verkeerde gegevens!";
} else
{
$http_u_a = strtolower(rawurldecode($_SERVER['HTTP_USER_AGENT']));
//browser
if(eregi('msie ([0-9]+\.[0-9]+)', $http_u_a, $regs)){
$browser = "Internet Explorer ".$regs[1];
}
elseif(eregi('mozilla/(.?)firefox/([0-9]{0,2}\.[0-9]{0,2}\.[0-9]{0,2})', $http_u_a, $regs)){
$browser = "Firefox ".$regs[1];
}
elseif((eregi('google', $http_u_a))){
$browser = "Google";
}
elseif((eregi('bot', $http_u_a)) || (eregi('slurp', $http_u_a)) || (eregi('scooter', $http_u_a)) || (eregi('spider', $http_u_a)) || (eregi('crawler', $http_u_a)) || (eregi('archiver', $http_u_a))){
$browser = 'Andere zoekmachine';
}
else{
$browser = "Anders";
}
//os
if(eregi("(win|windows)[ ]*((nt)*[ /]*([0-9]+(.?[0-9]+))*)", $http_u_a, $regs)){
if(eregi("(win|windows)[ ](95)", $http_u_a)){
$os = 'Windows 95';
}
elseif(eregi("(win|windows)[ ](98)", $http_u_a)){
$os = 'Windows 98';
}
elseif(eregi("(win|windows)[ ](me)", $http_u_a)){
$os = 'Windows ME';
}
elseif(eregi("(win|windows)[ ](nt)", $http_u_a)){
if(eregi("(win|windows)[ ](nt)[ ](5.1)", $http_u_a)){
$os = 'Windows XP';
}
elseif(eregi("(win|windows)[ ](nt)[ ](5.0)", $http_u_a)){
$os = 'Windows 2000';
}
else{
$os = 'Windows NT';
}
}
else{
$os = 'Windows';
}
}
else{
$os = 'Anders';
}
include('connect.php');
function AddStats($table, $value) {
$sql = "SELECT id FROM $table WHERE $table='$value'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
$id = mysql_result($result, 0, "id");
$sql = "UPDATE $table SET aantal=aantal+1 WHERE id='$id'";
}
else {
$sql = "INSERT INTO $table ($table, aantal) VALUES ('$value', '1')";
}
mysql_query($sql) or die("Geen verbinding met database");
return TRUE;
}
AddStats("browser", $browser);
AddStats("os", $os);
AddStats("pagina", $_GET['pagina']);
AddStats("referrer", $_GET['referrer']);
AddStats("screensize", $_GET['ss']);
}
?>
het probleem is dat er niks in de database wordt bijgewerkt als je naar index.php gaat. ga je alleen naar stats.php met alle gegevens in de url dan doet hij het wel
niemand die het weet?