<?php
##########################################################################
# #
# Vote for IT! #
# #
# #
# #
# This script is freeware and is realeased under the GPL #
# Copyright (C) 2002 #
# #
# This program 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. #
# #
# This program 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. #
# #
# In diesem File sind die Seiten, welcher der User zu sehen #
# bekommt von "Vote for IT!". In diesem File müssen im Normal- #
# fall keine Änderungen vorgenommen werden. #
# #
# Die Kommentare und Copyrights dürfen nicht gelöscht werden #
# #
# Version 2.0.3 (c) T.Zenerino http://www.zenerino.ch #
# #
##########################################################################
//Konfigurations Datei einschliessen in diese Seite
include("settings.inc.php");
//Admin Datei einschliessen
include("admin.php");
//Datei text.dat auslesen, und Variablen erstellen für spätere Ausgabe:
$filename = "results/text.dat";
if(file_exists($filename))
{
$file = fopen($filename,"r");
$line = fgets($file,1024);
$line = trim($line);
$results = explode("|",$line);
$title = "$results[0]";
$question = "$results[1]";
$answer1 = "$results[2]";
$answer2 = "$results[3]";
$answer3 = "$results[4]";
}
//Datei template.dat auslesen, und Variablen erstellen für spätere Ausgabe:
$filename = "results/template.dat";
if(file_exists($filename))
{
$file = fopen($filename,"r");
$line = fgets($file,1024);
$line = trim($line);
$results = explode("|",$line);
//Tabelle anzeigen: 0=Off; 1=On
$template0 = "$results[0]";
//Breite der Tabelle
$template1 = "$results[1]";
//Farbe der Tabelle 1 (Heller Rahmen)
$template2 = "$results[2]";
//Farbe der Tabelle 2 (Dunkler Rahmen)
$template3 = "$results[3]";
//Farbe des Titels
$template4 = "$results[4]";
//Grösse der Schrift des Titels
$template5 = "$results[5]";
//Farbe der Frage
$template6 = "$results[6]";
//Grösse der Schrift der Frage
$template7 = "$results[7]";
//Farbe des Normalentextes (Antworten, Text)
$template8 = "$results[8]";
//Grösse des Normaltextes (Antworten, Text)
$template9 = "$results[9]";
//Hintergrundfarbe Tabelle
$template10 = "$results[10]";
}
//Datei results.dat auslesen
$filename = "results/results.dat";
if(file_exists($filename))
{
$file = fopen($filename,"r");
$line = fgets($file,1024);
$line = trim($line);
$results = explode("|",$line);
$counter1 = "$results[0]";
$counter2 = "$results[1]";
$counter3 = "$results[2]";
}
//Datei ip.dat auslesen, flood Schutz
$filename = "results/ip.dat";
list($ip) = @file($filename);
if ($action == "" && $do == "")
{
echo"
<table bgcolor=\"$template10\" border=\"$template0\" width=\"$template1\" height=\"200\" bordercolorlight=\"$template2\" bordercolordark=\"$template3\">
<tr>
<td width=\"100%\" height=\"188\" valign=\"top\"><b><font color=\"$template4\" size=\"$template5\">$title:</font></b><br>
<font color=\"$template6\" size=\"$template7\">$question</font>
<form method=\"POST\" action=\"vote.php?action=vote&do=newvote\">
<p><input type=\"radio\" value=\"1\" name=\"options\"><font color=\"$template8\" size=\"$template9\">$answer1</font><br>
<input type=\"radio\" value=\"2\" checked name=\"options\"><font color=\"$template8\" size=\"$template9\">$answer2</font><br>
<input type=\"radio\" value=\"3\" name=\"options\"><font color=\"$template8\" size=\"$template9\">$answer3</font></p>
<p><input type=\"submit\" value=\"Teilnehmen\"></p>
</form>
<p><a href=\"$votefile?action=vote&do=results\">Resultat anzeigen</a></td>
</tr>
</table>
<br>powered by <a href=\"http://www.zenerino.ch\" target=\"_blank\">Vote for IT!</a>\n";
}
//Funktion für die Erfolgsausgabe, wenn bestätigt worden ist.
function complete($counter)
{
$filename = "results/template.dat";
if(file_exists($filename))
{
$file = fopen($filename,"r");
$line = fgets($file,1024);
$line = trim($line);
$results = explode("|",$line);
$template0 = "$results[0]";
$template1 = "$results[1]";
$template2 = "$results[2]";
$template3 = "$results[3]";
$template4 = "$results[4]";
$template5 = "$results[5]";
$template6 = "$results[6]";
$template7 = "$results[7]";
$template8 = "$results[8]";
$template9 = "$results[9]";
$template10 = "$results[10]";
}
$votefile = "vote.php";
echo"
<table bgcolor=\"$template10\" border=\"$template0\" width=\"$template1\" height=\"200\" bordercolorlight=\"$template2\" bordercolordark=\"$template3\">
<tr>
<td width=\"100%\" height=\"188\" valign=\"top\"><p><font color=\"$template8\" size=\"$template9\">Ihre Stimme wurde erfolgreich
hinzugezählt. Für diese Antwort haben bereits $counter gestimmt.</font>
<p><a href=\"$votefile?action=vote&do=results\">Resultat anzeigen</a></td>
</tr>
</table>
<br>powered by <a href=\"http://www.zenerino.ch\" target=\"_blank\">Vote for IT!</a>\n";
}
//Anwort hinzufügen
if ($action == "vote" && $do == "newvote")
{
//Überprüfen, ob der User die letzte Eingabe gemacht hat.
if($REMOTE_ADDR != $ip)
{
$filename = "results/ip.dat";
if(file_exists($filename))
{
//Die IP des Users wird gespeichert
$ip = "$REMOTE_ADDR";
$f = fopen($filename,"w");
if ($f)
{
fwrite($f,$ip);
fclose($f);
}
}
switch($options)
{
case 1 :
//Falls die erste Anwort gewählt wird, wird diese hier hinzugezählt.
$counter1++;
$counter = "$counter1";
$datei = "results/results.dat";
$zeile = file($datei);
$zeile[0] = $counter."|".$counter2."|".$counter3."|"."\n";
$eintragen = implode("",$zeile);
$eintragen = stripslashes($eintragen);
$ds = fopen($datei, "w");
fwrite($ds, $eintragen);
fclose($ds);
complete($counter);
break;
case 2 :
//Falls die zweite Anwort gewählt wird, wird diese hier hinzugezählt.
$counter2++;
$counter = "$counter2";
$datei = "results/results.dat";
$zeile = file($datei);
$zeile[0] = $counter1."|".$counter."|".$counter3."|"."\n";
$eintragen = implode("",$zeile);
$eintragen = stripslashes($eintragen);
$ds = fopen($datei, "w");
fwrite($ds, $eintragen);
fclose($ds);
complete($counter);
break;
case 3 :
//Falls die dritte Anwort gewählt wird, wird diese hier hinzugezählt.
$counter3++;
$counter = "$counter3";
$datei = "results/results.dat";
$zeile = file($datei);
$zeile[0] = $counter1."|".$counter2."|".$counter."|"."\n";
$eintragen = implode("",$zeile);
$eintragen = stripslashes($eintragen);
$ds = fopen($datei, "w");
fwrite($ds, $eintragen);
fclose($ds);
complete($counter);
break;
//Falls ein User direkt versucht auf diese Seite zuzugreifen, wird diese Seite angezeigt
default :
echo"<html>
<head>
<title>Fehler: Sie haben keine Auswahl getroffen</title>
</head>
<body bgcolor=\"$template10\"
<p><center><h2><font color=\"$template8\" size=\"$template9\">Fehler: Sie haben bei der Umfrage keine Antwort ausgewählt!</h2></center></p>
<p>Sie haben bei der Umfrage keine Antwort gewählt, bitte wählen Sie eine Anwort und versuchen
Sie es nochmals. Sollte dieser Fehler nochmals auftreten, wenden Sie sich an den <a href=\"mailto:$email\">Administrator</a>.</font></p>
<p> </p>
<p><a href=\"$votefile?\">Zurück zur Abstimmung</a></p>
</body>
</html>\n";
break;
}
}
else
{
echo" <table bgcolor=\"$template10\" border=\"$template0\" width=\"$template1\" height=\"200\" bordercolorlight=\"$template2\" bordercolordark=\"$template3\">
<tr>
<td width=\"100%\" height=\"188\" valign=\"top\"><p><font color=\"$template8\" size=\"$template9\">Sie können nur einmal abstimmen!
Von dieser IP wurde schon einmal eine Stimme abgegeben.</font>
<p>Ihre IP: $ip</p>
<p><a href=\"$votefile?action=vote&do=results\">zu den Resultaten.</a></td></p>
</tr>
</table>
<br>powered by <a href=\"http://www.zenerino.ch\">Vote for IT!</a>\n";
}
}
//Resultat anzeigen
if ($action == "vote" && $do == "results")
{
$gesammt = $counter1+$counter2+$counter3;
if($counter1>0)
{
$zresult1 = $gesammt/$counter1;
$defresult1 = round("100"/$zresult1,1);
}
else
{
$defresult1 = "0";
}
if($counter2>0)
{
$zresult2 = $gesammt/$counter2;
$defresult2 = round("100"/$zresult2,1);
}
else
{
$defresult2 = "0";
}
if($counter3>0)
{
$zresult3 = $gesammt/$counter3;
$defresult3 = round("100"/$zresult3,1);
}
else
{
$defresult3 = "0";
}
echo"<table bgcolor=\"$template10\" border=\"$template0\" width=\"$template1\" height=\"200\" bordercolorlight=\"$template2\" bordercolordark=\"$template3\">
<tr>
<td width=\"100%\" height=\"188\" valign=\"top\"><p><b><font color=\"$template4\" size=\"$template5\">$title:</font></b><br>
<font color=\"$template6\" size=\"$template7\">$question</font></p>
<font color=\"$template8\" size=\"$template9\">$answer1 ($counter1)<br></font>
<img src=\"results.php?imgnr=1\" border=0 alt=\"Antwort 1\"><font color=\"$template8\" size=\"$template9\">$defresult1%</font><br>
<font color=\"$template8\" size=\"$template9\">$answer2 ($counter2)<br></font>
<img src=\"results.php?imgnr=2\" border=0 alt=\"Antwort 2\"><font color=\"$template8\" size=\"$template9\">$defresult2%</font><br>
<font color=\"$template8\" size=\"$template9\">$answer3 ($counter3)<br></font>
<img src=\"results.php?imgnr=3\" border=0 alt=\"Antwort 3\"><font color=\"$template8\" size=\"$template9\">$defresult3%</font><br><br>
</tr>
</table>
<br>powered by <a href=\"http://www.zenerino.ch\" target=\"_blank\">Vote for IT!</a>\n";
}
?>