minor fixes
This commit is contained in:
parent
daace699a6
commit
2ce4424db7
20 changed files with 674 additions and 621 deletions
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../../libs/page.php");
|
||||
|
||||
$ref = 1732684297;
|
||||
require(__DIR__ . "/../../libs/page.php");
|
||||
|
||||
function getOut($typer, $idr) {
|
||||
$ref = 1732684297;
|
||||
|
||||
function getOut($typer, $idr)
|
||||
{
|
||||
if ($typer == 'user' || $typer == 'comment') {
|
||||
header("Location: " . '/' . $typer . '.php?id=' . htmlspecialchars($idr));
|
||||
die();
|
||||
|
@ -11,20 +13,23 @@
|
|||
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
function post_handler() {
|
||||
function post_handler()
|
||||
{
|
||||
global $ref;
|
||||
global $username;
|
||||
global $db;
|
||||
if (!$username || !array_key_exists('post',$_POST)) return;
|
||||
if (!$username || !array_key_exists('post', $_POST)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$postie = $_POST['post'];
|
||||
$postType = (array_key_exists('type',$_POST)) ? $_POST['type'] : 'root';
|
||||
$postId = (array_key_exists('id',$_POST)) ? $_POST['id'] : 'root';
|
||||
$postType = (array_key_exists('type', $_POST)) ? $_POST['type'] : 'root';
|
||||
$postId = (array_key_exists('id', $_POST)) ? $_POST['id'] : 'root';
|
||||
|
||||
if (strlen($postie) < 1 || strlen($postie) > 1024) {
|
||||
getOut($postType,$postId);
|
||||
getOut($postType, $postId);
|
||||
}
|
||||
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
|
||||
$fid = bin2hex(random_bytes(16));
|
||||
|
@ -67,7 +72,7 @@
|
|||
$postie = "A user commented on your wall: " . $postieP;
|
||||
$stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)");
|
||||
$stmt->execute([$user10,'notification',$postId,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]);
|
||||
} else if ($postType == 'comment') {
|
||||
} elseif ($postType == 'comment') {
|
||||
$stmt = $db->prepare("SELECT * FROM comment WHERE id = ? ORDER BY date DESC");
|
||||
$stmt->execute([
|
||||
$postId
|
||||
|
@ -81,8 +86,7 @@
|
|||
$stmt->execute([$user10,'notification',$posts2,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]);
|
||||
}
|
||||
|
||||
getOut($postType,$postId);
|
||||
}
|
||||
getOut($postType, $postId);
|
||||
}
|
||||
|
||||
post_handler();
|
||||
?>
|
||||
post_handler();
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../../libs/page.php");
|
||||
|
||||
function get_handler() {
|
||||
require(__DIR__ . "/../../libs/page.php");
|
||||
|
||||
function get_handler()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.follow");
|
||||
$stmt->execute([]);
|
||||
$result = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
$result = array_reverse($result,true);
|
||||
$result = array_reverse($result, true);
|
||||
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
get_handler();
|
||||
?>
|
||||
get_handler();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/auth.php");
|
||||
global $username;
|
||||
echo $username;
|
||||
require(__DIR__ . "/../libs/auth.php");
|
||||
global $username;
|
||||
echo $username;
|
||||
?>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
$ref = 1732684297;
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
page_header();
|
||||
comments("comment",$_GET['id']);
|
||||
page_footer();
|
||||
?>
|
||||
$ref = 1732684297;
|
||||
|
||||
page_header();
|
||||
comments("comment", $_GET['id']);
|
||||
page_footer();
|
||||
|
|
|
@ -134,6 +134,7 @@ pre {
|
|||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
width: var(--elem-width);
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
@ -186,12 +187,16 @@ iframe {
|
|||
border: none;
|
||||
}
|
||||
|
||||
.header a {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.header a, .clickie {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
font-weight: bold;
|
||||
margin: 5px;
|
||||
display: flex;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
page_header();
|
||||
if (!is_null($username)) {
|
||||
page_header();
|
||||
if (!is_null($username)) {
|
||||
//comments("root","root");
|
||||
}
|
||||
if (!($_GET['page'] > 0)) { ?>
|
||||
}
|
||||
if (!($_GET['page'] > 0)) { ?>
|
||||
<div class="banner"><img class="banner-background" src="/img/newlogo.svg">
|
||||
<div class="banner-content">
|
||||
<h1>BiglyChat</h1>
|
||||
|
@ -17,15 +17,13 @@
|
|||
<h2>Community</h2>
|
||||
|
||||
<a class="form-button" href="/tou.php">Terms of Use</a>
|
||||
<a class="form-button" href="/stats.php?ref=<?php echo $username ?>">Suggested Users</a>
|
||||
<a class="form-button" href="/stats.php">Top Users</a>
|
||||
<a class="form-button" href="https://dervland.net/">More Projects</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//if (is_null($username)) {
|
||||
comments("root","root");
|
||||
//}
|
||||
page_footer();
|
||||
}
|
||||
//if (is_null($username)) {
|
||||
comments("root", "root");
|
||||
//}
|
||||
page_footer();
|
||||
?>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
|
||||
function post_handler() {
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
|
||||
function post_handler()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// there is 100% a better way to do this but i need to test
|
||||
if (!array_key_exists('pass',$_POST) || !array_key_exists('user',$_POST)) {
|
||||
if (!array_key_exists('pass', $_POST) || !array_key_exists('user', $_POST)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -18,18 +20,22 @@
|
|||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$result) return 'Username does not exist.';
|
||||
if (!$result) {
|
||||
return 'Username does not exist.';
|
||||
}
|
||||
|
||||
$verified = password_verify($pass,$result['password']);
|
||||
$verified = password_verify($pass, $result['password']);
|
||||
|
||||
if (!$verified) return 'Password is wrong.';
|
||||
if (!$verified) {
|
||||
return 'Password is wrong.';
|
||||
}
|
||||
|
||||
$token = bin2hex(random_bytes(32));
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO main.token (username, token) VALUES (?, ?)");
|
||||
$stmt->execute([$user,$token]);
|
||||
|
||||
setcookie("token", $token, time()+3600*24);
|
||||
setcookie("token", $token, time() + 3600 * 24);
|
||||
|
||||
if (isset($_GET['next'])) {
|
||||
$gett = htmlspecialchars($_GET['next'] . '?token=' . $token);
|
||||
|
@ -40,16 +46,15 @@
|
|||
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
page_header();
|
||||
page_header();
|
||||
|
||||
$form_message = post_handler();
|
||||
$form_message = post_handler();
|
||||
|
||||
form("Log in (<a class='link' target='_blank' href='/register.php'>Register?</a>)", $form_message, array(
|
||||
form("Log in (<a class='link' target='_blank' href='/register.php'>Register?</a>)", $form_message, array(
|
||||
array('key' => 'Username', 'type' => 'text', 'name' => 'user', 'default' => ''),
|
||||
array('key' => 'Password', 'type' => 'password', 'name' => 'pass', 'default' => '')
|
||||
));
|
||||
));
|
||||
|
||||
page_footer();
|
||||
?>
|
||||
page_footer();
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
page_header();
|
||||
if (isset($_COOKIE)) {
|
||||
foreach ( $_COOKIE as $key => $value )
|
||||
{
|
||||
setcookie( $key, FALSE );
|
||||
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
page_header();
|
||||
if (isset($_COOKIE)) {
|
||||
foreach ($_COOKIE as $key => $value) {
|
||||
setcookie($key, false);
|
||||
}
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
page_footer();
|
||||
?>
|
||||
}
|
||||
page_footer();
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
$roles = array();
|
||||
$roles = array();
|
||||
|
||||
page_header();
|
||||
page_header();
|
||||
|
||||
// this is a mess
|
||||
function get_handler() {
|
||||
// this is a mess
|
||||
function get_handler()
|
||||
{
|
||||
global $db;
|
||||
global $username;
|
||||
global $user;
|
||||
|
@ -18,17 +19,17 @@
|
|||
global $roles;
|
||||
|
||||
// there is 100% a better way to do this but i need to test
|
||||
if (!array_key_exists('id',$_GET)) {
|
||||
if (!array_key_exists('id', $_GET)) {
|
||||
die();
|
||||
}
|
||||
|
||||
$user = $_GET['id'];
|
||||
|
||||
if (array_key_exists('type',$_GET)) {
|
||||
if (array_key_exists('type', $_GET)) {
|
||||
$type = $_GET['type'];
|
||||
if ($type == 'follow') {
|
||||
follow();
|
||||
} else if ($type == 'settings') {
|
||||
} elseif ($type == 'settings') {
|
||||
settings();
|
||||
}
|
||||
}
|
||||
|
@ -47,15 +48,16 @@
|
|||
$stmt->execute([$user]);
|
||||
|
||||
$followers = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
}
|
||||
get_handler();
|
||||
//todo: rewrite
|
||||
}
|
||||
get_handler();
|
||||
//todo: rewrite
|
||||
?>
|
||||
|
||||
<h2>Following</h2>
|
||||
|
||||
<?php
|
||||
foreach ($following as $user) { $usern = $user['username']; ?>
|
||||
foreach ($following as $user) {
|
||||
$usern = $user['username']; ?>
|
||||
<div class='comment'>
|
||||
<div class="avatar">
|
||||
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
|
||||
|
@ -70,13 +72,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Followers</h2>
|
||||
|
||||
<?php
|
||||
foreach ($followers as $user) { $usern = $user['target']; ?>
|
||||
foreach ($followers as $user) {
|
||||
$usern = $user['target']; ?>
|
||||
<div class='comment'>
|
||||
<div class="avatar">
|
||||
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
|
||||
|
@ -91,8 +94,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
page_footer();
|
||||
page_footer();
|
||||
?>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
$ref = 1732684297;
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
page_header();
|
||||
comments("notification",$username,true);
|
||||
page_footer();
|
||||
?>
|
||||
$ref = 1732684297;
|
||||
|
||||
page_header();
|
||||
comments("notification", $username, true);
|
||||
page_footer();
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
|
||||
function post_handler() {
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
|
||||
function post_handler()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// there is 100% a better way to do this but i need to test
|
||||
if (!array_key_exists('pass',$_POST) || !array_key_exists('user',$_POST) || !array_key_exists('pass2',$_POST)) {
|
||||
if (!array_key_exists('pass', $_POST) || !array_key_exists('user', $_POST) || !array_key_exists('pass2', $_POST)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -14,7 +16,7 @@
|
|||
$pass = $_POST['pass'];
|
||||
$pass2 = $_POST['pass2'];
|
||||
|
||||
preg_match("/[^A-Za-z0-9\-\_]/",$user,$matches);
|
||||
preg_match("/[^A-Za-z0-9\-\_]/", $user, $matches);
|
||||
|
||||
if ($pass != $pass2) {
|
||||
return 'Passwords are not the same.';
|
||||
|
@ -33,7 +35,9 @@
|
|||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) return 'Username is taken.';
|
||||
if ($result) {
|
||||
return 'Username is taken.';
|
||||
}
|
||||
|
||||
$hashed = password_hash($pass, PASSWORD_DEFAULT);
|
||||
|
||||
|
@ -42,17 +46,16 @@
|
|||
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
page_header();
|
||||
page_header();
|
||||
|
||||
$form_message = post_handler();
|
||||
$form_message = post_handler();
|
||||
|
||||
form("Join", $form_message, array(
|
||||
form("Join", $form_message, array(
|
||||
array('key' => 'Username', 'type' => 'text', 'name' => 'user', 'default' => ''),
|
||||
array('key' => 'Password', 'type' => 'password', 'name' => 'pass', 'default' => ''),
|
||||
array('key' => 'Password (again)', 'type' => 'password', 'name' => 'pass2', 'default' => '')
|
||||
));
|
||||
));
|
||||
|
||||
page_footer();
|
||||
?>
|
||||
page_footer();
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
function cmp($a, $b) {
|
||||
function cmp($a, $b)
|
||||
{
|
||||
if ($a == $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a > $b) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
page_header();
|
||||
page_header();
|
||||
?>
|
||||
|
||||
function get_handler() {
|
||||
<div>
|
||||
<a class="form-button" href="?username=<?php echo $username ?>">Local</a>
|
||||
<a class="form-button" href="?">Global</a>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
function get_handler()
|
||||
{
|
||||
$api = file_get_contents("https://nbg.dervland.net/node/top?ref=" . $_GET['ref']);
|
||||
$pr = json_decode($api);
|
||||
|
||||
|
@ -31,12 +41,12 @@
|
|||
</div>
|
||||
<div><b>Power</b>: <?php echo $rr ?></div>
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
<?php }
|
||||
}
|
||||
|
||||
get_handler();
|
||||
get_handler();
|
||||
?>
|
||||
|
||||
<?php
|
||||
page_footer();
|
||||
page_footer();
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
page_header();
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
page_header();
|
||||
?>
|
||||
|
||||
<div class="comment">
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
$roles = array();
|
||||
$roles = array();
|
||||
|
||||
page_header();
|
||||
page_header();
|
||||
|
||||
// this is a mess
|
||||
function get_handler() {
|
||||
// this is a mess
|
||||
function get_handler()
|
||||
{
|
||||
global $db;
|
||||
global $username;
|
||||
global $user;
|
||||
|
@ -18,17 +19,17 @@
|
|||
global $roles;
|
||||
|
||||
// there is 100% a better way to do this but i need to test
|
||||
if (!array_key_exists('id',$_GET)) {
|
||||
if (!array_key_exists('id', $_GET)) {
|
||||
die();
|
||||
}
|
||||
|
||||
$user = $_GET['id'];
|
||||
|
||||
if (array_key_exists('type',$_GET)) {
|
||||
if (array_key_exists('type', $_GET)) {
|
||||
$type = $_GET['type'];
|
||||
if ($type == 'follow') {
|
||||
follow();
|
||||
} else if ($type == 'settings') {
|
||||
} elseif ($type == 'settings') {
|
||||
settings();
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +55,10 @@
|
|||
$stmt->execute([$user]);
|
||||
|
||||
$roles = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
function follow() {
|
||||
function follow()
|
||||
{
|
||||
global $db;
|
||||
global $username;
|
||||
global $user;
|
||||
|
@ -66,7 +68,9 @@
|
|||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (is_null($username)) return;
|
||||
if (is_null($username)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$stmt = $db->prepare("DELETE FROM main.follow WHERE username = ? AND target = ?");
|
||||
|
@ -75,13 +79,16 @@
|
|||
$stmt = $db->prepare("INSERT INTO main.follow (username,target) VALUES (?,?)");
|
||||
$stmt->execute([$user,$username]);
|
||||
}
|
||||
}
|
||||
function settings() {
|
||||
}
|
||||
function settings()
|
||||
{
|
||||
global $db;
|
||||
global $username;
|
||||
global $user;
|
||||
|
||||
if (is_null($username)) return;
|
||||
if (is_null($username)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("DELETE FROM main.user WHERE username = ?");
|
||||
$stmt->execute([$username]);
|
||||
|
@ -90,9 +97,9 @@
|
|||
$stmt->execute([$username,$_POST['desc']]);
|
||||
|
||||
move_uploaded_file($_FILES['avatar']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pfp/' . $username . '.png');
|
||||
}
|
||||
}
|
||||
|
||||
get_handler();
|
||||
get_handler();
|
||||
?>
|
||||
<form class="banner" enctype="multipart/form-data" method="POST" action="/user.php?id=<?php echo $user ?>&type=follow">
|
||||
<img class="banner-background" src="/pfp/<?php echo $user ?>.png">
|
||||
|
@ -124,10 +131,10 @@
|
|||
form("Your Settings", $form_message, array(
|
||||
array('key' => 'Bio', 'type' => 'textarea', 'name' => 'desc', 'default' => $bio),
|
||||
array('key' => 'Avatar', 'type' => 'file', 'name' => 'avatar', 'default' => '')
|
||||
),'/user.php?id=' . $user . '&type=settings');
|
||||
), '/user.php?id=' . $user . '&type=settings');
|
||||
}
|
||||
|
||||
comments('user',$user);
|
||||
comments('user', $user);
|
||||
|
||||
page_footer();
|
||||
page_footer();
|
||||
?>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
require(__DIR__ . "/test_secret.php");
|
||||
require(__DIR__ . "/test_secret.php");
|
||||
|
||||
function auth($token) {
|
||||
if (is_null($token)) return null;
|
||||
function auth($token)
|
||||
{
|
||||
if (is_null($token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
global $db;
|
||||
|
||||
|
@ -10,7 +13,9 @@
|
|||
$stmt->execute([$token]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$result) return null;
|
||||
if (!$result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$username = $result['username'];
|
||||
|
||||
|
@ -18,13 +23,17 @@
|
|||
$stmt->execute([$username]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$result) return null;
|
||||
if (!$result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.ban WHERE username = ?");
|
||||
$stmt->execute([$username]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$result) return $username;
|
||||
if (!$result) {
|
||||
return $username;
|
||||
}
|
||||
|
||||
$reason = $result['reason']; ?>
|
||||
<!DOCTYPE html>
|
||||
|
@ -35,9 +44,9 @@
|
|||
</body>
|
||||
</html>
|
||||
<?php die();
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('token',$_COOKIE)) {
|
||||
if (array_key_exists('token', $_COOKIE)) {
|
||||
$username = auth($_COOKIE['token']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
<?php
|
||||
require(__DIR__ . "/markdown.php");
|
||||
function comments($typer, $idr, $disable = false) {
|
||||
require(__DIR__ . "/markdown.php");
|
||||
function comments($typer, $idr, $disable = false)
|
||||
{
|
||||
$ref = 1732684297;
|
||||
global $username;
|
||||
global $db;
|
||||
$page = array_key_exists('page',$_GET) ? ($_GET['page']) : 0;
|
||||
$mode = array_key_exists('mode',$_GET) ? ($_GET['mode']) : 'all';
|
||||
$page = array_key_exists('page', $_GET) ? ($_GET['page']) : 0;
|
||||
$mode = array_key_exists('mode', $_GET) ? ($_GET['mode']) : 'all';
|
||||
if ($username && !$disable) {
|
||||
form("Broadcast your thoughts...", '', array(
|
||||
array('key' => 'Your message', 'type' => 'textarea', 'name' => 'post', 'default' => ''),
|
||||
array('key' => '','type' => 'hidden','name' => 'type', 'default' => $typer),
|
||||
array('key' => '','type' => 'hidden','name' => 'id', 'default' => $idr),
|
||||
array('key' => 'Attachments', 'type' => 'file', 'name' => 'file', 'default' => '')
|
||||
),'/api/comment.php');
|
||||
), '/api/comment.php');
|
||||
}
|
||||
|
||||
$qs = parse_url($_SERVER['REQUEST_URI']);
|
||||
|
||||
if (is_null($qs)) $qs = array('query' => '?');
|
||||
if (is_null($qs)) {
|
||||
$qs = array('query' => '?');
|
||||
}
|
||||
$qsq = $qs['query'];
|
||||
|
||||
$qss = array();
|
||||
|
||||
parse_str($qsq,$qss);
|
||||
parse_str($qsq, $qss);
|
||||
|
||||
$qss['page'] = $page + 1;
|
||||
$qs_next = http_build_query($qss);
|
||||
|
@ -37,6 +40,10 @@
|
|||
$qs_2 = http_build_query($qss);
|
||||
?>
|
||||
|
||||
<div>
|
||||
<a class="form-button" href="?<?php echo $qs_1 ?>">Everyone</a>
|
||||
<a class="form-button" href="?<?php echo $qs_2 ?>">Following</a>
|
||||
</div>
|
||||
<div>
|
||||
<?php if ($page > 0) { ?>
|
||||
<a class="form-button" href="?<?php echo $qs_prev ?>">Previous</a>
|
||||
|
@ -44,10 +51,6 @@
|
|||
<a class="form-button" href="?<?php echo $qs_next ?>">Next</a>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<a class="form-button" href="?<?php echo $qs_1 ?>">Everyone</a>
|
||||
<a class="form-button" href="?<?php echo $qs_2 ?>">Following</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$posts = array();
|
||||
|
@ -60,9 +63,11 @@
|
|||
$theId
|
||||
]);
|
||||
$posts1 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
if (is_null($posts1) || count($posts1) < 1) break;
|
||||
if (is_null($posts1) || count($posts1) < 1) {
|
||||
break;
|
||||
}
|
||||
$theId = $posts1[0]['targetid'];
|
||||
$posts = array_merge($posts1,$posts);
|
||||
$posts = array_merge($posts1, $posts);
|
||||
}
|
||||
|
||||
if ($mode == 'all') {
|
||||
|
@ -87,7 +92,7 @@
|
|||
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
$edge = count($posts);
|
||||
$posts = array_merge($posts,$posts2);
|
||||
$posts = array_merge($posts, $posts2);
|
||||
|
||||
?>
|
||||
<meta property="og:title" content="NewBiglyChat" />
|
||||
|
@ -111,7 +116,7 @@
|
|||
</b></div>
|
||||
<div><b>
|
||||
<a class='link' href='/comment.php?id=<?php echo $post['id'] ?>'>
|
||||
<?php echo date(DATE_RFC2822,$post['date'] + $ref) ?>
|
||||
<?php echo date(DATE_RFC2822, $post['date'] + $ref) ?>
|
||||
</a>
|
||||
</b></div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
function form($title, $form_message, $inputs, $action = '') { ?>
|
||||
function form($title, $form_message, $inputs, $action = '')
|
||||
{ ?>
|
||||
<form class='form' enctype="multipart/form-data" method="POST" action="<?php echo $action ?>">
|
||||
<h1 class="form-heading">
|
||||
<?php echo $title ?>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
function markdown($text) {
|
||||
$search = array (
|
||||
function markdown($text)
|
||||
{
|
||||
$search = array(
|
||||
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(png|jpg|jpeg|gif))~i',
|
||||
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(mp3|wav))~i',
|
||||
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(webm|mp4))~i',
|
||||
|
@ -18,7 +19,7 @@
|
|||
'~(\[url\])(.*?)(\[\/url\])~i'
|
||||
);
|
||||
|
||||
$replace = array (
|
||||
$replace = array(
|
||||
'<a class="link" href="$1" target="_blank"><div>$1</div><img src="$1" class="img"></a>',
|
||||
'<a class="link" href="$1" target="_blank"><div>$1</div><audio controls src="$1"></a>',
|
||||
'<a class="link" href="$1" target="_blank"><div>$1</div><video controls class="img"><source src="$1"/></video></a>',
|
||||
|
@ -39,5 +40,5 @@
|
|||
$text = preg_replace($search, $replace, $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
require(__DIR__ . "/auth.php");
|
||||
global $username;
|
||||
function page_header() {
|
||||
require(__DIR__ . "/auth.php");
|
||||
global $username;
|
||||
function page_header()
|
||||
{
|
||||
global $db;
|
||||
global $username;
|
||||
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC");
|
||||
|
@ -11,7 +12,6 @@
|
|||
]);
|
||||
|
||||
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
$edge = count($posts2);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
@ -25,19 +25,21 @@
|
|||
<body>
|
||||
<div class="header">
|
||||
<a href="/"><img class="header-img header-link" src="/img/bgc.svg">BiglyChat</a>
|
||||
<?php
|
||||
if (isset($username)) { ?>
|
||||
<a href="/user.php?id=<?php echo $username ?>"><img class="header-img header-link" src="/img/home.svg">Home</a>
|
||||
<?php if (isset($username)) { ?>
|
||||
<a href="/user.php?id=<?php echo $username ?>"><img class="header-img header-link" src="/pfp/<?php echo $username ?>.png">Wall</a>
|
||||
<a href="/notif.php"> <img class="header-img header-link" src="/img/mail.svg"><span>Mail<sub> <?php echo $edge?></sub></span></a>
|
||||
<a href="/stats.php?username=<?php echo $username ?>"><img class="header-img header-link" src="/img/home.svg">Users</a>
|
||||
<a href="/logout.php"><img class="header-img header-link" src="/img/logout.svg">Leave</a>
|
||||
<?php } else { ?>
|
||||
<a href="/login.php"><img class="header-img header-link" src="/img/home.svg">Join</a>
|
||||
<?php }
|
||||
<a href="/stats.php"><img class="header-img header-link" src="/img/home.svg">Users</a>
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
<?php }
|
||||
function page_footer() { ?>
|
||||
<?php }
|
||||
function page_footer()
|
||||
{ ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php }
|
||||
<?php }
|
||||
?>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/test_secret.php");
|
||||
|
||||
global $db;
|
||||
require(__DIR__ . "/../libs/test_secret.php");
|
||||
|
||||
$sql = file_get_contents('../scripts/init.sql', true);
|
||||
global $db;
|
||||
|
||||
$db->exec($sql);
|
||||
$sql = file_get_contents('../scripts/init.sql', true);
|
||||
|
||||
echo "Database was set up.";
|
||||
?>
|
||||
$db->exec($sql);
|
||||
|
||||
echo "Database was set up.";
|
||||
|
|
Loading…
Reference in a new issue