Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = 'http://www.flashflashrevolution.com/api/api.php?key=hehu&action=ranks&username=' . $urlusername;
- #echo $url . "<p>";
- #echo "\n";
- #echo $username;
- #echo "\n";
- $json = file_get_contents($url) or die('not a user! or i can\'t connec to the internets.');
- # var_dump(json_decode($json, true));
- $array = json_decode($json, true);
- $username = mysql_real_escape_string($array['user']['name']);
- $siteid = $array['user']['id'];
- $numberofsongs = max(array_keys($array['songs']));
- $time2 = time() + microtime();
- for ($i = 0; $i < $numberofsongs; $i++) {
- # echo $array['user']['songs'][$i]['scores']['good'];
- if (isset($array['songs'][$i])) {
- $played[$i] = $array['songs'][$i]['scores']['played'];
- $notecount = $array['songs'][$i]['scores']['perfect'] + $array['songs'][$i]['scores']['good'] + $array['songs'][$i]['scores']['average'] + $array['songs'][$i]['scores']['miss'];
- $notesinsong = $array['songs'][$i]['info']['notes'];
- if ($notecount == $notesinsong) {
- $goodcount[$i] = $array['songs'][$i]['scores']['good'] + ($array['songs'][$i]['scores']['average'] * 1.8) + ($array['songs'][$i]['scores']['miss'] * 2.4) + ($array['songs'][$i]['scores']['boo'] * 0.2);
- }
- if ($goodcount[$i] > 20) {
- unset($goodcount[$i]);
- }
- $d = $array['songs'][$i]['info']['difficulty'];
- $songs[$d][$i] = $array['songs'][$i];
- $ngc[$d][$i] = $goodcount[$i];
- if (isset($goodcount[$i])) {
- $songweight[$i] = (20 - $goodcount[$i]) * $d;
- }
- #if(!empty($songweight[$i])) {
- #echo $i . " - " . $songweight[$i] . "<br>";
- if ($notecount == $notesinsong) {
- $played_weights[$d][$i] = $songweight[$i];
- }
- $weights[$d][$i] = $songweight[$i];
- #}
- /*
- echo "Song ID: " . $i . " - ";
- echo "Good Count: " . $goodcount[$i] . " - ";
- echo "Difficulty: " . $d . " - ";
- echo "Weight: " . $songweight[$i];
- echo "Played: " . $played[$i];
- echo "<br>";
- */
- }
- }
- $time3 = time() + microtime();
- $maximum_d = max(array_keys($weights)) - 900;
- #echo $maximum_d;
- for ($d = 1; $d <= $maximum_d; $d++) {
- if (isset($weights[$d])) {
- $n_w1d[$d] = count($weights[$d]);
- $n_w2d[$d] = count($played_weights[$d]);
- if ($n_w2d[$d] > 0) {
- $sums[$d] = array_sum($weights[$d]);
- $ngcsum[$d] = array_sum($ngc[$d]);
- $w[$d] = $sums[$d];
- $w1[$d] = $sums[$d] / $n_w1d[$d];
- $w2[$d] = $sums[$d] / $n_w2d[$d];
- $w3[$d] = $sums[$d] / $n_w2d[$d] + $ngcsum[$d];
- /*
- echo "difficulty: " . $d . "<br>";
- echo "songs played: " . $n_w2d[$d] . "/" . $n_w1d[$d] . " songs <br>";
- echo "NGC: " . $ngcsum[$d] . "<br>";
- echo "weight: " . $w[$d] . "<br>";
- echo "weight1: " . $w1[$d] . "<br>";
- echo "weight2: " . $w2[$d] . "<br>";
- echo "weight3: " . $w3[$d] . "<p>";
- */
- $dw[$d] = $w[$d] * $d;
- $dw1[$d] = $w1[$d] * $d;
- $dw2[$d] = $w2[$d] * $d;
- $dw3[$d] = $w3[$d] * $d;
- }
- /*
- echo "Sum of weights in difficulty: " . $d;
- echo " - ";
- echo $weights[$d]['sum'];
- echo "<br>";
- */
- }
- }
- $time4 = time() + microtime();
- $peak = max($w);
- $peak1 = max($w1);
- $peak2 = max($w2);
- $peak3 = max($w3);
- $peak_d = array_keys($w, $peak);
- $peak1_d = array_keys($w1, $peak1);
- $peak2_d = array_keys($w2, $peak2);
- $peak3_d = array_keys($w3, $peak3);
- /*
- var_dump($peak);
- var_dump($peak1);
- var_dump($peak2);
- var_dump($peak3);
- var_dump($peak_d);
- var_dump($peak1_d);
- var_dump($peak2_d);
- var_dump($peak3_d);
- var_dump($w);
- var_dump($w1);
- var_dump($w2);
- var_dump($w3);
- */
- for ($d = $peak_d[0]; $d <= $maximum_d; $d++) {
- $iw[$d] = $w[$d];
- $idw[$d] = $dw[$d];
- }
- $time4a = time() + microtime();
- for ($d = $peak1_d[0]; $d <= $maximum_d; $d++) {
- $iw1[$d] = $w1[$d];
- $idw1[$d] = $dw1[$d];
- }
- $time4b = time() + microtime();
- for ($d = $peak2_d[0]; $d <= $maximum_d; $d++) {
- $iw2[$d] = $w2[$d];
- $idw2[$d] = $dw2[$d];
- }
- $time4c = time() + microtime();
- for ($d = $peak3_d[0]; $d <= $maximum_d; $d++) {
- $iw3[$d] = $w3[$d];
- $idw3[$d] = $dw3[$d];
- }
- $time4d = time() + microtime();
- /*
- var_dump($iw);
- var_dump($idw);
- var_dump($iw1);
- var_dump($idw1);
- var_dump($iw2);
- var_dump($idw2);
- var_dump($iw3);
- var_dump($idw3);
- */
- $z_sum1 = array_sum($iw);
- $z_sum2 = array_sum($idw);
- $z1_sum1 = array_sum($iw1);
- $z1_sum2 = array_sum($idw1);
- $z2_sum1 = array_sum($iw2);
- $z2_sum2 = array_sum($idw2);
- $z3_sum1 = array_sum($iw3);
- $z3_sum2 = array_sum($idw3);
- $z = $z_sum2 / $z_sum1;
- $z1 = $z1_sum2 / $z1_sum1;
- $z2 = $z2_sum2 / $z2_sum1;
- $z3 = $z3_sum2 / $z3_sum1;
- $zA = ($z1 + $z2 + $z3) / 3;
- echo '<p>';
- $time5 = time() + microtime();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement