$myview = new Views(); $posts = new Posts(); session_start(); if (isset($_SESSION["loggedin"])) { //var_dump($_SESSION); echo "<br /> post's session start is working"; } else { header("Location: http://localhost/websites/ssl/day7/main.php"); } if (!isset($_SESSION["loggedin"])) { header("Location: http://localhost/websites/ssl/day7/main.php"); } if (!empty($_GET["action"])) { if ($_GET["action"] == "getAll") { $data = $posts->readPosts(); $myview->getView("../views/body.php", $data); } elseif ($_GET["action"] == "readPost") { $data = $posts->readPost($_GET["postId"]); $myview->getView("../views/blogPost.php", $data); } elseif ($_GET["action"] == "updatePost") { $data = $posts->readPost($_GET["postId"]); $myview->getView("../views/formUpdate.html", $data); } elseif ($_GET["action"] == "changePost") { $posts->updatePost($_POST["title"], $_POST["detail"], $_POST["postId"]); $data = $posts->readPosts(); $myview->getView("../views/body.php", $data); } elseif ($_GET["action"] == "deletePost") { $posts->deletePost($_GET["postId"]); $data = $posts->readPosts(); $myview->getView("../views/body.php", $data); } elseif ($_GET["action"] == "createPost") {
include "helpers/db.php"; //must be above the Post.php - order of operation include "models/Posts.php"; include "models/Users.php"; include "models/Image.php"; include "models/Items.php"; $myview = new Views(); //$posts = new Posts(); $image = new Image(); $items = new Items(); session_start(); $captchaString = md5(microtime()); $randomCaptcha = substr($captchaString, 0, 6); $image->msg($randomCaptcha); $_SESSION["captcha"] = $randomCaptcha; $myview->getView("views/header.html", array()); if (!empty($_GET["controller"])) { header("Location: controllers/post.php"); } else { ?> <div id="content"> <?php //$myview->getView("views/formLogin.html"); //$myview->getView("views/formRegister.html"); //echo("<hr />"); class Items2 extends db { public function getEntry($entryId) { $sql = "select * from newsitem where id =\"" . $entryId . "\""; $result = $this->dbcon->prepare($sql);
// Store in variables so that we can work with them later $views = new Views(); $create = new CreateData(); $read = new ReadData(); $update = new UpdateData(); $delete = new DeleteData(); $login = new Login(); // Controller starts routing the user based on the form "action" from Views; //Process if the action is not empty, if so move to next if statement //if statements act like switches for when a neccesary model is called upon from user at view //selected action can be seen in url // ! its important to have consistent $salt phrase unless database connection won't work for retrival if (!empty($_GET["action"])) { if ($_GET["action"] == "home") { //Shows Header & Both Forms; Then, show footer $views->getView("views/header.php"); $views->getView("views/signup_form.php"); $views->getView("views/login_form.php"); $views->getView("views/footer.php"); } //CRUD ACTION: CREATE // If user action is "sign-up" then "CREATE" signup if ($_GET["action"] == "signupUser") { // Show header + sign-up confirmation & footer; $views->getView("views/header.php"); $salt = "supperDupperSalt"; $epass = md5($_POST['password'] . $salt); $euser = $_POST['user']; $create->createrecord($euser, $epass); $views->getView("views/footer.php"); }
<?php //include "/lab/ssl/Views.php"; include "../models/Views.php"; $myview = new Views(); $myview->getView("../views/header.html"); ?> <div id="content"> <?php $myview->getView("../views/user-authentication-form.html"); //var_dump($_POST["username"]); //echo($_POST["username"]); if (!empty($_POST["username"])) { echo $_POST["username"] . "<br />"; } else { echo "<br />Please fill in the Username<br />"; } if (empty($_POST["password"])) { echo "Please fill in the password field<br />"; } elseif (strlen($_POST["password"]) < 8) { echo "Please use eight characters in the password<br />"; } else { echo $_POST["password"] . "<br />"; } if (empty($_POST["email"])) { echo "Please fill in a valid email"; } elseif (!preg_match("^[\\w-]+(\\.[\\w-]+)*@([a-z0-9-]+(\\.[a-z0-9-]+)*?\\.[a-z]{2,6}|(\\d{1,3}\\.){3}\\d{1,3})(:\\d{4})?\$^", $_POST["email"])) { echo "Please provide a valid email"; } else { echo $_POST["email"]; }
<?php include "Views.php"; $myview = new Views(); $myview->getView("../views/header.html"); $myview->getView("../views/index.html"); $myview->getView("../views/footer.html");
<?php include "../models/Views.php"; include "../helpers/db.php"; //must be above the Post.php - order of operation include "../models/Users.php"; $myview = new Views(); $users = new Users(); ?> <!--<link href="/day4/css/site.css" rel="stylesheet" />--> <!--dirrect path - can use this due to the ../ paths--> <?php if (!empty($_GET["action"])) { if ($_GET["action"] == "updateUser") { $data = $users->readUser($_GET["userId"]); $myview->getView("../views/formUpdate.php", $data); } elseif ($_GET["action"] == "changeUser") { $users->updateUser($_POST["userName"], $_POST["password"], $_POST["email"], $_POST["userId"]); $data = $users->readUsers(); $myview->getView("../views/body.php", $data); } elseif ($_GET["action"] == "deleteUser") { $users->deleteUser($_GET["userId"]); $data = $users->readUsers(); $myview->getView("../views/body.php", $data); } elseif ($_GET["action"] == "createUser") { $users->createUser($_POST["userName"], $_POST["password"], $_POST["email"]); $data = $users->readUsers(); $myview->getView("../views/body.php", $data); } } elseif (empty($_GET["userId"])) { $data = $users->readUsers(); $myview->getView("../views/body.php", $data);
* ====================================== * PROJECT: SSL - LAB 03 PREP * FILE: controllers/maincontroller.php * AUTHOR: Jana Nash-Siegle * CREATED: 12/2/2015 * ====================================== */ session_start(); include "models/model.php"; $views = new Views(); // If Browser URL (form action) is NOT empty, keep going... if (!empty($_GET["action"])) { // if URL (form action = captchaForm if ($_GET["action"] == "captchaForm") { //Display only the default layout $views->getView("views/header.php"); $views->getView("views/form.php"); $views->getView("views/footer.php"); // Else if $_GET form action = captchaVerify } else { if ($_GET["action"] == "captchaVerify") { //Display layout & results $views->getView("views/header.php"); $views->getView("views/results.php"); $views->getView("views/footer.php"); //Else (assuming action says "anything else"0, give the user the default layout) } else { $views->getView("views/header.php"); $views->getView("views/form.php"); $views->getView("views/footer.php"); }
<?php include "models/Views.php"; include "helpers/db.php"; //must be above the Post.php - order of operation include "models/Posts.php"; include "models/Users.php"; $myview = new Views(); //$posts = new Posts(); $myview->getView("views/header.html", array()); if (!empty($_GET["controller"])) { header("Location: controllers/post.php"); } else { ?> <div id="content"> <?php $myview->getView("views/formLogin.html"); $myview->getView("views/formRegister.html"); ?> </div> <?php } $myview->getView("views/footer.html", array());
<?php include "../models/Views.php"; include "../helpers/db.php"; //must be above the Post.php - order of operation include "../models/Posts.php"; $myview = new Views(); $posts = new Posts(); $myview->getView("../views/header.html", array()); //$data = $posts->readPosts(); /*if(!empty($_GET["postid"])){ $data = $posts->readPost($_GET["postid"]); $myview->getView("../views/blog.php",$data); }*/ //var_dump($data); //$post->addPost($_POST[""],$_POST[""])//use this for the lab ?> <div id="content"> <?php $myview->getView("../views/form.html"); if (!empty($_POST["title"]) && !empty($_POST["detail"])) { $posts->createPosts($_POST["title"], $_POST["detail"]); $data = $posts->readPosts(); //$data = var_dump($_POST["title"]); $myview->getView("../views/blog.php", $data); } else { $data = $posts->readPosts(); $myview->getView("../views/blog.php", $data); } ?> </div>
<?php //include "/lab/ssl/Views.php"; include "Views.php"; $myview = new Views(); $myview->getView("../views/header.html"); ?> <div id="content"> <?php $myview->getView("../views/data-entry-form.html"); //var_dump($_POST["username"]); //echo($_POST["username"]); if (empty($_POST["date"])) { echo "<br />Please fill in the date<br />"; } elseif (!is_numeric($_POST["date"])) { echo "<br />Please fill in a numeric date<br />"; } else { echo $_POST["date"] . "<br />"; } if (empty($_POST["experience"])) { echo "Please fill in experience<br />"; } elseif (!preg_match("^[-+]?\\d+(\\.\\d+)?\$^", $_POST["experience"])) { echo "Please use positive numbers or negetive numbers<br />"; } else { echo $_POST["experience"] . "<br />"; } if (empty($_POST["salary"])) { echo "Please fill in the salary<br />"; } elseif (!preg_match("^((?:\\+|\\-|\$)?(?:\\d+|\\d{1,3}(?:\\,\\d{3})*)(?:\\.\\d+)?(?:[a-zA-Z]{2}|\\%)?)\$^", $_POST["salary"])) { echo "Please use numbers in the salary field"; } else {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo "Untitled Document"; ?> </title> <?php //include "/scripts/js.js"; //include "/css/css.css"; include "Views.php"; $myview = new Views(); $myview->getView("header.php"); ?> </head> <body> <div id="myheader"><?php include "/views/header.php"; ?> </div> <?php //do the same as above //logo //login ?> <?php //footer ?>
* FILE: controllers/Action_Controller.php * AUTHOR: Jana Nash-Siegle * CREATED: 12/8/2015 * ====================================== */ session_start(); include "models/Views.Class.php"; include "models/WeatherAPI.Class.php"; $views = new Views(); $api = new WeatherAPI(); // If action is *NOT* empty keep going.... if (!empty($_GET["action"])) { // if action is specified as home: if ($_GET["action"] == "home") { //Display only the default layout $views->getView("views/header.php"); $views->getView("views/form.php"); $views->getView("views/footer.php"); } //if action is specified as lookup: if ($_GET["action"] == "lookup") { // if the zip code has a value AND is not set = to empty: if (isset($_POST['tf_zip']) && !empty($_POST['tf_zip'])) { $zipcode = $_POST['tf_zip']; // then, store the zipcode in a variable } else { $zipcode = '32792'; // then, store the default zip code in a variable } $data = $api->get_weather_by_zip($zipcode); $views->getView("views/header.php");
<?php include "../models/Views.php"; include "../helpers/db.php"; //must be above the Post.php - order of operation include "../models/Posts.php"; $myview = new Views(); $posts = new Posts(); ?> <link href="/day4/css/site.css" rel="stylesheet" /> <!--dirrect path - can use this due to the ../ paths--> <?php //$data = $posts->readPosts(); if (!empty($_GET["postid"])) { $data = $posts->readPost($_GET["postid"]); $myview->getView("../views/blog.php", $data); }