/
/
home
/
u523034047
/
domains
/
rakeshfilms.in
/
public_html
/
skw
/
admin
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.130
PHP 8.3.16
Dir:
/home/u523034047/domains/rakeshfilms.in/public_html/skw/admin
Edit:
/home/u523034047/domains/rakeshfilms.in/public_html/skw/admin/manage_pages.php
<?php // manage_pages.php include('conn.php'); error_reporting(0); // Determine selected page (PHP5-compatible) $selected_page = 'about'; if (isset($_POST['page_name']) && $_POST['page_name'] !== '') { $selected_page = $_POST['page_name']; } elseif (isset($_GET['page_name']) && $_GET['page_name'] !== '') { $selected_page = $_GET['page_name']; } // Escape for query $sel_escaped = mysqli_real_escape_string($connection, $selected_page); $query = "SELECT * FROM pages WHERE page_name = '" . $sel_escaped . "' LIMIT 1"; $result = mysqli_query($connection, $query); $data = mysqli_fetch_assoc($result); // Handle Save if (isset($_POST['save'])) { $page_name = isset($_POST['page_name']) ? $_POST['page_name'] : 'about'; $content = isset($_POST['htmlcode']) ? mysqli_real_escape_string($connection, $_POST['htmlcode']) : ''; // Handle Image Upload $upload_dir = "uploads/"; if (!file_exists($upload_dir)) { mkdir($upload_dir, 0777, true); } $image_update = ""; if (!empty($_FILES['image']['name'])) { $file_name = $_FILES['image']['name']; $tmp_name = $_FILES['image']['tmp_name']; $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); $allowed = array("jpg", "jpeg", "png", "webp"); if (in_array($ext, $allowed)) { $new_name = uniqid("photo_", true) . "." . $ext; $upload_path = $upload_dir . $new_name; if (move_uploaded_file($tmp_name, $upload_path)) { // Delete old image if exists if (!empty($data['image']) && file_exists($upload_dir . $data['image'])) { @unlink($upload_dir . $data['image']); } $image_update = ", image='" . mysqli_real_escape_string($connection, $new_name) . "'"; } } } // Update DB $update_sql = "UPDATE pages SET content='" . $content . "'" . $image_update . " WHERE page_name='" . mysqli_real_escape_string($connection, $page_name) . "'"; $update = mysqli_query($connection, $update_sql); if ($update) { // Redirect to same page to refresh $loc = 'manage_pages.php?page_name=' . urlencode($page_name); echo "<script>alert('Page updated successfully!'); window.location='" . $loc . "';</script>"; exit; } else { echo "<script>alert('Update failed!');</script>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Manage Pages | Admin</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="assets/css/bootstrap.css" rel="stylesheet"> <link href="assets/css/font-awesome.css" rel="stylesheet"> <link href="assets/css/custom.css" rel="stylesheet"> <link href="richtexteditor/rte_theme_default.css" rel="stylesheet"> <script src="richtexteditor/rte.js"></script> <script src="richtexteditor/plugins/all_plugins.js"></script> <style> body { background:#f4f6f9; } .panel-body label { font-weight:600; } .form-control, select { max-width:600px; } .preview-img { border:1px solid #ccc; border-radius:6px; margin-top:8px; } </style> </head> <body> <div id="wrapper"> <div class="navbar navbar-inverse navbar-fixed-top"> <?php include ('header.php');?> </div> <!-- /. NAV TOP --> <nav class="navbar-default navbar-side" role="navigation"> <?php include ('menu.php');?> </nav> <div id="page-wrapper"> <div id="page-inner"> <div class="row"> <div class="col-md-12"> <h2>Manage Page Details</h2> </div> </div> <hr> <div class="panel panel-primary"> <div class="panel-heading"><strong>Edit Page Content</strong></div> <div class="panel-body"> <!-- Page select form --> <form method="post" enctype="multipart/form-data"> <div class="form-group"> <label>Select Page:</label> <select name="page_name" class="form-control" style="max-width:300px;" onchange="this.form.submit()"> <option value="about"<?php if ($selected_page == 'about') echo ' selected'; ?>>About Page</option> <option value="director"<?php if ($selected_page == 'director') echo ' selected'; ?>>Director Message</option> <option value="principal"<?php if ($selected_page == 'principal') echo ' selected'; ?>>Principal Message</option> <option value="admission"<?php if ($selected_page == 'admission') echo ' selected'; ?>>Admission</option> <option value="feestructure"<?php if ($selected_page == 'feestructure') echo ' selected'; ?>>Fee Structure</option> <option value="facilities"<?php if ($selected_page == 'facilities') echo ' selected'; ?>>Facilities</option> <option value="examination_pattern"<?php if ($selected_page == 'examination_pattern') echo ' selected'; ?>>Examination Pattern</option> <option value="curriculum"<?php if ($selected_page == 'curriculum') echo ' selected'; ?>>Curriculum</option> <option value="mission_vision"<?php if ($selected_page == 'mission_vision') echo ' selected'; ?>>Mission Vision</option> <option value="teaching_methodology"<?php if ($selected_page == 'teaching_methodology') echo ' selected'; ?>>Teaching methodology</option> <option value="rules_of_conduct"<?php if ($selected_page == 'rules_of_conduct') echo ' selected'; ?>>Rules_of_conduct</option> <option value="school_uniform"<?php if ($selected_page == 'school_uniform') echo ' selected'; ?>>School uniform</option> <option value="school_timing"<?php if ($selected_page == 'school_timing') echo ' selected'; ?>>School Timing</option> </select> </div> </form> <!-- Edit form --> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="page_name" value="<?php echo htmlspecialchars($selected_page); ?>"> <div class="form-group"> <label>Upload Image (optional):</label><br> <input type="file" name="image" accept="image/*" class="form-control"> <?php if (!empty($data['image'])) { echo '<img src="uploads/' . htmlspecialchars($data['image']) . '" width="150" height="150" class="preview-img" alt="Image">'; } ?> </div> <div class="form-group"> <label>Page Description:</label> <input name="htmlcode" id="inp_htmlcode" type="hidden" value="<?php echo isset($data['content']) ? htmlspecialchars($data['content']) : ''; ?>"> <div id="div_editor1" class="richtexteditor" style="width:100%;max-width:960px;margin:0 auto;"></div> </div> <button type="submit" name="save" class="btn btn-success"><i class="fa fa-save"></i> Save Changes</button> </form> <script type="text/javascript"> var editor1 = new RichTextEditor(document.getElementById("div_editor1")); // set initial editor HTML from hidden input editor1.setHTMLCode(document.getElementById("inp_htmlcode").value); editor1.attachEvent("change", function () { document.getElementById("inp_htmlcode").value = editor1.getHTMLCode(); }); </script> </div> </div> </div> </div><!-- page-inner --> </div><!-- page-wrapper --> </div><!-- wrapper --> <div class="footer"><?php include('footer.php'); ?></div> <script src="assets/js/jquery-1.10.2.js"></script> <script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/custom.js"></script> </body> </html>
Ukuran: 8.4 KB