add change_username function
This commit is contained in:
parent
27aeb93b57
commit
938173cab7
@ -322,6 +322,7 @@ switch ($action) {
|
|||||||
$d->status = 'on';
|
$d->status = 'on';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// plan different then do something
|
||||||
if ($oldPlanID != $id_plan) {
|
if ($oldPlanID != $id_plan) {
|
||||||
$d->plan_id = $newPlan['id'];
|
$d->plan_id = $newPlan['id'];
|
||||||
$d->namebp = $newPlan['name_plan'];
|
$d->namebp = $newPlan['name_plan'];
|
||||||
|
@ -27,6 +27,12 @@ class Dummy {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// customer change username
|
||||||
|
public function change_username($from, $to)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add Plan to Mikrotik/Device
|
// Add Plan to Mikrotik/Device
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,27 @@ class MikrotikHotspot
|
|||||||
$this->removeHotspotActiveUser($client, $customer['username']);
|
$this->removeHotspotActiveUser($client, $customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// customer change username
|
||||||
|
public function change_username($plan, $from, $to)
|
||||||
|
{
|
||||||
|
$mikrotik = $this->info($plan['routers']);
|
||||||
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
//check if customer exists
|
||||||
|
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||||
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
|
$printRequest->setQuery(RouterOS\Query::where('name', $from));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
|
if (!empty($cid)) {
|
||||||
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||||
|
$setRequest->setArgument('numbers', $id);
|
||||||
|
$setRequest->setArgument('name', $to);
|
||||||
|
$client->sendSync($setRequest);
|
||||||
|
//disconnect then
|
||||||
|
$this->removeHotspotActiveUser($client, $from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
|
@ -42,6 +42,24 @@ class Radius
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function change_username($from, $to)
|
||||||
|
{
|
||||||
|
$c = $this->getTableCustomer()->where_equal('username', $from)->findMany();
|
||||||
|
if ($c) {
|
||||||
|
foreach ($c as $u) {
|
||||||
|
$u->username = $to;
|
||||||
|
$u->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$c = $this->getTableUserPackage()->where_equal('username', $from)->findMany();
|
||||||
|
if ($c) {
|
||||||
|
foreach ($c as $u) {
|
||||||
|
$u->username = $to;
|
||||||
|
$u->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
|
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
|
||||||
@ -169,24 +187,6 @@ class Radius
|
|||||||
return $n->save();
|
return $n->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerChangeUsername($from, $to)
|
|
||||||
{
|
|
||||||
$c = $this->getTableCustomer()->where_equal('username', $from)->findMany();
|
|
||||||
if ($c) {
|
|
||||||
foreach ($c as $u) {
|
|
||||||
$u->username = $to;
|
|
||||||
$u->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$c = $this->getTableUserPackage()->where_equal('username', $from)->findMany();
|
|
||||||
if ($c) {
|
|
||||||
foreach ($c as $u) {
|
|
||||||
$u->username = $to;
|
|
||||||
$u->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function customerDeactivate($username, $radiusDisconnect = true)
|
public function customerDeactivate($username, $radiusDisconnect = true)
|
||||||
{ {
|
{ {
|
||||||
global $radius_pass;
|
global $radius_pass;
|
||||||
|
@ -27,6 +27,11 @@ class RadiusRest {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// customer change username
|
||||||
|
public function change_username($from, $to)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Add Plan to Mikrotik/Device
|
// Add Plan to Mikrotik/Device
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,11 @@ class FileName {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// customer change username
|
||||||
|
public function change_username($from, $to)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Add Plan to Mikrotik/Device
|
// Add Plan to Mikrotik/Device
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user