Fixed blank browse bug, made public

This commit is contained in:
tcourage 2016-04-02 11:25:29 -04:00
parent a555987da5
commit 28123eee61
3 changed files with 30 additions and 14 deletions

View File

@ -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

View File

@ -10,19 +10,23 @@ echo '<body>';
echo '<div align="center">';
echo '<h1>Meme Machine</h1>';
$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 '<h2>Category: ' . $_POST["memeCategory"] . '</h2>';
$memeCategory = mysqli_real_escape_string($conn, $_POST["memeCategory"]);
$browse = "SELECT * FROM memes WHERE category = \"$memeCategory\"";
@ -51,7 +56,7 @@ if(isset($_POST["browse"])) {
<a href="./">Back</a>
<?php
}
} else {
} else { // If 'Browse All' is pressed
echo '<h2>Category: all</h2>';
$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 '<img src="' . $dir . '/' . $row["fileName"] . '" alt="' . $row["name"] . '" />';
if ($count == 3) {
if ($count == 3) { // Change this number based on how many pictures across you want on the page
echo '<br />';
}
}

View File

@ -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);