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: //opt/Newsmag/resumeteams.php
<?php
/*
Template Name: Resoconto Teams
*/

$commentEnabled = "Y";
$commentEnabled =  $wpdb->get_var( "SELECT valore FROM wp_plugin_atalantini_config where titolo = 'COMMENTI_ABILITATI'" );

if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        $maxCommentsPerDay =  $wpdb->get_var( "SELECT valore FROM wp_plugin_atalantini_config where titolo = 'MAX_COMMENTI_PER_GIORNO'" );
        $maxCommentsDone =  $wpdb->get_var( "select count(comment_ID) from wp_comments where user_id = " . $current_user->ID . " and comment_date like '" . date('Y-m-d') . "%';" );
        if ($maxCommentsDone >= $maxCommentsPerDay) {
                $commentEnabled = "N";
        }
}

$suffix = "";
if (isset($_GET['suffix'])) {
        $suffix = $_GET['suffix'];
}
$uri = $_SERVER['REQUEST_URI'];
//$totalPosts = str_replace("/","",str_replace("/ultime-news-","",$uri));
$totalPosts = $_GET['num'];
$current_user = wp_get_current_user();
$bannerLaterale =  $wpdb->get_var( "SELECT immagine FROM wp_plugin_atalantini_banner where tipo = 'QUADRATO'" );

// salvataggio votazione
if (isset($_POST['azione'])) {
	$wpdb->query("delete from wp_plugin_votazioni where username = '" . $current_user->user_login . "' and game = " . $_POST['game']);
	$sql = "select * from wp_plugin_atalantini_player;";
        $players = $wpdb->get_results($sql);
        foreach ( $players as $player )  {
                $wpdb->insert(
                        "wp_plugin_votazioni",
                        array(
                                'player_id' => $player->id,
                                'player_name' => $player->nominativo,
				'username' => $current_user->user_login,
				'game' => $_POST['game'],
				'vote' => $_POST['votazione' . $player->id]
                        ),
                        array(
                                '%d',
                                '%s',
				'%s',
				'%d',
				'%s'
                        )
                );

	}
}
?>
<?php get_header(); ?>
<div class="td-main-content-wrap">
        <div class="td-container">
                <div class="td-container-border">
                        <div class="td-pb-row">
                                <div class="td-pb-span12 td-main-content">
                                                        <img src="/wp-content/themes/atalantini/images/adagurdam.jpg" width="100%">
<?php
$team1 = "";
$team2 = "";
$img1 = "";
$img2 = "";
$game = "";
$ids = "";
$rs1 = "";
$rs2 = "";

$ruoli = array();
$ruoli[] = "PORTIERE";
$ruoli[] = "DIFENSORE";
$ruoli[] = "CENTROCAMPISTA";
$ruoli[] = "ATTACCANTE";
$ruoli[] = "ALLENATORE";
if (isset($_GET['id'])) {
        $sql = "select id, sq1, sq2, immagine1, immagine2,resultsq1, resultsq2,players from wp_plugin_atalantini_team" . $suffix . " where id = " . $_GET['id'] . ";";
} else {
	$sql = "select id, sq1, sq2, immagine1, immagine2,resultsq1, resultsq2,players from wp_plugin_atalantini_team" . $suffix . " where attivo = 'SI'  or attivo = 'CHIUSO';";
}
$teams = $wpdb->get_results($sql);
foreach ( $teams as $team )  {
	$game = $team->id;
	$team1 = $team->sq1;
	$img1 = $team->immagine1;
        $rs1 = $team->resultsq1;

        $team2 = $team->sq2;
        $img2 = $team->immagine2;
	$ids = $team->players;
        $rs2 = $team->resultsq2;
}
if ($img2 == "palermo.jpg") {
     $img2 = "palermo.png";
}
$comments_count =  $wpdb->get_var( "SELECT count(*) FROM wp_plugin_adagurdam_comment where comment_post_ID = " . $game);
?>
		<br>
                <table>
                   <tr>
			<td>
			<center>
			<h1><?= $team1 ?></h1>
			<img width="201" src="/wp-content/themes/atalantini/squadre/<?= $img1 ?>">
			<div class="iis-caption-game">
                        <center>
                        <h2><?= $rs1 ?></h2>
                        </center>
			</div>
			</center>
			</td>
			<td>
                        <center>
                        <h1><?= $team2 ?></h1>
                        <img width="201" src="/wp-content/themes/atalantini/squadre/<?= $img2 ?>">
                        <div class="iis-caption-game">
                        <center>
                        <h2><?= $rs2 ?></h2>
                        </center>
			</td>
		</tr>
		</table>
                <div class="row clearfix">
                                                        <div class="grid_4 omega">
								<center>
                                                                <h2>MVP</h2><br>
                                                                <?php
                                                                $nominativo = "";
                                                                $filename = "";
                                                                $id_player = "";
                                                                $sql = "select player_id from wp_plugin_votazioni" . $suffix . " where vote != 's.v.'  and vote != '' and game = " . $game . " and player_id in (select distinct(id) from wp_plugin_atalantini_player" . $suffix . " where ruolo != 'ALLENATORE') group by player_id order by avg(vote) desc limit 1";
                                                                $players = $wpdb->get_results($sql);
                                                                foreach ( $players as $player )  {
                                                                        $id_player = $player->player_id;
                                                                }

                                                                $sql = "select nominativo, file_player from wp_plugin_atalantini_player" . $suffix . " where id =" . $id_player . ";";
                                                                $players = $wpdb->get_results($sql);
                                                                foreach ( $players as $player )  {
                                                                        $nominativo = $player->nominativo;
                                                                        $filename = $player->file_player;
                                                                }

                                                                ?>
                                                                <b><?= $nominativo ?></b><br>
                                                                <img src="/wp-content/themes/atalantini/player/<?= $filename ?>">
								<br><br>
								</div>
								<div class="grid_4 omega">
								<center><h2>Votazioni:</h2></center><br>
                                                Ecco la media voti dei nostri lettori per la partita <b><?= $team1 ?> - <?= $team2 ?></b>:<br><br>
                                                        <table width="100%">
                                                                <?php
                                                                foreach ($ruoli as $ruolo) {
                                                                $sql = "select id, numero, nominativo, ruolo, (select sum(vote) from wp_plugin_votazioni" . $suffix . " where game = " . $game . " and vote != '' and vote != 's.v.' and player_id = wp_plugin_atalantini_player" . $suffix . ".id) as voto, (select count(distinct(username))  from wp_plugin_votazioni" . $suffix . " where game = " . $game . " and vote != '' and vote != 's.v.' and player_id = wp_plugin_atalantini_player" . $suffix . ".id) as totutenti, (select avg(vote) from wp_plugin_votazioni" . $suffix . " where game = " . $game . " and vote != '' and vote != 's.v.' and player_id = wp_plugin_atalantini_player" . $suffix . ".id) as maxtotale from wp_plugin_atalantini_player" . $suffix . " where ruolo = '" . $ruolo . "' and id in (" . $ids . ") order by maxtotale desc;";
                                                                $players = $wpdb->get_results($sql);
                                                                foreach ( $players as $player )  {
                                                                ?>
                                                                        <tr>
                                                                                <td><?= $player->nominativo ?></td>
                                                                                <td><?= round(($player->voto)/$player->totutenti,2) ?></td>
                                                                                <td><a href="javascript:seePlayer(<?= $player->id ?>)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Visualizza Commenti</a></td>
                                                                        </tr>
                                                                <?php
                                                                }
								}
                                                                ?>
                                                                </table>
							</div>
						</div><!-- /post day -->
                                                                <?php
                                                                $sql = "select id, numero, nominativo, ruolo from wp_plugin_atalantini_player" . $suffix . ";";
                                                                $players = $wpdb->get_results($sql);
                                                                foreach ( $players as $player )  {
                                                                $javascript .= "jQuery('#player_" . $player->id . "').css('display','none');\n";

                                                                ?>
<a name="player_<?= $player->id ?>"></a>
<div id="player_<?= $player->id ?>" style="display:none;">
<h2><?= $player->nominativo ?></h2>
<?php
$sql = "select * from wp_plugin_votazioni" . $suffix . " where username != '' and game = " . $game . " and player_id = " . $player->id;
$voters = $wpdb->get_results($sql);
foreach ( $voters as $vote )  {
   if ($vote->comment != "") {
?>
          <div  style="padding-left:2px;background-color:#e5e3ca;font-size:12pt;font-family: arial,sans serif;color:#000;">
        		<div class="title_bucomment" style="height:31px;">
					<div style="float:right">
			<?php if ($vote->sign == "lode") { ?>
                        <img src="/wp-content/uploads/avatar/award.png" style="margin-top:4px;">
			<?php } ?>
        			</div>
                    		&nbsp;&nbsp;&nbsp;<?= $vote->username ?>
				<div style="float:right">
				Voto: <?= $vote->vote?>&nbsp;&nbsp;
				</div>
           
    			</div>
	    <?= $vote->comment ?><br><br>
        </div>
	<br>
<?php
   }
}
?>
</div>
                                                                <?php
                                                                }
                                                                ?>

			                <div>
<hr>
<a name="commentsAtalantini"></a>
<ol id="comments-atalantini" class="commentlist" style="display:<?= $openPanelSite ?>">
<?php
$order = "desc";
$comments = $wpdb->get_results("select * from wp_plugin_adagurdam_comment");
foreach ( $comments as $comment ) {
	$args['style'] = "li";
	$depth = 7;
	//mytheme_comment_ada($comment, $args, $depth);
}
?>
</ol>

                                                <?php
                                                if ($commentEnabled == "Y") {
                                                ?>
						<hr>
                                                <div id="comments-atalantini-form" class="posts_block mbf clearfix">
						</div>
						<?php } ?>	

			                </div>
					</div><!-- /grid11 -->
                                        </div>
				</div><!-- /grid12 -->
			</div><!-- /row -->
		</div><!-- /end page content -->

<script>

function seePlayer(id) {
	<?= $javascript ?>
	jQuery('#player_' + id).css('display','block');
	location.href = "#player_" + id; 
}

</script>

                <script language="javascript">

jQuery(document).ready(function ($) {
        <?php
        if (isset($_GET['tag'])) {
        ?>
                setCommentsPosition('<?= $_GET['tag'] ?>');
        <?php
        } else {
        ?>
                setCommentsBegin('<?= $commentsPreference ?>');
        <?php
        }
        ?>

        });

                </script>
                <script type="text/javascript" src="<?php echo esc_url( get_template_directory_uri() ); ?>/js/customfn.js?v=2.0"></script>


<?php get_footer(); ?>