<?php /* ** blog - admin.php * 9/13/15 - Pg 157 - Tested & commited */ error_reporting(E_ALL); ini_set("display_errors", 1); /** Page_Data() **/ include_once "models/Page_Data.class.php"; $pageData = new Page_Data(); $pageData->title = "PHP/MySql blog demo"; $pageData->addCSS("css/blog.css"); ////$pageData->addScript("js/editor.js"); bug in downloaded books code $pageData->content = (include_once "views/admin/admin-navigation.php"); /* ** admin.php ** ** database connection: Table Data gateway design pattern vs active record pattern ** Table gateway pattern specifies one PHP class per table. ** Code from page 119 */ $dbInfo = "mysql:host=127.0.0.1;dbname=simple_blog"; $dbUser = "******"; $dbPassword = "******"; // try to create a database connection with a PDO object $db = new PDO($dbInfo, $dbUser, $dbPassword); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /* ** END of Database Connection */
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "models/Page_Data.class.php"; $pageData = new Page_Data(); $pageData->title = "My favorite recipes"; $pageData->addCSS("css/styles.css"); $dbInfo = "mysql:host=localhost;dbname=recipes"; $dbUser = "******"; $dbPassword = ""; $db = new PDO($dbInfo, $dbUser, $dbPassword); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pageData->content .= " <form action='search.php' method='GET'>\n <div style='text-align: center'>\n <h1> Search for Recipes or Chefs</h1>\n <input class='text-box' type='text' size='90' name='search'>\n <input class='search-button' type='submit' name='submit' value='Search'>\n </div>\n </form>\n"; $pageData->content .= (include_once "controllers/all_content.php"); $page = (include_once "views/page.php"); echo $page;
<?php error_reporting(E_ALL); ini_set('display_errors', 1); include_once "util/db.config.php"; // model include_once 'models/Page_Data.class.php'; $pageData = new Page_Data(); $pageData->title = "PHP/MySQL Blog Demo"; $pageData->addCSS('css/blog.css'); $pageData->content = "<h1>{$pageData->title}</h1>"; $pageData->content .= (include_once "views/search_form_html.php"); $controller = isset($_GET['page']) && $_GET['page'] === 'search' ? 'search' : 'blog'; $pageData->content .= (include_once "controllers/{$controller}.php"); // view $page = (include_once "views/page.php"); // view and model echo $page;
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "models/Page_Data.class.php"; $pageData = new Page_Data(); $pageData->title = "PHP/MySQL blog demo"; $pageData->addCSS("css/blog.css"); $pageData->addScript("js/editor.js"); $dbInfo = "mysql:host=127.0.0.1;port=3306;dbname=simple_blog"; $dbUser = "******"; $dbPassword = "******"; $db = new PDO($dbInfo, $dbUser, $dbPassword); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); include_once "models/Admin_User.class.php"; $admin = new Admin_User(); $pageData->content = (include_once "controllers/admin/login.php"); if ($admin->isLoggedIn()) { $pageData->content .= (include_once "views/admin/admin-navigation.php"); $navigationIsClicked = isset($_GET['page']); if ($navigationIsClicked) { $controller = $_GET['page']; } else { $controller = "entries"; } $pathToController = "controllers/admin/{$controller}.php"; $pageData->content .= (include_once $pathToController); } $page = (include_once "views/page.php"); echo $page;
<?php error_reporting(E_ALL); ini_set('display_errors', 1); $dbInfo = "mysql:host=localhost;dbname=simple_blog"; $dbUser = '******'; $dbPassword = '******'; include_once "util/db.config.php"; // model include_once 'models/Page_Data.class.php'; $pageData = new Page_Data(); $pageData->title = "PHP/MySQL Blog Demo"; $pageData->addCSS('css/blog.css'); $pageData->addScript('js/editor.js'); $pageData->addScript('js/tinymce/tinymce.min.js'); $pageData->content = "<h1>{$pageData->title}</h1>"; // view include_once "models/Admin_User.class.php"; $admin = new Admin_User(); $pageData->content = (include_once "controllers/admin/login.php"); if ($admin->isLoggedIn()) { $pageData->content .= (include "views/admin/adminNavigation.php"); $navigationIsClicked = isset($_GET['page']); if ($navigationIsClicked) { $controller = $_GET['page']; } else { $controller = "entries"; } $pathToController = "controllers/admin/{$controller}.php"; $pageData->content .= (include_once $pathToController); }
<?php //complete code for index.php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "classes/Page_Data.class.php"; $pageData = new Page_Data(); //embed external JS $pageData->addScript("js/lightbox.js"); $pageData->title = "Dynamic image gallery"; $pageData->content = (include_once "views/navigation.php"); $userClicked = isset($_GET['page']); if ($userClicked) { $fileToLoad = $_GET['page']; } else { $fileToLoad = "gallery"; } $pageData->addCSS('css/layout.css'); $pageData->addCSS('css/navigation.css'); $pageData->content .= (include_once "views/{$fileToLoad}.php"); $page = (include_once "templates/page.php"); echo $page;
<?php // Include website configuration include_once 'config/config.php'; // Include database connection include_once 'config/dbConnection.php'; // Include required models include_once 'models/Page_Data.class.php'; // Initialize front end controller object for page display - class Page_Data $pageData = new Page_Data(); // Load controller if exists from the get url value or load 404 error /* verify if tip controllers exists and load controller */ if (isset($_GET['tip'])) { $tipPage = $_GET['tip']; $page = "controllers/" . $tipPage . ".php"; if (file_exists($page)) { $pageFile = $page; } else { $pageFile = "controllers/404.php"; $footerFix = "footer-fixed"; } // set the $adminPage variable if is callng the admin page if ($tipPage === "admin") { $adminPage = "Yes"; } } else { $pageFile = "controllers/index.php"; } $breadcrumb = (include_once "views/breadcumb.php"); // Load CSS files // Load diferent content for admin page
<?php //errro handling //ini_set("display_errors", 1); //error_reporting(E_ALL); include_once "models/Page_Data.class.php"; $pageData = new Page_Data(); $pageData->title = "PHP/MySQl blog"; $pageData->addCSS("css/blog.css"); $pageData->addCSS("css/img.css"); $pageData->addScript("js/lightbox.js"); $pageData->addScript("js/editor.js"); //load navigatio //$pageData->content = include_once "views/admin/admin-navigation.php"; //establsh databse connection $dbInfo = "mysql:host=localhost;dbname=simple_blog"; $dbUser = "******"; $dbPassword = "******"; $db = new PDO($dbInfo, $dbUser, $dbPassword); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); include_once "models/User.class.php"; $admin = new User(); //load the login controller, which will show the login form $pageData->content = (include_once "controllers/admin/login.php"); //add a new if statement //show admin module only if user is logged in if ($admin->checkLogin()) { $pageData->content .= (include_once "views/admin/admin-navigation.php"); $navigationIsClicked = isset($_GET['page']); if ($navigationIsClicked) { $controller = $_GET['page'];