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) { $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)); $pr[$usern['username']] += $pr[$fn] / ($dst + 5) / 2; } $pr[$usern['username']] = pow($pr[$usern['username']], 1.1); } $new_sum = array_sum($pr); foreach ($result as $usern) { $pr[$usern['username']] = $pr[$usern['username']] * 10000 / $new_sum; } } function cmp($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } uasort($pr,'cmp'); foreach ($pr as $usern => $rr) { ?>
Power: