Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Polls |
Version | 1.00 |
Comparing to | |
See all releases |
Version 1.00
- pollbar.gif +0 -0
- polls-install.php +41 -0
- polls-manager.php +448 -0
- polls.php +91 -0
- readme.txt +115 -0
- wp-polls.php +112 -0
pollbar.gif
ADDED
Binary file
|
polls-install.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Polls Plugin For WordPress
|
4 |
+
* - polls-install.php
|
5 |
+
*
|
6 |
+
* Copyright � 2004-2005 Lester "GaMerZ" Chan
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Require WordPress Config
|
11 |
+
require_once('../wp-config.php');
|
12 |
+
|
13 |
+
// Create Polls Answers Table
|
14 |
+
$sql[] = "CREATE TABLE $wpdb->pollsa (".
|
15 |
+
" aid int(10) unsigned NOT NULL auto_increment,".
|
16 |
+
" qid int(10) NOT NULL default '0',".
|
17 |
+
" answers varchar(200) NOT NULL default '',".
|
18 |
+
" votes int(10) NOT NULL default '0',".
|
19 |
+
" PRIMARY KEY (aid))";
|
20 |
+
|
21 |
+
// Create Polls Question Table
|
22 |
+
$sql[] = "CREATE TABLE $wpdb->pollsq (".
|
23 |
+
" id int(10) unsigned NOT NULL auto_increment,".
|
24 |
+
" question varchar(200) NOT NULL default '',".
|
25 |
+
" timestamp varchar(20) NOT NULL default '',".
|
26 |
+
" total_votes int(10) NOT NULL default '0',".
|
27 |
+
" PRIMARY KEY (id)) ";
|
28 |
+
|
29 |
+
// Add In Poll Question/Answers
|
30 |
+
$sql[] = "INSERT INTO $wpdb->pollsq VALUES (1, 'How Is My Site?', '".time()."', 0);";
|
31 |
+
$sql[] = "INSERT INTO $wpdb->pollsa VALUES (1, 1, 'Good', 0);";
|
32 |
+
$sql[] = "INSERT INTO $wpdb->pollsa VALUES (2, 1, 'Excellent', 0);";
|
33 |
+
$sql[] = "INSERT INTO $wpdb->pollsa VALUES (3, 1, 'Bad', 0);";
|
34 |
+
$sql[] = "INSERT INTO $wpdb->pollsa VALUES (4, 1, 'Can Be Improved', 0);";
|
35 |
+
$sql[] = "INSERT INTO $wpdb->pollsa VALUES (5, 1, 'No Comments', 0);";
|
36 |
+
|
37 |
+
// Run The Queries
|
38 |
+
foreach($sql as $query) {
|
39 |
+
$wpdb->query($query);
|
40 |
+
}
|
41 |
+
?>
|
polls-manager.php
ADDED
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Polls Manager For WordPress
|
4 |
+
* - wp-admin/polls-manager.php
|
5 |
+
*
|
6 |
+
* Copyright � 2004-2005 Lester "GaMerZ" Chan
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
### Require Admin Header
|
11 |
+
require_once('admin.php');
|
12 |
+
|
13 |
+
|
14 |
+
### Variables Variables Variables
|
15 |
+
$title = __('Manage Polls');
|
16 |
+
$this_file = $parent_file = 'polls-manager.php';
|
17 |
+
$mode = trim($_GET['mode']);
|
18 |
+
$id = intval($_GET['id']);
|
19 |
+
$aid = intval($_GET['aid']);
|
20 |
+
|
21 |
+
|
22 |
+
### Cancel
|
23 |
+
if(isset($_POST['cancel'])) {
|
24 |
+
Header('Location: polls-manager.php');
|
25 |
+
exit();
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
### Form Processing
|
30 |
+
if($_POST['do']) {
|
31 |
+
// Decide What To Do
|
32 |
+
switch($_POST['do']) {
|
33 |
+
case 'Add Poll':
|
34 |
+
// Add Poll Question
|
35 |
+
if(get_magic_quotes_gpc())
|
36 |
+
$pollquestion = addslashes(trim($_POST['pollquestion']));
|
37 |
+
else
|
38 |
+
$pollquestion = trim($_POST['pollquestion']);
|
39 |
+
$now = time();
|
40 |
+
$addq = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollquestion', '$now', 0)");
|
41 |
+
if(!$addq) {
|
42 |
+
$text .= "<font color=\"red\">Error In Adding Poll '" . stripslashes($pollquestion) . "'</font>";
|
43 |
+
}
|
44 |
+
// Add Poll Answer
|
45 |
+
$pollanswers = $_POST['pollanswer'];
|
46 |
+
$poll_last_id = intval($wpdb->insert_id);
|
47 |
+
foreach($pollanswers as $pollanswer) {
|
48 |
+
if(get_magic_quotes_gpc())
|
49 |
+
$pollanswer = addslashes(trim($pollanswer));
|
50 |
+
else
|
51 |
+
$pollanswer = trim($pollanswer);
|
52 |
+
$adda = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0,$poll_last_id,'$pollanswer',0)");
|
53 |
+
if(!$adda) {
|
54 |
+
$text .= "<font color=\"red\">Error In Adding Poll's Answer '" . stripslashes($pollanswer) . "'</font>";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
if(empty($text)) {
|
58 |
+
$text = "<font color=\"green\">Poll '" . stripslashes($pollquestion) . "' Added Successfully</font>";
|
59 |
+
}
|
60 |
+
break;
|
61 |
+
case 'Edit Poll':
|
62 |
+
// Edit Poll Question
|
63 |
+
$id = intval($_POST['id']);
|
64 |
+
$total_votes = intval($_POST['total_votes']);
|
65 |
+
if(get_magic_quotes_gpc())
|
66 |
+
$pollquestion = addslashes(trim($_POST['pollquestion']));
|
67 |
+
else
|
68 |
+
$pollquestion = trim($_POST['pollquestion']);
|
69 |
+
$editpollq = $wpdb->query("UPDATE $wpdb->pollsq SET question = '$pollquestion', total_votes = $total_votes WHERE id=$id;");
|
70 |
+
if(!$editpollq) {
|
71 |
+
$text = "<font color=\"red\">Error In Editing Poll '" . stripslashes($pollquestion) . "'</font>";
|
72 |
+
}
|
73 |
+
// Get Poll Answers ID
|
74 |
+
$answers = array();
|
75 |
+
$getpollqid = $wpdb->get_results("SELECT aid FROM $wpdb->pollsa WHERE qid=$id ORDER BY answers");
|
76 |
+
if($getpollqid) {
|
77 |
+
foreach($getpollqid as $answer) {
|
78 |
+
$answers[] = intval($answer->aid);
|
79 |
+
}
|
80 |
+
foreach($answers as $answer) {
|
81 |
+
if(get_magic_quotes_gpc())
|
82 |
+
$answer_text = addslashes(trim($_POST[$answer]));
|
83 |
+
else
|
84 |
+
$answer_text = trim($_POST[$answer]);
|
85 |
+
$editpolla = $wpdb->query("UPDATE $wpdb->pollsa SET answers = '$answer_text' WHERE qid=$id AND aid=$answer");
|
86 |
+
if(!$editpolla) {
|
87 |
+
$text .= "<br /><font color=\"red\">Error In Editing Poll's Answer '" . stripslashes($answer_text) . "'</font>";
|
88 |
+
}
|
89 |
+
}
|
90 |
+
} else {
|
91 |
+
$text .= "<br /><font color=\"red\">Invalid Poll '" . stripslashes($pollquestion) . "'</font>";
|
92 |
+
}
|
93 |
+
if(empty($text)) {
|
94 |
+
$text = "<font color=\"green\">Poll '" . stripslashes($pollquestion) . "' Edited Successfully</font>";
|
95 |
+
} else {
|
96 |
+
$text .= '<br /><br /><font color="blue">Please do not be alarmed if you see the errors. The errors occur because most likely you did not modify the values.</font>';
|
97 |
+
}
|
98 |
+
break;
|
99 |
+
case 'Delete Poll':
|
100 |
+
$id = intval($_POST['id']);
|
101 |
+
$pollquestion = trim($_POST['poll_question']);
|
102 |
+
$delete_q = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE id=$id");
|
103 |
+
$delete_ans = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE qid=$id");
|
104 |
+
|
105 |
+
if(!$delete_q) {
|
106 |
+
$text = "<font color=\"red\">Error In Deleting Poll '" . stripslashes($pollquestion) . "' Question</font>";
|
107 |
+
}
|
108 |
+
if(!$delete_ans) {
|
109 |
+
$text .= "<br /><font color=\"red\">Error In Deleting Poll Answers For '" . stripslashes($pollquestion) . "'</font>";
|
110 |
+
}
|
111 |
+
if(empty($text)) {
|
112 |
+
$text = "<font color=\"green\">Poll '" . stripslashes($pollquestion) . "' Deleted Successfully</font>";
|
113 |
+
}
|
114 |
+
break;
|
115 |
+
case 'Add Answer':
|
116 |
+
$id = intval($_POST['id']);
|
117 |
+
if(get_magic_quotes_gpc())
|
118 |
+
$answer = addslashes(trim($_POST['answer']));
|
119 |
+
else
|
120 |
+
$answer = trim($_POST['answer']);
|
121 |
+
$addq = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0,$id,'$answer',0)");
|
122 |
+
if(!$addq) {
|
123 |
+
$text = "<font color=\"red\">Error In Adding Poll Answer '" . stripslashes($answer) . "'</font>";
|
124 |
+
} else {
|
125 |
+
$text = "<font color=\"green\">Poll Answer '" . stripslashes($answer) . "' Added Successfully</font>";
|
126 |
+
}
|
127 |
+
break;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
### Determines Which Mode It Is
|
133 |
+
switch($mode) {
|
134 |
+
// Add A Poll
|
135 |
+
case 'add':
|
136 |
+
$title = 'Add Poll';
|
137 |
+
$standalone = 0;
|
138 |
+
require("./admin-header.php");
|
139 |
+
if ($user_level < 5) {
|
140 |
+
die('<p>Insufficient Level</p>');
|
141 |
+
}
|
142 |
+
?>
|
143 |
+
<ul id="adminmenu2">
|
144 |
+
<li><a href="polls-manager.php">Manage Polls</a></li>
|
145 |
+
<li class="last"><a href="polls-manager.php?mode=add" class="current">Add Poll</a></li>
|
146 |
+
</ul>
|
147 |
+
<div class="wrap">
|
148 |
+
<h2>Add Poll</h2>
|
149 |
+
<?php
|
150 |
+
if(isset($_POST['addpollquestion'])) {
|
151 |
+
$noquestion = (int) $_POST['noquestion'];
|
152 |
+
if(get_magic_quotes_gpc())
|
153 |
+
$pollquestion = stripslashes(trim($_POST['pollquestion']));
|
154 |
+
else
|
155 |
+
$pollquestion = trim($_POST['pollquestion']);
|
156 |
+
?>
|
157 |
+
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
|
158 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
159 |
+
<tr>
|
160 |
+
<th align="left" scope="row">Question:</th>
|
161 |
+
<td><input type="text" size="50" maxlength="200" name="pollquestion" value="<?=$pollquestion?>"></td>
|
162 |
+
<?php
|
163 |
+
for($i=1; $i <= $noquestion; $i++) {
|
164 |
+
echo '<tr>';
|
165 |
+
echo "<th align=\"left\" scope=\"row\">Answers $i:</th>";
|
166 |
+
echo '<td><input type="text" size="30" maxlength="200" name="pollanswer[]"></td>';
|
167 |
+
echo '</tr>';
|
168 |
+
}
|
169 |
+
?>
|
170 |
+
</tr>
|
171 |
+
<tr>
|
172 |
+
<td colspan="2" align="center"><input type="submit" name="do" value="Add Poll" class="button"> <input type="submit" name="cancel" Value="Cancel" class="button"></td>
|
173 |
+
</tr>
|
174 |
+
</table>
|
175 |
+
</form>
|
176 |
+
<?php } else {?>
|
177 |
+
<form action="<?=$_SERVER['PHP_SELF']?>?mode=add" method="post">
|
178 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
179 |
+
<tr>
|
180 |
+
<th align="left" scope="row">Question:</th>
|
181 |
+
<td><input type="text" size="50" maxlength="200" name="pollquestion"></td>
|
182 |
+
</tr>
|
183 |
+
<th align="left" scope="row">No. Of Answers:</th>
|
184 |
+
<td>
|
185 |
+
<select size="1" name="noquestion">
|
186 |
+
<?php
|
187 |
+
for($i=1; $i <= 20; $i++) {
|
188 |
+
echo "<option value=\"$i\">$i</option>";
|
189 |
+
}
|
190 |
+
?>
|
191 |
+
</select>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<tr>
|
195 |
+
<td colspan="2" align="center"><input type="submit" name="addpollquestion" value="Add Question" class="button"> <input type="submit" name="cancel" Value="Cancel" class="button"></td>
|
196 |
+
</tr>
|
197 |
+
</table>
|
198 |
+
</form>
|
199 |
+
<?php } ?>
|
200 |
+
</div>
|
201 |
+
<?php
|
202 |
+
break;
|
203 |
+
// Edit A Poll
|
204 |
+
case 'edit':
|
205 |
+
$title = 'Edit Poll';
|
206 |
+
$standalone = 0;
|
207 |
+
require("./admin-header.php");
|
208 |
+
if ($user_level < 5) {
|
209 |
+
die('<p>Insufficient Level</p>');
|
210 |
+
}
|
211 |
+
$poll_question = $wpdb->get_row("SELECT question, total_votes FROM $wpdb->pollsq WHERE id = $id");
|
212 |
+
$poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $id ORDER BY answers");
|
213 |
+
?>
|
214 |
+
<ul id="adminmenu2">
|
215 |
+
<li><a href="polls-manager.php" class="current">Manage Polls</a></li>
|
216 |
+
<li class="last"><a href="polls-manager.php?mode=add">Add Poll</a></li>
|
217 |
+
</ul>
|
218 |
+
<!-- Edit Poll -->
|
219 |
+
<div class="wrap">
|
220 |
+
<h2>Edit Poll</h2>
|
221 |
+
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
|
222 |
+
<input type="hidden" name="id" value="<?=$id?>">
|
223 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
224 |
+
<tr>
|
225 |
+
<th scope="row" colspan="2">Question</th>
|
226 |
+
</tr>
|
227 |
+
<tr>
|
228 |
+
<th scope="row" colspan="2"><input type="text" size="70" maxlength="200" name="pollquestion" value="<?=$poll_question->question?>"></th>
|
229 |
+
</tr>
|
230 |
+
<tr>
|
231 |
+
<th align="left" scope="row">Answers</th>
|
232 |
+
<th align="left" scope="row">No. Of Votes</th>
|
233 |
+
</tr>
|
234 |
+
<?php
|
235 |
+
$i=1;
|
236 |
+
$totalvotes = 0;
|
237 |
+
foreach($poll_answers as $poll_answer) {
|
238 |
+
echo "<tr>\n<td>Answer $i: ";
|
239 |
+
echo "<input type=\"text\" size=\"50\" maxlength=\"200\" name=\"$poll_answer->aid\" value=\"$poll_answer->answers\"> \n";
|
240 |
+
echo "<a href=\"polls-manager.php?mode=deleteans&id=$id&aid=$poll_answer->aid\" onclick=\"return confirm('You Are About To Delete This Poll Answer \'$poll_answer->answers\'\\n \'Cancel\' to stop, \'OK\' to delete.')\">Delete</a>\n";
|
241 |
+
echo '</td>';
|
242 |
+
echo "<td>$poll_answer->votes</td>\n</tr>\n";
|
243 |
+
$totalvotes += $poll_answer->votes;
|
244 |
+
$i++;
|
245 |
+
}
|
246 |
+
?>
|
247 |
+
</tr>
|
248 |
+
<tr>
|
249 |
+
<th align="right" scope="row">Total Votes :</th>
|
250 |
+
<td><b><?=$poll_question->total_votes?></b> <input type="text" size="4" maxlength="4" name="total_votes" value="<?=$totalvotes?>"></td>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<td align="center" colspan="2"><input type="submit" name="do" value="Edit Poll" class="button"> <input type="submit" name="cancel" Value="Cancel" class="button"></td>
|
254 |
+
</tr>
|
255 |
+
</table>
|
256 |
+
</form>
|
257 |
+
</div>
|
258 |
+
<div class="wrap">
|
259 |
+
<h2>Add Answer</h2>
|
260 |
+
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
|
261 |
+
<input type="hidden" name="id" value="<?=$id?>">
|
262 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
263 |
+
<tr>
|
264 |
+
<td><b>Add Answer</b></td>
|
265 |
+
<td><input type="text" size="50" maxlength="200" name="answer"></td>
|
266 |
+
</tr>
|
267 |
+
<tr>
|
268 |
+
<td colspan="2" align="center"><input type="submit" name="do" value="Add Answer" class="button"></td>
|
269 |
+
</tr>
|
270 |
+
</table>
|
271 |
+
</form>
|
272 |
+
</div>
|
273 |
+
<?php
|
274 |
+
break;
|
275 |
+
// Delete A Poll
|
276 |
+
case 'delete':
|
277 |
+
$title = 'Delete Poll';
|
278 |
+
$standalone = 0;
|
279 |
+
require("./admin-header.php");
|
280 |
+
if ($user_level < 5) {
|
281 |
+
die('<p>Insufficient Level</p>');
|
282 |
+
}
|
283 |
+
$poll_question = $wpdb->get_row("SELECT question, total_votes FROM $wpdb->pollsq WHERE id = $id");
|
284 |
+
$poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $id ORDER BY answers");
|
285 |
+
$poll_question_text = stripslashes($poll_question->question);
|
286 |
+
?>
|
287 |
+
<ul id="adminmenu2">
|
288 |
+
<li><a href="polls-manager.php" class="current">Manage Polls</a></li>
|
289 |
+
<li class="last"><a href="polls-manager.php?mode=add">Add Poll</a></li>
|
290 |
+
</ul>
|
291 |
+
<!-- Delete Poll -->
|
292 |
+
<div class="wrap">
|
293 |
+
<h2>Delete Poll</h2>
|
294 |
+
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
|
295 |
+
<input type="hidden" name="id" value="<?=$id?>">
|
296 |
+
<input type="hidden" name="poll_question" value="<?=$poll_question_text?>">
|
297 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
298 |
+
<tr>
|
299 |
+
<th colspan="2" scope="row">Question</th>
|
300 |
+
</tr>
|
301 |
+
<tr>
|
302 |
+
<td colspan="2" align="center"><?=$poll_question_text?></td>
|
303 |
+
</tr>
|
304 |
+
<tr>
|
305 |
+
<th align="left" scope="row">Answers</th>
|
306 |
+
<th scope="row">No. Of Votes</th>
|
307 |
+
</tr>
|
308 |
+
<?php
|
309 |
+
$i=1;
|
310 |
+
foreach($poll_answers as $poll_answer) {
|
311 |
+
echo "<tr>\n<td>Answer $i: ";
|
312 |
+
echo "$poll_answer->answers\n";
|
313 |
+
echo '</td>';
|
314 |
+
echo "<td align=\"center\">$poll_answer->votes</td>\n</tr>\n";
|
315 |
+
$i++;
|
316 |
+
}
|
317 |
+
?>
|
318 |
+
</tr>
|
319 |
+
<tr>
|
320 |
+
<th colspan="2" scope="row">Total Votes : <?=$poll_question->total_votes?></th>
|
321 |
+
</tr>
|
322 |
+
<tr>
|
323 |
+
<td align="center" colspan="2"><br /><p><b>You Are About To Delete This Poll '<?=$poll_question_text?>'</b></p><input type="submit" class="button" name="do" value="Delete Poll" onclick="return confirm('You Are About To The Delete This Poll \'<?=$poll_question_text?>\'.\nThis Action Is Not Reversible.\n\n Choose \'Cancel\' to stop, \'OK\' to delete.')"> <input type="submit" name="cancel" Value="Cancel" class="button"></td>
|
324 |
+
</tr>
|
325 |
+
</table>
|
326 |
+
</form>
|
327 |
+
</div>
|
328 |
+
<?php
|
329 |
+
break;
|
330 |
+
// Delete A Poll Answer
|
331 |
+
case 'deleteans':
|
332 |
+
$title = 'Delete Poll\'s Answer';
|
333 |
+
$standalone = 0;
|
334 |
+
require("./admin-header.php");
|
335 |
+
if ($user_level < 5) {
|
336 |
+
die('<p>Insufficient Level</p>');
|
337 |
+
}
|
338 |
+
$poll_answer = $wpdb->get_row("SELECT votes, answers FROM $wpdb->pollsa WHERE aid=$aid AND qid=$id");
|
339 |
+
$votes = intval($poll_answer->votes);
|
340 |
+
$answer = stripslashes(trim($poll_answer->answers));
|
341 |
+
$delete_ans = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE aid=$aid AND qid=$id");
|
342 |
+
$update_q = $wpdb->query("UPDATE $wpdb->pollsq SET total_votes = (total_votes-$votes) WHERE id=$id");
|
343 |
+
?>
|
344 |
+
<ul id="adminmenu2">
|
345 |
+
<li><a href="polls-manager.php" class="current">Manage Polls</a></li>
|
346 |
+
<li class="last"><a href="polls-manager.php?mode=add">Add Poll</a></li>
|
347 |
+
</ul>
|
348 |
+
<!-- Delete Poll's Answer -->
|
349 |
+
<div class="wrap">
|
350 |
+
<h2>Delete Poll's Answer</h2>
|
351 |
+
<?php
|
352 |
+
if($delete_ans) {
|
353 |
+
$text = "<font color=\"green\">Poll Answer '$answer' Deleted Successfully</font>";
|
354 |
+
} else {
|
355 |
+
$text = "<font color=\"red\">Error In Deleting Poll Answer '$answer'</font>";
|
356 |
+
}
|
357 |
+
if($update_q) {
|
358 |
+
$text .= "<br /><font color=\"green\">Poll Question's Total Votes Updated Successfully</font>";
|
359 |
+
} else {
|
360 |
+
$text .= "<br /><font color=\"red\">Error In Updating Poll's Total Votes</font>";
|
361 |
+
}
|
362 |
+
echo $text;
|
363 |
+
?>
|
364 |
+
<p><b><a href="polls-manager.php?mode=edit&id=<?=$id?>">Click here To Go Back To The Poll Edit Page</a>.</b></p>
|
365 |
+
</div>
|
366 |
+
<?php
|
367 |
+
break;
|
368 |
+
// Main Page
|
369 |
+
default:
|
370 |
+
$title = 'Manage Polls';
|
371 |
+
$standalone = 0;
|
372 |
+
require("./admin-header.php");
|
373 |
+
if ($user_level < 5) {
|
374 |
+
die('<p>Insufficient Level</p>');
|
375 |
+
}
|
376 |
+
$polls = $wpdb->get_results("SELECT * FROM $wpdb->pollsq ORDER BY id DESC");
|
377 |
+
$total_ans = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pollsa");
|
378 |
+
$total_votes = 0;
|
379 |
+
?>
|
380 |
+
<ul id="adminmenu2">
|
381 |
+
<li><a href="polls-manager.php" class="current">Manage Polls</a></li>
|
382 |
+
<li class="last"><a href="polls-manager.php?mode=add">Add Poll</a></li>
|
383 |
+
</ul>
|
384 |
+
<?php if(!empty($text)) { echo '<!-- Last Action --><div class="wrap"><h2>Last Action</h2>'.$text.' </div>'; } ?>
|
385 |
+
<!-- Manage Polls -->
|
386 |
+
<div class="wrap">
|
387 |
+
<h2>Manage Polls</h2>
|
388 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
389 |
+
<tr>
|
390 |
+
<th scope="col">ID</b></th>
|
391 |
+
<th scope="col">Question</b></th>
|
392 |
+
<th scope="col">Total Votes</b></th>
|
393 |
+
<th scope="col">Date Added</b></th>
|
394 |
+
<th scope="col" colspan="2">Action</th>
|
395 |
+
</tr>
|
396 |
+
<?php
|
397 |
+
if($polls) {
|
398 |
+
$i = 0;
|
399 |
+
foreach($polls as $poll) {
|
400 |
+
if($i%2 == 0) {
|
401 |
+
$style = 'style=\'background-color: #eee\'';
|
402 |
+
} else {
|
403 |
+
$style = 'style=\'background-color: none\'';
|
404 |
+
}
|
405 |
+
echo "<tr $style>";
|
406 |
+
echo "<td><b>$poll->id</b></td>";
|
407 |
+
echo '<td>';
|
408 |
+
if($i == 0) { echo '<b>Displayed: </b>'; }
|
409 |
+
echo $poll->question.'</td>';
|
410 |
+
echo "<td>$poll->total_votes</td>";
|
411 |
+
echo '<td>'.date("d.m.Y", $poll->timestamp).'</td>';
|
412 |
+
echo "<td><a href=\"polls-manager.php?mode=edit&id=$poll->id\" class=\"edit\">Edit</a></td>";
|
413 |
+
echo "<td><a href=\"polls-manager.php?mode=delete&id=$poll->id\" class=\"delete\">Delete</a></td>";
|
414 |
+
echo '</tr>';
|
415 |
+
$i++;
|
416 |
+
$total_votes+= $poll->total_votes;
|
417 |
+
|
418 |
+
}
|
419 |
+
} else {
|
420 |
+
echo '<tr><td colspan="6" align="center"><b>No Polls Found</td></tr>';
|
421 |
+
}
|
422 |
+
?>
|
423 |
+
</table>
|
424 |
+
</div>
|
425 |
+
<!-- Polls Stats -->
|
426 |
+
<div class="wrap">
|
427 |
+
<h2>Polls Stats</h2>
|
428 |
+
<table border="0" cellspacing="3" cellpadding="3">
|
429 |
+
<tr>
|
430 |
+
<th align="left" scope="row">Total Polls:</th>
|
431 |
+
<td align="left"><?=$i?></td>
|
432 |
+
</tr>
|
433 |
+
<tr>
|
434 |
+
<th align="left" scope="row">Total Polls' Answers:</th>
|
435 |
+
<td align="left"><?=number_format($total_ans)?></td>
|
436 |
+
</tr>
|
437 |
+
<tr>
|
438 |
+
<th align="left" scope="row">Total Votes Casted:</th>
|
439 |
+
<td align="left"><?=number_format($total_votes)?></td>
|
440 |
+
</tr>
|
441 |
+
</table>
|
442 |
+
</div>
|
443 |
+
<?php
|
444 |
+
} // End switch($mode)
|
445 |
+
|
446 |
+
### Require Admin Footer
|
447 |
+
require_once 'admin-footer.php';
|
448 |
+
?>
|
polls.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Polls
|
4 |
+
Plugin URI: http://www.lesterchan.net/portfolio/programming.php
|
5 |
+
Description: Adds A Poll Feature To WordPress
|
6 |
+
Version: 1.5
|
7 |
+
Author: GaMerZ
|
8 |
+
Author URI: http://www.lesterchan.net
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
### Get Poll
|
13 |
+
function get_poll($poll_id = 0) {
|
14 |
+
global $wpdb, $voted;
|
15 |
+
// Get Poll Question And Answer Data
|
16 |
+
if($poll_id <= 0) {
|
17 |
+
$poll_question = $wpdb->get_row("SELECT id, question, total_votes FROM $wpdb->pollsq ORDER BY id DESC LIMIT 1");
|
18 |
+
$poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $poll_question->id ORDER BY votes DESC");
|
19 |
+
} else {
|
20 |
+
$poll_question = $wpdb->get_row("SELECT id, question, total_votes FROM $wpdb->pollsq WHERE id = $poll_id LIMIT 1");
|
21 |
+
$poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $poll_id ORDER BY votes DESC");
|
22 |
+
}
|
23 |
+
// If View Results
|
24 |
+
if(intval($_GET['showresults']) == 1) {
|
25 |
+
$vote_text = '<p align="center"><a href="index.php">Vote</a></p>';
|
26 |
+
}
|
27 |
+
|
28 |
+
// Poll Variables
|
29 |
+
$poll_question_text = stripslashes($poll_question->question);
|
30 |
+
|
31 |
+
// If User Click Vote
|
32 |
+
if(isset($_POST['vote'])) {
|
33 |
+
if(isset($_POST["poll-.$poll_question->id"])) {
|
34 |
+
$voted = true;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
// Check User Cookie
|
39 |
+
if(isset($_COOKIE["voted_$poll_question->id"])) { $voted = true; }
|
40 |
+
|
41 |
+
// If User Has Voted
|
42 |
+
if($voted || intval($_GET['showresults']) == 1) {
|
43 |
+
echo '<table width="100%" border="0" cellspacing="3" cellpadding="3">';
|
44 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\"><b>$poll_question_text</b></td>\n</tr>";
|
45 |
+
foreach($poll_answers as $poll_answer) {
|
46 |
+
// Make Sure Total Votes Is Not 0
|
47 |
+
if(intval($poll_question->total_votes) > 0) {
|
48 |
+
$percentage = round((($poll_answer->votes/$poll_question->total_votes)*100));
|
49 |
+
$imagebar = $percentage*0.9;
|
50 |
+
} else {
|
51 |
+
$percentage = 0;
|
52 |
+
$imagebar = 1;
|
53 |
+
}
|
54 |
+
$poll_answer_text = stripslashes($poll_answer->answers);
|
55 |
+
echo "<tr>\n<td align=\"left\" width=\"50%\">$poll_answer_text<br /><img src=\"".get_settings('home')."/wp-images/pollbar.gif\" height=\"5\" width=\"$imagebar\" alt=\"".htmlspecialchars($poll_answer_text)." -> $percentage% ($poll_answer->votes Votes)\" /></td>\n";
|
56 |
+
echo "<td align=\"right\" width=\"50%\"><b>$percentage%</b></td>\n</tr>\n";
|
57 |
+
}
|
58 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\">Total Votes: <b>$poll_question->total_votes</b>$vote_text</td>\n</tr>";
|
59 |
+
echo '</table>';
|
60 |
+
// If User Has Not Voted
|
61 |
+
} else {
|
62 |
+
echo '<form action="'.$_SERVER['REQUEST_URI'].'" name="polls" method="post">';
|
63 |
+
echo "<input type=\"hidden\" name=\"poll_id\" value=\"$poll_question->id\" />";
|
64 |
+
echo '<table width="100%" border="0" cellspacing="3" cellpadding="3">';
|
65 |
+
echo "<tr>\n<td align=\"center\"><b>$poll_question_text</b></td>\n</tr>\n<tr>\n<td align=\"left\">";
|
66 |
+
foreach($poll_answers as $poll_answer) {
|
67 |
+
echo "<input type=\"radio\" name=\"poll-$poll_question->id\" class=\"poll\" value=\"$poll_answer->aid\" /> ".strip_tags($poll_answer->answers)."<br />\n";
|
68 |
+
}
|
69 |
+
echo '</td></tr><tr><td align="center"><input type="submit" name="vote" value=" Vote " class="Buttons" /><br /><a href="index.php?showresults=1">View Results</a></td></tr></table></form>';
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
### Vote Poll
|
75 |
+
function vote_poll() {
|
76 |
+
global $wpdb;
|
77 |
+
if(isset($_POST['vote'])) {
|
78 |
+
$poll_id = intval($_POST['poll_id']);
|
79 |
+
$poll_aid = intval($_POST["poll-$poll_id"]);
|
80 |
+
if(!isset($_COOKIE["voted_$poll_id"])) {
|
81 |
+
$vote_a = $wpdb->query("UPDATE $wpdb->pollsa SET votes = (votes+1) WHERE qid = $poll_id AND aid = $poll_aid");
|
82 |
+
if($vote_a) {
|
83 |
+
$vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET total_votes = (total_votes+1) WHERE id = $poll_id");
|
84 |
+
if($vote_q) {
|
85 |
+
setcookie("voted_".$poll_id, 1, time() + 30000000, COOKIEPATH);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-> Polls Plugin For WordPress
|
2 |
+
--------------------------------------------------
|
3 |
+
Author -> Lester 'GaMerZ' Chan
|
4 |
+
Email -> lesterch@singnet.com.sg
|
5 |
+
Website -> http://www.lesterchan.net/
|
6 |
+
Demo -> http://www.lesterchan.net/blogs
|
7 |
+
Updated -> 4th October 2005
|
8 |
+
--------------------------------------------------
|
9 |
+
Notes -> Minium level required to add/edit/delete polls is 5
|
10 |
+
-> Please backup your database before trying to install this plugin
|
11 |
+
--------------------------------------------------
|
12 |
+
|
13 |
+
|
14 |
+
// Open wp-admin/menu.php
|
15 |
+
|
16 |
+
Find And Remove:
|
17 |
+
------------------------------------------------------------------
|
18 |
+
$submenu['polls-manager.php'][5] = array(__('Manage Polls'), 5, 'polls-manager.php');
|
19 |
+
$submenu['polls-manager.php'][10] = array(__('Add Poll'), 5, 'polls-add.php');
|
20 |
+
------------------------------------------------------------------
|
21 |
+
|
22 |
+
|
23 |
+
-> Installation Instructions
|
24 |
+
--------------------------------------------------
|
25 |
+
// Open wp-settings.php
|
26 |
+
|
27 |
+
Find:
|
28 |
+
------------------------------------------------------------------
|
29 |
+
$wpdb->postmeta = $table_prefix . 'postmeta';
|
30 |
+
------------------------------------------------------------------
|
31 |
+
Add Below It:
|
32 |
+
------------------------------------------------------------------
|
33 |
+
$wpdb->pollsa = $table_prefix . 'pollsa';
|
34 |
+
$wpdb->pollsq = $table_prefix . 'pollsq';
|
35 |
+
------------------------------------------------------------------
|
36 |
+
|
37 |
+
|
38 |
+
// Open wp-admin/menu.php
|
39 |
+
|
40 |
+
Find:
|
41 |
+
------------------------------------------------------------------
|
42 |
+
$menu[20] = array(__('Links'), 5, 'link-manager.php');
|
43 |
+
------------------------------------------------------------------
|
44 |
+
Add Below It:
|
45 |
+
------------------------------------------------------------------
|
46 |
+
$menu[21] = array(__('Polls'), 5, 'polls-manager.php');
|
47 |
+
------------------------------------------------------------------
|
48 |
+
|
49 |
+
// Open wp-admin folder
|
50 |
+
|
51 |
+
Put:
|
52 |
+
------------------------------------------------------------------
|
53 |
+
polls-install.php
|
54 |
+
polls-manager.php
|
55 |
+
------------------------------------------------------------------
|
56 |
+
|
57 |
+
|
58 |
+
// Open wp-content/plugins folder
|
59 |
+
|
60 |
+
Put:
|
61 |
+
------------------------------------------------------------------
|
62 |
+
polls.php
|
63 |
+
------------------------------------------------------------------
|
64 |
+
|
65 |
+
// Open Wordpress root folder
|
66 |
+
|
67 |
+
Put:
|
68 |
+
------------------------------------------------------------------
|
69 |
+
wp-polls.php
|
70 |
+
------------------------------------------------------------------
|
71 |
+
|
72 |
+
|
73 |
+
// Open wp-images folder
|
74 |
+
|
75 |
+
Put:
|
76 |
+
------------------------------------------------------------------
|
77 |
+
pollbar.gif
|
78 |
+
------------------------------------------------------------------
|
79 |
+
|
80 |
+
|
81 |
+
// Activate the polls plugin
|
82 |
+
|
83 |
+
|
84 |
+
// Run wp-admin/polls-install.php
|
85 |
+
|
86 |
+
Note:
|
87 |
+
------------------------------------------------------------------
|
88 |
+
If You See A Blank Page Means It Is Successfully
|
89 |
+
------------------------------------------------------------------
|
90 |
+
|
91 |
+
|
92 |
+
// Open wp-content/themes/<YOUR THEME NAME>/header.php
|
93 |
+
|
94 |
+
Add on the first line:
|
95 |
+
------------------------------------------------------------------
|
96 |
+
<?php vote_poll(); ?>
|
97 |
+
------------------------------------------------------------------
|
98 |
+
|
99 |
+
|
100 |
+
// Open wp-content/themes/<YOUR THEME NAME>/sidebar.php
|
101 |
+
|
102 |
+
Add:
|
103 |
+
------------------------------------------------------------------
|
104 |
+
<li>
|
105 |
+
<h2>Polls</h2>
|
106 |
+
<ul><?php get_poll();?></ul>
|
107 |
+
<p><a href="wp-polls.php">Polls Archive</a></p>
|
108 |
+
</li>
|
109 |
+
------------------------------------------------------------------
|
110 |
+
|
111 |
+
Note:
|
112 |
+
------------------------------------------------------------------
|
113 |
+
To show specific poll, use <?php get_poll(<ID>);?> where <ID> is your
|
114 |
+
poll id.
|
115 |
+
------------------------------------------------------------------
|
wp-polls.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Poll Plugin For WordPress
|
4 |
+
* - wp-polls.php
|
5 |
+
*
|
6 |
+
* Copyright � 2004-2005 Lester "GaMerZ" Chan
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Require WordPress Header
|
11 |
+
require('wp-blog-header.php');
|
12 |
+
|
13 |
+
// Vote Stuffs
|
14 |
+
vote_poll();
|
15 |
+
|
16 |
+
// Some Variable To Declare
|
17 |
+
$polls_questions = array();
|
18 |
+
$polls_answers = array();
|
19 |
+
|
20 |
+
$questions = $wpdb->get_results("SELECT * FROM $wpdb->pollsq ORDER BY id DESC");
|
21 |
+
$answers = $wpdb->get_results("SELECT aid, qid, answers, votes FROM $wpdb->pollsa ORDER BY votes DESC");
|
22 |
+
foreach($questions as $question) {
|
23 |
+
$polls_questions[] = array('id' => intval($question->id), 'question' => stripslashes($question->question), 'timestamp' => $question->timestamp, 'total_votes' => intval($question->total_votes));
|
24 |
+
}
|
25 |
+
foreach($answers as $answer) {
|
26 |
+
$polls_answers[] = array('aid' => intval($answer->aid), 'qid' => intval($answer->qid), 'answers' => stripslashes($answer->answers), 'votes' => intval($answer->votes));
|
27 |
+
}
|
28 |
+
|
29 |
+
// If View Results
|
30 |
+
if(intval($_GET['showresults']) == 1) {
|
31 |
+
$vote_text = '<p align="center"><a href="wp-polls.php">Vote</a></p>';
|
32 |
+
}
|
33 |
+
|
34 |
+
// If User Click Vote
|
35 |
+
if(isset($_POST['vote'])) {
|
36 |
+
if(isset($_POST['poll-'.$polls_questions[0]['id']])) {
|
37 |
+
$voted = true;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
// Check User Cookie
|
42 |
+
if(isset($_COOKIE["voted_".$polls_questions[0]['id']])) { $voted = true; }
|
43 |
+
?>
|
44 |
+
<?php get_header(); ?>
|
45 |
+
<div id="content" class="narrowcolumn">
|
46 |
+
<h2 class="pagetitle">Current Poll</h2>
|
47 |
+
<?php
|
48 |
+
if($voted || intval($_GET['showresults']) == 1) {
|
49 |
+
echo '<table width="100%" border="0" cellspacing="3" cellpadding="3">';
|
50 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\"><b>".$polls_questions[0]['question']."</b></td>\n</tr>";
|
51 |
+
foreach($polls_answers as $polls_answer) {
|
52 |
+
if($polls_questions[0]['id'] == $polls_answer['qid']) {
|
53 |
+
if(intval($polls_questions[0]['total_votes']) > 0) {
|
54 |
+
$percentage = round((($polls_answer['votes']/$polls_questions[0]['total_votes'])*100));
|
55 |
+
$imagebar = $percentage;
|
56 |
+
} else {
|
57 |
+
$percentage = 0;
|
58 |
+
$imagebar = 1;
|
59 |
+
}
|
60 |
+
echo "<tr>\n<td align=\"left\" width=\"50%\">".$polls_answer['answers']."<br /><img src=\"../wp-images/pollbar.gif\" height=\"5\" width=\"$imagebar\" alt=\"$percentage% (".$polls_answer['votes']." Votes)\"></td>\n";
|
61 |
+
echo "<td align=\"right\" width=\"50%\"><b>$percentage%</b></td>\n</tr>\n";
|
62 |
+
}
|
63 |
+
unset($polls_answer);
|
64 |
+
}
|
65 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\">Total Votes: <b>".$polls_questions[0]['total_votes']."</b>$vote_text</td>\n</tr>";
|
66 |
+
echo '</table><br />';
|
67 |
+
} else {
|
68 |
+
echo '<form action="wp-polls.php" name="polls" method="post">';
|
69 |
+
echo "<input type=\"hidden\" name=\"poll_id\" value=\"".$polls_questions[0]['id']."\">";
|
70 |
+
echo '<table width="100%" border="0" cellspacing="3" cellpadding="3">';
|
71 |
+
echo "<tr>\n<td align=\"center\"><b>".$polls_questions[0]['question']."</b></td>\n</tr>\n<tr>\n<td align=\"left\">";
|
72 |
+
foreach($polls_answers as $polls_answer) {
|
73 |
+
if($polls_questions[0]['id'] == $polls_answer['qid']) {
|
74 |
+
echo "<input type=\"radio\" name=\"poll-".$polls_questions[0]['id']."\" value=\"".$polls_answer['aid']."\"> ".$polls_answer['answers']."<br />\n";
|
75 |
+
unset($polls_answer);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
echo '</td></tr><tr><td align="center"><input type="submit" name="vote" value=" Vote " class="Buttons"><br /><a href="wp-polls.php?showresults=1">View Results</a></td></tr></table></form>';
|
79 |
+
}
|
80 |
+
// Delete The First Poll From The Array
|
81 |
+
unset($polls_questions[0]);
|
82 |
+
?>
|
83 |
+
<h2 class="pagetitle">Polls Archive</h2>
|
84 |
+
<?php
|
85 |
+
$i = 1;
|
86 |
+
foreach($polls_questions as $polls_question) {
|
87 |
+
echo '<table width="100%" border="0" cellspacing="3" cellpadding="3">';
|
88 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\"><b>".$polls_question['question']."</b></td>\n</tr>";
|
89 |
+
foreach($polls_answers as $polls_answer) {
|
90 |
+
if($polls_question['id'] == $polls_answer['qid']) {
|
91 |
+
if(intval($polls_question['total_votes']) > 0) {
|
92 |
+
$percentage = round((($polls_answer['votes']/$polls_question['total_votes'])*100));
|
93 |
+
$imagebar = $percentage;
|
94 |
+
} else {
|
95 |
+
$imagebar = 1;
|
96 |
+
}
|
97 |
+
echo "<tr>\n<td align=\"left\" width=\"50%\">".$polls_answer['answers']."<br /><img src=\"../wp-images/pollbar.gif\" height=\"5\" width=\"$imagebar\" alt=\"$percentage% (".$polls_answer['votes']." Votes)\"></td>\n";
|
98 |
+
echo "<td align=\"right\" width=\"50%\"><b>$percentage%</b></td>\n</tr>\n";
|
99 |
+
// Delete Away From Array
|
100 |
+
unset($polls_answer['answers']);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
echo "<tr>\n<td colspan=\"2\" align=\"center\">Total Votes: <b>".$polls_question['total_votes']."</b></td>\n</tr>";
|
104 |
+
echo '</table><br /><hr class="Divider" />';
|
105 |
+
$i++;
|
106 |
+
}
|
107 |
+
?>
|
108 |
+
</div>
|
109 |
+
<?php
|
110 |
+
get_sidebar();
|
111 |
+
get_footer();
|
112 |
+
?>
|