File: /var/www/net/3api.php
<?php
include "routeros_api.php";
include "name.php";
$vpn = $_GET['vpn'];
$mikrotik_ip = $vpn.'.sn.mynetname.net';
#$mikrotik_ip = 'hda083tab60.sn.mynetname.net';
$API = new RouterosAPI();
if ($API->connect($mikrotik_ip, $mikrotik_username,$mikrotik_password)) {
$startime = $API->comm("/system/resource/print");
$idname = $API->comm("/system/identity/print");
$chname = $API->comm("/system/note/print");
$secret = $API->comm("/ppp/secret/print");
$active = $API->comm("/ppp/active/print");
$oldday = $startime['0']['uptime'];
preg_match_all('!\d+!',$oldday,$newday);
$newdate = "主機上線:".getDay($oldday,$newday);
$test = $API->comm("/interface/pppoe-client/monitor
=.id=FTTH1
=once
");
$oldtime = $test['0']['uptime'];
preg_match_all('!\d+!',$oldtime,$newtime);
$newtimes = "1路外線上線:".getTime($oldtime,$newtime);
$test = $API->comm("/interface/pppoe-client/monitor
=.id=FTTH2
=once
");
$oldtime = $test['0']['uptime'];
preg_match_all('!\d+!',$oldtime,$newtime);
$new2times = "2路外線上線:".getTime($oldtime,$newtime);
$test = $API->comm("/interface/pppoe-client/monitor
=.id=FTTH3
=once
");
$oldtime = $test['0']['uptime'];
preg_match_all('!\d+!',$oldtime,$newtime);
$new3times = "3路外線上線:".getTime($oldtime,$newtime);
echo $idname['0']['name'].rawurldecode($chname['0']['note'])."<br>"."上線:".count($active)."戶&總數:".count($secret)."戶<br>".$newdate."<br>".$newtimes."<br>".$new2times."<br>".$new3times;
}else{
#echo "document.write('主機斷線中');";
echo"社區主機斷線中,請盡快搶修";
}
$API->disconnect();
?>