Jump to content

Ip-sentinel + Stargazer


Recommended Posts

на ваш суд выкладываю скрипт привязки биллинга к программе блокировки

внимание скрипт работает таким образом блокирует всех кроме тех у кого положительный баланс

для нормаьной его работы рекомендуеться привязывать еще ip + mac

arp -s ip mac

все пожелания и предложения писать сюда

скрип запускать при старте биллинга и в файле /etc/stargazer/OnChange

cat /etc/rc.d/block_unpaid

#!/usr/bin/php
<?
$data="0.0.0.0/0\n";
$d = dir("/var/stargazer/users");
while (false !== ($entry = $d->read())) {
if (($entry[0]<>".")){

$cash=shell_exec("cat /var/stargazer/users/".$entry."/stat|grep Cash|cut -d \"=\" -f2");
$pass=shell_exec("cat /var/stargazer/users/".$entry."/conf|grep Tariff|cut -d \"=\" -f2");

{
$ip=shell_exec("cat /var/stargazer/users/".$entry."/conf|grep IP|cut -d \"=\" -f2");
$ip=trim($ip);
$mac=shell_exec("arp -an|grep ".$ip."\)|cut -d \"(\" -f2 |cut -d \" \" -f3");
if ($cash>0)
if (trim($mac) !="<incomplete>")
      $data.=$ip."@!".$mac."\n";
  else
      $data.="!".$ip."\n";
}
}
}

file_put_contents("/var/lib/ip-sentinel/ips.cfg",$data);
?> 

Link to post
Share on other sites

для мускуля

 

#!/usr/bin/php

<?

$data="0.0.0.0/0\n";

@mysql_connect("localhost","LOGIN","PASSWORD") or die('Sorry can`t connect to database');

@mysql_select_db("stg") or die('error db');

$sql="SELECT * FROM `users` WHERE `Cash` >0";

$res=mysql_query($sql) or die ('error query');

while ($row = mysql_fetch_array($res)) {

$ip=trim($row['IP']);

$mac=shell_exec("arp -an|grep ".$ip."\)|cut -d \"(\" -f2 |cut -d \" \" -f3");

if ($row['Cash']>0)

if (trim($mac) !="<incomplete>")

$data.=$ip."@!".$mac."\n";

else

$data.="!".$ip."\n";

}

}

}

 

file_put_contents("/var/lib/ip-sentinel/ips.cfg",$data);

?>

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...