HEX
Server: Apache/2.4.37 (CentOS Stream) OpenSSL/1.1.1k
System: Linux ysnet.com.tw 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User: test (521)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //var/www/net/2api.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);
	echo $idname['0']['name'].rawurldecode($chname['0']['note'])."<br>"."上線:".count($active)."戶&總數:".count($secret)."戶<br>".$newdate."<br>".$newtimes."<br>".$new2times;
	}else{
			echo "document.write('主機斷線中');";
	}
	$API->disconnect();
?>