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

客户端ROS脚本:

{
: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脚本:

 

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文件:

$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‘);
}

  

 

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

上一篇:Go-26-Json


下一篇:MySQL 语法整理