Community discussions

 
flynno
Member Candidate
Member Candidate
Topic Author
Posts: 186
Joined: Wed Aug 27, 2014 8:11 pm

Kid Control

Thu Dec 06, 2018 11:14 pm

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
 
flynno
Member Candidate
Member Candidate
Topic Author
Posts: 186
Joined: Wed Aug 27, 2014 8:11 pm

Re: Kid Control

Fri Dec 07, 2018 5:57 pm

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

Solved using util
 
flynno
Member Candidate
Member Candidate
Topic Author
Posts: 186
Joined: Wed Aug 27, 2014 8:11 pm

Re: Kid Control

Sat Dec 08, 2018 5:27 pm

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('<div class="alert alert-danger" role="alert">Woops!! Please <b>Forward Ports 8728 and 8291</b> to Router IP Address to Avoid this Warning</div>');
}

$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
 
flynno
Member Candidate
Member Candidate
Topic Author
Posts: 186
Joined: Wed Aug 27, 2014 8:11 pm

Re: Kid Control  [SOLVED]

Sun Dec 09, 2018 11:30 pm

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('<div class="alert alert-danger" role="alert">Woops!! Please <b>Forward Ports 8728 and 8291</b> to Router IP Address to Avoid this Warning</div>');
}


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

header('Location: index.php');

exit();

Who is online

Users browsing this forum: No registered users and 6 guests