IP-check
Ik kan zelf de oorzaak niet vinden.
<html>
<body bgcolor="0099FF" text="000000" link="000000" alink="000000" vlink="000000">
</html>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
#####################################
# SMe Poll #
# written by scriptme #
# http://www.scriptme.com #
#####################################
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);
}
function head() {
include('config.php');
}
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;
}}}}
//##################### Save data ##############################
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);
}
//########################## Show Form ############################
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;
if ($use_image==1) echo "<b>$question</b><br><IMG SRC=\"$image_for_vote\"><b></b><br>";
else if ($use_image==0)echo "<b>$question</b><br>";
for($nb=1;$nb <= $nb_options; $nb++){
$option=explode("][","$data[$nb]");
echo "<div align=\"left\"><input type=\"radio\" name=\"answer\" value=\"$nb\"> ";
echo "$option[0]<br></div>";
}
echo "<input type=\"hidden\" name=\"save\" value=\"yes\">";
echo "<p align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\"></form></font>";
echo "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><a href=\""; echo $PHP_SELF; echo "?action=results\">Bekijk Resultaten</font></p>";
foot();
}
//################## Function to show results ########################
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;
if ($use_image==1) echo "<div align=\"left\"><IMG SRC=\"$image_for_vote\"><br><b>$data[0]</b><br>Aantal stemmen: <b>$votes</b><br>";
else if ($use_image==0)echo "<p align=\"left\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><b>$data[0] ($votes Stemmen)</b></div><br>";
do{
$subdata=explode("][",$data[$a]);
$av = $subdata[2] * $v;
echo "<table size=\"700\" border=\"1\">";
echo "<tr><td width=\"200\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\">$subdata[0]</td>";
$p2v = 100-$av;
echo "<td width=\"300\"><img src=\"$subdata[1]\" width=\"$av\" height=\"10\"></td>";
if ($subdata[2] == 0)
{
echo "<td width=\"100\">0</td><td width=\"100\">";
}
else
{
echo "<td width=\"100\">$subdata[2]</td><td width=\"100\">";
}
printf(" %01.1f", $av);
echo "%</td></tr>";
echo "</table>";
$a++;
} while ($a < $nb_answers);
echo "<br></div>";
foot();
}
//###################### Engine ####################################
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); }
?>
#####################################
# SMe Poll #
# written by scriptme #
# http://www.scriptme.com #
#####################################
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);
}
function head() {
include('config.php');
}
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;
}}}}
//##################### Save data ##############################
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);
}
//########################## Show Form ############################
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;
if ($use_image==1) echo "<b>$question</b><br><IMG SRC=\"$image_for_vote\"><b></b><br>";
else if ($use_image==0)echo "<b>$question</b><br>";
for($nb=1;$nb <= $nb_options; $nb++){
$option=explode("][","$data[$nb]");
echo "<div align=\"left\"><input type=\"radio\" name=\"answer\" value=\"$nb\"> ";
echo "$option[0]<br></div>";
}
echo "<input type=\"hidden\" name=\"save\" value=\"yes\">";
echo "<p align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\"></form></font>";
echo "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><a href=\""; echo $PHP_SELF; echo "?action=results\">Bekijk Resultaten</font></p>";
foot();
}
//################## Function to show results ########################
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;
if ($use_image==1) echo "<div align=\"left\"><IMG SRC=\"$image_for_vote\"><br><b>$data[0]</b><br>Aantal stemmen: <b>$votes</b><br>";
else if ($use_image==0)echo "<p align=\"left\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><b>$data[0] ($votes Stemmen)</b></div><br>";
do{
$subdata=explode("][",$data[$a]);
$av = $subdata[2] * $v;
echo "<table size=\"700\" border=\"1\">";
echo "<tr><td width=\"200\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\">$subdata[0]</td>";
$p2v = 100-$av;
echo "<td width=\"300\"><img src=\"$subdata[1]\" width=\"$av\" height=\"10\"></td>";
if ($subdata[2] == 0)
{
echo "<td width=\"100\">0</td><td width=\"100\">";
}
else
{
echo "<td width=\"100\">$subdata[2]</td><td width=\"100\">";
}
printf(" %01.1f", $av);
echo "%</td></tr>";
echo "</table>";
$a++;
} while ($a < $nb_answers);
echo "<br></div>";
foot();
}
//###################### Engine ####################################
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); }
?>
<html>
</body>
</html>
Heb zelf mijn eigen poll geschreven, en dmv een table ip_log per row een pollid en een ip adres..
Sta je bij poll 4 bv in de database, dan mag je niet meer meedoen..
Gewijzigd op 03/04/2005 22:38:00 door Mark Vergroesen
Niet nodig ->
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);
}
Nog 1 vraagje:
Stel ik wil dat van de uitslagen alleen de beste 5 uitslagen laat zien. Hoe doe ik dat?