diff --git a/README.md b/README.md index 6c56f5b..18b336a 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,46 @@ -# Meme Machine +# ImgHost -## Current Version: v0.3.6-beta +## Current Version: v0.4.0-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. +ImgHost is a self-hosted image hosting software. Upload your images and share them with the world! ## Features -Meme Machine is able to take in images up to 75MiB in size, and stores some basic metadata in a SQL database. +ImgHost is designed to be fully configurable for the ultimate photo sharing experience. User-configurable options range from changing the allowed file size (dependant on your web server), to how files are named and stored, layouts and fonts, to mundane things like table names in your databases. -When a user uploads a meme, they are able to specify a name/description of the meme, as well as a category to help easily organize the memes. +Many features are planned, so stay tuned! + +## Installation + +ImgHost is designed to be as plug-and-play as possible. You will need a: + +- Webserver, that supports +- PHP, coupled with +- MySQL or MariaDB + +You will also want to configure your server to allow for larger file uploads. + +First you will want to either clone this repo, or download the zip (and unzip it to) a directory that your web server software has full read/write access to. + +Next you need to edit `config/db_config.php` and add your SQL credentials. + +If you plan on using a custom domain, you can also edit `config/configuation.php` to include that. + +Then you will need to navigate to `http://imghost.local/config/` or your custom domain to finish database and folder setup. Simply change the available options based on your preferences and click `Setup databases`, once complete you will be redirected to the home page where your server should be ready to use! -Users are then able to browse the memes using the categories, and in future versions will be able to search memes by their name/description. ## Changelog +### v0.4.0-beta - Dec 16, 2023 + +- Full re-factor to convert the old "Meme Machine" to a general-purpose, plug-and-play image hosting software. +- Removed categories, removed names. These will come back as configurable options. +- Added user-configurable CSS for some pizzazz. +- Added private toggle, to prevent images from being shown in the public gallery. +- Photos are given a completely random 6-byte ID instead of storing full file names. + ### v0.3.6-beta - April 7, 2016 - Fixed critical issue where searches wouldn't work diff --git a/browse/browse.php b/browse/browse.php deleted file mode 100644 index 588c1e0..0000000 --- a/browse/browse.php +++ /dev/null @@ -1,80 +0,0 @@ -'; -echo ''; -echo 'Browse - Meme Machine'; -echo ''; -echo ''; -echo ''; -echo '
'; -echo '

Meme Machine

'; - -$dir = "../uploads"; // Directory for file uploads -$fileType = array( // Types of files that are thumbnail'd - 'jpg', - 'jpeg', - 'png', - 'gif' -); - -// MySQL server connection info - -$count = 0; - -//Connect to MySQL -$conn = mysqli_connect($servername, $username, $password, $dbname); - -if (!$conn) { - die ("CONNECTION FAIL " .mysqli_connect_error()); -} else { -} - - -if(isset($_POST["browse"]) && $_POST["memeCategory"]) { // If "Browse" is pressed - echo '

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

'; - $memeCategory = mysqli_real_escape_string($conn, $_POST["memeCategory"]); - $browse = "SELECT * FROM memes WHERE category = \"$memeCategory\""; - $result = mysqli_query($conn, $browse); - - if (mysqli_num_rows($result) > 0) { - while($row = mysqli_fetch_assoc($result)) { - $count++; - echo '' . $row['; - if ($count == 3) { - echo '
'; - } - } - } else { - echo "This category is empty. Please choose another or start uploading"; - ?> -

 

- Back - Category: all'; - $browse = "SELECT * FROM memes"; - $result = mysqli_query($conn, $browse); - //browse all code goes here - if (mysqli_num_rows($result) > 0) { - while($row = mysqli_fetch_assoc($result)) { - $count++; - echo '' . $row['; - if ($count == 3) { // Change this number based on how many pictures across you want on the page - echo '
'; - } - } - } else { - echo "Shit, something broke. Try again! Or if the problem persists contact the system administrator"; - ?> -

 

- Back - '; -echo ''; -?> diff --git a/browse/index.php b/browse/index.php index 7d659f7..dc881bc 100644 --- a/browse/index.php +++ b/browse/index.php @@ -1,105 +1,53 @@ - - - - Meme Machine Gallery - + - -
-

Meme Machine

-

Search by name

-
- - - - -
- -
- -
-

- OR -

-
- -
-
-

Browse by category: - -

-
- - -
- - - - +//Setting up the webpage +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo 'Browse - ' . $serverName . ''; +echo ''; +echo ''; +echo '
'; +echo '

' . $serverName . '

'; - +$count = 0; + +//Connect to MySQL +$conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword, $dbname); + +if (!$conn) { + die ("CONNECTION FAIL " . mysqli_connect_error()); +} else { +} + +echo '

All public photos

'; +$browse = "SELECT * FROM $tablename WHERE isPrivate = 0"; +$result = mysqli_query($conn, $browse); +//browse all code goes here +if (mysqli_num_rows($result) > 0) { + while($row = mysqli_fetch_assoc($result)) { + $file = $row["imgID"] . "." . $row["fileType"]; + $count++; + echo '' . $row['; + if ($count == 3) { // Change this number based on how many pictures across you want on the page + echo '
'; + } + } +} else { + echo "Shit, something broke. Try again! Or if the problem persists contact the system administrator"; + ?> +

 

+ Home + '; +echo ''; +?> diff --git a/browse/query.php b/browse/query.php deleted file mode 100644 index 8ae1fca..0000000 --- a/browse/query.php +++ /dev/null @@ -1,68 +0,0 @@ -'; -echo ''; -echo 'Browse - Meme Machine'; -echo ''; -echo ''; -echo ''; -echo '
'; -echo '

Meme Machine

'; - - $count = 0; - //Connect to MySQL - $conn = mysqli_connect($servername, $username, $password, $dbname); - - if (!$conn) { - die ("CONNECTION FAIL " .mysqli_connect_error()); - } else { - } - - $words = $_POST['term']; - - - $parts=explode(" ",trim($words)); - $clauses=array(); - foreach ($parts as $part){ - $clauses[]="'%" . $part . "%'"; - } - $clause .= implode(' OR ' ,$clauses); - - $sql = "SELECT * FROM memes WHERE name LIKE $clause OR category LIKE $clause"; - if(isset($_POST['search']) && $words){ - echo "You searched for: " . $words . "
"; - - $result = mysqli_query($conn, $sql); - - if (mysqli_num_rows($result) > 0) { - while($row = mysqli_fetch_assoc($result)) { - $count++; - echo '' . $row['; - if ($count == 3) { - echo '
'; - } - } - } else { - echo "Your search returned no results. Please go back and try again"; - ?> -

 

- Back - -

Please go back and enter a search query

-
-
- Back - '; -echo 'Back'; -echo ''; -echo ''; -?> diff --git a/config/configuration.php b/config/configuration.php new file mode 100644 index 0000000..8ec767a --- /dev/null +++ b/config/configuration.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/config/db_config.php b/config/db_config.php new file mode 100644 index 0000000..954ffb0 --- /dev/null +++ b/config/db_config.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/config/index.php b/config/index.php new file mode 100644 index 0000000..a296d40 --- /dev/null +++ b/config/index.php @@ -0,0 +1,36 @@ + + + + + + + <?php echo $serverName; ?> Config + + + + +
+

+
+
+
+

+
+
+
+
+
+
+
+ +
+
+
+
+
+
ImgHost (v0.4.0-beta)
+
+ diff --git a/config/initial_setup.php b/config/initial_setup.php new file mode 100644 index 0000000..829e8fd --- /dev/null +++ b/config/initial_setup.php @@ -0,0 +1,67 @@ +"; +echo "$sqlServer
"; +echo "$sqlUsername
"; +echo "$sqlPassword
"; + +$conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword); + +echo "Sql connection attempt
"; +if (!$conn) { + die("Connection failed: " . mysqli_connect_error()); +} +echo "Sql connection successful!
"; + +// Create the database, if it doesn't exist +$dbSetup = "CREATE DATABASE IF NOT EXISTS $dbname"; +echo "Preparing database with command - " . $dbSetup . "
"; + +if (mysqli_query($conn, $dbSetup)) { + echo "Database successfully prepared!
"; +} else { + echo "Database Error " . $sql . "
" . mysqli_error($conn); +} + + +echo "Reconnecting to new database...
"; +$conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword, $dbname); + +if (!$conn) { + die("Connection failed: " . mysqli_connect_error()); +} +echo "Sql connection successful!
"; + +// Create the table, if doesn't exit +$tableSetup = "CREATE TABLE IF NOT EXISTS $tablename ( + imgID CHAR(12), + fileType VARCHAR(4), + mimeType VARCHAR(20), + isPrivate BOOLEAN, + uploadDate DATETIME DEFAULT CURRENT_TIMESTAMP, + editDate DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + )"; + +echo "Preparing table with command - " . $tableSetup . "
"; + +if (mysqli_query($conn, $tableSetup)) { + echo "Table successfully prepared!
"; +} else { + echo "Database Error " . $sql . "
" . mysqli_error($conn); +} + +echo "Preparing images folder...
"; + +$directory = "../" . $targetDir; +echo $directory. "
"; +mkdir ($directory); + +echo "Initial setup complete! Enjoy!
" + +?> + +Homepage \ No newline at end of file diff --git a/config/style.css b/config/style.css new file mode 100644 index 0000000..12ffd73 --- /dev/null +++ b/config/style.css @@ -0,0 +1,40 @@ +.background { + background-attachment: fixed; + background: linear-gradient(237deg, #0000ffd2, #1eff009a, #7d00a7); + background-size: 500% 500%; + + -webkit-animation: AnimationName 45s ease infinite; + -moz-animation: AnimationName 45s ease infinite; + animation: AnimationName 45s ease infinite; +} +@-webkit-keyframes AnimationName { + 0%{background-position:0% 50%} + 50%{background-position:100% 50%} + 100%{background-position:0% 50%} +} +@-moz-keyframes AnimationName { + 0%{background-position:0% 50%} + 50%{background-position:100% 50%} + 100%{background-position:0% 50%} +} +@keyframes AnimationName { + 0%{background-position:0% 50%} + 50%{background-position:100% 50%} + 100%{background-position:0% 50%} +} + +.layout { + max-width: 900px; + margin: auto; + font-family: 'Calibri'; +} + +h1,h2,h3,h4,h5,h6,p { + text-align: center; +} + +img { + width:100%; + max-width:300px; + padding:7px; +} \ No newline at end of file diff --git a/index.php b/index.php index 7fd933c..8a21f22 100644 --- a/index.php +++ b/index.php @@ -1,108 +1,41 @@ + - Meme Machine + + + + <?php echo $serverName; ?> - - -
-

The Meme Machine

+ +
+

+
-

Name/Description of meme:

-

Category: - -


-

+

+

Private images will not be shown in the public gallery, but will still be accessible by visiting the provided link.

+

All links are generated at random, and are virtually impossible to guess. "Security" through obscurity!

+

-
-

-

Accepted file formats: .gif, .png, .jpg, .jpeg

+

Accepted file formats: .gif, .png, .jpg/jpeg, .webp




- - -
-
+


-
Meme Machine v0.3.6-beta
+
ImgHost (v0.4.0-beta)
diff --git a/upload.php b/upload.php index a7de8df..5b009c0 100644 --- a/upload.php +++ b/upload.php @@ -1,37 +1,48 @@ 75000000) { - echo "Sorry, your file is too large."; - $uploadOk = 0; -} -// Allow certain file formats -if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" -&& $imageFileType != "gif" ) { - echo "Only JPG, JPEG, PNG & GIF files are allowed."; + echo "Sorry, your image is too large (75 MB limit)."; $uploadOk = 0; } @@ -61,7 +66,11 @@ if ($uploadOk == 0) { // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { - echo "The meme ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; + echo "

The image ". $fileName . " has been uploaded.


"; + if ($isPrivate != 0) { + echo "

You have chosen to make this image private - it will not appear in the public gallery.

"; + } + echo "

View image

"; ?>

 

Back