ip-ban-class-met-text-file
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
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
//ip_ban.inc.php
class IP_ban {
public $Filename = NULL;
function __construct($Filename) {
$this->Filename = $Filename;
}
function Ban_IP($IP, $Hours_banned) {
$Expire_date = mktime(date('H')+$Hours_banned,date('i'),date('s'),date('m'),date(d),date('Y'));
$Content = @file_get_contents($this->Filename);
$Handle = fopen($this->Filename, 'w+');
$Content = $IP."\t".$Expire_date."&\r\n".$Content;
fwrite($Handle, $Content);
fclose($Handle);
}
function Is_banned($IP) {
$Now = time();
$Handle = @fopen($this->Filename, 'r');
$Content = @fread($Handle, filesize($this->Filename));
$Content = strstr($Content, $IP);
if($Content === 0) {
return 0;
}
else {
$Content = str_replace($IP."\t", '', $Content);
$Content = explode('&', $Content);
$Expire_date = $Content[0];
if($Now > $Expire_date) {
return 0;
}
else {
return 1;
}
}
}
}
?>
//ip_ban.inc.php
class IP_ban {
public $Filename = NULL;
function __construct($Filename) {
$this->Filename = $Filename;
}
function Ban_IP($IP, $Hours_banned) {
$Expire_date = mktime(date('H')+$Hours_banned,date('i'),date('s'),date('m'),date(d),date('Y'));
$Content = @file_get_contents($this->Filename);
$Handle = fopen($this->Filename, 'w+');
$Content = $IP."\t".$Expire_date."&\r\n".$Content;
fwrite($Handle, $Content);
fclose($Handle);
}
function Is_banned($IP) {
$Now = time();
$Handle = @fopen($this->Filename, 'r');
$Content = @fread($Handle, filesize($this->Filename));
$Content = strstr($Content, $IP);
if($Content === 0) {
return 0;
}
else {
$Content = str_replace($IP."\t", '', $Content);
$Content = explode('&', $Content);
$Expire_date = $Content[0];
if($Now > $Expire_date) {
return 0;
}
else {
return 1;
}
}
}
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17