forked from pathwar/pathwar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated and added imageboard challenge (pathwar#214)
feat: updated and added imageboard challenge
- Loading branch information
Showing
10 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '3.7' | ||
|
||
services: | ||
front: | ||
build: front | ||
ports: | ||
- 80 | ||
depends_on: | ||
- mysql | ||
|
||
mysql: | ||
build: mysql | ||
expose: | ||
- 3306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM php:7.3-apache | ||
RUN docker-php-ext-install mysqli | ||
COPY www/ /var/www/html/ | ||
COPY on-init /pathwar-hooks/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
sed -i "s/__PASSPHRASE__/$(pwctl passphrase 0)" /var/www/html/admin.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
//The passphrase is __PASSPHRASE__ | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
$mysqli = new mysqli('mysql:3306', 'imageboard', 'imageboard', 'imageboard'); | ||
|
||
if (mysqli_connect_errno()) { | ||
die(mysqli_connect_error()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
if (isset($_GET['file'])) { | ||
header('Content-Type: image/jpeg'); | ||
header("Content-Transfer-Encoding: binary"); | ||
readfile('/var/www/html/images/'.$_GET['file']); | ||
} | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" style="background: black"> | ||
<head> | ||
<title>1337Chan</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | ||
</head> | ||
<center><p>Welcome to my new image board ! It is not finished yet, but you can already see what it will look like !</p></center> | ||
<center><p>For can, only the admin can upload pictures, but you will soon be able to do the same !</p></center> | ||
|
||
<?php | ||
include('db.php'); | ||
//<a href="/admin.php">Admin<a/> //admin not finished yet | ||
$query='SELECT * from posts LIMIT 10;'; | ||
$res = $mysqli->query($query) or die($mysqli->error); | ||
while ($row=mysqli_fetch_assoc($res)) { | ||
echo '<div class="post">'; | ||
echo '<span class="info">Post '.$row['id'].' | Author : '.$row['author'].'</span>'; | ||
$query='SELECT * FROM images where id='.$row['image_id'].';'; | ||
$res2=$mysqli->query($query) or die($mysqli->error); | ||
echo '<img style="float: left;" src="get.php?file='.mysqli_fetch_assoc($res2)['path'].'">'; | ||
$query='SELECT * FROM comments where post_id='.$row['id'].';'; | ||
$res2=$mysqli->query($query) or die($mysqli->error); | ||
while ($row2=mysqli_fetch_assoc($res2)) { | ||
echo '<span class="comment" style="float: left; margin-top: 10px; margin-left: 10px;">'; | ||
echo '<blockquote>'.htmlentities($row2['content']).'</blockquote>'; | ||
echo '</span><br /><br /><br /><br /><br />'; | ||
} | ||
echo '</div><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />'; | ||
} | ||
?> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM mysql:5.7 | ||
COPY bootstrap.sql /docker-entrypoint-initdb.d/ | ||
ENV MYSQL_DATABASE=imageboard \ | ||
MYSQL_USER=imageboard \ | ||
MYSQL_PASSWORD=imageboard \ | ||
MYSQL_RANDOM_ROOT_PASSWORD=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DROP DATABASE IF EXISTS imageboard; | ||
CREATE DATABASE imageboard; | ||
GRANT ALL PRIVILEGES ON imageboard.* to 'imageboard'@'%'; | ||
USE imageboard; | ||
CREATE TABLE posts (id INTEGER AUTO_INCREMENT PRIMARY KEY, image_id INTEGER, author TEXT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP); | ||
CREATE TABLE comments (id INTEGER AUTO_INCREMENT PRIMARY KEY, content TEXT, post_id INTEGER); | ||
CREATE TABLE images (id INTEGER AUTO_INCREMENT PRIMARY KEY, path TEXT); | ||
INSERT INTO posts (image_id, author) VALUES (1, 'admin'); | ||
INSERT INTO posts (image_id, author) VALUES (1, 'admin'); | ||
INSERT INTO comments (content, post_id) VALUES ('Test comment, please ignore', 1); | ||
INSERT INTO comments (content, post_id) VALUES ('lakdsfj;la;sdkjf<sc>', 1); | ||
INSERT INTO comments (content, post_id) VALUES ('ffufufufufufuf', 2); | ||
INSERT INTO images (path) VALUES ('test.jpg'); |