Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/vhost/itms.arukustech.com/public/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhost/itms.arukustech.com/public/api/rented_return.php
<?php
require_once __DIR__ . '/../../app/db.php';
require_once __DIR__ . '/../../app/helpers/auth.php';
auth();

if (!isset($_GET['id'])) {
    header("Location: /rented_assign_list.php?error=invalid");
    exit;
}

$pdo = db();
$assignId = (int) $_GET['id'];
$admin_id = $_SESSION['user_id']; // Track who is processing the return

/* GET ASSIGNMENT DETAILS */
$stmt = $pdo->prepare("
    SELECT rented_inventory_id 
    FROM rented_assignments 
    WHERE id = ? AND status='assigned'
");
$stmt->execute([$assignId]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$row) {
    header("Location: /rented_assign_list.php?error=already_returned");
    exit;
}

try {
    $pdo->beginTransaction();

    /* 1. UPDATE ASSIGNMENT - Sets 'Returned' status and timestamp */
    $pdo->prepare("
        UPDATE rented_assignments 
        SET status='returned',
            returned_at=NOW(),
            returned_by=? 
        WHERE id = ?
    ")->execute([$admin_id, $assignId]);

    /* 2. UPDATE INVENTORY - Makes it available for next assignment */
    $pdo->prepare("
        UPDATE rented_inventory 
        SET status='available',
            assigned_to=NULL,
            assigned_at=NULL,
            project_name=NULL
        WHERE id = ?
    ")->execute([$row['rented_inventory_id']]);

    $pdo->commit();
    header("Location: /rented_assign_list.php?msg=Item returned successfully");
    exit;

} catch (Exception $e) {
    $pdo->rollBack();
    header("Location: /rented_assign_list.php?error=failed");
    exit;
}

Youez - 2016 - github.com/yon3zu
LinuXploit