pageview-limit
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
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
<?php
// PageView Limit
// No more than X pageviews in one minute.
//
// Author: Jeroen Boersma
// Email: Pianoplayer[@]Planet.nl
// 04-2005
// I've got the idea from Omerta (http://www.barafranca.nl) but ofcourse, i've written this script myself.
//
// Don't Delete this Header!
Function PageViewLimit(){
$PvlViews=15; // Number of pageviews.
$error="Sorry, but you've visited too many pages in the past 60 seconds."; // Change in the error in something you want.
session_start();
if(!isset($_SESSION['Pvl'])){
$_SESSION['Pvl']['Time']=time();
$_SESSION['Pvl']['Views']=1;
}
else{
// delete if excists longer than 60 seconds, and make a new one
if((time()-$_SESSION['Pvl']['Time']) >= 60){
session_unset();
session_destroy();
session_start();
$_SESSION['Pvl']['Time']=time();
$_SESSION['Pvl']['Views']=1;
}
else{
$_SESSION['Pvl']['Views']++;
if($_SESSION['Pvl']['Views']>=$PvlViews){
exit($error);
}
}
}
}
PageViewLimit();
?>
// PageView Limit
// No more than X pageviews in one minute.
//
// Author: Jeroen Boersma
// Email: Pianoplayer[@]Planet.nl
// 04-2005
// I've got the idea from Omerta (http://www.barafranca.nl) but ofcourse, i've written this script myself.
//
// Don't Delete this Header!
Function PageViewLimit(){
$PvlViews=15; // Number of pageviews.
$error="Sorry, but you've visited too many pages in the past 60 seconds."; // Change in the error in something you want.
session_start();
if(!isset($_SESSION['Pvl'])){
$_SESSION['Pvl']['Time']=time();
$_SESSION['Pvl']['Views']=1;
}
else{
// delete if excists longer than 60 seconds, and make a new one
if((time()-$_SESSION['Pvl']['Time']) >= 60){
session_unset();
session_destroy();
session_start();
$_SESSION['Pvl']['Time']=time();
$_SESSION['Pvl']['Views']=1;
}
else{
$_SESSION['Pvl']['Views']++;
if($_SESSION['Pvl']['Views']>=$PvlViews){
exit($error);
}
}
}
}
PageViewLimit();
?>