function selected_page() { global $current_subject; global $current_page; if (isset($_GET['subject'])) { $current_subject = Subject::find_by_id($_GET['subject']); $current_page = null; } elseif (isset($_GET['page'])) { $current_page = Page::find_by_id($_GET['page']); $current_subject = null; } else { $current_subject = null; $current_page = null; } }
<?php //require the framework require_once "../requires/initialize.php"; $page = new Page(); $page->name = "Update Page"; $page->is_admin_only = true; // check if page_wk is set if (!isset($_GET["page_wk"])) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } // grab the page so it's content can be pre-loaded into the form $update_page = Page::find_by_id($_GET["page_wk"]); // check that the page_wk exists if (!$update_page) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } // update the page if the form is submitted if (isset($_POST["submit"])) { $update_page->name = $_POST["page_name"]; $update_page->body = $_POST["page_content"]; // if the page successfully updates, go to the page if ($update_page->save()) { $session->message("Your page was updated successfully!"); redirect_head(ROOT_URL . "view_page.php?page_wk=" . $update_page->page_wk); } else { $session->message("The page was not updated. " . $database->last_error); } }
<?php //require the framework require_once "requires/initialize.php"; // check if page_wk is set if (!isset($_GET["page_wk"])) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } $page_wk = $_GET["page_wk"]; $page = Page::find_by_id($page_wk); // check that the page_wk exists if (!$page) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } require_once "requires/template/header.php"; //if homepage, show slider else show intended body if ($page_wk == 1) { require_once "requires/template/slider.php"; require_once "requires/template/pet_slider.php"; if (isset($website_settings['address']) && isset($website_settings['city']) && isset($website_settings['state'])) { $unescapedAddress = $website_settings['address']; $unescapedAddress = preg_replace('!\\s+!', ' ', $unescapedAddress); $escapedAddress = str_replace(' ', "+", $unescapedAddress); echo "<iframe width=\"100%\" height=\"450px\" frameborder=\"0\" style=\"border:0; margin:0px; padding:0px;\" src=\"https://www.google.com/maps/embed/v1/place?key=AIzaSyC1TqkP5WgrQc76w6jM-SiOuo5ZNns4dmU&q=" . $escapedAddress . "," . $website_settings['city'] . "," . $website_settings['state'] . "\" allowfullscreen></iframe>"; } } else { echo "<section id=\"blog\"><div class=\"container\"><div class=\"row\"><div class=\"col-md-12\"><div class=\"blog\"><div class=\"blog-item\"><div class=\"blog-content\">"; echo $page->body; echo "</div></div></div></div></div></div></section>";
<?php //require the framework require_once "../requires/initialize.php"; // create the page $page = new Page(); $page->name = "Delete Page"; $page->is_admin_only = true; // check if page_wk is set if (!isset($_GET["page_wk"])) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } $page_wk = $_GET["page_wk"]; $page_found = Page::find_by_id($page_wk); // check that the page_wk exists if (!$page_found) { $session->message("There is an error with the page you were trying to access."); redirect_head(ROOT_URL); } //make sure we're not deleting the home page or about us page if ($page_found == '1' || $page_found == '2') { $session->message("You cannot delete the following page: " . $page_found->name . "."); redirect_head(ROOT_URL . "view_page.php?page_wk=" . $page_found); } // if the user confirmd we're deleting the page if (isset($_POST["confirm"])) { // delete the page $page_found->delete(); $session->message("The page was successfully deleted!"); redirect_head(ROOT_URL . "index.php");