ROS白名单服务端PHP脚本,客户端ROS脚本

客户端ROS脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
:global rosid
:global addlist do={
/ip firewall address-list
:if (""=[find list=white_list address="$1"]) do={
add list=whitelist address="$1" timeout=2m
} else={
set [find list=white_list address="$1"] timeout=2m
}
}
 
 
:local ser "http://www.ip99.xyz/shortproxy.php\?rosid=$rosid"
/tool fetch url="$ser" mode=http dst-path=iplist.rsc
:delay 1
/import file=iplist.rsc
:delay 1
/file remove [find name=iplist.rsc]
}

  服务端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
if ( isset($_GET['rosid'])) {
    header('Content-type: text/plain');
    $rosid=filter_input(INPUT_GET,'rosid');
    $rosid=(int)$rosid;
    if($rosid>0) {
 
    } else {
        echo "no rosid";
        exit(0);
    }
    require_once './db/ip99.php';
    $sql="select getiplist('$rosid')";
    $conn=mysql_connect($host,$user,$pass);
    if (!$conn) {die("could not connect to the database.\n");}
    mysql_query("set names 'utf8'");
    $res=mysql_select_db($db);
    echo ":global addlist\r\n";
 
    $sql="select ipaddress from {$tb_whiteip} where expiration>now() and find_in_set($rosid,areas)";
    $res=mysql_query($sql,$conn);
    while($row=mysql_fetch_row($res)) {
        $ip=$row[0];
        if(strlen(trim($ip))>7) {
            echo " \$addlist $ip\r\n";
        }
    }
    mysql_close($conn);
    exit(0);
}

  数据库 PHP文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$host='www.ip99.xyz';
$user='user';
$pass='pass';
$db='dbname';
 
$tb_whiteip='whiteip';
 
$conn=mysqli_connect($host,$user,$pass,$db);
if (mysqli_errno($conn)) {
    die('db connect error:' . mysqli_error($conn)); 
     
} else {
    mysqli_set_charset($conn,'utf8');
}

  

 

posted @   嗷嗷鹿鸣[VX|dshoub]  阅读(350)  评论(0编辑  收藏  举报
编辑推荐:
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示