-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathajax_del_profile.php
40 lines (34 loc) · 1.13 KB
/
ajax_del_profile.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
29
30
31
32
33
34
35
36
37
38
39
40
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
if ( !isset($_SESSION) ) session_start();
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$profile_name=strtolower($_GET['profile_name']);
if ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$printRequest = new RouterOS\Request('/ip hotspot user profile print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
$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 profile remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
echo 2; //Success
}
else
{
echo 1; //Profile name Empty
}
}
else
{
echo 0; //Not Authorised
}
?>