%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/public_html/website_6ca89795/admin/ |
Upload File : |
<?php
include('function.php');
include('header.php');
include('../dbcon.php');
function clean_content($content) {
$content = trim($content); // Remove leading and trailing spaces
$content = str_replace(" ", " ", $content); // Replace non-breaking spaces
$content = htmlspecialchars_decode($content, ENT_QUOTES); // Decode HTML entities
return mysqli_real_escape_string($GLOBALS['conn'], $content);
}
if (isset($_POST['submit'])) {
$title = mysqli_real_escape_string($conn, $_POST['title']);
$title_ar = isset($_POST['title_ar']) ? mysqli_real_escape_string($conn, $_POST['title_ar']) : null;
$content = isset($_POST['content']) ? clean_content($_POST['content']) : null;
$content_ar = isset($_POST['content_ar']) ? clean_content($_POST['content_ar']) : null;
$category_id = mysqli_real_escape_string($conn, $_POST['category_id']);
$page_title = mysqli_real_escape_string($conn, $_POST['page_title']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$keywords = mysqli_real_escape_string($conn, $_POST['keywords']);
$robots = mysqli_real_escape_string($conn, $_POST['robots']);
$canonical = mysqli_real_escape_string($conn, $_POST['canonical']);
$uploadDir = "./dataimg/";
// Handling about image upload
$aboutImage = $_FILES['aboutimage']['name'];
$aboutImagePath = $uploadDir . basename($aboutImage);
if (!empty($aboutImage)) {
if (move_uploaded_file($_FILES['aboutimage']['tmp_name'], $aboutImagePath)) {
$titleslug = slug($title);
$qry = "INSERT INTO `services`
(`title`, `titleslug`, `title_ar`, `page_title`, `description`, `keywords`, `robots`, `canonical`, `category_id`, `content`, `content_ar`, `image`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($conn, $qry);
if ($stmt) {
mysqli_stmt_bind_param(
$stmt,
"ssssssssssss",
$title,
$titleslug,
$title_ar,
$page_title,
$description,
$keywords,
$robots,
$canonical,
$category_id,
$content,
$content_ar,
$aboutImage
);
if (mysqli_stmt_execute($stmt)) {
echo '<script>alert("Service added successfully!");</script>';
} else {
echo '<script>alert("Error adding service: ' . mysqli_error($conn) . '");</script>';
}
mysqli_stmt_close($stmt);
} else {
echo '<script>alert("Prepared statement error: ' . mysqli_error($conn) . '");</script>';
}
} else {
echo '<script>alert("Error uploading about image.");</script>';
}
} else {
echo '<script>alert("Please upload the about image.");</script>';
}
}
// Fetch categories
$categoryQuery = "SELECT id, category FROM `service_category`";
$categoryResult = mysqli_query($conn, $categoryQuery);
?>
<div class="container">
<div class="title">Add Our Services</div>
<script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" name="title" placeholder="Enter Product Name" required>
</div>
<div class="form-group">
<label for="page_title">Title In Arabic</label>
<input type="text" class="form-control" name="title_ar" placeholder="Title in Arabic" required>
</div>
<div class="form-group">
<label for="page_title">Page Title</label>
<input type="text" class="form-control" name="page_title" placeholder="Page Title" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" name="description" placeholder="Description" required></textarea>
</div>
<div class="form-group">
<label for="keywords">Keywords</label>
<input type="text" class="form-control" name="keywords" placeholder="Keywords">
</div>
<div class="form-group">
<label for="robots">Robots</label>
<input type="text" class="form-control" name="robots" placeholder="Robots">
</div>
<div class="form-group">
<label for="canonical">Canonical</label>
<input type="text" class="form-control" name="canonical" placeholder="Canonical">
</div>
<div class="form-group">
<label for="aboutimage">Image</label>
<input type="file" class="form-control" name="aboutimage" required>
</div>
<div class="form-group">
<label for="category_id">Service Category</label>
<select class="form-control" name="category_id" required>
<option value="" disabled selected>Select Category</option>
<?php while ($row = mysqli_fetch_assoc($categoryResult)): ?>
<option value="<?php echo $row['id']; ?>">
<?php echo $row['category']; ?>
</option>
<?php endwhile; ?>
</select>
</div>
<div class="form-group">
<label for="content">Content</label>
<textarea id="content" name="content"></textarea>
</div>
<div class="form-group">
<label for="content_ar">Content in Arabic</label>
<textarea id="content_ar" name="content_ar"></textarea>
</div>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<script>
CKEDITOR.replace('content', {
height: 200,
entities: false,
basicEntities: false,
removePlugins: 'pastefromword',
on: {
instanceReady: function (evt) {
let editorData = evt.editor.getData().replace(/ /g, ' ');
evt.editor.setData(editorData);
},
change: function (evt) {
let editorData = evt.editor.getData().replace(/ /g, ' ');
evt.editor.setData(editorData);
}
}
});
CKEDITOR.replace('content_ar', {
height: 200,
entities: false,
basicEntities: false,
removePlugins: 'pastefromword',
on: {
instanceReady: function (evt) {
let editorData = evt.editor.getData().replace(/ /g, ' ');
evt.editor.setData(editorData);
},
change: function (evt) {
let editorData = evt.editor.getData().replace(/ /g, ' ');
evt.editor.setData(editorData);
}
}
});
</script>
<div class="content-backdrop fade"></div>
</div>
<!-- Content wrapper -->
</div>
<!-- / Layout page -->
</div>
</div>
<!-- / Layout wrapper -->
<!-- Core JS -->
<!-- build:js assets/vendor/js/core.js -->
<script src="../assets/vendor/libs/jquery/jquery.js"></script>
<script src="../assets/vendor/libs/popper/popper.js"></script>
<script src="../assets/vendor/js/bootstrap.js"></script>
<script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<script src="../assets/vendor/js/menu.js"></script>
<!-- endbuild -->
<!-- Vendors JS -->
<!-- Main JS -->
<script src="../assets/js/main.js"></script>
<!-- Page JS -->
<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>