#!/usr/local/bin/php
<?
$f=date("Ymd")-1;
$f=$f.".rl1"; # name the file for boot to sql
$d="/usr/home/admin/traflog_i/"; # directory whee file
$f=$d.$f;
$fo=fopen($f,"r");
// skip 4 lines
for ($i=1;$i<=4;$i++) {
$st=fgets($fo);
}
include("setup.php");
$conn=mysql_connect($host,$mysql_user,$mysql_pass) or DIE("not connect to MySql");
@mysql_select_db("firewall") or die("not select base firewall");
// GoGo!
$pole7=date("Ymd")-1; # date
do {
# echo $pole1." --> ".$pole3." = ".$pole6."\r\n";
# echo $result."-" ;
$st=fgets($fo);
$pole1=trim(substr($st,0,15)); # ot
$pole2=trim(substr($st,19,6)); # port_ot
$pole3=trim(substr($st,27,15)); # to
$pole4=trim(substr($st,46,6)); # port_to
$pole5=trim(substr($st,54,4)); # proto
$pole6=trim(substr($st,69,10)); # bates all
if (empty($pole1)) {break;}
mysql_query("insert into `traffic` values('$pole1','$pole2','$pole3','$pole4','$pole5','$pole6','$pole7')");
} while (!feof($fo));
$sql_clo=mysql_close($conn);
$fc=fclose($fo);
?>
(Добавление)
Вот собственно творение от начала до конца. Может мысля зашивелится. Я пока по ссылке фаг поизучаю
|