home
/
aioutajg
/
nerdemoji.xyz
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
[DIR] assets
N/A
[DIR] includes
N/A
[DIR] uploads
N/A
.htaccess
350 bytes
Rename
Delete
Backup.zip
27.32 MB
Rename
Delete
Image converter, resizer and compressor tool script.zip
137.55 KB
Rename
Delete
about-us.php
1.81 KB
Rename
Delete
ads.txt
58 bytes
Rename
Delete
contact-us.php
1.07 KB
Rename
Delete
cookies.php
2.99 KB
Rename
Delete
disclaimer.php
2.13 KB
Rename
Delete
index.php
3.30 KB
Rename
Delete
privacy.php
3.51 KB
Rename
Delete
process.php
9.28 KB
Rename
Delete
sitemap.xml
1.31 KB
Rename
Delete
terms.php
2.73 KB
Rename
Delete
<?php // process.php // Enable error reporting for debugging (disable in production) ini_set('display_errors', 1); error_reporting(E_ALL); // Define the uploads directory define('UPLOADS_DIR', __DIR__ . '/uploads'); // Define the maximum file age (in seconds) define('MAX_FILE_AGE', 120); // 2 minutes // Cleanup function to delete old files function cleanupUploads() { $files = glob(UPLOADS_DIR . '/*'); // Get all file names $now = time(); foreach ($files as $file) { if (is_file($file)) { if ($now - filemtime($file) >= MAX_FILE_AGE) { unlink($file); } } } } // Call the cleanup function at the start cleanupUploads(); // Check if form is submitted if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Check if image is uploaded without errors if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) { $fileTmpPath = $_FILES['image']['tmp_name']; $originalName = $_FILES['image']['name']; $originalSize = $_FILES['image']['size']; $originalType = $_FILES['image']['type']; $originalExtension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION)); // Allowed formats $allowedFormats = ['png', 'jpg', 'jpeg', 'gif', 'ico', 'tiff', 'bmp']; if (!in_array($originalExtension, $allowedFormats)) { displayError("Unsupported file format."); } // Get user inputs $convertTo = $_POST['convert_to']; $resizeWidth = isset($_POST['resize_width']) ? intval($_POST['resize_width']) : 0; $resizeHeight = isset($_POST['resize_height']) ? intval($_POST['resize_height']) : 0; $resizePercentage = isset($_POST['resize_percentage']) ? intval($_POST['resize_percentage']) : 0; $compressType = $_POST['compress_type']; $compressValue = isset($_POST['compress_value']) ? intval($_POST['compress_value']) : 0; // Create image resource switch ($originalExtension) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($fileTmpPath); break; case 'png': $image = imagecreatefrompng($fileTmpPath); break; case 'gif': $image = imagecreatefromgif($fileTmpPath); break; case 'bmp': $image = imagecreatefrombmp($fileTmpPath); break; case 'ico': // ICO handling can be complex; using imagecreatefrompng as placeholder $image = imagecreatefrompng($fileTmpPath); break; case 'tiff': // TIFF requires Imagick if (extension_loaded('imagick')) { $imagick = new Imagick($fileTmpPath); $imagick->setImageFormat($convertTo); $imageData = $imagick->getImageBlob(); // Generate a unique filename $uniqueId = uniqid('converted_'); $newFileName = $uniqueId . '.' . $convertTo; $finalPath = UPLOADS_DIR . '/' . $newFileName; file_put_contents($finalPath, $imageData); displayResult($newFileName); exit; } else { displayError("TIFF format requires the Imagick extension."); } break; default: displayError("Unsupported format."); } if (!$image) { displayError("Failed to create image from the uploaded file."); } // Get original dimensions $origWidth = imagesx($image); $origHeight = imagesy($image); // Resize image if needed if ($resizeWidth > 0 && $resizeHeight > 0) { $newWidth = $resizeWidth; $newHeight = $resizeHeight; } elseif ($resizePercentage > 0) { $newWidth = round($origWidth * ($resizePercentage / 100)); $newHeight = round($origHeight * ($resizePercentage / 100)); } else { $newWidth = $origWidth; $newHeight = $origHeight; } if ($newWidth != $origWidth || $newHeight != $origHeight) { $resizedImage = imagecreatetruecolor($newWidth, $newHeight); // Preserve transparency for PNG and GIF if (in_array($convertTo, ['png', 'gif'])) { imagecolortransparent($resizedImage, imagecolorallocatealpha($resizedImage, 0, 0, 0, 127)); imagealphablending($resizedImage, false); imagesavealpha($resizedImage, true); } imagecopyresampled($resizedImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight); imagedestroy($image); $image = $resizedImage; } // Prepare for compression $quality = 90; // Default quality $targetSizeKB = 0; if ($compressType === 'quality' && $compressValue > 0) { $quality = $compressValue; } elseif ($compressType === 'size' && $compressValue > 0) { $targetSizeKB = $compressValue; } // Generate a unique filename $uniqueId = uniqid('converted_'); $newFileName = $uniqueId . '.' . $convertTo; $tempFile = UPLOADS_DIR . '/' . $newFileName; // Function to save image based on type $saveImage = function($image, $format, $path, $quality) { switch ($format) { case 'jpg': case 'jpeg': imagejpeg($image, $path, $quality); break; case 'png': // PNG quality: 0 (no compression) to 9 $pngQuality = 9 - round($quality / 10); imagepng($image, $path, $pngQuality); break; case 'gif': imagegif($image, $path); break; case 'bmp': imagebmp($image, $path); break; case 'ico': // ICO handling is not supported by GD; using PNG as placeholder imagepng($image, $path); break; default: // For other formats, attempt JPEG imagejpeg($image, $path, $quality); } }; // Initial save $saveImage($image, $convertTo, $tempFile, $quality); // If target size is specified, perform iterative compression if ($targetSizeKB > 0) { $maxAttempts = 10; $minQuality = 10; $currentQuality = $quality; while (filesize($tempFile) / 1024 > $targetSizeKB && $currentQuality > $minQuality && $maxAttempts > 0) { $currentQuality -= 10; $saveImage($image, $convertTo, $tempFile, $currentQuality); $maxAttempts--; } if (filesize($tempFile) / 1024 > $targetSizeKB) { // Unable to reach target size // Proceed with the best effort } } // Free memory imagedestroy($image); if (isset($imagick)) { $imagick->clear(); $imagick->destroy(); } // Display the result displayResult($newFileName); } else { displayError("No image uploaded or there was an upload error."); } } else { displayError("Invalid request method."); } // Function to display the result using the theme function displayResult($newFileName) { // Construct the URL to the uploaded file // Assuming 'uploads' is directly accessible via the web // Adjust the base URL if 'uploads' is in a subdirectory $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $domain = $_SERVER['HTTP_HOST']; $scriptDir = dirname($_SERVER['PHP_SELF']); $uploadsUrl = rtrim($protocol . $domain . $scriptDir, '/') . '/uploads/' . $newFileName; // Include the theme include 'includes/head.php'; echo '<body>'; include 'includes/header.php'; ?> <div class="container"> <h2>Image Conversion Successful!</h2> <div class="result"> <img src="<?php echo htmlspecialchars($uploadsUrl); ?>" alt="Converted Image"> </div> <a href="<?php echo htmlspecialchars($uploadsUrl); ?>" download>Download Image</a><br><br> <a href="/">Convert Another Image</a> </div> <?php include 'includes/footer.php'; echo '</body></html>'; exit; } // Function to display an error using the theme function displayError($errorMessage) { // Include the theme include 'includes/head.php'; echo '<body>'; include 'includes/header.php'; ?> <div class="container"> <h2>Error</h2> <p><?php echo htmlspecialchars($errorMessage); ?></p> <a href="/">Go Back</a> </div> <?php include 'includes/footer.php'; echo '</body></html>'; exit; } ?>
Save