* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License in GPL.txt for more details. */ session_start(); if (isset($_SESSION['login'])) { // Do nothing } else { header("Location: ."); exit(); } if (isset($_GET['logout'])) { if (isset($_SESSION['login'])) unset($_SESSION['login']); session_destroy(); header("Location: ."); exit(); } $date = date('jS F Y'); $ip = $_SERVER['REMOTE_ADDR']; require_once('../config.php'); $con = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname); if (mysqli_connect_errno()) { $sql_error = mysqli_connect_error(); die("Unable connect to database"); } $query = "SELECT @last_id := MAX(id) FROM admin_history"; $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) { $last_id = $row['@last_id := MAX(id)']; } $query = "SELECT * FROM admin_history WHERE id=" . Trim($last_id); $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) { $last_date = $row['last_date']; $last_ip = $row['ip']; } if ($last_ip == $ip) { if ($last_date == $date) { } else { $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; mysqli_query($con, $query); } } else { $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; mysqli_query($con, $query); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST{'editme'})) { $edit_me_id = htmlentities(Trim($_POST['editme'])); $page_name = Trim($_POST['page_name']); $page_title = Trim($_POST['page_title']); $page_content = $_POST['data']; $query = "UPDATE pages SET last_date='$date', page_name='$page_name', page_title='$page_title', page_content='$page_content' WHERE id='$edit_me_id'"; mysqli_query($con, $query); } else { $page_name = Trim($_POST['page_name']); $page_title = Trim($_POST['page_title']); $page_content = $_POST['data']; $query = "INSERT INTO pages (last_date,page_name,page_title,page_content) VALUES ('$date','$page_name','$page_title','$page_content')"; mysqli_query($con, $query); } $page_name = ""; $page_title = ""; $page_content = ""; } if (isset($_GET{'edit'})) { $page_id = trim($_GET['edit']); $sql = "SELECT * FROM pages where id='$page_id'"; $result = mysqli_query($con, $sql); //we loop through each records while ($row = mysqli_fetch_array($result)) { //populate and display results data in each row $page_name = $row['page_name']; $page_title = $row['page_title']; $page_content = $row['page_content']; } } ?> Paste - Pages
Add a Page

'; } ?>

Pages
' . mysqli_error($con) . ' '; } else { echo '
Page deleted.
'; } } $rec_limit = 20; $query = "SELECT count(id) FROM pages"; $retval = mysqli_query($con, $query); $row = mysqli_fetch_array($retval); $rec_count = Trim($row[0]); if (isset($_GET{'page'})) { // Get the current page $page = $_GET{'page'} + 1; $offset = $rec_limit * $page; } else { // Show first set of results $page = 0; $offset = 0; } $left_rec = $rec_count - ($page * $rec_limit); // Set the specific query to display in the table $sql = "SELECT * FROM pages ORDER BY `id` DESC LIMIT $offset, $rec_limit"; $result = mysqli_query($con, $sql); $no = 1; // Loop through each records while ($row = mysqli_fetch_array($result)) { // Populate and display results data in each row echo ''; echo ''; echo ''; echo ''; $myid = $row['id']; echo ''; echo ''; echo ''; $no++; } echo ''; echo ''; echo '
Date Added Page Name Page Title View Edit Delete
' . $row['last_date'] . '' . $row['page_name'] . '' . $row['page_title'] . '' . " View " . '' . " Edit " . '' . " Delete " . '
'; // Display the pagination echo '
    '; if ($left_rec < $rec_limit) { $last = $page - 2; if ($last < 0) { } else { echo @"
  • Previous
  • "; } } else if ($page == 0) { echo @"
  • Next
  • "; } else if ($page > 0) { $last = $page - 2; echo @"
  • Previous
  • "; echo @"
  • Next
  • "; } echo '
'; ?>