<?php
// Start session
session_start();
// Redirect to login page if not logged in
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("Location: login.php");
exit;
}
// Include coredb.php for database connection
require_once('config/core.php');
// Create database connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch favicon and company_copyright from site_settings table Begin
$sql = "SELECT favicon, company_copyright FROM site_settings LIMIT 1";
$result = $conn->query($sql);
// Check if data exists
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$favicon_url = $row['favicon'];
$company_copyright = $row['company_copyright'];
} else {
// Default values if not found in the database
$favicon_url = "default_favicon_url.ico";
$company_copyright = "";
}
// Fetch favicon and company_copyright from site_settings table End
// metatitle, metadescription, metakeyword Begin
// Prepare and bind the SQL query
$sql = "SELECT title, meta_description, meta_keyword FROM webpages WHERE webpage_name = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $webpage_name);
// Set the webpage name
$webpage_name = "webpages-list"; // Replace "your_webpage_name" with the actual webpage name
// Execute the query
$stmt->execute();
// Bind the result variables
$stmt->bind_result($title, $meta_description, $meta_keyword);
// Fetch the values
$stmt->fetch();
// Close statement
$stmt->close();
// metatitle, metadescription, metakeyword End
// fetch google_adsense data Begin
// Fetch data from google_adsense table
$sql = "SELECT script_1 FROM google_adsense ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
// Initialize variable to store the script
$script_1 = '';
// Check if the query was successful
if ($result && $result->num_rows > 0) {
// Fetch the script
$row = $result->fetch_assoc();
$script_1 = $row['script_1'];
}
// fetch google_adsense data End
// fetch data google_analytics Begin
// Initialize the variable
$analytics_script = '';
// SQL query to select the analytics_script from google_analytics table
$sql = "SELECT analytics_script FROM google_analytics";
// Execute the query
$result = $conn->query($sql);
// Check if the query was successful and if there is at least one row returned
if ($result && $result->num_rows > 0) {
// Fetch the data
$row = $result->fetch_assoc();
// Assign the analytics_script to the variable
$analytics_script = $row['analytics_script'];
} else {
$analytics_script = 'No analytics script found.';
}
// fetch data google_analytics End
// Close the database connection
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?php echo $title; ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link id="image_2" rel="icon" type="image/x-icon" href="<?php echo $favicon_url; ?>">
<meta name="robots" content="index, follow" />
<meta name="author" content="Design Collection">
<meta name="description" content="<?php echo $meta_description; ?>">
<meta name="keywords" content="<?php echo $meta_keyword; ?>">
<!-- Viewport configuration, scaling options -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- Bootstrap CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- custom CSS -->
<link href="assets/css/custom.css" rel="stylesheet">
<!-- Font Awesome icon -->
<link href="assets/fontawesome/css/fontawesome.css" rel="stylesheet" />
<!-- Google web font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!--analytics_script Begin-->
<?php echo $analytics_script ?>
<!--analytics_script End-->
</head>
<body>
<!--unique id begin -->
<div id="s_mm">
<?php include 'preloader.php';?>
<!--scroll-top Begin-->
<div id="scroll-top">
<!--sidebarwrapper Begin-->
<div id="sidebarwrapper">
<!--Sidebarmenu Begin-->
<?php include 'sidebar-menu.php';?>
<!--Sidebarmenu End-->
<!--content-wrapper Begin-->
<div id="content-wrapper" class="d-flex flex-column dashboard-navbar">
<!--maincontent Begin-->
<div id="maincontent">
<!-- Navbar Topbar Begin-->
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<button id="humbergersidebarToggleTop" class="btn btn-link rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
</nav>
<!-- Navbar Topbar End-->
<!-- Container Begin-->
<div class="container-fluid px-4">
<!--Row Begin-->
<div class="row">
<!--col-md-6 Begin-->
<?php include 'about-us.php';?>
<!--col-md-6 End-->
<!--col-md-6 Begin-->
<?php include 'contact-us.php';?>
<!--col-md-6 End-->
</div>
<!--Row End-->
<!--Row Begin-->
<div class="row">
<?php include 'webpagelist-deta.php';?>
</div>
<!--Row End-->
<!--row Begin-->
<!--Adsense Begin-->
<div class='row'>
<div class='col-md-12'>
<?php echo $script_1; ?>
</div>
</div>
<!--Adsense End-->
<!--row End-->
</div>
<!-- Container End-->
</div>
<!--maincontent End-->
<!--Copyright Begin-->
<div class="p-4 border bg-white">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-12 col-sm-12">
<p class="small text-center p-0 m-0"><?php echo $company_copyright; ?></p>
</div>
</div>
</div>
</div>
<!--Copyright End-->
</div>
<!--content-wrapper End-->
</div>
<!--sidebarwrapper End-->
<!--scroll to top Begin-->
<button onclick="topFunction()" id="gobackToTop" title="arrow-right"><i class="fas fa-angle-up"></i></button>
<!--scroll to top end-->
<!-- Jquery Script -->
<script src="assets/js/jquery-3.4.1.min.js"></script>
<!-- Bootstrap Script -->
<script src="assets/js/bootstrap.bundle.min.js"></script>
<!-- theme-min Script -->
<script src="assets/js/dashboard-custom.js"></script>
<script>
$(document).ready(function() {
// This function handles click events for elements with the class 'edit-webpagebutton'
$('.edit-webpagebutton').click(function() {
var title = $(this).data('title');
var metaDescription = $(this).data('meta-description');
var metaKeyword = $(this).data('meta-keyword');
var id = $(this).data('id');
$('#edit_title').val(title);
$('#edit_meta_description').val(metaDescription);
$('#edit_meta_keyword').val(metaKeyword);
$('#edit_id').val(id);
});
// This function handles click events for the element with the id 'saveChangesButton'
$('#saveChangesButton').click(function() {
var edited_title = $('#edit_title').val();
var edited_meta_description = $('#edit_meta_description').val();
var edited_meta_keyword = $('#edit_meta_keyword').val();
var edited_id = $('#edit_id').val();
// Send AJAX request to update the data in the database
$.ajax({
url: 'update_webpage.php',
method: 'POST',
data: {
title: edited_title,
meta_description: edited_meta_description,
meta_keyword: edited_meta_keyword,
id: edited_id
},
success: function(response) {
alert('Edit Meta title, Meta Description, Meta Title data has been successfully updated!');
console.log(response);
location.reload();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
$('#editModal').modal('hide');
});
});
</script>
<script>
$(document).ready(function() {
// Click event for the "Edit Content" button
$('.edit-content-btn').click(function() {
var content = $(this).closest('.card-body').find('textarea').text();
var aboutUsId = $(this).data('id');
$('#aboutUsContent').val(content);
$('#aboutUsId').val(aboutUsId);
$('#editAboutUsModal').modal('show');
});
// Click event for the "Save changes" button
$('#saveAboutUsChanges').click(function() {
var editedContent = $('#aboutUsContent').val();
var aboutUsId = $('#aboutUsId').val();
$.ajax({
url: 'update-about-us.php',
method: 'POST',
data: {
content: editedContent,
id: aboutUsId
},
success: function(response) {
alert('About page data has been successfully updated!');
console.log(response);
$('#editAboutUsModal').modal('hide');
location.reload(); // Reload the page to reflect changes
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
});
});
</script>
<script>
$(document).ready(function() {
// Click event for the "Edit Content" button
$('.edit-content-btn1').click(function() {
var content = $(this).closest('.card-body').find('.about-us-textarea').val();
var script = $(this).closest('.card-body').find('textarea:last').val();
var contactUsId = $(this).data('id');
$('#contactUsContent').val(content);
$('#contactUsScript').val(script);
$('#contactUsId').val(contactUsId);
$('#editContactUsModal').modal('show');
});
// Click event for the "Save changes" button
$('#saveContactUsChanges').click(function() {
var editedContent = $('#contactUsContent').val();
var editedScript = $('#contactUsScript').val();
var contactUsId = $('#contactUsId').val();
$.ajax({
url: 'update-contact-us.php',
method: 'POST',
data: {
content: editedContent,
script: editedScript,
id: contactUsId
},
success: function(response) {
alert('Contact page data has been successfully updated!');
console.log(response);
$('#editContactUsModal').modal('hide');
location.reload(); // Reload the page to reflect changes
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
});
});
</script>
</div>
<!--scroll-top End-->
</div>
<!--unique id End -->
</body>
</html>