send Telegram for Extend

This commit is contained in:
Ibnu Maksum 2024-04-22 10:16:21 +07:00
parent fbaf9dbe3f
commit 4d6041f614
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
2 changed files with 13 additions and 8 deletions

View File

@ -148,16 +148,18 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
$router = $tur['routers'];
}
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
if(!$p){
r2(U . 'home', '3', "Plan Not Found");
}
if ($tur['routers'] == 'radius') {
Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']);
Radius::customerAddPlan($user, $p, $tur['expiration'] . ' ' . $tur['time']);
} else {
if ($tur['type'] == 'Hotspot') {
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c);
Mikrotik::removeHotspotUser($client, $user['username']);
Mikrotik::addHotspotUser($client, $p, $user);
} else if ($tur['type'] == 'PPPOE') {
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c);
Mikrotik::removePpoeUser($client, $user['username']);
Mikrotik::addPpoeUser($client, $p, $user);
}
}
// make customer cannot extend again
@ -169,6 +171,9 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
App::setToken(_get('stoken'), $id);
file_put_contents($path, $m);
_log("Customer $tur[customer_id] $tur[username] extend for $days days", "Customer", $user['id']);
Message::sendTelegram("#u$c[username] #extend #".$p['type']." \n" . $p['name_plan'] .
"\nLocation: " . $p['routers'] .
"\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time']));
r2(U . 'home', 's', "Extend until $expiration");
}else{
r2(U . 'home', 'e', "Plan is not expired");

View File

@ -141,12 +141,12 @@ function r2($to, $ntype = 'e', $msg = '')
{
if ($msg == '') {
header("location: $to");
exit;
die();
}
$_SESSION['ntype'] = $ntype;
$_SESSION['notify'] = $msg;
header("location: $to");
exit;
die();
}
function copyFolder($from, $to, $exclude = [])