very bad meta page
This commit is contained in:
parent
78f1e016c1
commit
266a114e78
2 changed files with 101 additions and 0 deletions
98
docs/meta.php
Normal file
98
docs/meta.php
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
require(__DIR__ . "/../libs/page.php");
|
||||
require(__DIR__ . "/../libs/form.php");
|
||||
require(__DIR__ . "/../libs/comment.php");
|
||||
|
||||
$roles = array();
|
||||
|
||||
page_header();
|
||||
|
||||
// this is a mess
|
||||
function get_handler() {
|
||||
global $db;
|
||||
global $username;
|
||||
global $user;
|
||||
global $bio;
|
||||
global $followers;
|
||||
global $following;
|
||||
global $roles;
|
||||
|
||||
// there is 100% a better way to do this but i need to test
|
||||
if (!array_key_exists('id',$_GET)) {
|
||||
die();
|
||||
}
|
||||
|
||||
$user = $_GET['id'];
|
||||
|
||||
if (array_key_exists('type',$_GET)) {
|
||||
$type = $_GET['type'];
|
||||
if ($type == 'follow') {
|
||||
follow();
|
||||
} else if ($type == 'settings') {
|
||||
settings();
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.user WHERE UPPER(username) LIKE UPPER(?)"); //weirdly, this requires a schema name
|
||||
$stmt->execute([$user]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ?");
|
||||
$stmt->execute([$user]);
|
||||
|
||||
$following = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?");
|
||||
$stmt->execute([$user]);
|
||||
|
||||
$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
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Followers</h2>
|
||||
|
||||
<?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
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
page_footer();
|
||||
?>
|
|
@ -111,6 +111,9 @@
|
|||
<b><?php echo count($followers) ?> followers</b>
|
||||
<b><?php echo count($following) ?> following</b>
|
||||
</div>
|
||||
<div class='avatar'>
|
||||
<a class='link' href='/meta.php?id=<?php echo $user?>'>More info</a>
|
||||
</div>
|
||||
<input name="target" hidden="" value="<?php echo $user ?>">
|
||||
|
||||
<pre><?php echo htmlspecialchars($bio) ?></pre>
|
||||
|
|
Loading…
Reference in a new issue