ÿØÿà JFIF H H ÿÛ C GIF89;
| System: Linux in-mum-web1642.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64 Current Path : /home/u323559503/domains/purplelimonada.com/public_html/panel/admin/app/ |
| Current File : /home/u323559503/domains/purplelimonada.com/public_html/panel/admin/app/services.php |
<?php
session_start();
include '../../assets/constant/config.php';
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_POST['submit'])) {
$uploadDir = '../../assets/images/';
if (!empty($_FILES['photo']['tmp_name'])) {
$originalName = basename($_FILES['photo']['name']);
$extension = pathinfo($originalName, PATHINFO_EXTENSION);
$newName = uniqid() . '.' . $extension;
$newFilePath = $uploadDir . $newName;
if (move_uploaded_file($_FILES['photo']['tmp_name'], $newFilePath)) {
$img = $newName;
// compressImage($newFilePath, $newFilePath, 75);
} else {
echo 'There was an error uploading the file.';
// Handle the error appropriately (e.g., log it)
exit;
}
}
$uploadDir1 = '../../assets/images/';
if (!empty($_FILES['icon']['tmp_name'])) {
$originalName1 = basename($_FILES['icon']['name']);
$extension1 = pathinfo($originalName1, PATHINFO_EXTENSION);
$newName1 = uniqid() . '.' . $extension1;
$newFilePath1= $uploadDir1 . $newName1;
if (move_uploaded_file($_FILES['icon']['tmp_name'], $newFilePath1)) {
$img1 = $newName1;
// compressImage($newFilePath, $newFilePath, 75);
} else {
echo 'There was an error uploading the file.';
// Handle the error appropriately (e.g., log it)
exit;
}
}
$stmt = $conn->prepare("INSERT INTO `service`(`heading`,`short_content`,`content`,`photo`,`photo1` ,`metatitle`,`metadescription`,`keywords`,`robots`) VALUES (?,?,?,?,?,?,?,?,?)");
$stmt->execute([
htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['short_content'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['content'], ENT_QUOTES, 'UTF-8'),
$img,
$img1,
htmlspecialchars($_POST['metatitle'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['metadescription'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['keywords'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['robots'], ENT_QUOTES, 'UTF-8')
]);
$_SESSION['success'] = "success";
header("location:../manage_service.php");
}
if (isset($_POST['update'])) {
// Update main photo
if (!empty($_FILES['photo']['tmp_name'])) {
$file_extension = pathinfo($_FILES["photo"]["name"], PATHINFO_EXTENSION);
$new_filename = uniqid() . '.' . $file_extension;
$filepath = "../../assets/images/" . $new_filename;
if (move_uploaded_file($_FILES["photo"]["tmp_name"], $filepath)) {
$img = $new_filename;
@unlink("../../assets/images/" . htmlspecialchars($_POST['old_photo_img'], ENT_QUOTES, 'UTF-8'));
} else {
// Handle failed upload
// You might want to add error handling here
}
} else {
// Keep the old photo if no new one is uploaded
$img = htmlspecialchars($_POST['old_photo_img'], ENT_QUOTES, 'UTF-8');
}
// Update secondary photo
if (!empty($_FILES['icon']['tmp_name'])) {
$file_extension = pathinfo($_FILES["icon"]["name"], PATHINFO_EXTENSION);
$new_filename = uniqid() . '.' . $file_extension;
$filepath = "../../assets/images/" . $new_filename;
if (move_uploaded_file($_FILES["icon"]["tmp_name"], $filepath)) {
$img1 = $new_filename;
@unlink("../../assets/images/" . htmlspecialchars($_POST['old_icon_img'], ENT_QUOTES, 'UTF-8'));
} else {
// Handle failed upload
// You might want to add error handling here
}
} else {
// Keep the old icon if no new one is uploaded
$img1 = htmlspecialchars($_POST['old_icon_img'], ENT_QUOTES, 'UTF-8');
}
// Prepare and execute the SQL update statement
$stmt = $conn->prepare("UPDATE `service` SET `heading`=?, `short_content`=?,`content`=?,`photo`=?,`photo1`=? ,`metatitle`=?,`metadescription`=?,`keywords`=?,`robots`=? WHERE id=? ");
$stmt->execute([
htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['short_content'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['content'], ENT_QUOTES, 'UTF-8'),
$img,
$img1,
htmlspecialchars($_POST['metatitle'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['metadescription'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['keywords'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['robots'], ENT_QUOTES, 'UTF-8'),
htmlspecialchars($_POST['id'], ENT_QUOTES, 'UTF-8')
]);
$_SESSION['update'] = "update";
header("location:../manage_service.php");
}
if (isset($_POST['del_id'])) {
$stmt = $conn->prepare("UPDATE `service` SET delete_status='1' where id=? ");
$stmt->execute([htmlspecialchars($_POST['del_id'], ENT_QUOTES, 'UTF-8')]);
$_SESSION['delete'] = "delete";
header("location:../manage_service.php");
}
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}