LittleDemon WebShell


Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
Path : /home/u901718425/domains/cdn.urbanpillar.in/public_html/
File Upload :
Command :
Current File : /home/u901718425/domains/cdn.urbanpillar.in/public_html/uploadDeveloperImage.php

<?php
include_once "conn.php";


$pool = new ConnectionPool();
$connection1 = $pool->getConnection();
if (!$connection1) {
    die("Connection failed");
}

if ($_POST) {
    // id is only needed for update and identify the record, so we remove it from the array
    if (isset($_POST['id'])) {
        $id = $_POST['id'];
        unset($_POST['id']);
    }

    // set date and time to Indian time 
    date_default_timezone_set("Asia/Calcutta");
    $date = date("Y-m-d H:i:s");

    // add date to the array of data by default
    $_POST['date'] = $date;

    // Handle image upload
    if (isset($_FILES['logo']) && $_FILES['logo']['error'] == UPLOAD_ERR_OK) {
        $imagePath = uploadImage($_FILES);
        $_POST['logo'] = $imagePath;
    }

    $cols = array();
    foreach ($_POST as $key => $val) {
        $cols[] = strtolower($key) . "= :$key";
    }

    // create SQL query to put keys and data to complete the query
    $set = implode(", ", $cols);

    try {
        // Define the SQL query
        $query = "UPDATE `developer` SET $set WHERE id = :id";

        // Prepare and execute the query
        $stmt = $connection1->prepare($query);
        $stmt->bindValue(':id', $id, PDO::PARAM_INT);

        // Bind values
        foreach ($_POST as $key => $val) {
            $stmt->bindValue(":$key", $val);
        }

        // Execute the query
        $result = $stmt->execute();
          work($_POST['updated_by'], $id ,'Update Developer Logo ');
        // You don't need to fetch results for an UPDATE query
        $res[0] ='success';
        $res[1] = $result;
        
    } catch (PDOException $e) {
        // Handle any connection or query errors
         $res[0] ='error';
        $res[1] = $e->getMessage();
    } finally {
        // Release the connection back to the pool
        $pool->releaseConnection($connection1);
    }

    echo json_encode($res);
}

function convert_img_to_webp($file, $targetDir) {
    $sourceFile = pathinfo($file, PATHINFO_FILENAME);
    $outputFile = $targetDir . $sourceFile . '.webp';

    $image = @imagecreatefromstring(file_get_contents($file));

    if ($image !== false) {
        imagewebp($image, $outputFile);
        imagedestroy($image);
        return $outputFile;
    }

    return false;
}

function uploadImage($file)
{
            $filename = $_FILES['image']['name'];
            $tempPath = $_FILES['image']['tmp_name'];
            $targetDir = 'uploads/' . date('Y/m/d') . '/';
            $targetPath = $targetDir .'urbanpillar_'.rand()."_". basename($filename);

            // Create the directory structure if it doesn't exist
            if (!is_dir($targetDir)) {
                mkdir($targetDir, 0777, true);
            }

            // Move the file to the specified path
            move_uploaded_file($tempPath, $targetPath);

            // Convert to WebP if it's not already
            if (pathinfo($filename, PATHINFO_EXTENSION) != 'webp') {
                $targetPath = convert_img_to_webp($targetPath, $targetDir);
            }

        return $targetPath;
}
?>

LittleDemon - FACEBOOK
[ KELUAR ]