Tích hợp api clone v6

Ngày đăng: 2025-04-25 12:37:08 Đã xem: 26

File /ajaxs/client/napthe.php
vào edit file napthe.php xóa hết và dán đoạn này vào

<?php
define("IN_SITE", true);
require_once(__DIR__."/../../libs/db.php");
require_once(__DIR__."/../../config.php");
require_once(__DIR__."/../../libs/lang.php");
require_once(__DIR__."/../../libs/helper.php");
require_once(__DIR__."/../../libs/database/users.php");

$CMSNT = new DB();
$User = new users();
$Mobile_Detect = new Mobile_Detect();

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($CMSNT->site('status_demo') != 0) {
        die(json_encode(['status' => 'error', 'msg' => 'Bạn không được dùng chức năng này vì đây là trang web demo']));
    }
    if ($CMSNT->site('status') != 1 && isSecureCookie('admin_login') != true) {
        die(json_encode(['status' => 'error', 'msg' => __('Hệ thống đang bảo trì')]));
    }
    if ($CMSNT->site('status_napthe') != 1) {
        die(json_encode(['status' => 'error', 'msg' => __('Chức năng nạp thẻ đang được tắt')]));
    }
    if (empty($_POST['token'])) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng đăng nhập')]));
    }
    if (!$getUser = $CMSNT->get_row("SELECT * FROM `users` WHERE `token` = '".check_string($_POST['token'])."' AND `banned` = 0 ")) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng đăng nhập')]));
    }
    if (time() - $getUser['time_request'] < $config['max_time_load']) {
        die(json_encode(['status' => 'error', 'msg' => __('Bạn đang thao tác quá nhanh, vui lòng chờ')]));
    }
    if (empty($_POST['telco'])) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng chọn nhà mạng')]));
    }
    if (empty($_POST['amount'])) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng chọn mệnh giá cần nạp')]));
    }
    if ($_POST['amount'] <= 0) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng chọn mệnh giá cần nạp')]));
    }
    if (empty($_POST['serial'])) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng nhập serial thẻ')]));
    }
    if (empty($_POST['pin'])) {
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng nhập mã thẻ')]));
    }
    $telco = check_string($_POST['telco']);
    $amount = check_string($_POST['amount']);
    $serial = check_string($_POST['serial']);
    $pin = check_string($_POST['pin']);
    if (checkFormatCard($telco, $serial, $pin)['status'] != true) {
        die(json_encode(['status' => 'error', 'msg' => checkFormatCard($telco, $serial, $pin)['msg']]));
    }
    if($CMSNT->num_rows("SELECT * FROM `cards` WHERE `user_id` = '".$getUser['id']."' AND `status` = 0") > 5){
        die(json_encode(['status' => 'error', 'msg' => __('Vui lòng không spam!')]));
    }
    if(
        $CMSNT->num_rows("SELECT * FROM `cards` WHERE `status` = 2 AND `user_id` = '".$getUser['id']."' AND `create_date` >= DATE(NOW()) AND `create_date` < DATE(NOW()) + INTERVAL 1 DAY") - 
        $CMSNT->num_rows("SELECT * FROM `cards` WHERE `status` = 1 AND `user_id` = '".$getUser['id']."' AND `create_date` >= DATE(NOW()) AND `create_date` < DATE(NOW()) + INTERVAL 1 DAY") >= 5)
    {
        die(json_encode(['status' => 'error', 'msg' => __('Bạn đã bị chặn sử dụng chức năng nạp thẻ trong 1 ngày')]));
    }
    $trans_id = random('QWERTYUIOPASDFGHJKLZXCVBNM', 6).time();
    $data = card24h($telco, $amount, $serial, $pin, $trans_id);
    
    if($data['status'] == 99){
        $isInsert = $CMSNT->insert("cards", array(
            'trans_id'  => $trans_id,
            'telco'     => $telco,
            'amount'    => $amount,
            'serial'    => $serial,
            'pin'       => $pin,
            'price'     => 0,
            'user_id'   => $getUser['id'],
            'status'    => 0,
            'reason'    => '',
            'create_date'    => gettime(),
            'update_date'    => gettime()
        ));
        if ($isInsert) {
            $CMSNT->update("users", [
                'time_request' => time()
            ], " `id` = '".$getUser['id']."' ");
            $CMSNT->insert("logs", [
                'user_id'       => $getUser['id'],
                'ip'            => myip(),
                'device'        => $Mobile_Detect->getUserAgent(),
                'createdate'    => gettime(),
                'action'        => "Thực hiện nạp thẻ Serial: $serial - Pin: $pin"
            ]);
            die(json_encode(['status' => 'success', 'msg' => __('Nạp thẻ thành công, đang chờ xử lý')]));
        } else {
            die(json_encode(['status' => 'error', 'msg' => __('Nạp thẻ thất bại, vui lòng liên hệ Admin')]));
        }
    } elseif($data['status'] == 1){
        if($CMSNT->site('ck_napthe') == 0){
            $price = $amount;
        } else {
            $price = $amount - ($amount * $CMSNT->site('ck_napthe') / 100);
        }
        $isInsert = $CMSNT->insert("cards", array(
            'trans_id'  => $trans_id,
            'telco'     => $telco,
            'amount'    => $amount,
            'serial'    => $serial,
            'pin'       => $pin,
            'price'     => $price,
            'user_id'   => $getUser['id'],
            'status'    => 1,
            'reason'    => '',
            'create_date'    => gettime(),
            'update_date'    => gettime()
        ));
        if ($isInsert) {
            $User->AddCredits($getUser['id'], $price, "Nạp thẻ cào Seri ".$serial." - Pin ".$pin, 'TOPUP_CARD_'.$pin);

            $CMSNT->update("users", [
                'time_request' => time()
            ], " `id` = '".$getUser['id']."' ");
            $CMSNT->insert("logs", [
                'user_id'       => $getUser['id'],
                'ip'            => myip(),
                'device'        => $Mobile_Detect->getUserAgent(),
                'createdate'    => gettime(),
                'action'        => "Nạp thẻ thành công Serial: $serial - Pin: $pin"
            ]);
            $my_text = $CMSNT->site('naptien_notification');
            $my_text = str_replace('{domain}', $_SERVER['SERVER_NAME'], $my_text);
            $my_text = str_replace('{username}', $getUser['username'], $my_text);
            $my_text = str_replace('{method}', 'Thẻ Cào', $my_text);
            $my_text = str_replace('{amount}', $amount, $my_text);
            $my_text = str_replace('{price}', $price, $my_text);
            $my_text = str_replace('{time}', gettime(), $my_text);
            sendMessAdmin($my_text);
            
            die(json_encode(['status' => 'success', 'msg' => __('Nạp thẻ thành công, tiền đã được cộng vào tài khoản')]));
        } else {
            die(json_encode(['status' => 'error', 'msg' => __('Lỗi hệ thống, vui lòng liên hệ Admin')]));
        }
    } elseif($data['status'] == 3){
        $isInsert = $CMSNT->insert("cards", array(
            'trans_id'  => $trans_id,
            'telco'     => $telco,
            'amount'    => $amount,
            'serial'    => $serial,
            'pin'       => $pin,
            'price'     => 0,
            'user_id'   => $getUser['id'],
            'status'    => 2,
            'reason'    => 'Thẻ sai hoặc không hợp lệ',
            'create_date'    => gettime(),
            'update_date'    => gettime()
        ));
        if ($isInsert) {
            $CMSNT->update("users", [
                'time_request' => time()
            ], " `id` = '".$getUser['id']."' ");
            $CMSNT->insert("logs", [
                'user_id'       => $getUser['id'],
                'ip'            => myip(),
                'device'        => $Mobile_Detect->getUserAgent(),
                'createdate'    => gettime(),
                'action'        => "Nạp thẻ thất bại (thẻ sai) Serial: $serial - Pin: $pin"
            ]);
            die(json_encode(['status' => 'error', 'msg' => __('Thẻ sai hoặc không hợp lệ')]));
        } else {
            die(json_encode(['status' => 'error', 'msg' => __('Lỗi hệ thống, vui lòng liên hệ Admin')]));
        }
    } else {
        die(json_encode(['status' => 'error', 'msg' => isset($data['data']['msg']) ? $data['data']['msg'] : __('Lỗi không xác định')]));
    }
}

sau đó vào  thư mục libs/helper.php
edit file và tìm dòng có card24 xóa nó và dán đoạn code  thường dòng đó sẽ là dòng 1844 và dán đoạn code này vào
function card24h($telco, $amount, $serial, $pin, $trans_id){
    global $CMSNT;
    $partner_id = $CMSNT->site('partner_id_card');
    $partner_key = $CMSNT->site('partner_key_card');
    $url = base64_decode('aHR0cHM6Ly9uYXBwYXkudm4vY2hhcmdpbmd3cy92Mj9zaWduPQ==').md5($partner_key.$pin.$serial).'&telco='.$telco.'&code='.$pin.'&serial='.$serial.'&amount='.$amount.'&request_id='.$trans_id.'&partner_id='.$partner_id.'&command=charging';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    return json_decode($data, true);
}