HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: /var/www/html/www.uscornatese.it/json/bestplayers.php
<?php

require_once('../wp-load.php' );
global $wpdb;

                                                        $pl = array();
                                                        $tm = array();
							$play = array();
                                                        $sql = " select game as g,(select player_id from wp_plugin_votazioni where vote != 's.v.'  and vote != '' and game = g and player_id in (select distinct(id) from wp_plugin_atalantini_player where ruolo != 'ALLENATORE') group by player_id order by avg(vote) desc limit 1) as player_id, max(vote) from wp_plugin_votazioni where vote != 's.v.'  and vote != '' and player_id in (select id from wp_plugin_atalantini_player) group by game  order by count((vote));";
                                                        $teams = $wpdb->get_results($sql);
                                                        foreach ( $teams as $player )  {
                                                                if (!in_array($player->player_id, $pl)) {
                                                                        $pl[] = $player->player_id;
                                                                }
                                                                $tm[] = $player->player_id;
                                                        }
                                                        for ($x = 0; $x < count($pl); $x++) {
                                                                $totale = 0;
                                                                for ($i = 0; $i < count($tm); $i++) {
                                                                        if ($tm[$i] == $pl[$x]) {
                                                                                $totale++;
                                                                        }
                                                                }
                                                                $playername = "";
                                                                $playerfoto = "";
                                                                $teams = $wpdb->get_results("select nominativo, file_player from wp_plugin_atalantini_player where id = " . $pl[$x] . ";");
                                                                foreach ( $teams as $player )  {
									$player->totale = $totale;
									$play[] = $player;
                                                                }
                                                        }

echo json_encode($play);
?>