uitgebreid-bezoekersscript
Gesponsorde koppelingen
PHP script bestanden
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
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
<?php
$file = "log.txt"; // Bestand waar resultaten opgeslagen worden
$time = "600"; // Aantal seconden tussen 2 hits
// Hier niets wijzigen
// Nieuwe hit wordt opgeslagen
$fo = fopen($file, 'r');
$data = fread($fo, filesize($file));
fclose($fo);
$aantal = count(explode("%%", $data));
$aantal = $aantal - 1;
$dataexpla = explode("%%", $data);
$counter = 0;
while ( $counter < $aantal )
{
$dataexplb = explode("::", $dataexpla[$counter]);
if ( $dataexplb[0] == $_SERVER['REMOTE_ADDR'] )
{
$ok = 1;
}
$counter++;
}
if ( $ok == 1 )
{
$b = $dataexplb[1];
$c = time();
$d = $c - $time;
if ( $b < $d )
{
$fo = fopen($file, 'w');
fwrite($fo, $data);
fwrite($fo, $_SERVER['REMOTE_ADDR']);
fwrite($fo, "::");
fwrite($fo, $c);
fwrite($fo, "%%");
fclose($fo);
}
}
else
{
$fo = fopen($file, 'w');
fwrite($fo, $data);
fwrite($fo, $_SERVER['REMOTE_ADDR']);
fwrite($fo, "::");
$date = time();
fwrite($fo, $date);
fwrite($fo, "%%");
fclose($fo);
}
// Resultaten berekenen
$fo = fopen($file, 'r');
$data = fread($fo, filesize($file));
fclose($fo);
$aantal = count(explode("%%", $data));
$aantal = $aantal - 1;
$dataexpla = explode("%%", $data);
$counter = 0;
$timea = time() - 86400;
$timeb = time() - 604800;
$timec = time() - 2592000;
$timed = time() - 172800;
$a = 0;
$b = 0;
$c = 0;
$d = 0;
while ( $counter < $aantal )
{
$dataexplb = explode("::", $dataexpla[$counter]);
if ( $dataexplb[1] > $timea )
{
$a = $a + 1;
}
if ( $dataexplb[1] > $timeb )
{
$b = $b + 1;
}
if ( $dataexplb[1] > $timec )
{
$c = $c + 1;
}
if ( $dataexplb[1] < $timea and $dataexplb[1] > $timed )
{
$d = $d + 1;
}
$counter++;
}
// Resultaten tonen
echo "Bezoekers vandaag: ";
echo $a;
echo "<br>";
echo "Bezoekers gisteren: ";
echo $d;
echo "<br>";
echo "Bezoekers deze week: ";
echo $b;
echo "<br>";
echo "Bezoekers deze maand: ";
echo $c;
echo "<br>";
echo "Bezoekers totaal: ";
echo $aantal;
?>
$file = "log.txt"; // Bestand waar resultaten opgeslagen worden
$time = "600"; // Aantal seconden tussen 2 hits
// Hier niets wijzigen
// Nieuwe hit wordt opgeslagen
$fo = fopen($file, 'r');
$data = fread($fo, filesize($file));
fclose($fo);
$aantal = count(explode("%%", $data));
$aantal = $aantal - 1;
$dataexpla = explode("%%", $data);
$counter = 0;
while ( $counter < $aantal )
{
$dataexplb = explode("::", $dataexpla[$counter]);
if ( $dataexplb[0] == $_SERVER['REMOTE_ADDR'] )
{
$ok = 1;
}
$counter++;
}
if ( $ok == 1 )
{
$b = $dataexplb[1];
$c = time();
$d = $c - $time;
if ( $b < $d )
{
$fo = fopen($file, 'w');
fwrite($fo, $data);
fwrite($fo, $_SERVER['REMOTE_ADDR']);
fwrite($fo, "::");
fwrite($fo, $c);
fwrite($fo, "%%");
fclose($fo);
}
}
else
{
$fo = fopen($file, 'w');
fwrite($fo, $data);
fwrite($fo, $_SERVER['REMOTE_ADDR']);
fwrite($fo, "::");
$date = time();
fwrite($fo, $date);
fwrite($fo, "%%");
fclose($fo);
}
// Resultaten berekenen
$fo = fopen($file, 'r');
$data = fread($fo, filesize($file));
fclose($fo);
$aantal = count(explode("%%", $data));
$aantal = $aantal - 1;
$dataexpla = explode("%%", $data);
$counter = 0;
$timea = time() - 86400;
$timeb = time() - 604800;
$timec = time() - 2592000;
$timed = time() - 172800;
$a = 0;
$b = 0;
$c = 0;
$d = 0;
while ( $counter < $aantal )
{
$dataexplb = explode("::", $dataexpla[$counter]);
if ( $dataexplb[1] > $timea )
{
$a = $a + 1;
}
if ( $dataexplb[1] > $timeb )
{
$b = $b + 1;
}
if ( $dataexplb[1] > $timec )
{
$c = $c + 1;
}
if ( $dataexplb[1] < $timea and $dataexplb[1] > $timed )
{
$d = $d + 1;
}
$counter++;
}
// Resultaten tonen
echo "Bezoekers vandaag: ";
echo $a;
echo "<br>";
echo "Bezoekers gisteren: ";
echo $d;
echo "<br>";
echo "Bezoekers deze week: ";
echo $b;
echo "<br>";
echo "Bezoekers deze maand: ";
echo $c;
echo "<br>";
echo "Bezoekers totaal: ";
echo $aantal;
?>