-
Notifications
You must be signed in to change notification settings - Fork 1
/
blocked.class.php
executable file
·70 lines (51 loc) · 1.53 KB
/
blocked.class.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
<?php
namespace Corelib;
use Corelib\Func;
use Make\Database\Pdosql;
class Blocked {
static public function get_qry()
{
global $ip_qry;
$ip_ex = explode('.', MB_REMOTE_ADDR);
$ip_qry = array();
for ($i = 0; $i < count($ip_ex); $i++) {
$ip_rpt_txt = '';
$ip_rpt_ip = '';
$ip_rpt = 4 - ($i + 1);
for ($j = 0; $j < $ip_rpt; $j++) {
$ip_rpt_txt .= '.*';
}
for ($k = 0; $k <= $i; $k++) {
$ip_rpt_ip .= '.'.$ip_ex[$k];
}
$ip_qry[$i] = substr($ip_rpt_ip, 1).$ip_rpt_txt;
}
}
static public function chk_block()
{
global $MB, $ip_qry;
$localhosts = array('127.0.0.1', '::1', 'localhost', '255.255.255.0');
if (in_array(MB_REMOTE_ADDR, $localhosts)) return false;
$sql = new Pdosql();
self::get_qry();
$sql->query(
"
select *
from {$sql->table("blockmb")}
where (`ip`=:col1 or `ip`=:col2 or `ip`=:col3 or `ip`=:col4) or (`mb_idx`=:col5 and `mb_id`=:col6)
",
array(
$ip_qry[0],
$ip_qry[1],
$ip_qry[2],
$ip_qry[3],
$MB['idx'],
$MB['id']
)
);
$uri = Func::thisuri();
$loc_page = PH_DIR.'/member/warning';
if ($sql->getcount() > 0 && $uri != $loc_page) Func::location($loc_page);
}
}
Blocked::chk_block();