From be73bc42624df9651802d639d5c04a5df9d09704 Mon Sep 17 00:00:00 2001 From: dreygmly13 <94503453+dreygmly13@users.noreply.github.com> Date: Mon, 29 Nov 2021 21:40:38 +0800 Subject: [PATCH 1/2] Update index.php --- appengine/standard/helloworld/index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/appengine/standard/helloworld/index.php b/appengine/standard/helloworld/index.php index 39bd271241..b2543d7f7d 100644 --- a/appengine/standard/helloworld/index.php +++ b/appengine/standard/helloworld/index.php @@ -1,3 +1,10 @@ Date: Mon, 29 Nov 2021 21:42:36 +0800 Subject: [PATCH 2/2] Add files via upload --- .../standard/helloworld/Content/404.phtml | 1 + .../helloworld/Content/about-us.phtml | 4 + .../standard/helloworld/Content/contact.phtml | 9 + .../standard/helloworld/Content/home.phtml | 49 +++++ .../standard/helloworld/Content/robert.phtml | 3 + .../standard/helloworld/Content/top.phtml | 11 + appengine/standard/helloworld/DB/wiki.sql | 41 ++++ .../standard/helloworld/Includes/config.php | 26 +++ .../helloworld/Includes/functions.php | 208 ++++++++++++++++++ .../standard/helloworld/template/style.css | 81 +++++++ .../standard/helloworld/template/template.php | 34 +++ 11 files changed, 467 insertions(+) create mode 100644 appengine/standard/helloworld/Content/404.phtml create mode 100644 appengine/standard/helloworld/Content/about-us.phtml create mode 100644 appengine/standard/helloworld/Content/contact.phtml create mode 100644 appengine/standard/helloworld/Content/home.phtml create mode 100644 appengine/standard/helloworld/Content/robert.phtml create mode 100644 appengine/standard/helloworld/Content/top.phtml create mode 100644 appengine/standard/helloworld/DB/wiki.sql create mode 100644 appengine/standard/helloworld/Includes/config.php create mode 100644 appengine/standard/helloworld/Includes/functions.php create mode 100644 appengine/standard/helloworld/template/style.css create mode 100644 appengine/standard/helloworld/template/template.php diff --git a/appengine/standard/helloworld/Content/404.phtml b/appengine/standard/helloworld/Content/404.phtml new file mode 100644 index 0000000000..70b9ea7760 --- /dev/null +++ b/appengine/standard/helloworld/Content/404.phtml @@ -0,0 +1 @@ +

404 - This page does not exist.

\ No newline at end of file diff --git a/appengine/standard/helloworld/Content/about-us.phtml b/appengine/standard/helloworld/Content/about-us.phtml new file mode 100644 index 0000000000..433a3646ec --- /dev/null +++ b/appengine/standard/helloworld/Content/about-us.phtml @@ -0,0 +1,4 @@ +

NOLA Natives  

+

The Malouse family has been native to New Orleans for several generations

+ +

We come in peace

\ No newline at end of file diff --git a/appengine/standard/helloworld/Content/contact.phtml b/appengine/standard/helloworld/Content/contact.phtml new file mode 100644 index 0000000000..36919b09db --- /dev/null +++ b/appengine/standard/helloworld/Content/contact.phtml @@ -0,0 +1,9 @@ + + +

Robert Malouse

+

robert@malouse.com

+

(504) 717-5885

\ No newline at end of file diff --git a/appengine/standard/helloworld/Content/home.phtml b/appengine/standard/helloworld/Content/home.phtml new file mode 100644 index 0000000000..962f167d12 --- /dev/null +++ b/appengine/standard/helloworld/Content/home.phtml @@ -0,0 +1,49 @@ +

Welcome to Malouse.com

+ +

This is my family

+ +
+
+ +

Robert

+
+ +

Robert wrote his own description so he gets the best one. + He is super stylish, awesome, and everyone else pretty much thinks he's the best. + It doesn't matter if they don't agree because he only hears what he wants to hear.

+
+ +
+

Caroline

+
+ +

Caroline

+
+ +

Caroline hasn't written her description yet

+ +
+ + +
+

Mark

+
+ +

Mark

+
+ +

Mark hasn't written his description yet

+ +
+ + +
+

Julie

+
+ +

Julie

+
+ +

Julie hasn't written her description yet

+ +
\ No newline at end of file diff --git a/appengine/standard/helloworld/Content/robert.phtml b/appengine/standard/helloworld/Content/robert.phtml new file mode 100644 index 0000000000..c66b1ed423 --- /dev/null +++ b/appengine/standard/helloworld/Content/robert.phtml @@ -0,0 +1,3 @@ +

Welcome!

+

My site is currently a WIP

+

Feel free to get in touch.

\ No newline at end of file diff --git a/appengine/standard/helloworld/Content/top.phtml b/appengine/standard/helloworld/Content/top.phtml new file mode 100644 index 0000000000..51a5a6f8ac --- /dev/null +++ b/appengine/standard/helloworld/Content/top.phtml @@ -0,0 +1,11 @@ + + + + Robert Malouse's Website + Nobody will ever see this. Contact robert@malouse.com if you want a trophy + + + +

Malouse.com

+ + diff --git a/appengine/standard/helloworld/DB/wiki.sql b/appengine/standard/helloworld/DB/wiki.sql new file mode 100644 index 0000000000..ac7e4542cf --- /dev/null +++ b/appengine/standard/helloworld/DB/wiki.sql @@ -0,0 +1,41 @@ +-- phpMyAdmin SQL Dump +-- version 5.0.2 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost +-- Generation Time: Nov 01, 2020 at 11:33 PM +-- Server version: 10.4.14-MariaDB +-- PHP Version: 7.2.33 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `wiki` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `articles` +-- + +DROP DATABASE IF EXISTS guest_form; +CREATE DATABASE guest_form; +USE guest_form; + +CREATE TABLE comments ( + item_id INT AUTO_INCREMENT, + name VARCHAR(100) NOT NULL, + body longtext NOT NULL, + PRIMARY KEY(item_id) +); + +-- +-- Dumping data for table `articles` +-- + +INSERT INTO `comments` (`item_id`, `name`, `body`) VALUES ('item_id', 'name', 'body'); + diff --git a/appengine/standard/helloworld/Includes/config.php b/appengine/standard/helloworld/Includes/config.php new file mode 100644 index 0000000000..7973d6984e --- /dev/null +++ b/appengine/standard/helloworld/Includes/config.php @@ -0,0 +1,26 @@ + 'Malouse.com', + 'site_url' => '', + 'pretty_uri' => false, + 'nav_menu' => [ + 'home' => 'Home', + 'about-us' => 'About', + 'contact' => 'Contact', + 'robert' => 'Robert', + ], + 'template_path' => 'template', + 'content_path' => 'Content', + 'version' => 'v1.1', + ]; + + return isset($config[$key]) ? $config[$key] : null; +} diff --git a/appengine/standard/helloworld/Includes/functions.php b/appengine/standard/helloworld/Includes/functions.php new file mode 100644 index 0000000000..eb350839ea --- /dev/null +++ b/appengine/standard/helloworld/Includes/functions.php @@ -0,0 +1,208 @@ + $name) { + $query_string = str_replace('page=', '', $_SERVER['QUERY_STRING'] ?? ''); + $class = $query_string == $uri ? ' active' : ''; + $url = config('site_url') . '/' . (config('pretty_uri') || $uri == '' ? '' : '?page=') . $uri; + + // Add nav item to list. See the dot in front of equal sign (.=) + $nav_menu .= '' . $name . '' . $sep; + } + + echo trim($nav_menu, $sep); +} + +/** + * Displays page title. It takes the data from + * URL, it replaces the hyphens with spaces and + * it capitalizes the words. + */ +function page_title() +{ + $page = isset($_GET['page']) ? htmlspecialchars($_GET['page']) : 'Home'; + + echo ucwords(str_replace('-', ' ', $page)); +} + +/** + * Displays page content. It takes the data from + * the static pages inside the pages/ directory. + * When not found, display the 404 error page. + */ +function page_content() +{ + $page = isset($_GET['page']) ? $_GET['page'] : 'home'; + $path = getcwd() . '/' . config('content_path') . '/' . $page . '.phtml'; + + if (! file_exists($path)) { + $path = getcwd() . '/' . config('content_path') . '/404.phtml'; + } + + echo file_get_contents($path); +} + +/** + * Starts everything and displays the template. + */ +function init() +{ + require config('template_path') . '/template.php'; +} + +# Returns TRUE if given password is correct password for this user name. +function is_password_correct($name, $password) { + $db = new PDO("mysql:host=localhost;dbname=wiki", "root", ""); + $name = $db->quote($name); + $rows = $db->query("SELECT password FROM users WHERE name = $name"); + if ($rows) { + foreach ($rows as $row) { + $correct_password = $row["password"]; + return $password === $correct_password; + } + } else { + return FALSE; # user not found + } +} + +/* +end banago +*/ + +/* +function user_exist($name) { //done dont even think about touch + $db = new PDO("mysql:host=localhost;dbname=wiki", "root", ""); + $name = $db->quote($name); + $rows = $db->query("SELECT name FROM users WHERE name = $name"); + if ($rows) { + foreach ($rows as $row) { + $user = $row["password"]; + return $user !== $name; #user found + } + } else { + return FALSE; #user not found + } +} + +function register($name, $password) { //done do not touch + $db = mysqli_connect("localhost", "root", "", "wiki"); + $query = "INSERT INTO users VALUES ('$name', '$password')"; + if (!mysqli_query($db, $query)) { + die('Error '.mysqli_error($db)); + } +} + +function post_article($stitle, $title, $body) { //done do not touch + $db = mysqli_connect("localhost", "root", "", "wiki"); + $stitle = $_REQUEST["short_title"]; + $title = $_REQUEST["title"]; + $body = $_REQUEST["body"]; + $query = "INSERT INTO articles VALUES ('$stitle', '$title', '$body')"; + if (empty($stitle) || empty($title) || empty($body)) { //this took me WAY too long to figure out. Okay? A simple if statement. Way too long. I am actually ashamed of myself. + redirect("/Content/writearticle.phtml", "Please provide a short title, title, and body."); + } elseif (!mysqli_query($db, $query)) { + return redirect("/Content/writearticle.phtml", "Article with short title $stitle already exists!"); + // die('Error '.mysqli_error($db)); + } else { + redirect ("/Content/viewarticle.phtml?short_title=$stitle", "Article Posted!"); + exit(); + } +} + +function get_articles() { + $db = mysqli_connect("localhost", "root", "", "wiki"); + // $query = "SELECT * FROM articles"; + return $db->query("SELECT * FROM articles"); +} + +function get_article($stitle) { + $db = mysqli_connect("localhost", "root", "", "wiki"); + // $query = "SELECT * FROM articles"; + return $db->query("SELECT * FROM articles WHERE short_title = '{$stitle}'"); +} + +function update_title($stitle, $title) { + $db = mysqli_connect("localhost", "root", "", "wiki"); + if (empty($title)){ + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Please provide title text"); + } else{ + $db->query("UPDATE articles SET title = '$title' WHERE short_title = '$stitle'"); + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Succesfully updated title!"); + } +} + +function update_body($stitle, $body) { + $db = mysqli_connect("localhost", "root", "", "wiki"); + if (empty($body)){ + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Please provide title text"); + } else{ + $db->query("UPDATE articles SET body = '$body' WHERE short_title = '$stitle'"); + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Succesfully updated body!"); + } +} + +function update_article($stitle, $title, $body) { + $db = mysqli_connect("localhost", "root", "", "wiki"); + if (empty($body) && empty($title)){ + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Please provide title/body text"); + } else{ + $db->query("UPDATE articles SET title = '$title' WHERE short_title = '$stitle'"); + $db->query("UPDATE articles SET body = '$body' WHERE short_title = '$stitle'"); + redirect("/Content/viewarticle.phtml?short_title=$stitle", "Succesfully updated title and body!"); + } +} + +# Redirects current page to user.phtml if user is not logged in. +function ensure_logged_in() { + if (!isset($_SESSION["name"])) { + redirect("/Content/user.phtml", "You must log in before you can view that page."); + } +} + +# Redirects current page to the given URL and optionally sets flash message. +function redirect($url, $flash_message = NULL) { + if ($flash_message) { + $_SESSION["flash"] = $flash_message; + } + # session_write_close(); + header("Location: $url"); + die; +} + +*/ + +?> \ No newline at end of file diff --git a/appengine/standard/helloworld/template/style.css b/appengine/standard/helloworld/template/style.css new file mode 100644 index 0000000000..f7dfc46b09 --- /dev/null +++ b/appengine/standard/helloworld/template/style.css @@ -0,0 +1,81 @@ +/* +CSS Source: Banago +*/ +.wrap { + padding: 25px; + text-align: center; + box-shadow: 0 4px 25px -4px #9da5ab; +} +article { + padding: 25px 0; + line-height: 150%; + text-align: left; +} + +nav .item { + text-decoration: none; +} +nav .active { + border-bottom: 1px solid; +} + +@media only screen and (min-width: 768px) { + article { + padding: 40px; + } + .wrap { + max-width: 750px; + margin: 50px auto; + padding: 30px 40px; + } +} + +/* +CSS Source: Me +*/ +#navigation li { + display: inline; + padding: 0.5em; + background-color: #ddd; + border: 3px outset gray; + margin: 1em 1em 2em 1em; + } + + +h1, #navigation, #flash { + text-align: center; + } + +#flash { + background-color: #ffffcc; + border: 1px dotted #ccccaa; + margin: 0.5em; + padding: 0.5em; + } + +#container{ + margin: 25px; + max-width: 100%; + height: 225px; + border-radius: 10px; + background: rgb(218, 240, 240); + text-align: center; + /* border:5px solid yellow; */ +} + +#floated{ + margin:10px; + float: left; + width:175px; + text-align: center; + /* border:5px solid yellow; */ + /* background: red; */ +} + +/* span { + position: absolute; + /* top: 50%; */ + /* transform: translate(0, -50%); */ + /* border: 5px solid #FFFF00; */ + /*padding: 10px; + } */ \ No newline at end of file diff --git a/appengine/standard/helloworld/template/template.php b/appengine/standard/helloworld/template/template.php new file mode 100644 index 0000000000..e67e8ca641 --- /dev/null +++ b/appengine/standard/helloworld/template/template.php @@ -0,0 +1,34 @@ + + + + + + + + <?php page_title(); ?> | <?php site_name(); ?> + + + + + + +
+
+

+ +
+ +
+ + +
+ + + +
+ +