From aaa6cb08453bea1ad2a9e5b1e8c4406a16c81719 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Mon, 3 Feb 2025 07:13:47 -0500 Subject: [PATCH] switch to NodeJS api --- docs/stats.php | 109 ++----------------------------------------------- 1 file changed, 4 insertions(+), 105 deletions(-) diff --git a/docs/stats.php b/docs/stats.php index c0f3f77..7fc025d 100755 --- a/docs/stats.php +++ b/docs/stats.php @@ -13,110 +13,9 @@ page_header(); function get_handler() { - // this does a ton of weird matrix math - global $db; - - $stmt = $db->prepare("SELECT * FROM main.auth"); - $stmt->execute([]); - $result = $stmt->fetchAll(PDO::FETCH_DEFAULT); - $result = array_reverse($result,true); - - $pr = array(); - $fcount = array(); - $frs = array(); - $fng = array(); - $matrixe = array(); - $msum_old = 0; - - foreach ($result as $usern) { - $fn = $usern['username']; - - $pr[$fn] = 1; - - $stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ? AND NOT username = ?"); - $stmt->execute([$fn,$fn]); - - $fng[$fn] = $stmt->fetchAll(PDO::FETCH_DEFAULT); - $fcount[$fn] = count($fng[$fn]); - - $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ? AND NOT target = ?"); - $stmt->execute([$fn,$fn]); - - $frs[$fn] = $stmt->fetchAll(PDO::FETCH_DEFAULT); - - $matrixe[$fn] = array(); - $matrixe[$fn][$fn] = 1; - $msum_old++; - } - - $ch = 0; - foreach ($result as $usern) { - $theuser = $usern['username']; - - $followers = $frs[$theuser]; - - if (count($followers) > 0) { - $ch++; - } - - foreach ($followers as $follown) { - $fn = $follown['target']; - - if ($usern['username'] == $fn) continue; - $dst = $fcount[$fn]; - - $msum_old += $matrixe[$usern['username']][$fn] = 1 + 1 / ($dst + 10) / 10; - } - } - - for ($i = 0; $i < 10; $i++) { - $prold = $pr; - $matrixf = $matrixe; - $msum = 0; - - foreach ($result as $usera) { - $una = $usera['username']; - $pr[$una] = 0; - if (count($frs[$una]) == 0) continue; - - foreach ($result as $userb) { - $unb = $userb['username']; - $prb = $prold[$unb]; - if ($prb < 1 / 1e3 || count($fng[$unb]) == 0) { - //$msum += $matrixe[$una][$unb]; - continue; - } - $matrixe[$una][$unb] = 0.03; - - foreach ($result as $userc) { - $unc = $userc['username']; - $matrixe[$una][$unb] += $matrixf[$una][$unc] * $matrixf[$unc][$unb]; - } - - $msum += $matrixe[$una][$unb]; - $pr[$una] += $prb * $matrixe[$una][$unb]; - } - } - - foreach ($result as $usera) { - $una = $usera['username']; - if (count($frs[$una]) == 0) continue; - - foreach ($result as $userb) { - $unb = $userb['username']; - $matrixe[$una][$unb] *= $msum_old / $msum; - } - } - - $new_sum = array_sum($pr); - foreach ($result as $usern) { - $h = $pr[$usern['username']]; - $pr[$usern['username']] /= $new_sum; - } - } - - uasort($pr,'cmp'); - + $api = file_get_contents("https://nbg.dervland.net/node/top"); + $pr = json_decode($api); + foreach ($pr as $usern => $rr) { ?>
@@ -130,7 +29,7 @@
-
Power: %
+
Power: