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/teams.php
<?php
/*
Template Name: Teams
*/
$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'" );
$signs = array();
$signs[] = " ";
$signs[] = "+";
$signs[] = "-";

$values = array();
$values_tia = array();

$values[] = "s.v.";
$values[] = "4";
$values[] = "4.25";
$values[] = "4.50";
$values[] = "4.75";
$values[] = "5";
$values[] = "5.25";
$values[] = "5.50";
$values[] = "5.75";
$values[] = "6";
$values[] = "6.25";
$values[] = "6.50";
$values[] = "6.75";
$values[] = "7";
$values[] = "7.25";
$values[] = "7.50";
$values[] = "7.75";
$values[] = "8";

$values_tia[] = "s.v.";
$values_tia[] = "4";
$values_tia[] = "4.25";
$values_tia[] = "4.50";
$values_tia[] = "4.75";
$values_tia[] = "5";
$values_tia[] = "5.25";
$values_tia[] = "5.50";
$values_tia[] = "5.75";
$values_tia[] = "6";
$values_tia[] = "6.25";
$values_tia[] = "6.50";
$values_tia[] = "6.75";
$values_tia[] = "7";
$values_tia[] = "7.25";
$values_tia[] = "7.50";
$values_tia[] = "7.75";
$values_tia[] = "8";
$values_tia[] = "9";
$values_tia[] = "10";

$ruoli = array();
$ruoli[] = "PORTIERE";
$ruoli[] = "DIFENSORE";
$ruoli[] = "CENTROCAMPISTA";
$ruoli[] = "ATTACCANTE";
$ruoli[] = "ALLENATORE";

// 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],
                                'comment' => $_POST['commento' . $player->id],
                                'sign' => $_POST['sign' . $player->id]
                        ),
                        array(
                                '%d',
                                '%s',
				'%s',
				'%d',
				'%s',
                                '%s',
                                '%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">
<?php
$team1 = "";
$team2 = "";
$img1 = "";
$img2 = "";
$game = "";
$attivo = "";
$ids = "";
$sql = "select id, sq1, sq2, immagine1, immagine2, attivo,players, resultsq1,resultsq2  from wp_plugin_atalantini_team where attivo = 'SI'  or attivo = 'CHIUSO';";
$teams = $wpdb->get_results($sql);
$isTeam = 0;
foreach ( $teams as $team )  {
	$game = $team->id;
	$team1 = $team->sq1;
	$img1 = $team->immagine1;
        $rs1 = $team->resultsq1;

        $team2 = $team->sq2;
        $img2 = $team->immagine2;
	if ($img2 == "palermo.jpg") {
		$img2 = "palermo.png";
	}
        $rs2 = $team->resultsq2;
	$attivo = $team->attivo;
	$ids = $team->players;
	$isTeam = 1;
}
if ( !is_user_logged_in() ) {
	$isTeam = 2;
}
if ($isTeam == 1) {
?>


                        <div class="td-pb-row">
							<img src="/wp-content/themes/atalantini/images/adagurdam.jpg" width="100%">
<br>
                                <div class="td-pb-span6 td-main-content">
								<div class="post_day_content">
								<center>
								<h1><?= $team1 ?></h1>
                                                        	<img height="150" style="height:150px;" src="/wp-content/themes/atalantini/squadre/<?= $img1 ?>">
					                        <div class="iis-caption-game">
					                        <center>
					                        <h2><?= $rs1 ?></h2>
					                        </center>
					                        </div>
								</center>
								</div><!-- /post content -->
							</div><!-- /grid6 omega -->
                                <div class="td-pb-span6 td-main-content">

                                                                <div class="post_day_content">
                                                               <center>
                                                                <h1><?= $team2 ?></h1>
                                                                <img height="150" style="height:150px;" src="/wp-content/themes/atalantini/squadre/<?= $img2 ?>">
					                        <div class="iis-caption-game">
					                        <center>
					                        <h2><?= $rs2 ?></h2>
        					                </center>
       						                 </div>
                                                                </center>
                                                                </div><!-- /post content -->
                                                        </div><!-- /grid6 omega -->
                                <div class="td-pb-span12 td-main-content">
								<h2>Votazioni:</h2><br>
								</form>
								<form method="post"id="votaForm" name="votaForm">
                                                                <span style="float:right"><a href="/risultati-partite/">Visualizza i commenti degli altri utenti</a></span>
								<input type="hidden" name="azione" value="vota">
                                                                <input type="hidden" name="game" value="<?= $game ?>">
								<table width="100%">
								<tr>
									<td><b>Numero:</b></td>
                                                                        <td><b>Giocatore:</b></td>
                                                                        <td><b>Ruolo:</b></td>
                                                                        <td><b>Voto:</b></td>
                                                                        <td><b>Lode:</b></td>
                                                                        <td><b>Commento:</b></td>
								</tr>
								<?php
								$votato = 0;
								foreach ($ruoli as $ruolo) {
								$sql = "select id, numero, nominativo, ruolo, (select vote from wp_plugin_votazioni where game = " . $game . " and player_id = wp_plugin_atalantini_player.id and username = '" . $current_user->user_login . "') as voto, (select comment from wp_plugin_votazioni where game = " . $game . " and player_id = wp_plugin_atalantini_player.id and username = '" . $current_user->user_login . "') as comment, (select sign from wp_plugin_votazioni where game = " . $game . " and player_id = wp_plugin_atalantini_player.id and username = '" . $current_user->user_login . "') as sign from wp_plugin_atalantini_player where id in (" . $ids . ") and ruolo = '" . $ruolo . "';";
								$players = $wpdb->get_results($sql);
								foreach ( $players as $player )  {
								?>
									<tr>
										<td><b><?= $player->numero ?></b></td>
                                                                                <td><?= $player->nominativo ?></td>
                                                                                <td><?= substr($player->ruolo,0,1) ?></td>
                                                                                <td>
											<select name="votazione<?= $player->id ?>">
											<?php
                                                                                           for ($i = 0; $i < count($values); $i++) {
												if ($values[$i] == $player->voto) {
													echo "<option value=\"" . $values[$i] . "\" selected>" . $values[$i] . "</option>";
													$votato = 1;
												} else {
                                                                                                        echo "<option value=\"" . $values[$i] . "\">" . $values[$i] . "</option>";
												}
											   }
											?>
											</selected>
										</td>
                                                                                <td>
										<?php if ($player->sign == "lode") { ?>
                                                                                        <input checked style="margin-left:10px;" type="checkbox" value="lode" name="sign<?= $player->id ?>">
										<?php } else { ?>
                                                                                        <input style="margin-left:10px;" type="checkbox" value="lode" name="sign<?= $player->id ?>">

										<?php } ?>
                                                                                </td>
                                                                                <td><input name="commento<?= $player->id ?>" type="text" value="<?= $player->comment ?>" size="70%"></td>
									</tr>
								<?php
								}
								}
								?>
								</table>
<?php //if ($attivo == "CHIUSO") { ?>
								<span style="float:left"><br><br><a href="/risultati-partite/">Visualizza i commenti degli altri utenti</a></span>
<?php //} ?>
<?php if ($attivo == "SI") {?>
<?php if ($votato  == "1") {?>
<br>
Grazie mille. Attenzione, hai gia'  espresso i tuoi voti.
<br>
<?php } else { ?>


								<input  type="button" onClick="document.votaForm.submit();" value="Invia" style="background-color: #2c8cd6; color:#fff;width:100px; float:right;margin-top:20px;height:40px;" name="sendMessage">
<?php } 
if ($current_user->user_login == "admin") {
?>
                                                                <input  type="button" onClick="document.votaForm.submit();" value="Invia" style="background-color: #2c8cd6; color:#fff;width:100px; float:right;margin-top:20px;height:40px;" name="sendMessage">
<?php

}
} ?>
								</form>
							</div>
						</div><!-- /post day -->
<?php } else { ?>
<?php 
if ($isTeam == 0) {
?>
	<br><br><br><h1> Non ci sono votazioni attive ora</h1>
<?php } else { ?>
        <br><br><br><h1> Inserisci username e password per accedere alla pagina delle votazioni:</h1>
	<form method="post" action="/logincs.php">
	Username:<br>
	<input type="text" name="username" size="30"><br>
	Password:<br>
        <input type="password" name="password" size="30"><br>
	<input  type="submit" value="Loggati" style="background-color: #2c8cd6; color:#fff;width:100px; float:left;margin-top:20px;height:40px;" name="sendMessage">
	</form>
<?php } ?>
<?php } ?>


					</div><!-- /grid11 -->
				</div><!-- /grid12 -->
			</div><!-- /row -->
		</div><!-- /end page content -->	
		</div>
<?php get_footer(); ?>