Add remaining project files (exclude ignored folders)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../config/api_mik.php";
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
|
||||
|
||||
$arrID=$API->comm("/ip/firewall/nat/getall",
|
||||
array(
|
||||
".proplist"=> ".id",
|
||||
"?dst-port" => $m_remote ,
|
||||
));
|
||||
|
||||
$API->comm("/ip/firewall/nat/set",
|
||||
array(
|
||||
".id" => $arrID[0][".id"],
|
||||
"to-addresses" => "192.168.100.100",
|
||||
)
|
||||
);
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
|
||||
echo "<pre>";
|
||||
print_r($arrID);
|
||||
echo "</pre>";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = false;
|
||||
|
||||
if ($API->connect('192.168.12.1', 'syifa1501', 'insh4re04')) {
|
||||
|
||||
$data = $API->comm('/ip/hotspot/user/print',
|
||||
array(
|
||||
"?uptime" => "0s"
|
||||
));
|
||||
|
||||
echo "<pre>";
|
||||
print_r($data);
|
||||
echo "</pre>";
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
|
||||
|
||||
$API->write('/interface/wireless/registration-table/print',false);
|
||||
$API->write('=stats=');
|
||||
|
||||
$READ = $API->read(false);
|
||||
$ARRAY = $API->parseResponse($READ);
|
||||
|
||||
print_r($ARRAY);
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/* Example for adding a VPN user */
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect('192.168.100.23', 'admin', 'putr4bungsu08')) {
|
||||
|
||||
$API->comm('/ppp/secret/add', array(
|
||||
"name" => "user2",
|
||||
"password" => "pass2",
|
||||
"remote-address" => "192.168.5.121",
|
||||
"comment" => "BARU3",
|
||||
"service" => "pptp",
|
||||
));
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/* Example of finding registration-table ID for specified MAC */
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
|
||||
|
||||
$ARRAY = $API->comm("/interface/wireless/registration-table/print", array(
|
||||
".proplist"=> ".id",
|
||||
"?mac-address" => "00:0E:BB:DD:FF:FF",
|
||||
));
|
||||
|
||||
print_r($ARRAY);
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/* Example of counting leases from a specific IP Pool (using regexp) */
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
|
||||
|
||||
$ARRAY = $API->comm("/ip/dhcp-server/lease/print", array(
|
||||
"count-only"=> "",
|
||||
"~active-address" => "1.1.",
|
||||
));
|
||||
|
||||
print_r($ARRAY);
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/* 3 step action
|
||||
1) fetch all static dns hosts
|
||||
2) remove all static dns hosts
|
||||
3) add example host
|
||||
*/
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
$API = new RouterosAPI();
|
||||
|
||||
if ($API->connect('192.168.100.23', 'admin', 'putr4bungsu08')) {
|
||||
# Get all current hosts
|
||||
$API->write('/ip/dns/static/print');
|
||||
$ips = $API->read();
|
||||
|
||||
# delete them all !
|
||||
foreach($ips as $num => $ip_data) {
|
||||
$API->write('/ip/dns/static/remove', false);
|
||||
$API->write("=.id=" . $ip_data[".id"], true);
|
||||
}
|
||||
|
||||
#add some new
|
||||
$API->comm("/ip/dns/static/add", array(
|
||||
"name" => "jefkeklak",
|
||||
"address" => "1.2.3.4",
|
||||
"ttl" => "1m"
|
||||
));
|
||||
|
||||
#show me what you got
|
||||
$API->write('/ip/dns/static/print');
|
||||
$ips = $API->read();
|
||||
var_dump($ips);
|
||||
$API->disconnect();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
include "../../config/api_mik.php";
|
||||
|
||||
require('../routeros_api.class.php');
|
||||
|
||||
$API = new RouterosAPI();
|
||||
|
||||
$API->debug = true;
|
||||
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
|
||||
$cek = $API->comm("/ip/firewall/nat/set",
|
||||
array(
|
||||
"?dst-port" => $m_remote ,
|
||||
"to-addresses" => "192.168.100.100",
|
||||
)
|
||||
);
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
}
|
||||
echo "<pre>";
|
||||
print_r($cek);
|
||||
echo "</pre>";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user