test stats
This commit is contained in:
parent
6bfad09cf9
commit
61cdb6775e
2 changed files with 53 additions and 0 deletions
1
docs/index.php
Executable file → Normal file
1
docs/index.php
Executable file → Normal file
|
@ -13,6 +13,7 @@
|
||||||
<h2>Community</h2>
|
<h2>Community</h2>
|
||||||
|
|
||||||
<a class="form-button" href="/tou.php">Terms of Use</a>
|
<a class="form-button" href="/tou.php">Terms of Use</a>
|
||||||
|
<a class="form-button" href="/stats.php">Top Users</a>
|
||||||
<a class="form-button" href="https://dervland.net/">More Projects</a>
|
<a class="form-button" href="https://dervland.net/">More Projects</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
52
docs/stats.php
Executable file
52
docs/stats.php
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
<?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();
|
||||||
|
?>
|
Loading…
Reference in a new issue