diff --git a/.htaccess b/.htaccess index 1283c6e..e69de29 100644 --- a/.htaccess +++ b/.htaccess @@ -1,2 +0,0 @@ -RewriteEngine On -RewriteRule ^test_redirect$ /index.php [R=302,L] \ No newline at end of file diff --git a/includes/ImageProcessor.php b/includes/ImageProcessor.php new file mode 100644 index 0000000..00cffea --- /dev/null +++ b/includes/ImageProcessor.php @@ -0,0 +1,125 @@ += 0) { + // Get the transparent color from the original image + $trnprt_color = imagecolorsforindex($image, $trnprt_indx); + // Allocate the same color in the new image + $trnprt_indx = imagecolorallocate($resizedImage, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); + imagefill($resizedImage, 0, 0, $trnprt_indx); + imagecolortransparent($resizedImage, $trnprt_indx); + } + } + + imagecopyresampled($resizedImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); + + $success = false; + switch ($mimeType) { + case 'image/jpeg': + $success = imagejpeg($resizedImage, $imagePath, 90); // 90% quality + break; + case 'image/png': + $success = imagepng($resizedImage, $imagePath); + break; + case 'image/gif': + $success = imagegif($resizedImage, $imagePath); + break; + } + + imagedestroy($image); + imagedestroy($resizedImage); + + return $success; + } +} diff --git a/index.php b/index.php index 7ef7f17..13dec30 100644 --- a/index.php +++ b/index.php @@ -25,25 +25,6 @@ -queryString; -} -?> -
-        DEBUG INFORMATION:
-        GET Parameters: 
-        Current Category ID: 
-        Current Category Name: 
-        Current Links Count: 
-        Raw Query String: 
-        SQL Query for links: 
-    
- prepare( - "SELECT l.*, s.name as subcategory_name FROM links l " . - "JOIN subcategories s ON l.subcategory_id = s.id " . - "WHERE s.category_id = ? AND l.status = \'approved\' ORDER BY s.name ASC, l.created_at DESC" + "SELECT l.*, s.name as subcategory_name FROM links l " . + "JOIN subcategories s ON l.subcategory_id = s.id " . + "WHERE s.category_id = ? AND l.status = 'approved' ORDER BY s.name ASC, l.created_at DESC" ); $link_stmt->execute([$current_category_id]); } else { @@ -87,7 +68,16 @@ if ($current_category_id) { ); } $current_links = $link_stmt->fetchAll(); - +?> +
+        DEBUG INFORMATION:
+        GET Parameters: 
+        Current Category ID: 
+        Current Category Name: 
+        Current Links Count: 
+        Raw Query String: 
+        SQL Query for links: queryString ?? "SQL Query not set yet."); ?>
+    
diff --git a/submit.php b/submit.php index aae7963..4f91207 100644 --- a/submit.php +++ b/submit.php @@ -1,6 +1,7 @@ prepare("INSERT INTO links (user_id, subcategory_id, title, url, description, thumbnail_url, status) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$_SESSION['user_id'], $subcategory_id, $title, $url, $description, $thumbnail_url, $status]); @@ -90,7 +100,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {

Thank you for your submission! It will be reviewed shortly.

-
+
@@ -123,6 +133,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
+ +