This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
poll.php
139 lines (120 loc) · 5.43 KB
/
poll.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
135
136
137
138
139
<?php
/*
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Free Content / Management System #
# / #
# #
# #
# Copyright 2005-2011 by webspell.org #
# #
# visit webSPELL.org, webspell.info to get webSPELL for free #
# - Script runs under the GNU GENERAL PUBLIC LICENSE #
# - It's NOT allowed to remove this copyright-tag #
# -- http://www.fsf.org/licensing/licenses/gpl.html #
# #
# Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), #
# Far Development by Development Team - webspell.org #
# #
# visit webspell.org #
# #
##########################################################################
*/
$_language->read_module('polls');
function vote($poll) {
global $userID, $_language;
$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;
if($poll) $lastpoll = safe_query("SELECT * FROM ".PREFIX."poll WHERE aktiv='1' AND laufzeit>".time()." AND intern<=".isclanmember($userID)." and pollID='".$poll."' LIMIT 0,1");
else {
$num = mysql_num_rows(safe_query("SELECT * FROM ".PREFIX."poll WHERE aktiv='1' AND laufzeit>".time()." AND intern<=".isclanmember($userID).""));
if($num) {
$start = rand(0,($num-1));
$lastpoll = safe_query("SELECT * FROM ".PREFIX."poll WHERE aktiv='1' AND laufzeit>".time()." AND intern<=".isclanmember($userID)." ORDER BY pollID DESC LIMIT ".$start.",".($start+1)."");
}
else {
echo $_language->module['no_active_poll'].'<br /><br />• <a href="index.php?site=polls">'.$_language->module['show_polls'].'</a>';
return true;
}
}
$anz = mysql_num_rows($lastpoll);
$ds = mysql_fetch_array($lastpoll);
if($anz) {
$anz = mysql_num_rows(safe_query("SELECT pollID FROM `".PREFIX."poll` WHERE pollID='".$ds['pollID']."' AND hosts LIKE '%".$_SERVER['REMOTE_ADDR']."%' AND intern<=".isclanmember($userID).""));
$anz_user = false;
if($userID) {
$user_ids = explode(";", $ds['userIDs']);
if(in_array($userID, $user_ids)) $anz_user = true;
}
$cookie = false;
if(isset($_COOKIE['poll']) && is_array($_COOKIE['poll'])){
$cookie = in_array($ds['pollID'], $_COOKIE['poll']);
}
if($cookie or $anz or $anz_user) {
if($ds['intern'] == 1) $isintern = '('.$_language->module['intern'].')';
else $isintern = '';
$title = $ds['titel'];
for ($n = 1; $n <= 10; $n++) {
if($ds['o'.$n]) $options[] = clearfromtags($ds['o'.$n]);
}
$votes = safe_query("SELECT * FROM ".PREFIX."poll_votes WHERE pollID='".$ds['pollID']."'");
$dv = mysql_fetch_array($votes);
$gesamtstimmen = $dv['o1'] + $dv['o2'] + $dv['o3'] + $dv['o4'] + $dv['o5'] + $dv['o6'] + $dv['o7'] + $dv['o8'] + $dv['o9'] + $dv['o10'];
eval("\$poll_voted_head = \"".gettemplate("poll_voted_head")."\";");
echo $poll_voted_head;
$n=1;
$bg = BG_2;
foreach ($options as $option) {
$stimmen = $dv['o'.$n];
if ($gesamtstimmen) {
$perc = $stimmen / $gesamtstimmen * 10000;
settype($perc, "integer");
$perc = $perc/100;
}
else $perc = 0;
$picwidth = $perc;
settype($picwidth, "integer");
eval("\$poll_voted_content = \"".gettemplate("poll_voted_content")."\";");
echo $poll_voted_content;
$n++;
}
$anzcomments = getanzcomments($ds['pollID'], 'po');
$comments='<a href="index.php?site=polls&pollID='.$ds['pollID'].'">['.$anzcomments.'] '.$_language->module['comments'].'</a>';
eval("\$poll_voted_foot = \"".gettemplate("poll_voted_foot")."\";");
echo $poll_voted_foot;
unset($options);
}
else {
if($ds['intern'] == 1) $isintern = '('.$_language->module['intern'].')';
else $isintern = '';
$title = $ds['titel'];
eval("\$poll_head = \"".gettemplate("poll_head")."\";");
echo $poll_head;
for ($n=1; $n<=10; $n++) {
if($ds['o'.$n]) $options[]=$ds['o'.$n];
}
$n=1;
foreach ($options as $option) {
$option=$option;
eval("\$poll_content = \"".gettemplate("poll_content")."\";");
echo $poll_content;
$n++;
}
$pollID = $ds['pollID'];
eval("\$poll_foot = \"".gettemplate("poll_foot")."\";");
echo $poll_foot;
}
}
else{
echo $_language->module['no_active_poll'].'<br /><br />• <a href="index.php?site=polls">'.$_language->module['show_polls'].'</a>';
}
}
if(!isset($pollID)) $pollID = '';
vote($pollID);
?>