Permalink
Browse files

Bootstrap Implementation

Bootstrap now handles the display of most pages on Sekai now.
Added script to automatically update DNS servers.
Added new page templates to simplify page building.
Added a few comments.
Changed the layouts of countless pages.
Changed the structure of dependancies.
Changed the usage of quotes everywhere.
Fixed errors in chan post submission.
  • Loading branch information...
Wish495 committed May 23, 2017
1 parent d05a50f commit 08bfcee4df55cec9e396fc72ffb3b2cff42fca9e
View
@@ -33,3 +33,12 @@ ps/
*test*
phpmyadmin/
dlf/
.well-known/
css/bootstrap*
css/font-awesome*
js/bootstrap*
js/jquery*
js/livestamp*
js/moment*
js/tether*
fonts/fontawesome*
View
@@ -0,0 +1,3 @@
<?php
file_get_contents("http://freedns.afraid.org/dynamic/update.php?VG10OE8yclVyMVlMeHNubmNvQVhxVm1UOjE2NzgxNTU1");
?>
View
@@ -1,12 +1,14 @@
<?php
session_start();
include("{$_SERVER['DOCUMENT_ROOT']}/access/sql.php");
$getData = mysqli_query($link,"SELECT username, password, approved FROM login WHERE username = '".$_POST['username']."'");
$getData = mysqli_query($link,"SELECT password, approved FROM login WHERE username = '{$_POST['username']}'");
if($userData = mysqli_fetch_array($getData,MYSQLI_ASSOC)) {
if($userData['approved'] == 1) {
if(password_verify($_POST['password'],$userData['password'])) {
$getData = mysqli_query($link,"SELECT username, linkstyle, tilestyle, postsshown FROM login WHERE username = '".$_POST['username']."'");
$getData = mysqli_query($link,"SELECT userid, username, linkstyle, tilestyle, postsshown FROM login WHERE username = '{$_POST['username']}'");
$userData = mysqli_fetch_array($getData,MYSQLI_ASSOC);
$logData = mysqli_query($link,"INSERT INTO login_logs (userid) VALUES ('{$userData['userid']}')");
$_SESSION['userid'] = $userData['userid'];
$_SESSION['username'] = $userData['username'];
$_SESSION['linkstyle'] = $userData['linkstyle'];
$_SESSION['tilestyle'] = $userData['tilestyle'];
View
@@ -1,28 +1,28 @@
<?php
session_start();
include($_SERVER['DOCUMENT_ROOT'].'/access/sql.php');
$get = mysqli_query($link,"SELECT password FROM login WHERE username = '".$_SESSION['username']."'");
include("{$_SERVER["DOCUMENT_ROOT"]}/access/sql.php");
$get = mysqli_query($link,"SELECT password FROM login WHERE username = '{$_SESSION["username"]}'");
$oldPassword = mysqli_fetch_array($get,MYSQLI_ASSOC);
if(password_verify($_POST['oldpassword'],$oldPassword['password'])) {
if($_POST['newpassword'] == $_POST['confirmpassword']) {
$newPassword = password_hash($_POST['newpassword'],PASSWORD_DEFAULT);
if(mysqli_query($link,"UPDATE login SET password = '$newPassword' WHERE username = '".$_SESSION['username']."'")) {
if(password_verify($_POST["oldpassword"],$oldPassword["password"])) {
if($_POST["newpassword"] == $_POST["confirmpassword"]) {
$newPassword = password_hash($_POST["newpassword"],PASSWORD_DEFAULT);
if(mysqli_query($link,"UPDATE login SET password = '$newPassword' WHERE username = '{$_SESSION["username"]}'")) {
mysqli_close($link);
header("Location: /account/password/?success=1");
header("Location: /account/?passwordsuccess=1");
exit();
} else {
echo('MYSQL ERROR: '.mysqli_error($link));
echo("MYSQL ERROR: ".mysqli_error($link));
mysqli_close($link);
exit();
}
} else {
mysqli_close($link);
header('Location: /account/password/?error=2');
header("Location: /account/password/?passworderror=2");
exit();
}
} else {
mysqli_close($link);
header('Location: /account/password/?error=1');
header("Location: /account/password/?passworderror=1");
exit();
}
?>
View
@@ -1,16 +1,108 @@
<?php include("{$_SERVER['DOCUMENT_ROOT']}/webassets/default.php");?>
<title>Sekai: Account</title>
<p class="subTitle" style="color:white;font-size:150%">Sekai > Account</p>
<p>[<a href="/">Return</a>]<br>
[<a href="/account/password/">Change Password</a>]<br>
<form method="post" action="/access/preferences.php" style="font-family:Arial,Verdana,Tahoma;color:white;">
<input type="radio" name="linkstyle" value="0" required<?php if($_SESSION['linkstyle']==0){echo(' checked');}?>>4chan Style Hyperlinks<br>
<input type="radio" name="linkstyle" value="1" required<?php if($_SESSION['linkstyle']==1){echo(' checked');}?>>YouTube Style Hyperlinks<br><br>
<input type="radio" name="tilestyle" value="0" required<?php if($_SESSION['tilestyle']==0){echo(' checked');}?>>GIF Menu Tiles (Color)<br>
<input type="radio" name="tilestyle" value="1" required<?php if($_SESSION['tilestyle']==1){echo(' checked');}?>>GIF Menu Tiles (Greyscale)<br>
<input type="radio" name="tilestyle" value="2" required<?php if($_SESSION['tilestyle']==2){echo(' checked');}?>>PNG Menu Tiles<br><br>
<input type="number" name="postsshown" value="<?php echo($_SESSION['postsshown']);?>" required min="5" max="50" style="max-width:3em;"> Threads shown on each 世界chan page<br><br>
<input type="submit" value="Update Preferences">
</form>
<?php
include("{$_SERVER['DOCUMENT_ROOT']}/webassets/defaultHeader.php");
include("{$_SERVER['DOCUMENT_ROOT']}/webassets/defaultBody.php");
include("{$_SERVER['DOCUMENT_ROOT']}/webassets/defaultNavbar.php");
?>
<br>
<div class="row" style="justify-content:center;margin:0px;">
<div class="card-group" style="width:40rem;">
<div class="card">
<div class="card-header">
Change website preferences
</div>
<div class="card-block">
<form method="POST" action="/access/preferences.php">
<fieldset class="form-group">
<legend>
Hyperlink style
</legend>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="linkstyle" value="0"<?php if($_SESSION["linkstyle"]==0){echo(" checked");}?>>
4chan Style Hyperlinks
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="linkstyle" value="1"<?php if($_SESSION["linkstyle"]==1){echo(" checked");}?>>
YouTube Style Hyperlinks
</label>
</div>
</fieldset>
<fieldset class="form-group">
<legend>
Homepage tile style
</legend>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="tilestyle" value="0"<?php if($_SESSION["tilestyle"]==0){echo(" checked");}?>>
Animated and colored tiles
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="tilestyle" value="1"<?php if($_SESSION["tilestyle"]==1){echo(" checked");}?>>
Animated and grey tiles
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="tilestyle" value="2"<?php if($_SESSION["tilestyle"]==2){echo(" checked");}?>>
Static tiles
</label>
</div>
</fieldset>
<fieldset class="form-group">
<legend>
世界chan threads per page
</legend>
<div class="form-check">
<label class="form-check-label">
<input type="number" class="form-check-input" name="postsshown" value="<?php echo("{$_SESSION["postsshown"]}");?>">
posts
</label>
</div>
</fieldset>
<input type="submit" class="btn btn-success" value="Update preferences">
</form>
</div>
</div>
<br>
<div class="card">
<div class="card-header">
Change password
</div>
<div class="card-block">
<form method="POST" action="/access/password.php">
<fieldset class="form-group">
<legend>
Current password
</legend>
<div class="form-check">
<input type="password" class="form-control" name="oldpassword" id="oldpassword" maxlength="16" required>
</div>
</fieldset>
<fieldset class="form-group">
<legend>
New password
</legend>
<div class="form-check">
<input type="password" class="form-control" name="newpassword" id="newpassword" maxlength="16" required>
</div>
</fieldset>
<fieldset class="form-group">
<legend>
Confirm password
</legend>
<div class="form-check">
<input type="password" class="form-control" name="confirmpassword" id="confirmpassword" maxlength="16" required>
</div>
</fieldset>
<input type="submit" class="btn btn-success" value="Update password">
</form>
</div>
</div>
</div>
</div>
</body>
</html>
View
@@ -1,9 +1,13 @@
<?php
include("{$_SERVER["DOCUMENT_ROOT"]}/access/sql.php");
$x = $_SESSION["postsshown"];
$x = $_SESSION['postsshown'];
$page = end(explode('?',$_SERVER['REQUEST_URI']));
$offset = 0;
if(is_numeric($page)) {
if(is_float($page)) {
$page = floor($page);
header("Location: /chan?$page");
}
if($page < 1) {
header('Location: /chan?1');
exit();
@@ -20,31 +24,22 @@
} else {
$page = 1;
$pageNext = 2;
$pagePrev = 0;
}
$pages = ' [<a href="?1">1</a>] [<a href="?2">2</a>] [<a href="?3">3</a>] [<a href="?4">4</a>] [<a href="?5">5</a>] [<a href="?6">6</a>] [<a href="?7">7</a>] [<a href="?8">8</a>] [<a href="?9">9</a>] [<a href="?10">10</a>]';
$pages = explode('[<a href="?'.$page.'">'.$page.'</a>]', $pages);
$pages = $pages[0].'[<a href="?'.$page.'"><b>'.$page.'</b></a>]'.$pages[1];
$threads = mysqli_query($link,"SELECT DISTINCT thread FROM posts ORDER BY id DESC LIMIT $x OFFSET $offset");
$y = 1;
while($thread = mysqli_fetch_array($threads,MYSQLI_ASSOC)) {
$displayThreads[$y] = $thread;
$y += 1;
}
echo('<p>[<a href="/" class="highlight">Return</a>]</p>
<div class="commentBox">
<select form="upload" name="threadUpload" id="threadUpload"><option value="new">New thread</option>');
echo("<div class=\"commentBox\"><form class=\"commentBox\" action=\"submit.php\" method=\"post\" enctype=\"multipart/form-data\" id=\"upload\"><select form=\"upload\" name=\"threadUpload\" id=\"threadUpload\"><option value=\"new\">New thread</option>");
for($x=1;$x<=count($displayThreads);$x++) {
echo('<option value="'.$displayThreads[$x]['thread'].'">Thread #'.$displayThreads[$x]['thread'].'</option>');
echo("<option value=\"{$displayThreads[$x]['thread']}\">Thread #{$displayThreads[$x]['thread']}</option>");
}
echo('</select><br>
<textarea placeholder="Comment" form="upload" name="textUpload" id="textUpload"></textarea>
<form class="commentBox" action="submit.php" method="post" enctype="multipart/form-data" id="upload"><input type="file" name="fileUpload" id="fileUpload"><br><input style="margin-top:7px;" type="submit" value="Submit file" name="submit"></form>
</div>
');
echo("</select><br><textarea placeholder=\"Comment\" form=\"upload\" name=\"textUpload\" id=\"textUpload\"></textarea><br><input type=\"file\" name=\"fileUpload\" id=\"fileUpload\"><div class=\"g-recaptcha\" data-sitekey=\"6LdkYRoUAAAAAOPDZh5DE_9DRkvcEg6jXNzcORCM\"></div><input style=\"margin-top:7px;\" type=\"submit\" value=\"Submit file\" name=\"submit\"></form></div>\n");
for($x=1;$x<=count($displayThreads);$x++) {
echo('<div class="thread">
');
$postData[$x] = mysqli_query($link,"SELECT id, thread, name, time, body, filename, filetype, filesize, resolution FROM posts WHERE op = 1 AND thread = ".$displayThreads[$x]['thread']);
echo("<div class=\"thread\">");
$postData[$x] = mysqli_query($link,"SELECT id, thread, name, time, body, filename, filetype, filesize, resolution FROM posts WHERE op = 1 AND thread = {$displayThreads[$x]['thread']}");
$postData[$x] = mysqli_fetch_array($postData[$x],MYSQLI_ASSOC);
$postData[$x]['replyCount'] = mysqli_query($link,"SELECT COUNT(id) FROM posts WHERE op = 0 AND thread = {$postData[$x]['id']}");
$postData[$x]['replyCount'] = mysqli_fetch_array($postData[$x]['replyCount'],MYSQLI_ASSOC);
@@ -55,97 +50,48 @@
$postData[$x]['replyCount'] = $postData[$x]['replyCount']['COUNT(id)'];
$postData[$x]['replyFormat'] = 1;
}
echo('<div class="post"><p class="chan"><a href="/chan/files/'.
$postData[$x]['id'].
'.'.
$postData[$x]['filetype'].
'" class="notHighlight" target="_blank"><img class="chan" src="/chan/thumbs/'.
$postData[$x]['id'].
'.jpg">'.
$postData[$x]['filename'].
'</a> '.
$postData[$x]['filesize'].
'B ('.
$postData[$x]['resolution'].
')<br><b>'.
$postData[$x]['name'].
'</b> '.
$postData[$x]['time'].
' <a href="?thread='.
$postData[$x]['id'].
'" class="notHighlight">No.</a><a id="'.
$postData[$x]['id'].
'" onclick="insertReply(event);insertThread(this.id)" class="notHighlight">'.
$postData[$x]['id'].
'</a> [<a href="?thread='.
$postData[$x]['id'].
'">Reply</a>] '.
$postData[$x]['replyCount'].
' ');
if($postData[$x]['replyFormat'] == 0) {
echo('reply');
} else {
echo('replies');
}
if($postData[$x]['replyCount'] > 3) {
echo(' ('.($postData[$x]['replyCount'] - 3).' omitted)');
}
echo('</p><p class="comment">'.
$postData[$x]['body']);
echo('</p></div>');
echo("<div class=\"post\"><a href=\"/chan/files/{$postData[$x]['id']}.{$postData[$x]['filetype']}\" class=\"notHighlight\" target=\"_blank\"><img src=\"/chan/thumbs/{$postData[$x]['id']}.jpg\"></a><div class=\"postinfo\"><p><b>{$postData[$x]['name']}</b> {$postData[$x]['time']} <a href=\"?thread={$postData[$x]['id']}\" class=\"notHighlight\">No.</a><a id=\"{$postData[$x]['id']}\" onclick=\"insertReply(event);insertThread(this.id)\" class=\"notHighlight\">{$postData[$x]['id']}</a> [<a href=\"?thread={$postData[$x]['id']}\">Reply</a>] {$postData[$x]['replyCount']}");
if($postData[$x]['replyFormat'] == 0) {
echo(' reply');
} else {
echo(' replies');
}
if($postData[$x]['replyCount'] > 3) {
$omissions = $postData[$x]['replyCount'] - 3;
echo(" ($omissions omitted)");
}
echo("<br><a href=\"/chan/files/{$postData[$x]['id']}.{$postData[$x]['filetype']}\" class=\"notHighlight\" target=\"_blank\">{$postData[$x]['filename']}</a> {$postData[$x]['filesize']}B ({$postData[$x]['resolution']})</p></div><div class=\"comment\">{$postData[$x]['body']}</div></div>");
$z = 1;
for($y=2;$y>=0;$y--) {
$postData[$x]['replies'][$z] = mysqli_query($link,"SELECT id, name, time, body, filename, filetype, filesize, resolution FROM posts WHERE thread = '{$displayThreads[$x]['thread']}' AND op = 0 ORDER by id DESC LIMIT 1 OFFSET $y");
$postData[$x]['replies'][$z] = mysqli_fetch_array($postData[$x]['replies'][$z],MYSQLI_ASSOC);
if($postData[$x]['replies'][$z]['name'] != "") {
echo('<div class="reply"><p class="chan">');
echo('<div class="reply">');
if($postData[$x]['replies'][$z]['filename'] != '') {
echo('<a href="/chan/files/'.
$postData[$x]['replies'][$z]['id'].
'.'.
$postData[$x]['replies'][$z]['filetype'].
'" class="notHighlight" target="_blank"><img class="chan" src="/chan/thumbs/'.
$postData[$x]['replies'][$z]['id'].
'.jpg">'.
$postData[$x]['replies'][$z]['filename'].
'</a> '.
$postData[$x]['replies'][$z]['filesize'].
'B ('.
$postData[$x]['replies'][$z]['resolution'].
')<br>');
echo("<a href=\"/chan/files/{$postData[$x]['replies'][$z]['id']}.{$postData[$x]['replies'][$z]['filetype']}\" class=\"notHighlight\" target=\"_blank\"><img class=\"chan\" src=\"/chan/thumbs/{$postData[$x]['replies'][$z]['id']}.jpg\"></a>");
}
echo('<b>'.
$postData[$x]['replies'][$z]['name'].
'</b> '.
$postData[$x]['replies'][$z]['time'].
' <a href="?post='.
$postData[$x]['replies'][$z]['id'].
'" class="notHighlight">No.</a><a id="'.
$postData[$x]['id'].
'" onclick="insertReply(event);insertThread(this.id)" class="notHighlight">'.
$postData[$x]['replies'][$z]['id'].
'</a> <a href="?thread='.
$postData[$x]['id'].
'" class="notHighlight"><span class="replyThread">&gt;&gt;'.$postData[$x]['id'].
'</span></a></p><p class="comment">'.
$postData[$x]['replies'][$z]['body'].
'</p></div>');
echo("<div class=\"postinfo\"><p><b>{$postData[$x]['replies'][$z]['name']}</b> {$postData[$x]['replies'][$z]['time']} <a href=\"?post={$postData[$x]['replies'][$z]['id']}\" class=\"notHighlight\">No.</a><a id=\"{$postData[$x]['id']}\" onclick=\"insertReply(event);insertThread(this.id)\" class=\"notHighlight\">{$postData[$x]['replies'][$z]['id']}</a> <a href=\"?thread={$postData[$x]['id']}\" class=\"notHighlight\"><span class=\"replyThread\">&gt;&gt;{$postData[$x]['id']}</span></a>");
if($postData[$x]['replies'][$z]['filename'] != '') {
echo("<br><a href=\"/chan/files/{$postData[$x]['replies'][$z]['id']}.{$postData[$x]['replies'][$z]['filetype']}\" class=\"notHighlight\" target=\"_blank\">{$postData[$x]['replies'][$z]['filename']}</a> {$postData[$x]['replies'][$z]['filesize']}B ({$postData[$x]['replies'][$z]['resolution']})");
}
echo("</p></div><div class=\"comment\">{$postData[$x]['replies'][$z]['body']}</div></div>");
}
$z += 1;
}
echo('
</div>
');
echo("</div>\n");
}
mysqli_close($link);
echo('<div class="pageBox"><div><a href="?'.$pagePrev.'"><button');
if($page <= 1) {
echo(' disabled');
}
echo('>Previous</button></a></div><div><p class="pages">'.$pages.'</p></div><div><a href="?'.$pageNext.'"><button');
if($page >= 10) {
echo(' disabled');
}
echo('>Next</button></a></div></div>
');
echo("<div class=\"pageWrapper\">
<div>
<a class=\"btn btn-outline-info\" href=\"?$pagePrev\"><i class=\"fa fa-arrow-circle-left\"></i> Previous</a>");
for($x=1;$x<=10;$x++) {
if($x == $page) {
echo("<a class=\"btn btn-primary\"><strong>$x</strong></a>");
} else {
echo("<a class=\"btn btn-secondary\" href=\"?$x\">$x</a>");
}
}
echo("<a class=\"btn btn-outline-info\" href=\"?$pageNext\">Next <i class=\"fa fa-arrow-circle-right\"></i></a>
</div>
</div>");
?>
Oops, something went wrong.

0 comments on commit 08bfcee

Please sign in to comment.