-
Notifications
You must be signed in to change notification settings - Fork 48
/
ajax_uninitiated.php
28 lines (26 loc) · 1.16 KB
/
ajax_uninitiated.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
//Start Removing All Un-initiated Guest User Accounts
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] <= 2) {
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,limit-uptime,uptime,name');
//$printRequest->setQuery(RouterOS\Query::where('name', 'default-trial', RouterOS\Query::OP_EQ) ->not());
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if ($item->getProperty('uptime') == 0) {
$idList .= ',' . $item->getProperty('.id');
}
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
}
//End Removing All Un-initiated Guest User Accounts
?>