if has keyword, then add to user recharge
This commit is contained in:
parent
2b104d2ed7
commit
4d7c2bd373
@ -276,11 +276,9 @@ class Package
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
// if started with voucher, don't insert into tbl_user_recharges
|
|
||||||
// this is not necessary, but in case a bug come
|
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
||||||
if (strlen($p['device']) > 7 && substr($p['device'], 0, 7) == 'Voucher') {
|
if (Validator::containsKeyword($p['device'])) {
|
||||||
// maybe something need in here for buy Voucher
|
|
||||||
}else{
|
|
||||||
$b->customer_id = $id_customer;
|
$b->customer_id = $id_customer;
|
||||||
$b->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
$b->plan_id = $plan_id;
|
$b->plan_id = $plan_id;
|
||||||
@ -392,10 +390,9 @@ class Package
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if started with voucher, don't insert into tbl_user_recharges
|
|
||||||
if (strlen($p['device']) > 7 && substr($p['device'], 0, 7) == 'Voucher') {
|
|
||||||
|
|
||||||
}else{
|
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
||||||
|
if (Validator::containsKeyword($p['device'])) {
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
$d->customer_id = $id_customer;
|
$d->customer_id = $id_customer;
|
||||||
$d->username = $c['username'];
|
$d->username = $c['username'];
|
||||||
|
@ -301,7 +301,8 @@ class Validator
|
|||||||
return (bool)in_array($format, $formats);
|
return (bool)in_array($format, $formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function countRouterPlan($plans, $router){
|
public static function countRouterPlan($plans, $router)
|
||||||
|
{
|
||||||
$n = 0;
|
$n = 0;
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($plan['routers'] == $router) {
|
if ($plan['routers'] == $router) {
|
||||||
@ -311,7 +312,8 @@ class Validator
|
|||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isRouterHasPlan($plans, $router){
|
public static function isRouterHasPlan($plans, $router)
|
||||||
|
{
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($plan['routers'] == $router) {
|
if ($plan['routers'] == $router) {
|
||||||
return true;
|
return true;
|
||||||
@ -320,4 +322,9 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function containsKeyword($string, $keywords = ['mikrotik', 'hotspot', 'pppoe', 'radius', 'dummy'])
|
||||||
|
{
|
||||||
|
$regex = '/' . implode('|', $keywords) . '/i';
|
||||||
|
return preg_match($regex, $string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user