53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
|
<?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++) {
|
||
|
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) {
|
||
|
if ($usern == $follown['target']) continue;
|
||
|
$pr[$usern['username']] += $pr[$follown['target']];
|
||
|
}
|
||
|
|
||
|
$h = $pr[$usern['username']];
|
||
|
|
||
|
$pr[$usern['username']] = log($h/10 + 1)*10* M_E;
|
||
|
}
|
||
|
}
|
||
|
foreach ($result as $usern) { ?>
|
||
|
<div class='comment'>
|
||
|
<b><?php echo $usern['username'] ?></b>
|
||
|
<div>Rank: <?php echo (int)($pr[$usern['username']] * 10) ?></div>
|
||
|
</div>
|
||
|
<?php }
|
||
|
}
|
||
|
|
||
|
get_handler();
|
||
|
?>
|
||
|
|
||
|
<?php
|
||
|
page_footer();
|
||
|
?>
|