2025-01-23 20:00:36 -05:00
|
|
|
<?php
|
|
|
|
require(__DIR__ . "/../libs/page.php");
|
|
|
|
require(__DIR__ . "/../libs/form.php");
|
|
|
|
require(__DIR__ . "/../libs/comment.php");
|
|
|
|
|
|
|
|
page_header();
|
|
|
|
|
|
|
|
function get_handler() {
|
|
|
|
global $db;
|
|
|
|
|
|
|
|
$stmt = $db->prepare("SELECT * FROM main.auth"); //weirdly, this requires a schema name
|
|
|
|
$stmt->execute([]);
|
|
|
|
$result = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
|
|
|
|
|
|
|
$pr = array();
|
|
|
|
|
|
|
|
foreach ($result as $usern) {
|
|
|
|
$pr[$usern['username']] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ($i = 0; $i < 10; $i++) {
|
2025-01-24 02:52:28 -05:00
|
|
|
foreach ($result as $usern) {
|
|
|
|
$theuser = $usern['username'];
|
|
|
|
$stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?");
|
|
|
|
$stmt->execute([$theuser]);
|
|
|
|
|
|
|
|
$followers = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
|
|
|
|
|
|
|
foreach ($followers as $follown) {
|
2025-01-24 13:58:22 -05:00
|
|
|
if ($usern['username'] == $follown['target']) continue;
|
2025-01-24 02:52:28 -05:00
|
|
|
$pr[$usern['username']] += $pr[$follown['target']] / 10;
|
2025-01-23 20:00:36 -05:00
|
|
|
}
|
2025-01-24 02:52:28 -05:00
|
|
|
|
|
|
|
$h = $pr[$usern['username']];
|
|
|
|
}
|
2025-01-23 20:00:36 -05:00
|
|
|
}
|
2025-01-23 20:04:50 -05:00
|
|
|
|
|
|
|
function cmp($a, $b) {
|
|
|
|
if ($a == $b) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ($a > $b) ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
uasort($pr,'cmp');
|
|
|
|
|
|
|
|
foreach ($pr as $usern => $rr) { ?>
|
2025-01-23 20:00:36 -05:00
|
|
|
<div class='comment'>
|
2025-01-24 02:52:28 -05:00
|
|
|
<div class="avatar">
|
|
|
|
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
|
|
|
|
<div>
|
|
|
|
<div><b>
|
2025-01-24 02:53:22 -05:00
|
|
|
<a class="link" href="/user.php?id=<?php echo $usern ?>">
|
2025-01-24 02:52:28 -05:00
|
|
|
<?php echo $usern ?>
|
|
|
|
</a>
|
|
|
|
</b>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div><b>Rank</b>: <?php echo (int)($rr * 10) ?></div>
|
2025-01-23 20:00:36 -05:00
|
|
|
</div>
|
|
|
|
<?php }
|
|
|
|
}
|
|
|
|
|
|
|
|
get_handler();
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
page_footer();
|
|
|
|
?>
|