Add forums (beta)
This commit is contained in:
parent
efea83e7ca
commit
b0034c937b
12 changed files with 299 additions and 9 deletions
1
3ds/forums/data/topic/0.json
Normal file
1
3ds/forums/data/topic/0.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"name":"General Beta","description":"General topic for all users to use (beta)","allowGuest":false,"posts":[{"title":"System Post","from":"System","cont":"wuzzup guise???","time":0,"com":[]},{"title":"Hey guys","from":"HxOr1337","cont":"Hey guys\n\n[code]<?php\n\/\/ Hello everyone, this is my first\n\/\/ post. I'm not exactly sure how\n\/\/ all this will play out on the\n\/\/ Nintendo 3DS, but here's to\n\/\/ hoping highlight.js plays\n\/\/ nice with the Nintendo 3DS\n?>[/code]","time":0,"com":[]}]}
|
||||
77
3ds/forums/index.php
Normal file
77
3ds/forums/index.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
session_start();
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
width: 320px;
|
||||
background-color: #fffff;
|
||||
font-size: 12px;
|
||||
}
|
||||
#contenttop {
|
||||
background-color: #f0f0f0;
|
||||
height: 208px;
|
||||
}
|
||||
|
||||
#contentbot {
|
||||
background-color: #f0f0f0;
|
||||
height: 222px;
|
||||
overflow-y: scroll;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.commentbox {
|
||||
width: 250px;
|
||||
outline: 1px solid black;
|
||||
min-height: 200px;
|
||||
}
|
||||
.aqua {
|
||||
background-color: #33CCFF;
|
||||
}
|
||||
.crow {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid black;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<title>3DSTownSquare forums</title>
|
||||
<meta name="viewport" content="width=320">
|
||||
<meta name="description" content="Welcome to 3DSTownSquare forums. It's a place to post about whatever you want!">
|
||||
</head>
|
||||
<body>
|
||||
<div id="contenttop">
|
||||
<img src="../../images/header3ds.png" alt="Oops! Our header could not be displayed!" />
|
||||
<center><b><u>Welcome to 3DSTownSquare forums!</u></b></center>
|
||||
</div>
|
||||
<div id="contentbot">
|
||||
<center>
|
||||
<div class="commentbox">
|
||||
<div class="aqua">
|
||||
Topics
|
||||
</div>
|
||||
<div id="comments">
|
||||
<?php
|
||||
$files = scandir('data/topic');
|
||||
foreach($files as $file) {
|
||||
// echo $file;
|
||||
if(is_file("data/topic/".$file)){
|
||||
$jsonF = file_get_contents("data/topic/".$file);
|
||||
$jsonD = json_decode($jsonF, true);
|
||||
$name = "<a href='topic.php?t=".str_replace(".json","",$file)."'>".$jsonD["name"]."</a>";
|
||||
$desc = $jsonD["description"];
|
||||
$latestPost = "Latest post by: ".$jsonD["posts"][0]["from"].", \"".htmlspecialchars($jsonD["posts"][0]["title"])."\"";
|
||||
echo "<div class='crow' alt='".$desc."'>" . $name . "<br/><font color='grey'>".$latestPost."</font></div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a href="../">Back</a>
|
||||
</center>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
87
3ds/forums/topic.php
Normal file
87
3ds/forums/topic.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
session_start();
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
width: 320px;
|
||||
background-color: #fffff;
|
||||
font-size: 12px;
|
||||
}
|
||||
#contenttop {
|
||||
background-color: #f0f0f0;
|
||||
height: 208px;
|
||||
}
|
||||
|
||||
#contentbot {
|
||||
background-color: #f0f0f0;
|
||||
height: 222px;
|
||||
overflow-y: scroll;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.commentbox {
|
||||
width: 250px;
|
||||
outline: 1px solid black;
|
||||
min-height: 200px;
|
||||
}
|
||||
.aqua {
|
||||
background-color: #33CCFF;
|
||||
}
|
||||
.crow {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid black;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<title>3DSTownSquare forums</title>
|
||||
<meta name="viewport" content="width=320">
|
||||
<meta name="description" content="Welcome to 3DSTownSquare forums. It's a place to post about whatever you want!">
|
||||
</head>
|
||||
<body>
|
||||
<div id="contenttop">
|
||||
<img src="../../images/header3ds.png" alt="Oops! Our header could not be displayed!" />
|
||||
<center><b><u>Welcome to 3DSTownSquare forums!</u></b></center>
|
||||
</div>
|
||||
<div id="contentbot">
|
||||
<center>
|
||||
<?php
|
||||
$error = "";
|
||||
if(isset($_GET["t"]) && file_exists("data/topic/".$_GET["t"].".json")){
|
||||
$jsonF = file_get_contents("data/topic/".$_GET["t"].".json");
|
||||
$jsonD = json_decode($jsonF, true);
|
||||
} else {
|
||||
$error = "There are no posts in this topic.";
|
||||
}
|
||||
?>
|
||||
<div class="commentbox">
|
||||
<div class="aqua">
|
||||
<?php if($error == ""){
|
||||
?>
|
||||
Posts in <?php echo htmlspecialchars($jsonD["name"]) ?>
|
||||
<?php
|
||||
} else {
|
||||
echo "Error";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="comments">
|
||||
<?php if($error == ""){
|
||||
foreach($jsonD["posts"] as $key => $post){
|
||||
echo "<div class='crow'><a href='view.php?topic=".$_GET["t"]."&post=".$key."'>\"".$post["title"]."\" from " . $post["from"] . "</a></div>";
|
||||
}
|
||||
} else {
|
||||
echo $error;
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a href="../forums">Back</a>
|
||||
</center>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
105
3ds/forums/view.php
Normal file
105
3ds/forums/view.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
session_start();
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet"
|
||||
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
width: 320px;
|
||||
background-color: #fffff;
|
||||
font-size: 12px;
|
||||
}
|
||||
#contenttop {
|
||||
background-color: #f0f0f0;
|
||||
height: 208px;
|
||||
}
|
||||
|
||||
#contentbot {
|
||||
background-color: #f0f0f0;
|
||||
height: 222px;
|
||||
overflow-y: scroll;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.commentbox {
|
||||
width: 250px;
|
||||
outline: 1px solid black;
|
||||
min-height: 200px;
|
||||
}
|
||||
.aqua {
|
||||
background-color: #33CCFF;
|
||||
}
|
||||
.crow {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid black;
|
||||
text-align: left;
|
||||
}
|
||||
pre {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<title>3DSTownSquare forums</title>
|
||||
<meta name="viewport" content="width=320">
|
||||
<meta name="description" content="Welcome to 3DSTownSquare forums. It's a place to post about whatever you want!">
|
||||
</head>
|
||||
<body>
|
||||
<div id="contenttop">
|
||||
<img src="../../images/header3ds.png" alt="Oops! Our header could not be displayed!" />
|
||||
<center><b><u>Welcome to 3DSTownSquare forums!</u></b></center>
|
||||
</div>
|
||||
<div id="contentbot">
|
||||
<center>
|
||||
|
||||
<?php
|
||||
$error = "";
|
||||
if(isset($_GET["topic"]) && isset($_GET["post"]) && file_exists("data/topic/".$_GET["topic"].".json")){
|
||||
$jsonF = file_get_contents("data/topic/".$_GET["topic"].".json");
|
||||
$jsonD = json_decode($jsonF, true);
|
||||
if(isset($_GET["post"]) && (count($jsonD["posts"])-1) >= strval($_GET["post"])){
|
||||
$post = $jsonD["posts"][strval($_GET["post"])];
|
||||
$cont = str_ireplace("\\n", "<br />", htmlspecialchars($post["cont"]));
|
||||
$cont = str_ireplace("[code]", "<pre><code>", $cont);
|
||||
$cont = str_ireplace("[/code]", "</pre></code>", $cont);
|
||||
} else {
|
||||
$error = "forums.errors.postnotfound";
|
||||
}
|
||||
} else {
|
||||
$error = "forums.errors.notfound";
|
||||
}
|
||||
?>
|
||||
<div class="commentbox">
|
||||
<div class="aqua">
|
||||
<?php
|
||||
if($error == ""){
|
||||
echo htmlspecialchars($post["title"]);
|
||||
} else {
|
||||
echo $error;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="comments" style="text-align: left">
|
||||
<?php
|
||||
if($error == ""){
|
||||
echo $post["from"]." says:<br/>";
|
||||
echo $cont;
|
||||
} else {
|
||||
echo $error;
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<a href="topic.php?t=<?php if(isset($_GET["topic"])){ echo $_GET["topic"]; } else { echo "0"; } ?>">Back</a>
|
||||
</center>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue