Auto increment updaten
Raar ik krijg het niet voor elkaar, ik post hier mn hele pagina ff, hoop dat het niet voor overlast zorgt
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?
session_start();
$_SESSION['userData'];
$verloopdata = time() + 86400;
setcookie('countProtect','count_al_geregistreerd', $verloopdata, '','*.gigabyte.barrypostma.com');
?>
session_start();
$_SESSION['userData'];
$verloopdata = time() + 86400;
setcookie('countProtect','count_al_geregistreerd', $verloopdata, '','*.gigabyte.barrypostma.com');
?>
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
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
<?
$server = "localhost"; // Your mySQL Server
$db_user = "zeg ik niet"; // Your mySQLUsername
$db_pass = "blijft ook geheim"; // Your mySQLPassword
$database = "barrypos_visitors"; // Your mySQLDatabasename
$timeoutseconds = 120;
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
//IP adres verkrijgen
if(getenv($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = getenv($_SERVER['HTTP_X_FORWARDED_FOR']);
} elseif(getenv($_SERVER['HTTP_CLIENT_IP'])) {
$ip = getenv($_SERVER['HTTP_CLIENT_IP']);
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$host = gethostbyaddr($ip);
$dblink = mysql_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");
mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF','$session')") or die("Useronline Database INSERT Error");
$checkclient = mysql_query("SELECT * FROM visits WHERE ip = '". $ip ."' AND host = '". $host ."' ");
if(!$checkclient) {
if($_COOKIE['countProtect'] == "count_al_geregistreerd") {
$insertHostAndIP = mysql_db_query($database, "INSERT INTO visits VALUES ('','$ip','$host')");
$updateVisit = mysql_query("UPDATE visits SET bezoek = bezoek+1");
}
} else {
$updateVisit = mysql_query("UPDATE visits SET bezoek = bezoek+1");
}
$getVisits = "SELECT bezoek FROM visits WHERE ip = ". $ip ."";
$visitResults = mysql_query($getVisits);
mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout") or die("Useronline Database DELETE Error");
$result=mysql_db_query($database, "SELECT DISTINCT session FROM useronline") or die("Useronline Database SELECT Error");
$user =mysql_num_rows($result);
mysql_close();
if($user==1) {
echo "Er is ". $user . " Bezoeker online<br />";
} else {
echo "Er zijn" . $user . " Bezoekers online<br />";
}
while($nrVisits = mysql_fetch_array($visitResults)) {
if($getVisits['bezoek'] > 1) {
echo "U hebt deze pagina " . $nrVisits['bezoek'] . " keer bezocht...<br />";
}
else {
echo "Welkom, dit is uw eerste bezoek<br />";
}
}
echo "Uw IP adres is: " . $ip . "<br />";
echo "U bent verbonden via host: " . $host . "<br />";
echo "<input type=\"submit\" name=\"delete\" value=\"delete the cookie\" /><br />";
if($delete) {
setcookie('countProtect');
}
?>
$server = "localhost"; // Your mySQL Server
$db_user = "zeg ik niet"; // Your mySQLUsername
$db_pass = "blijft ook geheim"; // Your mySQLPassword
$database = "barrypos_visitors"; // Your mySQLDatabasename
$timeoutseconds = 120;
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
//IP adres verkrijgen
if(getenv($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = getenv($_SERVER['HTTP_X_FORWARDED_FOR']);
} elseif(getenv($_SERVER['HTTP_CLIENT_IP'])) {
$ip = getenv($_SERVER['HTTP_CLIENT_IP']);
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$host = gethostbyaddr($ip);
$dblink = mysql_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");
mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF','$session')") or die("Useronline Database INSERT Error");
$checkclient = mysql_query("SELECT * FROM visits WHERE ip = '". $ip ."' AND host = '". $host ."' ");
if(!$checkclient) {
if($_COOKIE['countProtect'] == "count_al_geregistreerd") {
$insertHostAndIP = mysql_db_query($database, "INSERT INTO visits VALUES ('','$ip','$host')");
$updateVisit = mysql_query("UPDATE visits SET bezoek = bezoek+1");
}
} else {
$updateVisit = mysql_query("UPDATE visits SET bezoek = bezoek+1");
}
$getVisits = "SELECT bezoek FROM visits WHERE ip = ". $ip ."";
$visitResults = mysql_query($getVisits);
mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout") or die("Useronline Database DELETE Error");
$result=mysql_db_query($database, "SELECT DISTINCT session FROM useronline") or die("Useronline Database SELECT Error");
$user =mysql_num_rows($result);
mysql_close();
if($user==1) {
echo "Er is ". $user . " Bezoeker online<br />";
} else {
echo "Er zijn" . $user . " Bezoekers online<br />";
}
while($nrVisits = mysql_fetch_array($visitResults)) {
if($getVisits['bezoek'] > 1) {
echo "U hebt deze pagina " . $nrVisits['bezoek'] . " keer bezocht...<br />";
}
else {
echo "Welkom, dit is uw eerste bezoek<br />";
}
}
echo "Uw IP adres is: " . $ip . "<br />";
echo "U bent verbonden via host: " . $host . "<br />";
echo "<input type=\"submit\" name=\"delete\" value=\"delete the cookie\" /><br />";
if($delete) {
setcookie('countProtect');
}
?>