Add Files

This commit is contained in:
Emily Daemon 2022-11-17 20:23:43 +02:00
parent 4024be8235
commit 2d40265c67
36 changed files with 320 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Ignore files that may contain irrelevant content or secrets
config.php
creds.php

5
README Normal file
View File

@ -0,0 +1,5 @@
~ m o o d b l o g ~
to set up:
1: copy templates/config.def.php to templates/config.php and change the placeholders
2: copy creds.def.php to creds.php and change the placeholders

8
creds.def.php Normal file
View File

@ -0,0 +1,8 @@
<?php
$databaseHost='127.0.0.1';
$databaseUsername='username';
$databasePassword='password';
$databaseName='database';
$mysqli=mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
?>

97
css/glazed-gray.css Normal file
View File

@ -0,0 +1,97 @@
html, body {
margin: 0px 5px 5px 5px;
background-color: #c0c0c0;
}
body {
margin: auto;
width: 728px;
font-family: sans-serif;
}
@media screen and (max-width: 728px) {
body {
width: 100%;
}
}
div.window-bar {
background: linear-gradient(180deg, rgba(128,128,128,1) 0%, rgba(54,54,54,1) 13%, rgba(51,51,51,1) 49%, rgba(29,29,29,1) 51%, rgba(4,4,4,1) 81%, rgba(0,0,0,1) 100%);
color: #ffffff;
/*padding: 2px 8px 2px 8px;*/
padding: 4px 8px 4px 8px;
}
div.window {
background-color: #eeeeee;
margin-top: 10px;
margin-bottom: 10px;
}
div.window-content {
padding: 15px;
border: 2px solid #000000;
border-top: 0px;
}
.post-date {
float: right;
}
img.pfp {
float: left;
padding: 2px;
border: 2px solid #000000;
margin-right: 15px;
display: block;
}
div.bio {
grid-area: bio;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
hr {
border: 1px solid #000000;
}
footer {
text-align: center;
}
a.options {
text-decoration: none;
}
a.options:visited {
color: #0000ee;
}
.monospace {
font-family: monospace;
}
img.mood {
vertical-align: middle;
}
div.hidden-info {
display: none;
font-family: monospace;
}
label.show-info {
color: #0000ee;
cursor: pointer;
}
label.show-info:active {
color: #ff0000;
}
input.show-info:checked ~ div.hidden-info {
display: flex;
}
pre.hidden-info {
margin: 5px 0px 0px 0px;
}
div.grid-container {
display: grid;
grid-template-columns: auto auto auto;
}
div.bio-grid-container {
display: grid;
/*grid-template-columns: 98px auto auto;*/
grid-template-areas:
'pfp bio';
}
pre {
white-space: pre-wrap;
word-break: break-word;
}

BIN
img/moods/alarmed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

BIN
img/moods/angry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

BIN
img/moods/cheeky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

BIN
img/moods/dumb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

BIN
img/moods/embarassed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

BIN
img/moods/evil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

BIN
img/moods/fat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

BIN
img/moods/frustrated.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

BIN
img/moods/happy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

BIN
img/moods/mad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

BIN
img/moods/neutral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

BIN
img/moods/ninja.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

BIN
img/moods/no-mouth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

BIN
img/moods/old.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

BIN
img/moods/questioning.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

BIN
img/moods/sad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

BIN
img/moods/silly.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

BIN
img/moods/surprised.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

BIN
img/moods/tired.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

BIN
img/moods/torn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

BIN
img/moods/what-a-night.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
img/moods/whistle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

BIN
img/pfp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

32
index.php Normal file
View File

@ -0,0 +1,32 @@
<?php
include('templates/header.php');
include('templates/bio.php');
require('creds.php');
$result = mysqli_query($mysqli, "SELECT ID, Title, Mood, MoodImage, Song, DATE_FORMAT(Time, '%d-%m-%Y %H:%i'), Message FROM articles ORDER BY ID DESC");
while($res = mysqli_fetch_array($result)) {
echo "<div class='window' id='".$res['ID']."'>";
echo " <div class='window-bar'>";
echo " <span>".$res['Title']."</span>";
echo " <span class='post-date'>".$res["DATE_FORMAT(Time, '%d-%m-%Y %H:%i')"]."</span>";
echo " </div>";
echo " <div class='window-content'>";
echo " <span class='pre-post'>";
echo " <b class='mood'>current mood:</b> <img class='mood' src='img/moods/".$res['MoodImage']."'/> ".$res['Mood'];
echo " </span>";
echo " <br/>";
echo " <span class='pre-post'>";
echo " <b class='tunes'>current tunes:</b> ".$res['Song'];
echo " </span>";
echo " <hr/>";
echo $res['Message'];
echo " <hr/>";
echo " <span class='options'>share: <input type='text' readonly='readonly' value='".$root."/#".$res['ID']."'</span>";
echo " </div>";
echo "</div>";
}
include('templates/footer.php');
?>

9
schema.sql Normal file
View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS articles (
ID INT NOT NULL AUTO_INCREMENT primary key,
Time TIMESTAMP,
Title VARCHAR(512) NOT NULL,
Mood VARCHAR(256),
MoodImage VARCHAR(256),
Song VARCHAR(256),
Message MEDIUMTEXT NOT NULL
);

22
templates/bio.php Normal file
View File

@ -0,0 +1,22 @@
<div class="window">
<div class="window-bar">
<span><?php echo $blog_title; ?></span>
</div>
<div class="window-content clearfix">
<img class="pfp" src="<?php echo $root; ?>/img/pfp.png" alt="profile picture"/>
<div class="bio">
<b><?php echo $username; ?></b>
<hr/>
<i><?php echo $tagline; ?></i>
<br/>
<label for="dropdown-1" class="show-info">(more info)</label>
<input class="show-info" type="checkbox" id="dropdown-1" value="0" aria-hidden="true" hidden/>
<br/>
<div class="hidden-info">
<pre class="hidden-info">
<?php echo $more_info; ?>
</pre>
</div>
</div>
</div>
</div>

19
templates/config.def.php Normal file
View File

@ -0,0 +1,19 @@
<?php
$version="v0.0-dev";
$copyright_date="2022";
$url="http://192.168.8.222:2202";
$root=$url.""; // If moodblog is located in a subdirectory, you'll want to change this.
$style="glazed-gray.css"; // This would be a file located in your /css folder
$charset="UTF-8"; // If you don't know what this is, leave it be!
$blog_title="Example User's blog created with moodblog"; // Title shown in the bio window
$short_blog_title="Example moodblog"; // String used in <title>
$username="User";
$tagline='"Sample tagline, not necessarily surrounded with quotes"';
$more_info="IRC Nickname: Example
E-Mail: example@example.com
Interests: Being an example, writing Lorem Ipsum-type texts, ReplacingSpacesWithNothingToDemonstrateLineWrapping";
?>

7
templates/footer.php Normal file
View File

@ -0,0 +1,7 @@
<footer>
<span>moodblog <?php echo $version; ?></span>
<br>
<span>&copy; <?php echo $copyright_date; ?></span>
</footer>
</body>
</html>

12
templates/header.php Normal file
View File

@ -0,0 +1,12 @@
<?php include('config.php') ?>
<!DOCTYPE html>
<html lang="us">
<head>
<title><?php echo $short_blog_title; ?></title>
<meta charset="<?php echo $charset; ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="<?php echo $root."/css/".$style; ?>">
<style>
</style>
</head>
<body>

View File

@ -0,0 +1,16 @@
<?php
$version="v0.0-dev";
$rootdir="/var/www/moodblog";
$url="http://192.168.8.222:2202";
$style="glazed-gray.css"; // This would be a file located in your /css folder
$blog_title="Example User's blog created with moodblog";
$short_blog_title="Example moodblog"; // String used in <title>
$username="User";
$tagline='"Sample tagline, not necessarily surrounded with quotes"';
$more_info="IRC Nickname: Example
E-Mail: example@example.com
Interests: Being an example, writing Lorem Ipsum-type texts";
?>

53
write/index.php Normal file
View File

@ -0,0 +1,53 @@
<?php include('../templates/header.php') ?>
<div class="window">
<div class="window-bar">
<span>write</span>
</div>
<div class="window-content">
<form name="blogpost" method="post" action="post.php">
<b>choose an icon that represents your mood the most:</b>
<div class="grid-container">
<div class="grid-item">
<input type="radio" name="moodimage" value="alarmed.png"><img src="<?php echo $root; ?>/img/moods/alarmed.png" alt="alarmed.png" class="mood"/> alarmed.png<br/>
<input type="radio" name="moodimage" value="angry.png"><img src="<?php echo $root; ?>/img/moods/angry.png" alt="angry.png" class="mood"/> angry.png<br/>
<input type="radio" name="moodimage" value="cheeky.png"><img src="<?php echo $root; ?>/img/moods/cheeky.png" alt="cheeky.png" class="mood"/> cheeky.png<br/>
<input type="radio" name="moodimage" value="dumb.png"><img src="<?php echo $root; ?>/img/moods/dumb.png" alt="dumb.png" class="mood"/> dumb.png<br/>
<input type="radio" name="moodimage" value="embarassed.png"><img src="<?php echo $root; ?>/img/moods/embarassed.png" alt="embarassed.png" class="mood"/> embarassed.png<br/>
<input type="radio" name="moodimage" value="evil.png"><img src="<?php echo $root; ?>/img/moods/evil.png" alt="evil.png" class="mood"/> evil.png<br/>
<input type="radio" name="moodimage" value="fat.png"><img src="<?php echo $root; ?>/img/moods/fat.png" alt="fat.png" class="mood"/> fat.png<br/>
<input type="radio" name="moodimage" value="frustrated.png"><img src="<?php echo $root; ?>/img/moods/frustrated.png" alt="frustrated.png" class="mood"/> frustrated.png<br/>
<input type="radio" name="moodimage" value="happy.png"><img src="<?php echo $root; ?>/img/moods/happy.png" alt="happy.png" class="mood"/> happy.png<br/>
<input type="radio" name="moodimage" value="mad.png"><img src="<?php echo $root; ?>/img/moods/mad.png" alt="mad.png" class="mood"/> mad.png<br/>
<input type="radio" name="moodimage" value="neutral.png"><img src="<?php echo $root; ?>/img/moods/neutral.png" alt="neutral.png" class="mood"/> neutral.png<br/>
</div>
<div class="grid-item">
<input type="radio" name="moodimage" value="ninja.png"><img src="<?php echo $root; ?>/img/moods/ninja.png" alt="ninja.png" class="mood"/> ninja.png<br/>
<input type="radio" name="moodimage" value="no-mouth.png"><img src="<?php echo $root; ?>/img/moods/no-mouth.png" alt="no-mouth.png" class="mood"/> no-mouth.png<br/>
<input type="radio" name="moodimage" value="old.png"><img src="<?php echo $root; ?>/img/moods/old.png" alt="old.png" class="mood"/> old.png<br/>
<input type="radio" name="moodimage" value="questioning.png"><img src="<?php echo $root; ?>/img/moods/questioning.png" alt="questioning.png" class="mood"/> questioning.png<br/>
<input type="radio" name="moodimage" value="sad.png"><img src="<?php echo $root; ?>/img/moods/sad.png" alt="sad.png" class="mood"/> sad.png<br/>
<input type="radio" name="moodimage" value="silly.png"><img src="<?php echo $root; ?>/img/moods/silly.png" alt="silly.png" class="mood"/> silly.png<br/>
<input type="radio" name="moodimage" value="surprised.png"><img src="<?php echo $root; ?>/img/moods/surprised.png" alt="surprised.png" class="mood"/> surprised.png<br/>
<input type="radio" name="moodimage" value="tired.png"><img src="<?php echo $root; ?>/img/moods/tired.png" alt="tired.png" class="mood"/> tired.png<br/>
<input type="radio" name="moodimage" value="torn.png"><img src="<?php echo $root; ?>/img/moods/torn.png" alt="torn.png" class="mood"/> torn.png<br/>
<input type="radio" name="moodimage" value="what-a-night.png"><img src="<?php echo $root; ?>/img/moods/what-a-night.png" alt="what-a-night.png" class="mood"/> what-a-night.png<br/>
<input type="radio" name="moodimage" value="whistle.png"><img src="<?php echo $root; ?>/img/moods/whistle.png" alt="whistle.png" class="mood"/> whistle.png<br/>
</div>
</div>
<b>post title:</b> <input type="text" name="title"/>
<br/>
<b>current mood:</b> <input type="text" name="mood"/>
<br/>
<b>current tunes:</b> <input type="text" name="tunes"/>
<br/>
<b>article:</b> (HTML markup is allowed)
<br/>
<textarea name="articlebody" cols="80" rows="25"></textarea>
<br/>
<b>enter your password:</b> <input type="password" name="password"/>
<br/>
<input type="submit" value="post!"/>
</form>
</div>
</div>
<?php include('../templates/footer.php') ?>

37
write/post.php Normal file
View File

@ -0,0 +1,37 @@
<?php
include("../templates/header.php");
include("../config.php");
require("../creds.php");
$go_back = "<br/><a class='button options' href='".$root."'>go back!</a>";
?>
<div class='window'>
<div class='window-bar'>
<span>post results</span>
</div>
<div class='window-content'>
<?php
if(isset($_POST['articlebody'])) {
if($_POST['password'] == "yeppers") {
$title = mysqli_real_escape_string($mysqli, $_POST['title']);
$mood = mysqli_real_escape_string($mysqli, $_POST['mood']);
$moodimage = mysqli_real_escape_string($mysqli, $_POST['moodimage']);
$song = mysqli_real_escape_string($mysqli, $_POST['tunes']);
$articlebody = mysqli_real_escape_string($mysqli, $_POST['articlebody']);
$mysqli->query("INSERT INTO articles (Title, Mood, MoodImage, Song, Message) VALUES('".$title."', '".$mood."', '".$moodimage."', '".$song."', '".$articlebody."')");
#$mysqli->query('INSERT INTO articles (Title, Mood, MoodImage, Song, Message) VALUES("title test", "mood", "what-a-night.png", "music", "styles!")');
#$mysqli->query('INSERT INTO articles (Title, Mood, MoodImage, Song, Message) VALUES("'.$title.'", "'.$mood.'", "what-a-night.png", "music", "styles!")');
echo "success".$go_back;
header("Location: ".$root);
exit();
}
echo "<p>".$_POST['password']."</p>";
die("wrong password".$go_back);
}
die("no POST".$go_back);
?>
</div>
</div>
<?php include("../templates/footer.php"); ?>