Location: PHPKode > projects > PHPOLL php - mysql poll system > phpoll_files/admin/votanti.php
<!--

This file is part of PHPOLL.

    PHPOLL is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    PHPOLL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PHPOLL; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

-->

<?php

if (isset ($_GET['language'])) { 
	$language=(int)$_GET['language'];
}

else {
	$language=1;
}

if ($language==0) {

  die ("Try a different way!");

}

include "../config/config.php";
include "localization.php";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<script type="text/javascript" language="JavaScript" src="public_smo_scripts.js"></script>

<script type="text/javascript" language="JavaScript">

<!--

function submitForm () {
	
	var answer = confirm ("<?php print $config_alert_cancella; ?>");
  
		if (answer) {
			window.document.modifica_votanti.submit();
		}
		else {
			alert ("<?php print $config_alert_annulla; ?>");
		}
		
}

function invia_stamp () {
	
		window.document.modifica_stamp.submit();
		
}
	
// -->

</script>

<title>PHPOLL - votanti</title>
<link rel="stylesheet" href="../css/phpoll_layout.css" title="phpoll layout" />
</head>
<body>

<div class="corpo">

<img src="../img/poll_logo.jpg" alt="phpoll logo" />
<img src="../main_img/phpoll_char.gif" alt="phpoll" />

<br />

<a href="config_editor.php?language=1"><img src="../img/ita.jpg" alt="italiano" /></a>
<a href="config_editor.php?language=2"><img src="../img/eng.jpg" alt="english" /></a>

<br />

<?php

print "<div class=\"titolo_db\">";
print "POLL: ".$prepoll;
print "&nbsp;&nbsp;&nbsp;IP: ".$_SERVER['REMOTE_ADDR'];
print "</div>";

?>

<div class="menu">

<?php 

print "<a href=\"config_editor.php?language=".$language."\">".$admin_menu_config."</a>";
print "<a href=\"band_editor.php?language=".$language."\">".$admin_menu_candidati."</a>";
print "<a class=\"attuale\" href=\"votanti.php\">".$admin_menu_voti."</a>";
print "<a href=\"risultati_config.php?language=".$language."\">".$admin_menu_risultati."</a>";

?>

</div>

<div class="forms">

<?php

// assegno le variabili di connessione
$phpoll_db = mysql_connect ($phpoll_host, $phpoll_user, $phpoll_password)
	or die ("Errore nella connessione a MySQL");
	
// selezione del database
mysql_select_db($phpoll_database, $phpoll_db)
	or die ("Errore nella connessione al database ".$phpoll_database);
	
// QUERY per MySQL
$query_login = "SELECT login, password FROM phpoll_".$prepoll."_configurazione;";	
	
$estrai_login = mysql_query($query_login, $phpoll_db)
	or die ("Errore nella connessione per estrazione login configurazione dal database ".$phpoll_database);
	
$string_cook_login = "phpoll_".$prepoll."_login";
$string_cook_password = "phpoll_".$prepoll."_password";	
	
while ($dati_login=mysql_fetch_assoc ($estrai_login)) {
	
	$log=$dati_login['login'];
	$pw=$dati_login['password'];

	if ($log!="admin"&&$pw!="admin") {

	if ((isset($_COOKIE[$string_cook_login])&&$log==$_COOKIE[$string_cook_login])&&(isset($_COOKIE[$string_cook_password])&&$pw==$_COOKIE[$string_cook_password])) {
		
		$test_log = true;
		
	}
	
	else {
		
		$test_log = false;
		
	}
	
	}
	
	else {
		
		$test_log = true;
		
	}	

}

if ($test_log) {

if (isset($_POST['indietro_di'])) {
	$indietro_di = $_POST['indietro_di'];
}
else {
	$indietro_di = "giorno";
}

if (isset($_POST['candidate'])&&$_POST['candidate']!="--- ALL ---") {
	
	$candidate=" AND MATCH (band_votate) AGAINST ('\"".$_POST['candidate']."\"' in boolean mode)";

}
else if (isset($_POST['candidate'])&&$_POST['candidate']=="--- ALL ---") {
	$candidate="";
}
else {
	$candidate="";
}

/*
if (isset($_POST['IP'])&&$_POST['IP']!="--- ALL ---") {
	
	$IP=" AND ip = '".$_POST['IP']."'";

}
else if (isset($_POST['IP'])&&$_POST['IP']=="--- ALL ---") {
	$IP="";
}
else {
	$IP="";
}

*/
switch ($indietro_di) {
	
	case $config_giorno: 	$giorno=" selected=\"selected\"";
					$stamp = time()- 86400;
					$frase = $config_mostravoti;
					break;
	case $config_settimana : $settimana=" selected=\"selected\"";
					$stamp = time()- 604800;
					$frase = $config_mostravoti2;
					break;
	case $config_mese : $mese=" selected=\"selected\""; 
				 $stamp = time()- 18144000;
				 $frase = $config_mostravoti;
				 break;
	case "--- ALL ---": $tutti=" selected=\"selected\"";
				  $frase = $config_mostravotiall;
				  $stamp = 0;
				  break;
				  
	default: $giorno=" selected=\"selected\"";
			 $stamp = time()- 86400;
			 $frase = $config_mostravoti;
			 break;
	
}

// QUERY per MySQL
$query_banda = "SELECT nome_band FROM ".$tab_band." ORDER BY nome_band;";

$estrai_banda = mysql_query($query_banda, $phpoll_db)
	or die ("Errore nella connessione per estrazione voti al database ".$phpoll_database);
/*	
// QUERY per MySQL
$query_ip = "SELECT ip FROM ".$tab_voti." ORDER BY ip;";

$estrai_ip = mysql_query($query_ip, $phpoll_db)
	or die ("Errore nella connessione per estrazione voti al database ".$phpoll_database);	

*/
print "<form action=\"votanti.php?language=".$language."\" method=\"post\" name=\"modifica_stamp\">";
print "<label>".$frase." </label>";
print "<select onChange=\"invia_stamp();\" name=\"indietro_di\">";
print "<option".$giorno.">";
print $config_giorno;
print "</option>";
print "<option".$settimana.">";
print $config_settimana;
print "</option>";
print "<option".$mese.">";
print $config_mese;
print "</option>";
print "<option".$tutti.">";
print "--- ALL ---";
print "</option>";
print "</select>";

print "<label> ".$config_candidato." </label>";
print "<select onChange=\"invia_stamp();\" name=\"candidate\">";

if ($_POST['candidate']=="--- ALL ---") {
		$band_selected=" selected=\"selected\"";
	}

print "<option".$band_selected.">--- ALL ---</option>";

while ($dati_banda=mysql_fetch_assoc ($estrai_banda)) {
	
	if ($_POST['candidate']==$dati_banda['nome_band']) {
		$band_selected=" selected=\"selected\"";
	}
	else {
		$band_selected="";
	}
	
	print "<option".$band_selected.">".$dati_banda['nome_band']."</option>";
	
}

print "</select>";

print "</form>";
	
// QUERY per MySQL
$query_voti = "SELECT * FROM ".$tab_voti." WHERE timestamp > ".$stamp.$candidate." ORDER BY band_votate, timestamp DESC, ip;";

//print $query_voti;

$estrai_voti = mysql_query($query_voti, $phpoll_db)
	or die ("Errore nella connessione per estrazione voti al database ".$phpoll_database);	
	

print "<div class=\"votanti\">";	

print "<form onSubmit=\"return cancella();\" action=\"modifica_votanti.php?language=".$language."\" method=\"post\" name=\"modifica_votanti\">";

print "<table border=\"1\">";
print "<tr id=\"votanti_titoli\">";
print "<td>".$config_votatoper."</td>";
print "<td>".$config_data."</td>";	
print "<td>ip</td>";
print "<td>browser</td>";
print "<td>email</td>";
print "<td>".$config_confermato."</td>";
print "<td><img src=\"../img/gomma.gif\" alt=\"cancella\" /></td>";		
print "</tr>";

$c=0;	
while ($dati_voti=mysql_fetch_assoc ($estrai_voti)) {

	print "<tr>";
	
		print "<td>";
			print $dati_voti['band_votate'];
		print "</td>";
		print "<td>";
			print date ("F j, Y, g:i a", $dati_voti['timestamp']);
		print "</td>";
		print "<td>";
			print $dati_voti['ip'];
		print "</td>";
		print "<td>";
			print $dati_voti['browser'];
		print "</td>";
		print "<td>";
			print "<a href=\"mailto:".$dati_voti['email']."\">".$dati_voti['email']."</a>";
		print "</td>";
		print "<td>";
		if ($dati_voti['votato']=="1") { $votato="yes"; } else { $votato="no"; }
			print $votato;
		print "</td>";
		print "<td>";
		print "<input type=\"checkbox\" name=\"".$dati_voti['id']."\" />";
		print "</td>";
		
	print "</tr>";
$c++;
}

print "<tr><td colspan=4>TOTAL = ".$c."</td><td colspan=2 align=right><em>".$config_selectall."</em>&nbsp;</td>";
print "<td>";
print "<input type=\"checkbox\" name=\"checkall\" onclick=\"checkUncheckAll(this);\" />";
print "</td>";
print "</tr>";
print "</table>";

print "<a href=\"#\" onClick=\"submitForm();\"><img src=\"../img/disk.gif\" alt=\"".$config_salvamodifiche."\" /> ".$config_salvamodifiche."</a>";
//print "<input type=\"submit\" name=\"submit\" value=\"conferma modifica\" />";
print "</form>";

print "</div>";

mysql_close ($phpoll_db);

}

else {
	
	print "<form action=\"elabora_cookie.php\" method=\"post\" name=\"form_elabora\">";
	print "<table align=\"center\">";
	print "<tr>";
	print "<td>login</td>";
	print "<td>";
	print "<input type=\"text\" name=\"log\" size=\"30\" />";
	print "</td>";
	print"</tr><tr>";
	print "<td>password</td>";
	print "<td>";
	print "<input type=\"password\" name=\"pw\" size=\"30\" />";
	print "</td>";
	print "</tr></table>";
	print "<input type=\"submit\" name=\"submit\" value=\"".$config_conferma."\" />";
	print "</form>";
		
	
}

?>


</div>
</div>

</body>
</html>
Return current item: PHPOLL php - mysql poll system