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;
|
|
|
|
}
|
|
|
|
|
2025-01-25 10:19:29 -05:00
|
|
|
for ($i = 0; $i < 50; $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);
|
2025-01-25 09:48:11 -05:00
|
|
|
|
2025-01-24 02:52:28 -05:00
|
|
|
foreach ($followers as $follown) {
|
2025-01-24 14:05:36 -05:00
|
|
|
$fn = $follown['target'];
|
|
|
|
|
|
|
|
if ($usern['username'] == $fn) continue;
|
|
|
|
|
|
|
|
$stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ? AND NOT username = ?");
|
|
|
|
$stmt->execute([$fn,$fn]);
|
|
|
|
|
|
|
|
$dst = count($stmt->fetchAll(PDO::FETCH_DEFAULT));
|
|
|
|
|
2025-01-25 10:23:20 -05:00
|
|
|
$pr[$usern['username']] += $pr[$fn] / ($dst + 10) / 10;
|
2025-01-23 20:00:36 -05:00
|
|
|
}
|
2025-01-25 09:57:59 -05:00
|
|
|
}
|
2025-01-24 02:52:28 -05:00
|
|
|
|
2025-01-25 10:19:29 -05:00
|
|
|
$dist = 1 - ($i / 50);
|
2025-01-27 17:08:30 -05:00
|
|
|
$dist = pow($dist,0.3);
|
2025-01-25 10:07:50 -05:00
|
|
|
|
2025-01-25 09:57:59 -05:00
|
|
|
$new_sum = array_sum($pr);
|
|
|
|
foreach ($result as $usern) {
|
2025-01-25 10:17:16 -05:00
|
|
|
$h = $pr[$usern['username']];
|
2025-01-27 17:08:30 -05:00
|
|
|
$pr[$usern['username']] = (pow($h / $new_sum,1.1) * 100) * $dist + ($h * (1 - $dist));
|
2025-01-24 02:52:28 -05:00
|
|
|
}
|
2025-01-23 20:00:36 -05:00
|
|
|
}
|
2025-01-23 20:04:50 -05:00
|
|
|
|
2025-01-25 10:14:32 -05:00
|
|
|
|
|
|
|
$new_sum = array_sum($pr);
|
|
|
|
foreach ($result as $usern) {
|
2025-01-27 17:08:30 -05:00
|
|
|
$pr[$usern['username']] = $pr[$usern['username']] * 100 / $new_sum;
|
2025-01-25 10:14:32 -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>
|
2025-01-27 17:08:30 -05:00
|
|
|
<div><b>Power</b>: <?php echo $rr ?>%</div>
|
2025-01-23 20:00:36 -05:00
|
|
|
</div>
|
|
|
|
<?php }
|
|
|
|
}
|
|
|
|
|
|
|
|
get_handler();
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
page_footer();
|
|
|
|
?>
|