<?php session_start(); include '../../assets/constant/config.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (isset($_POST['submit'])) { // print_r($_POST);exit; $uploadDir = '../../assets/images/'; if (!empty($_FILES['photo']['tmp_name'])) { $originalName = basename($_FILES['photo']['name']); $extension = pathinfo($originalName, PATHINFO_EXTENSION); $newName = rand(100, 999) . '.' . $extension; $newFilePath = $uploadDir . $newName; if (move_uploaded_file($_FILES['photo']['tmp_name'], $newFilePath)) { $img = $newName; // Compression Logic // compressImage($newFilePath, $newFilePath, 75); // 75 is the compression quality } else { echo 'There was an error uploading the file.'; exit; } } $stmt = $conn->prepare("INSERT INTO `service`(`heading`,`short_content`,`photo` , `content`) VALUES (?,?,?,?)"); $stmt->execute([ htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($_POST['short_content'], ENT_QUOTES, 'UTF-8'), $img, htmlspecialchars($_POST['content'], ENT_QUOTES, 'UTF-8'), ]); $st = $conn->prepare("SELECT * FROM subscribe "); $st->execute(); $rw=$st->fetchALL(); foreach($rw as $tg){ $rt= $tg['email']; } // email start $stmt = $conn->prepare("SELECT * FROM emailsetting"); $stmt->execute(); $result = $stmt->fetchAll(); //print_r($result); foreach ($result as $row) { $smtp_server = $row['smtp_server']; $smtp_password = $row['smtp_password']; $smtp_enc = $row['smtp_type']; $smtp_username = $row['smtp_username']; $smtp_port = $row['stmp_port']; // $email = $row['email']; $email = $rt; } $dt = date('Y-m-d H:i:s'); $msg1 = " Dear Subscriber,<br><br> Thank you for subscribing to Bharatiya Open Volunteer Association (OVA)! We're excited to keep you informed with the latest services updates.<br><br> You can view our latest services and updates by clicking the link below:<br> <a href='https://system365.cloud/ova/service.php'>Bharatiya Open Volunteer Association (OVA)</a><br><br> Stay tuned for latest services, in-depth analysis, and exclusive coverage delivered right to you.<br><br> Best regards,<br> The Bharatiya Open Volunteer Association (OVA) Team "; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = $smtp_server; $mail->SMTPAuth = true; $mail->Username = $smtp_username; $mail->Password = $smtp_password; $mail->SMTPSecure = $smtp_enc; $mail->Port = $smtp_port; $mail->setFrom($smtp_username); $mail->addAddress($email); $mail->isHTML(true); $mail->Subject = 'Bharatiya Open Volunteer Association (OVA)' . $dt; $mail->Body = $msg1; $mail->AltBody = $msg1; $mail->send(); $_SESSION['success'] = "Added Service"; ?> <script> // Redirect to ../about_seo.php window.location.href = "../manage_service.php"; </script> <?php } ////update Services if (isset($_POST['update'])) { if (!empty($_FILES['photo']['tmp_name'])) { $file_extension = pathinfo(htmlspecialchars($_FILES["photo"]["name"], ENT_QUOTES, 'UTF-8'), PATHINFO_EXTENSION); $new_filename = uniqid() . '.' . $file_extension; $filepath = "../../assets/images/" . $new_filename; if (move_uploaded_file($_FILES["photo"]["tmp_name"], $filepath)) { $img = $new_filename; // Compression Logic // compressImage($filepath, $filepath, 75); // 75 is the compression quality @unlink("../../assets/images/" . $_POST['old_photo_img']); } } else { $img = $_POST['old_photo_img']; } // Prepare and execute the SQL update statement $stmt = $conn->prepare("UPDATE `service` SET `heading`=?, `short_content`=?,`photo`=?,`content`=? WHERE id=? "); $stmt->execute([ htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($_POST['short_content'], ENT_QUOTES, 'UTF-8'), $img, // $img12, htmlspecialchars($_POST['content'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($_POST['id'], ENT_QUOTES, 'UTF-8') ]); $_SESSION['success'] = "Service Updated"; ?> <script> // Redirect to ../about_seo.php window.location.href = "../manage_service.php"; </script> <?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['success'] = "Service Deleted"; ?> <script> // Redirect to ../about_seo.php window.location.href = "../manage_service.php"; </script> <?php } } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } function compressImage($source, $destination, $quality) { $info = getimagesize($source); if ($info['mime'] == 'image/jpeg') { $image = imagecreatefromjpeg($source); imagejpeg($image, $destination, $quality); } elseif ($info['mime'] == 'image/png') { $image = imagecreatefrompng($source); imagepng($image, $destination, round(9 - ($quality / 10))); // PNG quality ranges from 0 to 9 } }