Kid Control

Hey guys,

i require help removing a device using the Pear2 api
Two lines of code below that I am using to remove the device.
I have a form created to get the name of the device to be removed that passes the variable $device_remove

$addRequest = new RouterOS\Request(‘/ip kid-control device remove’);
$addRequest->setArgument(‘name’, $_POST[‘device_remove’]);

Thanks in advance

$util->setMenu(‘/ip/kid-control/device’);
$util->remove(($_POST[‘device_remove’]));

Solved using util

Anyone have the correct API to update a current profile to another profile without deleting the existing one.
Here is what I have so far;

<?php // Receiving variables from filled form @$device_name = addslashes($_POST['device_name']); @$profile_select = addslashes($_POST['profile_select']); use PEAR2\Net\RouterOS; include_once 'PEAR2/Autoload.php'; try { $client = new RouterOS\Client($_SESSION['user']['remoteadd'],$_SESSION['user']['remoteuser'],$_SESSION['user']['remotepass']); } catch (Exception $e) { die('
Woops!! Please Forward Ports 8728 and 8291 to Router IP Address to Avoid this Warning
'); } $addRequest = new RouterOS\Request('/ip kid-control device'); $addRequest->setArgument('name', $_POST['device_name']); $addRequest->setArgument('user', $_POST['profile_select']); \ \ if ($client->sendSync($addRequest)->getType() !== RouterOS\Response::TYPE_FINAL) { die("Device already active, please remove device and set new profile"); } \ \ \ header('Location: index.php'); exit(); ?>



I want to be able to update an existing profile in kid-control without having to delete the profile to add a new one

Solution

// Receiving variables
@$device_name = addslashes($_POST[‘device_name’]);
@$profile_select = addslashes($_POST[‘profile_select’]);


use PEAR2\Net\RouterOS;
require_once ‘PEAR2/Autoload.php’;


try {
$util = new RouterOS\Util(
$client = new RouterOS\Client($_SESSION[‘user’][‘remoteadd’],$_SESSION[‘user’][‘remoteuser’],$_SESSION[‘user’][‘remotepass’])
);
} catch (Exception $e) {
die(‘

Woops!! Please Forward Ports 8728 and 8291 to Router IP Address to Avoid this Warning
’);
}


$util->setMenu(‘/ip/kid-control/device’);
$util->set(
$_POST[‘device_name’],
array(
‘user’ => $_POST[‘profile_select’]
)
);

header(‘Location: index.php’);

exit();