bugfixes, refactoring

This commit is contained in:
biglyderv 2025-02-07 11:37:04 -05:00
parent 0ef97c4889
commit f542656bc9
Signed by: biglyderv
GPG key ID: 1398543B9746192C
5 changed files with 50 additions and 94 deletions

View file

@ -4,8 +4,6 @@ require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
require(__DIR__ . "/../libs/comment.php");
$ref = 1732684297;
page_header();
comments("comment", $_GET['id']);
page_footer();

View file

@ -50,28 +50,13 @@ function get_handler()
$followers = $stmt->fetchAll(PDO::FETCH_DEFAULT);
}
get_handler();
//todo: rewrite
?>
<h2>Following</h2>
<?php
foreach ($following as $user) {
$usern = $user['username']; ?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
<div>
<div><b>
<a class="link" href="/user.php?id=<?php echo $usern ?>">
<?php echo $usern ?>
</a>
</b>
</div>
</div>
</div>
</div>
<?php
user_block($user['username'], false, false);
}
?>
@ -79,23 +64,7 @@ get_handler();
<?php
foreach ($followers as $user) {
$usern = $user['target']; ?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
<div>
<div><b>
<a class="link" href="/user.php?id=<?php echo $usern ?>">
<?php echo $usern ?>
</a>
</b>
</div>
</div>
</div>
</div>
<?php
user_block($user['target'], false, false);
}
?>
<?php
page_footer();
?>

View file

@ -27,22 +27,9 @@ function get_handler()
$api = file_get_contents($node_backend . "/top?ref=" . $_GET['username']);
$pr = json_decode($api);
foreach ($pr as $usern => $rr) { ?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
<div>
<div><b>
<a class="link" href="/user.php?id=<?php echo $usern ?>">
<?php echo $usern ?>
</a>
</b>
</div>
</div>
</div>
<div><b>Power</b>: <?php echo $rr ?></div>
</div>
<?php }
foreach ($pr as $usern => $rr) {
user_block($usern, $rr, "Popularity");
}
}
get_handler();

View file

@ -2,40 +2,24 @@
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',
//'~(https://studio\.penguinmod\.com/[^\s<?#]*[#]([^\s<]*))~i',
//'~(https://studio\.penguinmod\.com/[^\s<?#]*[?#]?([^\s<#]*)[#]?([^\s<]*))~i',
'~(?:\s|^)(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i',
'~(?:@)([^\s]+)(?:\s|$)~i',
'~(\[b\])(.*?)(\[\/b\])~i',
'~(\[i\])(.*?)(\[\/i\])~i',
'~(\[u\])(.*?)(\[\/u\])~i',
'~(\[ul\])(.*?)(\[\/ul\])~i',
'~(\[li\])(.*?)(\[\/li\])~i',
'~(\[h\])(.*?)(\[\/h\])~i',
'~(\[url=)(.*?)(\])(.*?)(\[\/url\])~i',
'~(\[url\])(.*?)(\[\/url\])~i'
);
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(png|jpg|jpeg|gif))~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(mp3|wav))~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(webm|mp4))~i',
//'~(https://studio\.penguinmod\.com/[^\s<?#]*[#]([^\s<]*))~i',
//'~(https://studio\.penguinmod\.com/[^\s<?#]*[?#]?([^\s<#]*)[#]?([^\s<]*))~i',
'~(?:\s|^)(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i',
'~(?:@)([^\s]+)(?:\s|$)~i',
);
$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>',
//'https://studio.penguinmod.com/?#$2',
//'<a class="link" href="$1" target="_blank"><div>$1</div><iframe src="https://studio.penguinmod.com/embed?$2#$3"></iframe></a>',
'<a class="link" href="$0" target="_blank">$0</a>',
'<a class="link" href="/user.php?id=$1" target="_blank">@$1</a>',
'<strong>$2</strong>',
'<em>$2</em>',
'<u>$2</u>',
'<ul>$2</ul>',
'<li>$2</li>',
'<h2>$2</h2>',
'<a class="link" href="$2" target="_blank">$4</a>',
'<a class="link" href="$2" target="_blank">$2</a>'
);
'<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>',
//'https://studio.penguinmod.com/?#$2',
//'<a class="link" href="$1" target="_blank"><div>$1</div><iframe src="https://studio.penguinmod.com/embed?$2#$3"></iframe></a>',
'<a class="link" href="$0" target="_blank">$0</a>',
'<a class="link" href="/user.php?id=$1" target="_blank">@$1</a>',
);
$text = preg_replace($search, $replace, $text);

View file

@ -7,8 +7,8 @@ function page_header()
global $username;
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC");
$stmt->execute([
"notification",
$username,
"notification",
$username,
]);
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
@ -25,21 +25,39 @@ function page_header()
<body>
<div class="header">
<a href="/"><img class="header-img header-link" src="/img/bgc.svg">BiglyChat</a>
<?php if (isset($username)) { ?>
<?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>
<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>
<a href="/stats.php"><img class="header-img header-link" src="/img/home.svg">Users</a>
<?php }
<a href="/stats.php"><img class="header-img header-link" src="/img/home.svg">Users</a>
<?php }
?>
</div>
<?php }
<?php }
function page_footer()
{ ?>
</body>
</html>
<?php }
</body>
</html>
<?php }
function user_block($usern, $meta, $tag)
{
?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
<div>
<div><b>
<a class="link" href="/user.php?id=<?php echo $usern ?>">
<?php echo $usern ?>
</a>
</b>
</div>
</div>
</div>
<?php echo (is_null($meta) || !$meta) ? '' : "<b>$tag</b>: $meta"; ?>
</div>
<?php }
?>