ugrás a tartalomhoz

Szavazás gondok!

juhasztibi · 2005. Már. 9. (Sze), 16.40
hello gondom van a szavazásommal az aladdindisco.hu oldalon!Mégpedig az,hogy egyik gépen felkínálja a lehetőséget a szavazásra a másikon nem!/olyan gépről próbáltam amiről még nem szavaztak/!itt a forráskód,ha valaki tud segítsen!előre is köszönöm:)


vote.php
---------

<?php
function head() {
include('config.php');
echo "<table width=\"130\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
<tr><td bgcolor=\"$tableborder\">
<table width=\"130\" border=\"0\" cellpadding=\"0\" cellspacing=\"\" align=\"center\">
<tr><td bgcolor=\"$bgcolor\">";
}
function foot () {
echo "</td></tr></table></td></tr></table>";
}
function record($REMOTE_ADDR) {
include('config.php');
$fp=fopen("$ip_file", "a+");
fputs ($fp,$REMOTE_ADDR."][".time()."\n");
fclose($fp);
}
function check($REMOTE_ADDR) {
include('config.php');
global $valid;
$ip=$REMOTE_ADDR;
$data=file("$ip_file");
$now=time();
foreach ($data as $record) {
$subdata=explode("][",$record);
if ($now < ($subdata[1]+3600*$timeout)) {
if ($ip == $subdata[0]) {
$valid=0;
break;
}}}}
function save($answer){
global $answer;
include('config.php');
$data=file($datafile);
$subdata=explode("][",$data[$answer]);
$subdata[2]+=1;
$data[$answer]=implode("][", $subdata);
$data[$answer]=$data[$answer]."\n";
$fp=fopen($datafile,"w+");
$a=0;
do{
fputs($fp,$data[$a]);
$a++;
}while($a<count($data));
fclose($fp);
}
function form($PHP_SELF){
include('config.php');
head();
echo "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><form method=\"post\" action=\"$PHP_SELF\"><p align=\"center\">";
$data=file($datafile);
$question=$data[0];
$nb_options=count($data)-1;
echo "<b>$question</b></p>";
for($nb=1;$nb <= $nb_options; $nb++){
$option=explode("][","$data[$nb]");
echo "<input type=\"radio\" name=\"answer\" value=\"$nb\"> ";
echo "$option[0]<br>";
}
echo "<input type=\"hidden\" name=\"save\" value=\"yes\">";
echo "<p align=\"center\"><input type=\"submit\" name=\"Szavazok\" value=\"Szavazok!\"></form></font>";
echo "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><a href=\""; echo $PHP_SELF; echo "?action=results\">Szavazás állása</font></p>";
foot();
}
function results(){
include('config.php');
head();
$data=file($datafile);
$nb_answers=count($data);
$votes=0;
$a=1;
do{
$subdata=explode("][",$data[$a]);
$votes += $subdata[2];
$a++;
}while($a < $nb_answers);
$a=1;
$b="answerv";
$v=100/$votes;
echo "<p align=\"center\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><b>$data[0] <br>($votes szavazat)</b><br><br>";
do{
$subdata=explode("][",$data[$a]);
$av = $subdata[2] * $v;
echo "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\">$subdata[0] -"; printf(" %01.1f", $av); echo"%<br>";
$p2v = 100-$av;
echo "<img src=\"$subdata[1]\" width=\"$av\" height=\"10\"><img src=\"$image\" width=\"$p2v\" height=\"10\"><br>";
$a++;
} while ($a < $nb_answers);
echo "<br>";
foot();
}
check($REMOTE_ADDR);
if ($valid=="0"){ results();}
elseif ($action=="results") { results(); }
elseif ($save=="yes" && $valid!="0") { save($Answer); record($REMOTE_ADDR); results();}
elseif ($action=="save" && !empty($valid)) { results(); }
elseif ($action!="save" && $valid!="0"){ form($PHP_SELF); }
?>

config.php
-----------
<?php
$textcolor='red';
$linkcolor='#FFFFFF';
$bgcolor='#b2b2b2';
$tableborder='#000000';
$timeout='336';
$ip_file='ip.txt';
$font='impact';
$fontsize='2';
$datafile='data.txt';
$option='4';
?>

admin.php
---------
<?php

$password = 'xxxxxx';

if (!ini_get ("register_globals"))
{//globals turned Off
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_ENV_VARS);
extract($HTTP_SERVER_VARS);
}



if(!isset($passwd) or $passwd!=$password){
echo "<table width=\"303\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" height=\"169\" bgcolor=\"#336699\" align=\"center\"><tr><td bgcolor=\"#336699\" height=\"110\">
<table width=\"311\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\" height=\"136\">
<tr><td height=\"175\"><div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\"><b><font size=\"2\">Admin Login!</font></b></font><br>
</div><form name=\"form1\" method=\"post\" action=\"$PHP_SELF\"><div align=\"center\">
<input type=\"password\" name=\"passwd\"><br><input type=\"submit\" name=\"Submit\" value=\"Login\">
</div></form></td></tr></table></td></tr></table>";

}elseif ($passwd==$password){
if (isset($submit)){
$fp=fopen($datafile, "w");
fputs($fp, $question."\n");
for($i=1; $i <=50; $i++){
if($answer[$i]==""){ break;}
$input=$answer[$i]."][".$image[$i]."][".$votes[$i]."\n";
fputs($fp, $input);
}
fclose($fp);
$config="<?php\n";
$config.="\$textcolor='$textcolor';\n";
$config.="\$linkcolor='#FFFFFF';\n";
$config.="\$bgcolor='$bgcolor';\n";
$config.="\$tableborder='$tableborder';\n";
$config.="\$timeout='$timeout';\n";
$config.="\$ip_file='$ip_file';\n";
$config.="\$font='$font';\n";
$config.="\$fontsize='$fontsize';\n";
$config.="\$datafile='$datafile';\n";
$config.="\$option='$option';\n";

$config.="?>";
$fp=fopen($ip_file, "w");
fclose($fp);
$fp=fopen("config.php", "w");
fputs($fp, $config);
fclose($fp);
echo "<div align=\"center\"><b><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#00CC00\">Your
settings have been updated!</font></b></div>";
}

include('config.php');
$data=file($datafile);
$nb=count($data);
?>
<html>
<head>
<title>aladdindisco szavazás admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="k.css" rel=STYLESHEET type=text/css>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#FFFFFF" vlink="#CCCCCC" alink="#CCCCCC">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center" height="566"><IMG SRC="gfx/aladdin.gif" BORDER=0 ALT="szavazás">

<tr>
<td bgcolor="#336699" height="221">
<table width="100%" border="0" cellspacing="1" cellpadding="5">
<tr>
<td bgcolor="#EEEDEA" height="463" valign="top">
<form name="APP" method="post" action="">
<p><b><i>beállítások:</i></b><br>
<br>
</p>
<table width="100%" border="0" cellspacing="1" cellpadding="3" height="396" align="center">
<tr>
<td width="116" height="15"><b>Question</b></td>
<td colspan="3" height="15">
<input type="text" name="question" size="50" maxlength="150" value="<?php echo $data[0]; ?>">
</td>
</tr>
<tr>
<td colspan="4" height="10">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><b></b> </td>
</tr>
<tr>
<td width="116">&nbsp;</td>
<td width="246">
<div align="center"><b>címe</b></div>
</td>
<td width="181">
<div align="center"><b>kép file</b></div>
</td>
<td>
<div align="center"><b>szavazás</b></div>
</td>
<?
for($i=1; $i<=$option; $i++){
$subdata=explode("][",$data[$i]);

echo "<tr><td width=\"116\">
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>Option $i</b></font></td>
<td width=\"246\">
<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">
<input type=\"text\" name=\"answer[$i]\" size=\"40\" maxlength=\"40\" value=\"$subdata[0]\"></font></div>
</td><td width=\"181\">
<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" >
<input type=\"text\" name=\"image[$i]\" size=\"25\" maxlength=\"50\" value=\"$subdata[1]\">
</font></div></td><td width=\"181\">
<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">
<input type=\"text\" name=\"votes[$i]\" size=\"4\" maxlength=\"4\" value=\"$subdata[2]\">
</font></div></td></tr>";
}
?>

</table>
<hr width="95%" size="1" align="center" noshade>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#EEEDEA">
<td width="154" height="22"><b>szín</b></td>
<td width="148" height="22">&nbsp;</td>
<td width="22" height="22">&nbsp;</td>
<td colspan="2" height="22"><b>visszaállít
</b></td>
</tr>
<tr bgcolor="#EEEDEA">
<td width="154">szöveg</td>
<td width="148">
<input type="text" name="textcolor" maxlength="10" size="10" value="<?php echo $textcolor; ?>">
</font></td>
<td width="22">&nbsp;</td>
<td width="218">lejárat
(óra)</td>
<td width="205">
<input type="text" name="timeout" size="3" maxlength="3" value="<?php echo $timeout; ?>">
</td>
</tr>
<tr bgcolor="#EEEDEA">
<td width="154">Háttérszín</td>
<td width="148">
<input type="text" name="bgcolor" size="10" maxlength="10" value="<?php echo $bgcolor; ?>">
</td>
<td width="22">&nbsp;</td>
<td width="218">data file neve:</td>
<td width="205">
<input type="text" name="datafile" size="25" maxlength="50" value="<?php echo $datafile; ?>">
</td>
</tr>
<tr bgcolor="#EEEDEA">
<td width="154">Border</td>
<td width="148">
<b>
<input type="text" name="tableborder" size="10" maxlength="10" value="<?php echo $tableborder; ?>">
</b> </td>
<td width="22"></td>
<td width="218">ip mentése a következő fájlba:</td>
<td width="205"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="ip_file" size="25" maxlength="50" value="<?php echo $ip_file; ?>">
</td>
</tr>
<tr bgcolor="#EEEDEA">
<td width="154">Font</td>
<td width="148">
<input type="text" name="font" size="20" maxlength="100" value="<?php echo $font; ?>">
</td>
<tr bgcolor="#EEEDEA">
<td width="218">Font-Size</td>
<td width="205">
<input type="text" name="fontsize" value="<?php echo $fontsize; ?>" size="1" maxlength="1">
</td>
<td width="22"><td width="154">Option</td>
<td width="148">
<input type="text" name="option" size="20" maxlength="100" value="<?php echo $option; ?>"></td>

</td>
</tr>
</table>
<div align="center">
<input type="hidden" name="passwd" value="<?php echo $password; ?>">
<hr width="95%" size="1" align="center" noshade>
<input type="submit" name="submit" value="Mentés">
<input type="reset" name="Submit2" value="Törlés">
</div>
</form>
<p>&nbsp; </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php } ?>