Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/bond-lounge.com/public_html/admin9120/ |
<?php session_start();
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?>, Admin, PDF MENUS</title>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container"> </div>
</section>
<!-- End Breadcrumbs -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact inner-page">
<div class="container" data-aos="fade-up">
<div class="section-title">
<h2>PDF Menus</h2>
<p></p>
</div>
<div class='row'>
<?php $x="x";
$stmt = $con -> prepare('SELECT * FROM pdf_menus');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$pdf,$name);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
echo"
<div class='col-md-4'>
<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"' method='post'class='php-email-form1'enctype='multipart/form-data'>
<div class='form-row'>
<div class='form-group col-md-12'> <h3>$name</h3>
<iframe src='../pdfs/$pdf' width='100%' height='300px' style='border: none;''></iframe>
<input type='file' name='fileField$id' class='form-control'/>
</div>
</div>
<div class='text-center'>
<a class='btn btn-primary' href='../pdfs/$pdf'>View</a>
<button type='submit' name='update$id'>Update</button>
</div>
</form>
</div>
";
if (isset($_POST["update$id"])) {
$file = $_FILES["fileField$id"];
// Check if a file was uploaded
if ($file['error'] !== UPLOAD_ERR_NO_FILE) {
// Handle file upload errors
if ($file['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $file['error']);
}
// Optional: validate file size, type, etc.
// if ($file['size'] > 5 * 1024 * 1024) die("File too large.");
// Remove old file
if (file_exists("../pdfs/$pdf")) {
unlink("../pdfs/$pdf");
}
$random_id = substr(md5(rand()), 0, 8);
$extension = pathinfo($file['name'], PATHINFO_EXTENSION);
$newFileName = "$random_id.$extension";
$destination = "../pdfs/$newFileName";
if (!move_uploaded_file($file['tmp_name'], $destination)) {
die("Failed to move uploaded file.");
}
// Update DB with new file name
$pdf = $newFileName;
$stmt = $con->prepare("UPDATE pdf_menus SET pdf = ? WHERE id = ?");
$stmt->bind_param("si", $pdf, $id);
$stmt->execute();
}
$_SESSION["action"] = "true";
$message = "Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name&m=$message\">";
}
}
}
?>
</div>
</div>
</section><!-- End Contact Section -->
<?php include("footer.php"); ?>