From 28123eee61b325a0c307a6488389873d9572fcf4 Mon Sep 17 00:00:00 2001 From: tcourage Date: Sat, 2 Apr 2016 11:25:29 -0400 Subject: [PATCH] Fixed blank browse bug, made public --- README.md | 13 ++++++++++++- browse/browse.php | 23 ++++++++++++++--------- upload.php | 8 ++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fce8b63..d4f1a6b 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -## Meme Machine +# Meme Machine + +## Current Version: v0.2 BETA + +## Overview + +The Meme Machine is a semi-private repository of memes that can be easily searched, indexed, and accessed anywhere at any time. Content is not limited to memes, either. Reaction images and gifs, cancerous stuff, friends/members-related stuff, fails, replies, anything, really. It's mostly here for organization and access. This is the source code. + +## Running + +Clone the repository to the root (or other subdirectory) of your website. Change the appropriate files so that your database is being accessed with your credentials. Make a folder called "uploads" or change the code to suit your needs + diff --git a/browse/browse.php b/browse/browse.php index 9ffb2c1..49bc699 100644 --- a/browse/browse.php +++ b/browse/browse.php @@ -10,19 +10,23 @@ echo ''; echo '
'; echo '

Meme Machine

'; -$dir = "../uploads"; -$fileType = array( +$dir = "../uploads"; // Directory for file uploads +$fileType = array( // Types of files that are thumbnail'd 'jpg', 'jpeg', 'png', 'gif' ); -$servername = "localhost"; -$username = "root"; -$password = "Flamingh0m()"; -$dbname = "memes"; + +// MySQL server connection info +$servername = "db_address"; +$username = "db_username"; +$password = "db_password"; +$dbname = "db_name"; + $count = 0; +//Connect to MySQL $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { @@ -30,7 +34,8 @@ if (!$conn) { } else { } -if(isset($_POST["browse"])) { + +if(isset($_POST["browse"]) && $var) { // If "Browse" is pressed echo '

Category: ' . $_POST["memeCategory"] . '

'; $memeCategory = mysqli_real_escape_string($conn, $_POST["memeCategory"]); $browse = "SELECT * FROM memes WHERE category = \"$memeCategory\""; @@ -51,7 +56,7 @@ if(isset($_POST["browse"])) { Back Category: all'; $browse = "SELECT * FROM memes"; $result = mysqli_query($conn, $browse); @@ -60,7 +65,7 @@ if(isset($_POST["browse"])) { while($row = mysqli_fetch_assoc($result)) { $count++; echo '' . $row['; - if ($count == 3) { + if ($count == 3) { // Change this number based on how many pictures across you want on the page echo '
'; } } diff --git a/upload.php b/upload.php index 72debe0..d84a702 100644 --- a/upload.php +++ b/upload.php @@ -4,10 +4,10 @@ $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); -$servername = "localhost"; -$username = "root"; -$password = "Flamingh0m()"; -$dbname = "memes"; +$servername = "db_address"; +$username = "db_username"; +$password = "db_password"; +$dbname = "db_name"; $conn = mysqli_connect($servername, $username, $password, $dbname);