Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Polls |
Version | 2.02a |
Comparing to | |
See all releases |
Version 2.02a
- pollbar.gif +0 -0
- polls-install.php +221 -0
- polls-manager.php +559 -0
- polls-options.php +384 -0
- polls-upgrade-202.php +169 -0
- polls-upgrade.php +185 -0
- polls.php +251 -0
- readme-install.txt +101 -0
- readme-upgrade.txt +71 -0
- readme.txt +39 -0
- wp-polls.php +289 -0
pollbar.gif
ADDED
Binary file
|
polls-install.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - Install WP-Polls 2.02 |
|
14 |
+
| - wp-admin/polls-install.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Require Config
|
21 |
+
require('../wp-config.php');
|
22 |
+
|
23 |
+
### Variables, Variables, Variables
|
24 |
+
$current_timestamp = current_time('timestamp');
|
25 |
+
$create_table = array();
|
26 |
+
$insert_pollq = array();
|
27 |
+
$insert_polla = array();
|
28 |
+
$insert_options = array();
|
29 |
+
$error = '';
|
30 |
+
|
31 |
+
### Create Tables (3 Tables)
|
32 |
+
$create_table[] = "CREATE TABLE $wpdb->pollsq (".
|
33 |
+
"pollq_id int(10) NOT NULL auto_increment,".
|
34 |
+
"pollq_question varchar(200) NOT NULL default '',".
|
35 |
+
"pollq_timestamp varchar(20) NOT NULL default '',".
|
36 |
+
"pollq_totalvotes int(10) NOT NULL default '0',".
|
37 |
+
"PRIMARY KEY (pollq_id))";
|
38 |
+
$create_table[] = "CREATE TABLE $wpdb->pollsa (".
|
39 |
+
"polla_aid int(10) NOT NULL auto_increment,".
|
40 |
+
"polla_qid int(10) NOT NULL default '0',".
|
41 |
+
"polla_answers varchar(200) NOT NULL default '',".
|
42 |
+
"polla_votes int(10) NOT NULL default '0',".
|
43 |
+
"PRIMARY KEY (polla_aid))";
|
44 |
+
$create_table[] = "CREATE TABLE $wpdb->pollsip (".
|
45 |
+
"pollip_id int(10) NOT NULL auto_increment,".
|
46 |
+
"pollip_qid varchar(10) NOT NULL default '',".
|
47 |
+
"pollip_aid varchar(10) NOT NULL default '',".
|
48 |
+
"pollip_ip varchar(100) NOT NULL default '',".
|
49 |
+
"pollip_host VARCHAR(200) NOT NULL default '',".
|
50 |
+
"pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
|
51 |
+
"pollip_user tinytext NOT NULL,".
|
52 |
+
"PRIMARY KEY (pollip_id))";
|
53 |
+
|
54 |
+
### Insert Poll Question (1 Row)
|
55 |
+
$insert_pollq[] = "INSERT INTO $wpdb->pollsq VALUES (1, 'How Is My Site?', '$current_timestamp', 0);";
|
56 |
+
|
57 |
+
### Insert Poll Answers (5 Rows)
|
58 |
+
$insert_polla[] = "INSERT INTO $wpdb->pollsa VALUES (1, 1, 'Good', 0);";
|
59 |
+
$insert_polla[] = "INSERT INTO $wpdb->pollsa VALUES (2, 1, 'Excellent', 0);";
|
60 |
+
$insert_polla[] = "INSERT INTO $wpdb->pollsa VALUES (3, 1, 'Bad', 0);";
|
61 |
+
$insert_polla[] = "INSERT INTO $wpdb->pollsa VALUES (4, 1, 'Can Be Improved', 0);";
|
62 |
+
$insert_polla[] = "INSERT INTO $wpdb->pollsa VALUES (5, 1, 'No Comments', 0);";
|
63 |
+
|
64 |
+
### Insert Options (16 Rows)
|
65 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_voteheader', 'Y', 3, '<table width=\\\"100%\\\" border=\\\"0\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\">\r\n<tr>\r\n<td align=\\\"center\\\"><b>%POLL_QUESTION%</b></td>\r\n</tr>', 20, 8, 'Template For Poll''s Question', 8, 'yes');";
|
66 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (124, 0, 'poll_template_votebody', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"poll-%POLL_ID%\\\" value=\\\"%POLL_ANSWER_ID%\\\" /> %POLL_ANSWER%</td>\r\n</tr>', 20, 8, 'Template For Poll''s Answers', 8, 'yes');";
|
67 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (123, 0, 'poll_template_votefooter', 'Y', 3, '<tr>\r\n<td align=\\\"center\\\"><input type=\\\"submit\\\" name=\\\"vote\\\" value=\\\" Vote \\\" class=\\\"Buttons\\\" /><br /><a href=\\\"index.php?pollresult=1\\\">View Results</a></td>\r\n</tr>\r\n</table>', 20, 8, 'Template For Poll''s Voting Footer', 8, 'yes');";
|
68 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultheader', 'Y', 3, '<table width=\\\"100%\\\" border=\\\"0\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\">\r\n<tr>\r\n<td colspan=\\\"2\\\" align=\\\"center\\\"><b>%POLL_QUESTION%</b></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
69 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultbody', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\" width=\\\"70%\\\">%POLL_ANSWER%<br /><img src=\\\"wp-images/pollbar.gif\\\" height=\\\"5\\\" width=\\\"%POLL_ANSWER_IMAGEWIDTH%\\\" alt=\\\"%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\\\" /></td>\r\n<td align=\\\"right\\\" width=\\\"30%\\\"><b>%POLL_ANSWER_PERCENTAGE%%</b></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
70 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultbody2', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\" width=\\\"70%\\\"><i>%POLL_ANSWER%</i><br /><img src=\\\"wp-images/pollbar.gif\\\" height=\\\"5\\\" width=\\\"%POLL_ANSWER_IMAGEWIDTH%\\\" alt=\\\"You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\\\" /></td>\r\n<td align=\\\"right\\\" width=\\\"30%\\\"><i><b>%POLL_ANSWER_PERCENTAGE%%</b></i></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
71 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultfooter', 'Y', 3, '<tr>\r\n<td colspan=\\\"2\\\" align=\\\"center\\\">Total Votes: <b>%POLL_TOTALVOTES%</b><td>\r\n</tr>\r\n</table>', 20, 8, '', 8, 'yes');";
|
72 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_disable', 'Y', 3, 'Sorry, there are no polls available at the moment.', 20, 8, 'Template For Poll When It Is Disabled', 8, 'yes');";
|
73 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_error', 'Y', '3', 'An error has occurred when processing your poll.', '20', '8', 'Template For Poll When An Error Has Occured', '8', 'yes');";
|
74 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_currentpoll', 'Y', 3, '0', 20, 8, 'Current Displayed Poll', 8, 'yes');";
|
75 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_latestpoll', 'Y', 3, '1', 20, 8, 'The Lastest Poll', 8, 'yes');";
|
76 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_archive_perpage', 'Y', 3, '5', 2, 8, 'Number Of Polls To Display Per Page On The Poll''s Archive', 8, 'no');";
|
77 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_sortby', 'Y', 1, 'polla_aid', 20, 8, 'Sorting Of Poll''s Answers', 8, 'yes');";
|
78 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_sortorder', 'Y', 1, 'asc', 20, 8, 'Sort Order Of Poll''s Answers', 8, 'yes');";
|
79 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_result_sortby', 'Y', 1, 'polla_votes', 20, 8, 'Sorting Of Poll''s Answers Result', 8, 'yes');";
|
80 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_result_sortorder', 'Y', 1, 'desc', 20, 8, 'Sorting Order Of Poll''s Answers Result', 8, 'yes');";
|
81 |
+
|
82 |
+
### Check Whether There Is Any Pre Errors
|
83 |
+
$wpdb->show_errors = false;
|
84 |
+
$check_install = $wpdb->query("SHOW COLUMNS FROM $wpdb->pollsq");
|
85 |
+
if($check_install) {
|
86 |
+
$error = __('You Had Already Installed WP-Polls.');
|
87 |
+
}
|
88 |
+
if(empty($wpdb->pollsq) || empty($wpdb->pollsa) || empty($wpdb->pollsip)) {
|
89 |
+
$error = __('Please Define The pollsq, pollsa and pollsip in wp-settings.php.');
|
90 |
+
}
|
91 |
+
?>
|
92 |
+
|
93 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
94 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
95 |
+
<head>
|
96 |
+
<title>WordPress › <?php _e('Installing'); ?> › <?php _e('WP-Polls'); ?></title>
|
97 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
98 |
+
<style type="text/css" media="screen">
|
99 |
+
@import url( wp-admin.css );
|
100 |
+
</style>
|
101 |
+
</head>
|
102 |
+
<body>
|
103 |
+
<div class="wrap">
|
104 |
+
<h2><?php _e('Install WP-Polls'); ?></h2>
|
105 |
+
<p><?php _e('This install script will install WP-Polls for your Wordpress'); ?>.</p>
|
106 |
+
<p>
|
107 |
+
<?php _e('This install script will be doing the following:'); ?><br />
|
108 |
+
<b>»</b> <b>3</b> <?php _e('tables will be created namely <b>pollsq</b>, <b>pollsa</b> and <b>pollsip</b>.'); ?><br />
|
109 |
+
<b>»</b> <b>1</b> <?php _e('poll question (<b>How Is My Site?</b>) will be inserted into <b>pollsq</b> table.'); ?><br />
|
110 |
+
<b>»</b> <b>5</b> <?php _e('poll answers(<b>Good</b>, <b>Excellent</b>, <b>Bad</b>, <b>Can Be Improved</b>, <b>No Comments</b>) will be inserted into <b>pollsa</b> table.'); ?><br />
|
111 |
+
<b>»</b> <b>15</b> <?php _e('options will be inserted into the <b>options</b> table.'); ?><br />
|
112 |
+
<b>»</b> <b>4</b> <?php _e('tables will be optimized namely <b>pollsq</b>, <b>pollsa</b>, <b>pollsip</b> and <b>options</b>.'); ?><br />
|
113 |
+
</p>
|
114 |
+
<?php
|
115 |
+
if(empty($error)) {
|
116 |
+
if(!empty($_POST['install'])) {
|
117 |
+
// Create Tables
|
118 |
+
$create_table_count = 0;
|
119 |
+
echo "<p><b>".__('Creating Tables:')."</b>";
|
120 |
+
foreach($create_table as $createtable) {
|
121 |
+
$wpdb->query($createtable);
|
122 |
+
}
|
123 |
+
$check_pollsq = $wpdb->query("SHOW COLUMNS FROM $wpdb->pollsq");
|
124 |
+
$check_pollsa = $wpdb->query("SHOW COLUMNS FROM $wpdb->pollsa");
|
125 |
+
$check_pollsip = $wpdb->query("SHOW COLUMNS FROM $wpdb->pollsip");
|
126 |
+
if($check_pollsq) {
|
127 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsq</b>) created.";
|
128 |
+
$create_table_count++;
|
129 |
+
} else {
|
130 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsq</b>) table NOT created.</font>";
|
131 |
+
}
|
132 |
+
if($check_pollsa) {
|
133 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsa</b>) created.";
|
134 |
+
$create_table_count++;
|
135 |
+
} else {
|
136 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsa</b>) table NOT created.</font>";
|
137 |
+
}
|
138 |
+
if($check_pollsip) {
|
139 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsip</b>) created.";
|
140 |
+
$create_table_count++;
|
141 |
+
} else {
|
142 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsip</b>) table NOT created.</font>";
|
143 |
+
}
|
144 |
+
echo "<br /><b>»</b> <b>$create_table_count / 3</b> Tables Created.</p>";
|
145 |
+
// Insert Poll Questions
|
146 |
+
$insert_pollq_count = 0;
|
147 |
+
echo "<p><b>".__('Inserting Poll Questions:')."</b>";
|
148 |
+
foreach($insert_pollq as $insertpollq) {
|
149 |
+
$temp_pollq = $wpdb->query($insertpollq);
|
150 |
+
$temp_poll_question = explode("VALUES ", $insertpollq);
|
151 |
+
$temp_poll_question = $temp_poll_question[1];
|
152 |
+
$temp_poll_question = substr($temp_poll_question, 5, -20);
|
153 |
+
if($temp_pollq) {
|
154 |
+
echo "<br /><b>»</b> Poll question (<b>$temp_poll_question</b>) inserted.";
|
155 |
+
$insert_pollq_count ++;
|
156 |
+
} else {
|
157 |
+
echo "<br /><b>»</b> <font color=\"red\">Poll question (<b>$temp_poll_question</b>) NOT inserted.</font>";
|
158 |
+
}
|
159 |
+
}
|
160 |
+
echo "<br /><b>»</b> <b>$insert_pollq_count / 1</b> Poll Questions Inserted.</p>";
|
161 |
+
// Insert Poll Answers
|
162 |
+
$insert_polla_count = 0;
|
163 |
+
echo "<p><b>".__('Inserting Poll Answers:')."</b>";
|
164 |
+
foreach($insert_polla as $insertpolla) {
|
165 |
+
$temp_polla = $wpdb->query($insertpolla);
|
166 |
+
$temp_poll_answer = explode("VALUES ", $insertpolla);
|
167 |
+
$temp_poll_answer = $temp_poll_answer[1];
|
168 |
+
$temp_poll_answer = substr($temp_poll_answer, 8, -6);
|
169 |
+
if($temp_polla) {
|
170 |
+
echo "<br /><b>»</b> Poll answer (<b>$temp_poll_answer</b>) inserted.";
|
171 |
+
$insert_polla_count ++;
|
172 |
+
} else {
|
173 |
+
echo "<br /><b>»</b> <font color=\"red\">Poll answer (<b>$temp_poll_answer</b>) NOT inserted.</font>";
|
174 |
+
}
|
175 |
+
}
|
176 |
+
echo "<br /><b>»</b> <b>$insert_polla_count / 5</b> Poll Answers Inserted.</p>";
|
177 |
+
// Insert Options
|
178 |
+
$insert_options_count = 0;
|
179 |
+
echo "<p><b>".__('Inserting Options:')."</b>";
|
180 |
+
foreach($insert_options as $insertoptions) {
|
181 |
+
$temp_options = $wpdb->query($insertoptions);
|
182 |
+
$temp_option = explode(" ", $insertoptions);
|
183 |
+
$temp_option = $temp_option[6];
|
184 |
+
$temp_option = substr($temp_option, 1, -2);
|
185 |
+
if($temp_options) {
|
186 |
+
echo "<br /><b>»</b> Option (<b>$temp_option</b>) inserted.";
|
187 |
+
$insert_options_count ++;
|
188 |
+
} else {
|
189 |
+
echo "<br /><b>»</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT inserted.</font>";
|
190 |
+
}
|
191 |
+
}
|
192 |
+
echo "<br /><b>»</b> <b>$insert_options_count / 16</b> Options Inserted.</p>";
|
193 |
+
// Optimize Tables
|
194 |
+
$optimize_table_count = 0;
|
195 |
+
echo "<p><b>".__('Optimizing Tables:')."</b>";
|
196 |
+
$optimize_tables = $wpdb->query("OPTIMIZE TABLE $wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip, $wpdb->options");
|
197 |
+
if($optimize_tables) {
|
198 |
+
echo "<br /><b>»</b> Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) optimized.";
|
199 |
+
$optimize_table_count = 4;
|
200 |
+
} else {
|
201 |
+
echo "<br /><b>»</b> <font color=\"red\">Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) NOT optimized.</font>";
|
202 |
+
}
|
203 |
+
echo "<br /><b>»</b> <b>$optimize_table_count / 4</b> Tables Optimized.</p>";
|
204 |
+
// Check Whether Install Is Successful
|
205 |
+
if($create_table_count == 3 && $insert_pollq_count == 1 && $insert_polla_count == 5 && $insert_options_count == 16) {
|
206 |
+
echo '<p align="center"><b>'.__('WP-Polls Installed Successfully.').'</b><br />'.__('Please remember to delete this file before proceeding on.').'</p>';
|
207 |
+
}
|
208 |
+
} else {
|
209 |
+
?>
|
210 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
211 |
+
<div align="center"><input type="submit" name="install" value="<?php _e('Click Here To Install WP-Polls'); ?>" class="button"></div>
|
212 |
+
</form>
|
213 |
+
<?php
|
214 |
+
}
|
215 |
+
} else {
|
216 |
+
echo "<p align=\"center\"><font color=\"red\"><b>$error</b></font></p>\n";
|
217 |
+
}
|
218 |
+
?>
|
219 |
+
</div>
|
220 |
+
</body>
|
221 |
+
</html>
|
polls-manager.php
ADDED
@@ -0,0 +1,559 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - CManage Your Polls |
|
14 |
+
| - wp-admin/polls-manager.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Require Admin
|
21 |
+
require_once('admin.php');
|
22 |
+
|
23 |
+
### Variables Variables Variables
|
24 |
+
$title = __('Manage Polls');
|
25 |
+
$this_file = $parent_file = 'polls-manager.php';
|
26 |
+
$mode = trim($_GET['mode']);
|
27 |
+
$poll_id = intval($_GET['id']);
|
28 |
+
$poll_aid = intval($_GET['aid']);
|
29 |
+
|
30 |
+
### Magic Quotes GPC
|
31 |
+
if (get_magic_quotes_gpc()) {
|
32 |
+
function traverse(&$arr) {
|
33 |
+
if(!is_array($arr))
|
34 |
+
return;
|
35 |
+
foreach($arr as $key => $val)
|
36 |
+
is_array($arr[$key]) ? traverse($arr[$key]) : ($arr[$key] = stripslashes($arr[$key]));
|
37 |
+
}
|
38 |
+
$gpc = array(&$_GET, &$_POST, &$_COOKIE);
|
39 |
+
traverse($gpc);
|
40 |
+
}
|
41 |
+
|
42 |
+
### Cancel
|
43 |
+
if(isset($_POST['cancel'])) {
|
44 |
+
Header('Location: polls-manager.php');
|
45 |
+
exit();
|
46 |
+
}
|
47 |
+
|
48 |
+
### Form Processing
|
49 |
+
if(!empty($_POST['do'])) {
|
50 |
+
// Decide What To Do
|
51 |
+
switch($_POST['do']) {
|
52 |
+
// Add Poll
|
53 |
+
case 'Add Poll':
|
54 |
+
// Add Poll Question
|
55 |
+
$pollq_question = addslashes(trim($_POST['pollq_question']));
|
56 |
+
$pollq_timestamp = current_time('timestamp');
|
57 |
+
$add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollq_question', '$pollq_timestamp', 0)");
|
58 |
+
if(!$add_poll_question) {
|
59 |
+
$text .= '<font color="red">Error In Adding Poll \''.stripslashes($pollq_question).'\'</font>';
|
60 |
+
}
|
61 |
+
// Add Poll Answers
|
62 |
+
$polla_answers = $_POST['polla_answers'];
|
63 |
+
$polla_qid = intval($wpdb->insert_id);
|
64 |
+
foreach($polla_answers as $polla_answer) {
|
65 |
+
$polla_answer = addslashes(trim($polla_answer));
|
66 |
+
$add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answer', 0)");
|
67 |
+
if(!$add_poll_answers) {
|
68 |
+
$text .= '<font color="red">Error In Adding Poll\'s Answer \''.stripslashes($polla_answer).'\'</font>';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
// Update Lastest Poll ID To Poll Options
|
72 |
+
$update_latestpoll = $wpdb->query("UPDATE $wpdb->options SET option_value = $polla_qid WHERE option_name = 'poll_latestpoll'");
|
73 |
+
if(!$update_latestpoll) {
|
74 |
+
$text .= "<font color=\"red\">There Is An Error Updating The Lastest Poll ID ($polla_qid) To The Poll Option</font>";
|
75 |
+
}
|
76 |
+
if(empty($text)) {
|
77 |
+
$text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Added Successfully</font>';
|
78 |
+
}
|
79 |
+
break;
|
80 |
+
// Edit Poll
|
81 |
+
case 'Edit Poll':
|
82 |
+
// Update Poll's Question
|
83 |
+
$pollq_id = intval($_POST['pollq_id']);
|
84 |
+
$pollq_totalvotes = intval($_POST['pollq_totalvotes']);
|
85 |
+
$pollq_question = addslashes(trim($_POST['pollq_question']));
|
86 |
+
$edit_poll_question = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_question = '$pollq_question', pollq_totalvotes = $pollq_totalvotes WHERE pollq_id = $pollq_id");
|
87 |
+
if(!$edit_poll_question) {
|
88 |
+
$text = '<font color="blue">No Changes Had Been Made To \''.stripslashes($pollq_question).'\'</font>';
|
89 |
+
}
|
90 |
+
// Update Polls' Answers
|
91 |
+
$polla_aids = array();
|
92 |
+
$get_polla_aids = $wpdb->get_results("SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = $pollq_id ORDER BY polla_aid ASC");
|
93 |
+
if($get_polla_aids) {
|
94 |
+
foreach($get_polla_aids as $get_polla_aid) {
|
95 |
+
$polla_aids[] = intval($get_polla_aid->polla_aid);
|
96 |
+
}
|
97 |
+
foreach($polla_aids as $polla_aid) {
|
98 |
+
$polla_answers = addslashes(trim($_POST['polla_aid-'.$polla_aid]));
|
99 |
+
$edit_poll_answer = $wpdb->query("UPDATE $wpdb->pollsa SET polla_answers = '$polla_answers' WHERE polla_qid = $pollq_id AND polla_aid = $polla_aid");
|
100 |
+
if(!$edit_poll_answer) {
|
101 |
+
$text .= '<br /><font color="blue">No Changes Had Been Made To Poll\'s Answer \''.stripslashes($polla_answers).'\'</font>';
|
102 |
+
}
|
103 |
+
}
|
104 |
+
} else {
|
105 |
+
$text .= '<br /><font color="red">Invalid Poll \''.stripslashes($pollq_question).'\'</font>';
|
106 |
+
}
|
107 |
+
if(empty($text)) {
|
108 |
+
$text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Edited Successfully</font>';
|
109 |
+
}
|
110 |
+
break;
|
111 |
+
// Delete Poll
|
112 |
+
case 'Delete Poll':
|
113 |
+
$pollq_id = intval($_POST['pollq_id']);
|
114 |
+
$pollq_question = trim($_POST['pollq_question']);
|
115 |
+
$delete_poll_question = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE pollq_id = $pollq_id");
|
116 |
+
$delete_poll_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_qid = $pollq_id");
|
117 |
+
$delete_poll_ip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id");
|
118 |
+
$poll_option_lastestpoll = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'");
|
119 |
+
if(!$delete_poll_question) {
|
120 |
+
$text = '<font color="red">Error In Deleting Poll \''.stripslashes($pollq_question).'\' Question</font>';
|
121 |
+
}
|
122 |
+
if(!$delete_poll_answers) {
|
123 |
+
$text .= '<br /><font color="red">Error In Deleting Poll Answers For \''.stripslashes($pollq_question).'\'</font>';
|
124 |
+
}
|
125 |
+
if(!$delete_poll_ip) {
|
126 |
+
$text .= '<br /><font color="red">Error In Deleting Voted IPs For \''.stripslashes($pollq_question).'\'</font>';
|
127 |
+
}
|
128 |
+
if(empty($text)) {
|
129 |
+
if($poll_option_lastestpoll == $pollq_id) {
|
130 |
+
$poll_lastestpoll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq ORDER BY pollq_id DESC LIMIT 1");
|
131 |
+
if($poll_lastestpoll) {
|
132 |
+
$poll_lastestpoll = intval($poll_lastestpoll);
|
133 |
+
$update_latestpoll = $wpdb->query("UPDATE $wpdb->options SET option_value = $poll_lastestpoll WHERE option_name = 'poll_latestpoll'");
|
134 |
+
}
|
135 |
+
}
|
136 |
+
$text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Deleted Successfully</font>';
|
137 |
+
}
|
138 |
+
break;
|
139 |
+
// Add Poll's Answer
|
140 |
+
case 'Add Answer':
|
141 |
+
$polla_qid = intval($_POST['polla_qid']);
|
142 |
+
$polla_answers = addslashes(trim($_POST['polla_answers']));
|
143 |
+
$add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answers', 0)");
|
144 |
+
if(!$add_poll_question) {
|
145 |
+
$text = '<font color="red">Error In Adding Poll Answer \''.stripslashes($polla_answers).'\'</font>';
|
146 |
+
} else {
|
147 |
+
$text = '<font color="green">Poll Answer \''.stripslashes($polla_answers).'\' Added Successfully</font>';
|
148 |
+
}
|
149 |
+
break;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
### Determines Which Mode It Is
|
155 |
+
switch($mode) {
|
156 |
+
// Add A Poll
|
157 |
+
case 'add':
|
158 |
+
$title = __('Add Poll');
|
159 |
+
$standalone = 0;
|
160 |
+
require("./admin-header.php");
|
161 |
+
if ($user_level < 8) {
|
162 |
+
die(__('Access Denied: Insufficient Access'));
|
163 |
+
}
|
164 |
+
?>
|
165 |
+
<ul id="adminmenu2">
|
166 |
+
<li><a href="polls-manager.php"><?php _e('Manage Polls'); ?></a></li>
|
167 |
+
<li><a href="polls-manager.php?mode=add" class="current"><?php _e('Add Poll'); ?></a></li>
|
168 |
+
<li class="last"><a href="polls-options.php"><?php _e('Polls Options'); ?></a></li>
|
169 |
+
</ul>
|
170 |
+
<div class="wrap">
|
171 |
+
<h2>Add Poll</h2>
|
172 |
+
<?php
|
173 |
+
if(isset($_POST['addpollquestion'])) {
|
174 |
+
$poll_noquestion = intval($_POST['poll_noquestion']);
|
175 |
+
$pollq_question = stripslashes(trim($_POST['pollq_question']));
|
176 |
+
?>
|
177 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
178 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
179 |
+
<tr>
|
180 |
+
<th align="left" scope="row"><?php _e('Question') ?></th>
|
181 |
+
<td><input type="text" size="50" maxlength="200" name="pollq_question" value="<?php echo $pollq_question; ?>"></td>
|
182 |
+
<?php
|
183 |
+
for($i=1; $i<=$poll_noquestion; $i++) {
|
184 |
+
echo "<tr>\n";
|
185 |
+
echo "<th align=\"left\" scope=\"row\">Answers $i:</th>\n";
|
186 |
+
echo "<td><input type=\"text\" size=\"30\" maxlength=\"200\" name=\"polla_answers[]\"></td>\n";
|
187 |
+
echo "</tr>\n";
|
188 |
+
}
|
189 |
+
?>
|
190 |
+
</tr>
|
191 |
+
<tr>
|
192 |
+
<td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Poll'); ?>" class="button"> <input type="submit" name="cancel" Value="<?php _e('Cancel'); ?>" class="button"></td>
|
193 |
+
</tr>
|
194 |
+
</table>
|
195 |
+
</form>
|
196 |
+
<?php } else {?>
|
197 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?mode=add" method="post">
|
198 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
199 |
+
<tr>
|
200 |
+
<th align="left" scope="row"><?php _e('Question') ?></th>
|
201 |
+
<td><input type="text" size="50" maxlength="200" name="pollq_question"></td>
|
202 |
+
</tr>
|
203 |
+
<th align="left" scope="row"><?php _e('No. Of Answers:') ?></th>
|
204 |
+
<td>
|
205 |
+
<select size="1" name="poll_noquestion">
|
206 |
+
<?php
|
207 |
+
for($i=2; $i <= 20; $i++) {
|
208 |
+
echo "<option value=\"$i\">$i</option>";
|
209 |
+
}
|
210 |
+
?>
|
211 |
+
</select>
|
212 |
+
</td>
|
213 |
+
</tr>
|
214 |
+
<tr>
|
215 |
+
<td colspan="2" align="center"><input type="submit" name="addpollquestion" value="<?php _e('Add Question'); ?>" class="button"> <input type="submit" name="cancel" Value="<?php _e('Cancel'); ?>" class="button"></td>
|
216 |
+
</tr>
|
217 |
+
</table>
|
218 |
+
</form>
|
219 |
+
<?php } ?>
|
220 |
+
</div>
|
221 |
+
<?php
|
222 |
+
break;
|
223 |
+
// Edit A Poll
|
224 |
+
case 'edit':
|
225 |
+
$title = __('Edit Poll');
|
226 |
+
$standalone = 0;
|
227 |
+
require("./admin-header.php");
|
228 |
+
if ($user_level < 8) {
|
229 |
+
die(__('Access Denied: Insufficient Access'));
|
230 |
+
}
|
231 |
+
$poll_question = $wpdb->get_row("SELECT pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
|
232 |
+
$poll_answers = $wpdb->get_results("SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = $poll_id ORDER BY polla_aid ASC");
|
233 |
+
$poll_question_text = stripslashes($poll_question->pollq_question);
|
234 |
+
$poll_totalvotes = intval($poll_question->pollq_totalvote);
|
235 |
+
?>
|
236 |
+
<ul id="adminmenu2">
|
237 |
+
<li><a href="polls-manager.php" class="current"><?php _e('Manage Polls'); ?></a></li>
|
238 |
+
<li><a href="polls-manager.php?mode=add"><?php _e('Add Poll'); ?></a></li>
|
239 |
+
<li class="last"><a href="polls-options.php"><?php _e('Polls Options'); ?></a></li>
|
240 |
+
</ul>
|
241 |
+
<!-- Edit Poll -->
|
242 |
+
<div class="wrap">
|
243 |
+
<h2><?php _e('Edit Poll'); ?></h2>
|
244 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
245 |
+
<input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>">
|
246 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
247 |
+
<tr>
|
248 |
+
<th scope="row" colspan="2"><?php _e('Question') ?></th>
|
249 |
+
</tr>
|
250 |
+
<tr>
|
251 |
+
<td align="center" colspan="2"><input type="text" size="70" maxlength="200" name="pollq_question" value="<?php echo $poll_question_text; ?>" /></td>
|
252 |
+
</tr>
|
253 |
+
<tr>
|
254 |
+
<th align="left" scope="row"><?php _e('Answers:') ?></th>
|
255 |
+
<th align="right" scope="row"><?php _e('No. Of Votes') ?></th>
|
256 |
+
</tr>
|
257 |
+
<?php
|
258 |
+
$i=1;
|
259 |
+
$poll_actual_totalvotes = 0;
|
260 |
+
if($poll_answers) {
|
261 |
+
$pollip_answers = array();
|
262 |
+
$pollip_answers[0] = __('Null Votes');
|
263 |
+
foreach($poll_answers as $poll_answer) {
|
264 |
+
$polla_aid = intval($poll_answer->polla_aid);
|
265 |
+
$polla_answers = stripslashes($poll_answer->polla_answers);
|
266 |
+
$polla_votes = intval($poll_answer->polla_votes);
|
267 |
+
$pollip_answers[$polla_aid] = $polla_answers;
|
268 |
+
echo "<tr>\n";
|
269 |
+
echo "<td align=\"left\">".__('Answer')." $i: <input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_aid-$polla_aid\" value=\"$polla_answers\"> ";
|
270 |
+
echo "<a href=\"polls-manager.php?mode=deleteans&id=$poll_id&aid=$polla_aid\" onclick=\"return confirm('You Are About To Delete This Poll Answer \'$polla_answers\'\\n \'Cancel\' to stop, \'OK\' to delete.')\">Delete</a></td>\n";
|
271 |
+
echo "<td align=\"right\">$polla_votes</td>\n</tr>\n";
|
272 |
+
$poll_actual_totalvotes += $polla_votes;
|
273 |
+
$i++;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
?>
|
277 |
+
</tr>
|
278 |
+
<tr>
|
279 |
+
<td align="right" colspan="2"><b><?php _e('Total Votes'); ?>: <?php echo $poll_actual_totalvotes; ?></b> <input type="text" size="4" maxlength="4" name="pollq_totalvotes" value="<?php echo $poll_actual_totalvotes; ?>"></td>
|
280 |
+
</tr>
|
281 |
+
<tr>
|
282 |
+
<td align="center" colspan="2"><input type="submit" name="do" value="<?php _e('Edit Poll'); ?>" class="button"> <input type="submit" name="cancel" Value="<?php _e('Cancel'); ?>" class="button"></td>
|
283 |
+
</tr>
|
284 |
+
</table>
|
285 |
+
</form>
|
286 |
+
</div>
|
287 |
+
<!-- Add Poll's Answer -->
|
288 |
+
<div class="wrap">
|
289 |
+
<h2><?php _e('Add Answer') ?></h2>
|
290 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?mode=edit&id=<?php echo $poll_id; ?>" method="post">
|
291 |
+
<input type="hidden" name="polla_qid" value="<?php echo $poll_id; ?>">
|
292 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
293 |
+
<tr>
|
294 |
+
<td><b><?php _e('Add Answer') ?></b></td>
|
295 |
+
<td><input type="text" size="50" maxlength="200" name="polla_answers"></td>
|
296 |
+
</tr>
|
297 |
+
<tr>
|
298 |
+
<td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Answer'); ?>" class="button"></td>
|
299 |
+
</tr>
|
300 |
+
</table>
|
301 |
+
</form>
|
302 |
+
</div>
|
303 |
+
<!-- Users Voted For This Poll -->
|
304 |
+
<?php
|
305 |
+
$poll_ips = $wpdb->get_results("SELECT pollip_aid, pollip_ip, pollip_host, pollip_timestamp, pollip_user FROM $wpdb->pollsip WHERE pollip_qid = $poll_id ORDER BY pollip_aid ASC, pollip_user ASC");
|
306 |
+
?>
|
307 |
+
<div class="wrap">
|
308 |
+
<h2><?php _e('Users Voted For This Poll') ?></h2>
|
309 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
310 |
+
<?php
|
311 |
+
if($poll_ips) {
|
312 |
+
$k = 1;
|
313 |
+
$poll_last_aid = -1;
|
314 |
+
foreach($poll_ips as $poll_ip) {
|
315 |
+
$pollip_aid = intval($poll_ip->pollip_aid);
|
316 |
+
$pollip_user = stripslashes($poll_ip->pollip_user);
|
317 |
+
$pollip_ip = $poll_ip->pollip_ip;
|
318 |
+
$pollip_host = $poll_ip->pollip_host;
|
319 |
+
$pollip_date = date("jS F Y @ H:i", $poll_ip->pollip_timestamp);
|
320 |
+
if($pollip_aid != $poll_last_aid) {
|
321 |
+
if($pollip_aid == 0) {
|
322 |
+
echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><b>$pollip_answers[$pollip_aid]</b></td>\n</tr>\n";
|
323 |
+
} else {
|
324 |
+
echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><b>".__('Answer')." $k: $pollip_answers[$pollip_aid]</b></td>\n</tr>\n";
|
325 |
+
$k++;
|
326 |
+
}
|
327 |
+
echo "<tr>\n";
|
328 |
+
echo "<th scope=\"row\">".__('No.')."</th>\n";
|
329 |
+
echo "<th scope=\"row\">".__('User')."</th>\n";
|
330 |
+
echo "<th scope=\"row\">".__('IP/Host')."</th>\n";
|
331 |
+
echo "<th scope=\"row\">".__('Date')."</th>\n";
|
332 |
+
echo "</tr>\n";
|
333 |
+
$i = 1;
|
334 |
+
}
|
335 |
+
if($i%2 == 0) {
|
336 |
+
$style = 'style=\'background-color: none\'';
|
337 |
+
} else {
|
338 |
+
$style = 'style=\'background-color: #eee\'';
|
339 |
+
}
|
340 |
+
echo "<tr $style>\n";
|
341 |
+
echo "<td>$i</td>\n";
|
342 |
+
echo "<td>$pollip_user</td>\n";
|
343 |
+
echo "<td>$pollip_ip / $pollip_host</td>\n";
|
344 |
+
echo "<td>$pollip_date</td>\n";
|
345 |
+
echo "</tr>\n";
|
346 |
+
$poll_last_aid = $pollip_aid;
|
347 |
+
$i++;
|
348 |
+
}
|
349 |
+
} else {
|
350 |
+
echo "<tr>\n<td colspan=\"4\" align=\"center\">".__('No IP Has Been Logged Yet.')."</td>\n</tr>\n";
|
351 |
+
}
|
352 |
+
?>
|
353 |
+
</table>
|
354 |
+
</div>
|
355 |
+
<?php
|
356 |
+
break;
|
357 |
+
// Delete A Poll
|
358 |
+
case 'delete':
|
359 |
+
$title = __('Delete Poll');
|
360 |
+
$standalone = 0;
|
361 |
+
require("./admin-header.php");
|
362 |
+
if ($user_level < 8) {
|
363 |
+
die(__('Access Denied: Insufficient Access'));
|
364 |
+
}
|
365 |
+
$poll_question = $wpdb->get_row("SELECT pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
|
366 |
+
$poll_answers = $wpdb->get_results("SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = $poll_id ORDER BY polla_answers");
|
367 |
+
$poll_question_text = stripslashes($poll_question->pollq_question);
|
368 |
+
$poll_totalvotes = intval($poll_question->pollq_totalvotes);
|
369 |
+
?>
|
370 |
+
<ul id="adminmenu2">
|
371 |
+
<li><a href="polls-manager.php" class="current"><?php _e('Manage Polls'); ?></a></li>
|
372 |
+
<li><a href="polls-manager.php?mode=add"><?php _e('Add Poll'); ?></a></li>
|
373 |
+
<li class="last"><a href="polls-options.php"><?php _e('Polls Options'); ?></a></li>
|
374 |
+
</ul>
|
375 |
+
<!-- Delete Poll -->
|
376 |
+
<div class="wrap">
|
377 |
+
<h2><?php _e('Delete Poll') ?></h2>
|
378 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
379 |
+
<input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>">
|
380 |
+
<input type="hidden" name="pollq_question" value="<?php echo $poll_question_text; ?>">
|
381 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
382 |
+
<tr>
|
383 |
+
<th colspan="2" scope="row"><?php _e('Question') ?></th>
|
384 |
+
</tr>
|
385 |
+
<tr>
|
386 |
+
<td colspan="2" align="center"><?php echo $poll_question_text; ?></td>
|
387 |
+
</tr>
|
388 |
+
<tr>
|
389 |
+
<th align="left" scope="row"><?php _e('Answers') ?></th>
|
390 |
+
<th scope="row"><?php _e('No. Of Votes') ?></th>
|
391 |
+
</tr>
|
392 |
+
<?php
|
393 |
+
$i=1;
|
394 |
+
if($poll_answers) {
|
395 |
+
foreach($poll_answers as $poll_answer) {
|
396 |
+
$polla_answers = stripslashes($poll_answer->polla_answers);
|
397 |
+
$polla_votes = intval($poll_answer->polla_votes);
|
398 |
+
echo "<tr>\n";
|
399 |
+
echo "<td>".__('Answer')." $i: $polla_answers</td>\n";
|
400 |
+
echo "<td align=\"center\">$polla_votes</td>\n</tr>\n";
|
401 |
+
$i++;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
?>
|
405 |
+
</tr>
|
406 |
+
<tr>
|
407 |
+
<th colspan="2" scope="row"><?php _e('Total Votes'); ?>: <?php echo $poll_totalvotes; ?></th>
|
408 |
+
</tr>
|
409 |
+
<tr>
|
410 |
+
<td align="center" colspan="2"><br /><p><b><?php _e('You Are About To Delete This Poll'); ?> '<?php echo $poll_question_text; ?>'</b></p><input type="submit" class="button" name="do" value="<?php _e('Delete Poll'); ?>" onclick="return confirm('You Are About To The Delete This Poll \'<?php echo $poll_question_text; ?>\'.\nThis Action Is Not Reversible.\n\n Choose \'Cancel\' to stop, \'OK\' to delete.')"> <input type="submit" name="cancel" Value="<?php _e('Cancel'); ?>" class="button"></td>
|
411 |
+
</tr>
|
412 |
+
</table>
|
413 |
+
</form>
|
414 |
+
</div>
|
415 |
+
<?php
|
416 |
+
break;
|
417 |
+
// Delete A Poll Answer
|
418 |
+
case 'deleteans':
|
419 |
+
$title = __('Delete Poll\'s Answer');
|
420 |
+
$standalone = 0;
|
421 |
+
require("./admin-header.php");
|
422 |
+
if ($user_level < 8) {
|
423 |
+
die(__('Access Denied: Insufficient Access'));
|
424 |
+
}
|
425 |
+
$poll_answers = $wpdb->get_row("SELECT polla_votes, polla_answers FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id");
|
426 |
+
$polla_votes = intval($poll_answers->polla_votes);
|
427 |
+
$polla_answers = stripslashes(trim($poll_answers->polla_answers));
|
428 |
+
$delete_polla_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id");
|
429 |
+
$update_pollq_totalvotes = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes-$polla_votes) WHERE pollq_id=$poll_id");
|
430 |
+
?>
|
431 |
+
<ul id="adminmenu2">
|
432 |
+
<li><a href="polls-manager.php" class="current"><?php _e('Manage Polls'); ?></a></li>
|
433 |
+
<li><a href="polls-manager.php?mode=add"><?php _e('Add Poll'); ?></a></li>
|
434 |
+
<li class="last"><a href="polls-options.php"><?php _e('Polls Options'); ?></a></li>
|
435 |
+
</ul>
|
436 |
+
<!-- Delete Poll's Answer -->
|
437 |
+
<div class="wrap">
|
438 |
+
<h2><?php _e('Delete Poll\'s Answer') ?></h2>
|
439 |
+
<?php
|
440 |
+
if($delete_polla_answers) {
|
441 |
+
$text = "<font color=\"green\">Poll Answer '$polla_answers' Deleted Successfully</font>";
|
442 |
+
} else {
|
443 |
+
$text = "<font color=\"red\">Error In Deleting Poll Answer '$polla_answers'</font>";
|
444 |
+
}
|
445 |
+
if($update_pollq_totalvotes) {
|
446 |
+
$text .= "<br /><font color=\"green\">Poll Question's Total Votes Updated Successfully</font>";
|
447 |
+
} else {
|
448 |
+
$text .= "<br /><font color=\"blue\">No Changes Had Been Made To The Poll's Total Votes</font>";
|
449 |
+
}
|
450 |
+
_e($text);
|
451 |
+
?>
|
452 |
+
<p><b><a href="polls-manager.php?mode=edit&id=<?php echo $poll_id; ?>"><?php _e('Click here To Go Back To The Poll Edit Page'); ?></a>.</b></p>
|
453 |
+
</div>
|
454 |
+
<?php
|
455 |
+
break;
|
456 |
+
// Main Page
|
457 |
+
default:
|
458 |
+
$title = __('Manage Polls');
|
459 |
+
$standalone = 0;
|
460 |
+
require("./admin-header.php");
|
461 |
+
if ($user_level < 8) {
|
462 |
+
die(__('Access Denied: Insufficient Access'));
|
463 |
+
}
|
464 |
+
$polls = $wpdb->get_results("SELECT * FROM $wpdb->pollsq ORDER BY pollq_id DESC");
|
465 |
+
$total_ans = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pollsa");
|
466 |
+
$total_votes = 0;
|
467 |
+
?>
|
468 |
+
<ul id="adminmenu2">
|
469 |
+
<li><a href="polls-manager.php" class="current"><?php _e('Manage Polls'); ?></a></li>
|
470 |
+
<li><a href="polls-manager.php?mode=add"><?php _e('Add Poll'); ?></a></li>
|
471 |
+
<li class="last"><a href="polls-options.php"><?php _e('Polls Options'); ?></a></li>
|
472 |
+
</ul>
|
473 |
+
<?php if(!empty($text)) { echo '<!-- Last Action --><div class="wrap"><h2>'.__('Last Action').'</h2>'.__($text).'</div>'; } ?>
|
474 |
+
<!-- Manage Polls -->
|
475 |
+
<div class="wrap">
|
476 |
+
<h2><?php _e('Manage Polls'); ?></h2>
|
477 |
+
<table width="100%" border="0" cellspacing="3" cellpadding="3">
|
478 |
+
<tr>
|
479 |
+
<th scope="col"><?php _e('ID'); ?></b></th>
|
480 |
+
<th scope="col"><?php _e('Question'); ?></b></th>
|
481 |
+
<th scope="col"><?php _e('Total Votes'); ?></b></th>
|
482 |
+
<th scope="col"><?php _e('Date Added'); ?></b></th>
|
483 |
+
<th scope="col" colspan="2"><?php _e('Action'); ?></th>
|
484 |
+
</tr>
|
485 |
+
<?php
|
486 |
+
if($polls) {
|
487 |
+
$i = 0;
|
488 |
+
$current_poll = intval(get_settings('poll_currentpoll'));
|
489 |
+
foreach($polls as $poll) {
|
490 |
+
$poll_id = intval($poll->pollq_id);
|
491 |
+
$poll_question = stripslashes($poll->pollq_question);
|
492 |
+
$poll_date = date("jS F Y @ H:i", $poll->pollq_timestamp);
|
493 |
+
$poll_totalvotes = intval($poll->pollq_totalvotes);
|
494 |
+
if($i%2 == 0) {
|
495 |
+
$style = 'style=\'background-color: #eee\'';
|
496 |
+
} else {
|
497 |
+
$style = 'style=\'background-color: none\'';
|
498 |
+
}
|
499 |
+
if($current_poll > 0) {
|
500 |
+
if($current_poll == $poll_id) {
|
501 |
+
$style = 'style=\'background-color: #b8d4ff\'';
|
502 |
+
}
|
503 |
+
} else {
|
504 |
+
if($i == 0) {
|
505 |
+
$style = 'style=\'background-color: #b8d4ff\'';
|
506 |
+
}
|
507 |
+
}
|
508 |
+
echo "<tr $style>\n";
|
509 |
+
echo "<td><b>$poll_id</b></td>\n";
|
510 |
+
echo '<td>';
|
511 |
+
if($current_poll > 0) {
|
512 |
+
if($current_poll == $poll_id) {
|
513 |
+
echo '<b>'.__('Displayed:').'</b> ';
|
514 |
+
}
|
515 |
+
} elseif($current_poll != -1) {
|
516 |
+
if($i == 0) {
|
517 |
+
echo '<b>'.__('Displayed:').'</b> ';
|
518 |
+
}
|
519 |
+
}
|
520 |
+
echo "$poll_question</td>\n";
|
521 |
+
echo "<td>$poll_totalvotes</td>\n";
|
522 |
+
echo "<td>$poll_date</td>\n";
|
523 |
+
echo "<td><a href=\"polls-manager.php?mode=edit&id=$poll_id\" class=\"edit\">".__('Edit')."</a></td>\n";
|
524 |
+
echo "<td><a href=\"polls-manager.php?mode=delete&id=$poll_id\" class=\"delete\">".__('Delete')."</a></td>\n";
|
525 |
+
echo '</tr>';
|
526 |
+
$i++;
|
527 |
+
$total_votes+= $poll_totalvotes;
|
528 |
+
|
529 |
+
}
|
530 |
+
} else {
|
531 |
+
echo '<tr><td colspan="6" align="center"><b>'.__('No Polls Found').'</b></td></tr>';
|
532 |
+
}
|
533 |
+
?>
|
534 |
+
</table>
|
535 |
+
</div>
|
536 |
+
<!-- Polls Stats -->
|
537 |
+
<div class="wrap">
|
538 |
+
<h2><?php _e('Polls Stats'); ?></h2>
|
539 |
+
<table border="0" cellspacing="3" cellpadding="3">
|
540 |
+
<tr>
|
541 |
+
<th align="left" scope="row"><?php _e('Total Polls:'); ?></th>
|
542 |
+
<td align="left"><?php echo $i; ?></td>
|
543 |
+
</tr>
|
544 |
+
<tr>
|
545 |
+
<th align="left" scope="row"><?php _e('Total Polls\' Answers:'); ?></th>
|
546 |
+
<td align="left"><?php echo number_format($total_ans); ?></td>
|
547 |
+
</tr>
|
548 |
+
<tr>
|
549 |
+
<th align="left" scope="row"><?php _e('Total Votes Casted:'); ?></th>
|
550 |
+
<td align="left"><?php echo number_format($total_votes); ?></td>
|
551 |
+
</tr>
|
552 |
+
</table>
|
553 |
+
</div>
|
554 |
+
<?php
|
555 |
+
} // End switch($mode)
|
556 |
+
|
557 |
+
### Require Admin Footer
|
558 |
+
require_once 'admin-footer.php';
|
559 |
+
?>
|
polls-options.php
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - Configure Poll Options |
|
14 |
+
| - wp-admin/polls-options.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Require Admin
|
21 |
+
require_once('admin.php');
|
22 |
+
|
23 |
+
### Variables Variables Variables
|
24 |
+
$title = __('Poll Options');
|
25 |
+
$this_file = $parent_file = 'polls-options.php';
|
26 |
+
$id = intval($_GET['id']);
|
27 |
+
$standalone = 0;
|
28 |
+
|
29 |
+
### Require Admin Header
|
30 |
+
require("./admin-header.php");
|
31 |
+
|
32 |
+
### If User Less Than 8, Don't Let Him Pass
|
33 |
+
if ($user_level < 8) {
|
34 |
+
die(__('Access Denied: Insufficient Access'));
|
35 |
+
}
|
36 |
+
|
37 |
+
### Magic Quotes GPC
|
38 |
+
if (get_magic_quotes_gpc()) {
|
39 |
+
function traverse(&$arr) {
|
40 |
+
if(!is_array($arr))
|
41 |
+
return;
|
42 |
+
foreach($arr as $key => $val)
|
43 |
+
is_array($arr[$key]) ? traverse($arr[$key]) : ($arr[$key] = stripslashes($arr[$key]));
|
44 |
+
}
|
45 |
+
$gpc = array(&$_GET, &$_POST, &$_COOKIE);
|
46 |
+
traverse($gpc);
|
47 |
+
}
|
48 |
+
|
49 |
+
### If Form Is Submitted
|
50 |
+
if($_POST['Submit']) {
|
51 |
+
$poll_ans_sortby = addslashes(strip_tags(trim($_POST['poll_ans_sortby'])));
|
52 |
+
$poll_ans_sortorder = addslashes(strip_tags(trim($_POST['poll_ans_sortorder'])));
|
53 |
+
$poll_ans_result_sortby = addslashes(strip_tags(trim($_POST['poll_ans_result_sortby'])));
|
54 |
+
$poll_ans_result_sortorder = addslashes(strip_tags(trim($_POST['poll_ans_result_sortorder'])));
|
55 |
+
$poll_template_voteheader =addslashes(trim($_POST['poll_template_voteheader']));
|
56 |
+
$poll_template_votebody = addslashes(trim($_POST['poll_template_votebody']));
|
57 |
+
$poll_template_votefooter = addslashes(trim($_POST['poll_template_votefooter']));
|
58 |
+
$poll_template_resultheader = addslashes(trim($_POST['poll_template_resultheader']));
|
59 |
+
$poll_template_resultbody = addslashes(trim($_POST['poll_template_resultbody']));
|
60 |
+
$poll_template_resultbody2 = addslashes(trim($_POST['poll_template_resultbody2']));
|
61 |
+
$poll_template_resultfooter = addslashes(trim($_POST['poll_template_resultfooter']));
|
62 |
+
$poll_template_disable =addslashes( trim($_POST['poll_template_disable']));
|
63 |
+
$poll_template_error =addslashes( trim($_POST['poll_template_error']));
|
64 |
+
$poll_archive_perpage = intval($_POST['poll_archive_perpage']);
|
65 |
+
$poll_currentpoll = intval($_POST['poll_currentpoll']);
|
66 |
+
$update_poll_queries = array();
|
67 |
+
$update_poll_text = array();
|
68 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_ans_sortby' WHERE option_name = 'poll_ans_sortby'";
|
69 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_ans_sortorder' WHERE option_name = 'poll_ans_sortorder'";
|
70 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_ans_result_sortby' WHERE option_name = 'poll_ans_result_sortby'";
|
71 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_ans_result_sortorder' WHERE option_name = 'poll_ans_result_sortorder'";
|
72 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_voteheader' WHERE option_name = 'poll_template_voteheader'";
|
73 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_votebody' WHERE option_name = 'poll_template_votebody'";
|
74 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_votefooter' WHERE option_name = 'poll_template_votefooter'";
|
75 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_resultheader' WHERE option_name = 'poll_template_resultheader'";
|
76 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_resultbody' WHERE option_name = 'poll_template_resultbody'";
|
77 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_resultbody2' WHERE option_name = 'poll_template_resultbody2'";
|
78 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_resultfooter' WHERE option_name = 'poll_template_resultfooter'";
|
79 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_disable' WHERE option_name = 'poll_template_disable'";
|
80 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_template_error' WHERE option_name = 'poll_template_error'";
|
81 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_archive_perpage' WHERE option_name = 'poll_archive_perpage'";
|
82 |
+
$update_poll_queries[] = "UPDATE $wpdb->options SET option_value = '$poll_currentpoll' WHERE option_name = 'poll_currentpoll'";
|
83 |
+
$update_poll_text[] = __('Sort Poll Answers By Option');
|
84 |
+
$update_poll_text[] = __('Sort Order Of Poll Answers Option');
|
85 |
+
$update_poll_text[] = __('Sort Poll Results By Option');
|
86 |
+
$update_poll_text[] = __('Sort Order Of Poll Results Option');
|
87 |
+
$update_poll_text[] = __('Voting Form Header Template');
|
88 |
+
$update_poll_text[] = __('Voting Form Body Template');
|
89 |
+
$update_poll_text[] = __('Voting Form Footer Template');
|
90 |
+
$update_poll_text[] = __('Result Header Template');
|
91 |
+
$update_poll_text[] = __('Result Body Template');
|
92 |
+
$update_poll_text[] = __('Result Body2 Template');
|
93 |
+
$update_poll_text[] = __('Result Footer Template');
|
94 |
+
$update_poll_text[] = __('Poll Disabled Template');
|
95 |
+
$update_poll_text[] = __('Poll Error Template');
|
96 |
+
$update_poll_text[] = __('Archive Polls Per Page Option');
|
97 |
+
$update_poll_text[] = __('Current Active Poll Option');
|
98 |
+
$i=0;
|
99 |
+
$text = '';
|
100 |
+
foreach($update_poll_queries as $update_poll_query) {
|
101 |
+
$updating = $wpdb->query($update_poll_query);
|
102 |
+
if($updating) {
|
103 |
+
$text .= '<font color="green">'.$update_poll_text[$i].' '.__('Updated').'</font><br />';
|
104 |
+
}
|
105 |
+
$i++;
|
106 |
+
}
|
107 |
+
if(empty($text)) {
|
108 |
+
$text = '<font color="red">'.__('No Poll Option Updated').'</font>';
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
?>
|
113 |
+
<script language="JavaScript" type="text/javascript">
|
114 |
+
function poll_default_templates(template) {
|
115 |
+
var default_template;
|
116 |
+
switch(template) {
|
117 |
+
case "voteheader":
|
118 |
+
default_template = "<table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n<tr>\n<td align=\"center\"><b>%POLL_QUESTION%</b></td>\n</tr>";
|
119 |
+
break;
|
120 |
+
case "votebody":
|
121 |
+
default_template = "<tr>\n<td align=\"left\"><input type=\"radio\" name=\"poll-%POLL_ID%\" value=\"%POLL_ANSWER_ID%\" /> %POLL_ANSWER%</td>\n</tr>";
|
122 |
+
break;
|
123 |
+
case "votefooter":
|
124 |
+
default_template = "<tr>\n<td align=\"center\"><input type=\"submit\" name=\"vote\" value=\" Vote \" class=\"Buttons\" /><br /><a href=\"index.php?pollresult=1\">View Results</a></td>\n</tr>\n</table>";
|
125 |
+
break;
|
126 |
+
case "resultheader":
|
127 |
+
default_template = "<table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n<tr>\n<td colspan=\"2\" align=\"center\"><b>%POLL_QUESTION%</b></td>\n</tr>";
|
128 |
+
break;
|
129 |
+
case "resultbody":
|
130 |
+
default_template = "<tr>\n<td align=\"left\" width=\"70%\">%POLL_ANSWER%<br /><img src=\"wp-images/pollbar.gif\" height=\"5\" width=\"%POLL_ANSWER_IMAGEWIDTH%\" alt=\"%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" /></td>\n<td align=\"right\" width=\"30%\"><b>%POLL_ANSWER_PERCENTAGE%%</b></td>\n</tr>";
|
131 |
+
break;
|
132 |
+
case "resultbody2":
|
133 |
+
default_template = "<tr>\n<td align=\"left\" width=\"70%\"><i>%POLL_ANSWER%</i><br /><img src=\"wp-images/pollbar.gif\" height=\"5\" width=\"%POLL_ANSWER_IMAGEWIDTH%\" alt=\"You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" /></td>\n<td align=\"right\" width=\"30%\"><i><b>%POLL_ANSWER_PERCENTAGE%%</b></i></td>\n</tr>";
|
134 |
+
break;
|
135 |
+
case "resultfooter":
|
136 |
+
default_template = "<tr>\n<td colspan=\"2\" align=\"center\">Total Votes: <b>%POLL_TOTALVOTES%</b><td>\n</tr>\n</table>";
|
137 |
+
break;
|
138 |
+
case "disable":
|
139 |
+
default_template = 'Sorry, there are no polls available at the moment.';
|
140 |
+
break;
|
141 |
+
case "error":
|
142 |
+
default_template = 'An error has occurred when processing your poll.';
|
143 |
+
break;
|
144 |
+
}
|
145 |
+
document.getElementById("poll_template_" + template).value = default_template;
|
146 |
+
}
|
147 |
+
|
148 |
+
</script>
|
149 |
+
<ul id="adminmenu2">
|
150 |
+
<li><a href="polls-manager.php"><?php _e('Manage Polls'); ?></a></li>
|
151 |
+
<li><a href="polls-manager.php?mode=add"><?php _e('Add Poll'); ?></a></li>
|
152 |
+
<li class="last"><a href="polls-options.php" class="current"><?php _e('Poll Options'); ?></a></li>
|
153 |
+
</ul>
|
154 |
+
<?php if(!empty($text)) { echo '<!-- Last Action --><div class="wrap"><h2>'.__('Last Action').'</h2>'.$text.'</div>'; } ?>
|
155 |
+
<div class="wrap">
|
156 |
+
<h2><?php echo $title; ?></h2>
|
157 |
+
<form name="polls_options" method="post" action="polls-options.php">
|
158 |
+
<fieldset class="options">
|
159 |
+
<legend><?php _e('Sorting Of Poll Answers'); ?></legend>
|
160 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
161 |
+
<tr valign="top">
|
162 |
+
<th scope="row" width="40%"><?php _e('Sort Poll Answers By:'); ?></th>
|
163 |
+
<td>
|
164 |
+
<select name="poll_ans_sortby" size="1">
|
165 |
+
<option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_sortby')); ?>><?php _e('Exact Order'); ?></option>
|
166 |
+
<option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
|
167 |
+
</select>
|
168 |
+
</td>
|
169 |
+
</tr>
|
170 |
+
<tr valign="top">
|
171 |
+
<th scope="row" width="40%"><?php _e('Sort Order Of Poll Answers:'); ?></th>
|
172 |
+
<td>
|
173 |
+
<select name="poll_ans_sortorder" size="1">
|
174 |
+
<option value="asc"<?php selected('asc', get_settings('poll_ans_sortorder')); ?>><?php _e('Ascending'); ?></option>
|
175 |
+
<option value="desc"<?php selected('desc', get_settings('poll_ans_sortorder')); ?>><?php _e('Descending'); ?></option>
|
176 |
+
</select>
|
177 |
+
</td>
|
178 |
+
</tr>
|
179 |
+
</table>
|
180 |
+
</fieldset>
|
181 |
+
<fieldset class="options">
|
182 |
+
<legend><?php _e('Sorting Of Poll Results'); ?></legend>
|
183 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
184 |
+
<tr valign="top">
|
185 |
+
<th scope="row" width="40%"><?php _e('Sort Poll Results By:'); ?></th>
|
186 |
+
<td>
|
187 |
+
<select name="poll_ans_result_sortby" size="1">
|
188 |
+
<option value="polla_votes"<?php selected('polla_votes', get_settings('poll_ans_result_sortby')); ?>><?php _e('Votes'); ?></option>
|
189 |
+
<option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_result_sortby')); ?>><?php _e('Exact Order'); ?></option>
|
190 |
+
<option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_result_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
|
191 |
+
</select>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<tr valign="top">
|
195 |
+
<th scope="row" width="40%"><?php _e('Sort Order Of Poll Results:'); ?></th>
|
196 |
+
<td>
|
197 |
+
<select name="poll_ans_result_sortorder" size="1">
|
198 |
+
<option value="asc"<?php selected('asc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Ascending'); ?></option>
|
199 |
+
<option value="desc"<?php selected('desc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Descending'); ?></option>
|
200 |
+
</select>
|
201 |
+
</td>
|
202 |
+
</tr>
|
203 |
+
</table>
|
204 |
+
</fieldset>
|
205 |
+
<fieldset class="options">
|
206 |
+
<legend><?php _e('Poll Archive'); ?></legend>
|
207 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
208 |
+
<tr valign="top">
|
209 |
+
<th scope="row" width="40%"><?php _e('Polls Per Page:'); ?></th>
|
210 |
+
<td><input type="text" name="poll_archive_perpage" value="<?php form_option('poll_archive_perpage'); ?>" size="2" /></td>
|
211 |
+
</tr>
|
212 |
+
</table>
|
213 |
+
</fieldset>
|
214 |
+
<fieldset class="options">
|
215 |
+
<legend><?php _e('Current Active Poll'); ?></legend>
|
216 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row" width="40%"><?php _e('Current Active Poll:'); ?></th>
|
219 |
+
<td>
|
220 |
+
<select name="poll_currentpoll" size="1">
|
221 |
+
<option value="-1"<?php selected('-1', get_settings('poll_currentpoll')); ?>><?php _e('Do NOT Display Poll (Disable)'); ?></option>
|
222 |
+
<option value="0"<?php selected('0', get_settings('poll_currentpoll')); ?>><?php _e('Display Latest Poll'); ?></option>
|
223 |
+
<option value="0"></option>
|
224 |
+
<?php
|
225 |
+
$polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
|
226 |
+
if($polls) {
|
227 |
+
foreach($polls as $poll) {
|
228 |
+
$poll_question = stripslashes($poll->pollq_question);
|
229 |
+
$poll_id = intval($poll->pollq_id);
|
230 |
+
if($poll_id == intval(get_settings('poll_currentpoll'))) {
|
231 |
+
echo "<option value=\"$poll_id\" selected=\"selected\">$poll_question</option>\n";
|
232 |
+
} else {
|
233 |
+
echo "<option value=\"$poll_id\">$poll_question</option>\n";
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
?>
|
238 |
+
</select>
|
239 |
+
</td>
|
240 |
+
</tr>
|
241 |
+
</table>
|
242 |
+
</fieldset>
|
243 |
+
<fieldset class="options">
|
244 |
+
<legend><?php _e('Template Variables'); ?></legend>
|
245 |
+
<table width="100%" cellspacing="2" cellpadding="5" align="center">
|
246 |
+
<tr>
|
247 |
+
<td><b>%POLL_ID%</b> - <?php _e('Display the poll\'s ID'); ?></td>
|
248 |
+
<td><b>%POLL_ANSWER_ID%</b> - <?php _e('Display the poll\'s answer ID'); ?></td>
|
249 |
+
</tr>
|
250 |
+
<tr>
|
251 |
+
<td><b>%POLL_QUESTION%</b> - <?php _e('Display the poll\'s question'); ?></td>
|
252 |
+
<td><b>%POLL_ANSWER%</b> - <?php _e('Display the poll\'s answer'); ?></td>
|
253 |
+
</tr>
|
254 |
+
<tr>
|
255 |
+
<td><b>%POLL_TOTALVOTES%</b> - <?php _e('Display the poll\'s total votes'); ?></td>
|
256 |
+
<td><b>%POLL_ANSWER_VOTES%</b> - <?php _e('Display the poll\'s answer votes'); ?></td>
|
257 |
+
</tr>
|
258 |
+
<tr>
|
259 |
+
<td> </td>
|
260 |
+
<td><b>%POLL_ANSWER_PERCENTAGE%</b> - <?php _e('Display the poll\'s answer percentage'); ?></td>
|
261 |
+
</tr>
|
262 |
+
<tr>
|
263 |
+
<td> </td>
|
264 |
+
<td><b>"%POLL_ANSWER_IMAGEWIDTH%</b> - <?php _e('Display the poll\'s answer image width'); ?></td>
|
265 |
+
</tr>
|
266 |
+
</table>
|
267 |
+
</fieldset>
|
268 |
+
<fieldset class="options">
|
269 |
+
<legend><?php _e('Poll Voting Form Templates'); ?></legend>
|
270 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
271 |
+
<tr valign="top">
|
272 |
+
<td width="30%" align="left">
|
273 |
+
<b><?php _e('Voting Form Header:'); ?></b><br /><br /><br />
|
274 |
+
<?php _e('Allowed Variables:'); ?><br />
|
275 |
+
- %POLL_ID%<br />
|
276 |
+
- %POLL_QUESTION%<br />
|
277 |
+
- %POLL_TOTALVOTES%<br /><br />
|
278 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('voteheader');" class="button" />
|
279 |
+
</td>
|
280 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_voteheader" name="poll_template_voteheader"><?php echo stripslashes(get_settings('poll_template_voteheader')); ?></textarea></td>
|
281 |
+
</tr>
|
282 |
+
<tr valign="top">
|
283 |
+
<td width="30%" align="left">
|
284 |
+
<b><?php _e('Voting Form Body:'); ?></b><br /><br /><br />
|
285 |
+
<?php _e('Allowed Variables:'); ?><br />
|
286 |
+
- %POLL_ID%<br />
|
287 |
+
- %POLL_ANSWER_ID%<br />
|
288 |
+
- %POLL_ANSWER%<br />
|
289 |
+
- %POLL_ANSWER_VOTES%<br /><br />
|
290 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votebody');" class="button" />
|
291 |
+
</td>
|
292 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_votebody" name="poll_template_votebody"><?php echo stripslashes(get_settings('poll_template_votebody')); ?></textarea></td>
|
293 |
+
</tr>
|
294 |
+
<tr valign="top">
|
295 |
+
<td width="30%" align="left">
|
296 |
+
<b><?php _e('Voting Form Footer:'); ?></b><br /><br /><br />
|
297 |
+
<?php _e('Allowed Variables:'); ?><br />
|
298 |
+
- N/A<br /><br />
|
299 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votefooter');" class="button" />
|
300 |
+
</td>
|
301 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_votefooter" name="poll_template_votefooter"><?php echo stripslashes(get_settings('poll_template_votefooter')); ?></textarea></td>
|
302 |
+
</tr>
|
303 |
+
</table>
|
304 |
+
</fieldset>
|
305 |
+
<fieldset class="options">
|
306 |
+
<legend><?php _e('Poll Result Templates'); ?></legend>
|
307 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
308 |
+
<tr valign="top">
|
309 |
+
<td width="30%" align="left">
|
310 |
+
<b><?php _e('Result Header:'); ?></b><br /><br /><br />
|
311 |
+
<?php _e('Allowed Variables:'); ?><br />
|
312 |
+
- %POLL_ID%<br />
|
313 |
+
- %POLL_QUESTION%<br />
|
314 |
+
- %POLL_TOTALVOTES%<br /><br />
|
315 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultheader');" class="button" />
|
316 |
+
</td>
|
317 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_resultheader" name="poll_template_resultheader"><?php echo stripslashes(get_settings('poll_template_resultheader')); ?></textarea></td>
|
318 |
+
</tr>
|
319 |
+
<tr valign="top">
|
320 |
+
<td width="30%" align="left">
|
321 |
+
<b><?php _e('Result Body:'); ?></b><br /><?php _e('Normal'); ?><br /><br />
|
322 |
+
<?php _e('Allowed Variables:'); ?><br />
|
323 |
+
- %POLL_ANSWER_ID%<br />
|
324 |
+
- %POLL_ANSWER%<br />
|
325 |
+
- %POLL_ANSWER_VOTES%<br />
|
326 |
+
- %POLL_ANSWER_PERCENTAGE%<br />
|
327 |
+
- %POLL_ANSWER_IMAGEWIDTH%<br /><br />
|
328 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody');" class="button" />
|
329 |
+
</td>
|
330 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_resultbody" name="poll_template_resultbody"><?php echo stripslashes(get_settings('poll_template_resultbody')); ?></textarea></td>
|
331 |
+
</tr>
|
332 |
+
<tr valign="top">
|
333 |
+
<td width="30%" align="left">
|
334 |
+
<b><?php _e('Result Body:'); ?></b><br /><?php _e('Displaying Of User\'s Voted Answer'); ?><br /><br />
|
335 |
+
<?php _e('Allowed Variables:'); ?><br />
|
336 |
+
- %POLL_ANSWER_ID%<br />
|
337 |
+
- %POLL_ANSWER%<br />
|
338 |
+
- %POLL_ANSWER_VOTES%<br />
|
339 |
+
- %POLL_ANSWER_PERCENTAGE%<br />
|
340 |
+
- %POLL_ANSWER_IMAGEWIDTH%<br /><br />
|
341 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody2');" class="button" />
|
342 |
+
</td>
|
343 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_resultbody2" name="poll_template_resultbody2"><?php echo stripslashes(get_settings('poll_template_resultbody2')); ?></textarea></td>
|
344 |
+
</tr>
|
345 |
+
<tr valign="top">
|
346 |
+
<td width="30%" align="left">
|
347 |
+
<b><?php _e('Result Footer:'); ?></b><br /><br /><br />
|
348 |
+
<?php _e('Allowed Variables:'); ?><br />
|
349 |
+
- %POLL_TOTALVOTES%<br /><br />
|
350 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultfooter');" class="button" />
|
351 |
+
</td>
|
352 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_resultfooter" name="poll_template_resultfooter"><?php echo stripslashes(get_settings('poll_template_resultfooter')); ?></textarea></td>
|
353 |
+
</tr>
|
354 |
+
</table>
|
355 |
+
</fieldset>
|
356 |
+
<fieldset class="options">
|
357 |
+
<legend><?php _e('Poll Misc Templates'); ?></legend>
|
358 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
359 |
+
<tr valign="top">
|
360 |
+
<td width="30%" align="left">
|
361 |
+
<b><?php _e('Poll Disabled'); ?></b><br /><br /><br />
|
362 |
+
<?php _e('Allowed Variables:'); ?><br />
|
363 |
+
- N/A<br /><br />
|
364 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('disable');" class="button" />
|
365 |
+
</td>
|
366 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_disable" name="poll_template_disable"><?php echo stripslashes(get_settings('poll_template_disable')); ?></textarea></td>
|
367 |
+
</tr>
|
368 |
+
<tr valign="top">
|
369 |
+
<td width="30%" align="left">
|
370 |
+
<b><?php _e('Poll Error'); ?></b><br /><br /><br />
|
371 |
+
<?php _e('Allowed Variables:'); ?><br />
|
372 |
+
- N/A<br /><br />
|
373 |
+
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('error');" class="button" />
|
374 |
+
</td>
|
375 |
+
<td width="70%" align="right"><textarea cols="100" rows="10" id="poll_template_error" name="poll_template_error"><?php echo stripslashes(get_settings('poll_template_error')); ?></textarea></td>
|
376 |
+
</tr>
|
377 |
+
</table>
|
378 |
+
</fieldset>
|
379 |
+
<p class="submit">
|
380 |
+
<input type="submit" name="Submit" value="<?php _e('Update Options'); ?> »" />
|
381 |
+
</p>
|
382 |
+
</form>
|
383 |
+
</div>
|
384 |
+
<?php include('./admin-footer.php') ?>
|
polls-upgrade-202.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - Upgrade WP-Polls From 2.0x To 2.02 |
|
14 |
+
| - wp-admin/polls-upgrade-202.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Require Config
|
21 |
+
require('../wp-config.php');
|
22 |
+
|
23 |
+
### Variables, Variables, Variables
|
24 |
+
$alter_table = array();
|
25 |
+
$insert_options = array();
|
26 |
+
$update_options = array();
|
27 |
+
$error = '';
|
28 |
+
|
29 |
+
### Alter Tables (1 Table)
|
30 |
+
$alter_table[] = "ALTER TABLE $wpdb->pollsip ADD pollip_host VARCHAR(200) NOT NULL AFTER pollip_ip;";
|
31 |
+
|
32 |
+
### Insert Options (1 Row)
|
33 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_error', 'Y', '3', 'An error has occurred when processing your poll.', '20', '8', 'Template For Poll When An Error Has Occured', '8', 'yes');";
|
34 |
+
|
35 |
+
### Update Options (1 Row)
|
36 |
+
$update_options[] = "UPDATE $wpdb->options SET autoload = 'no' WHERE option_name = 'poll_archive_perpage'";
|
37 |
+
|
38 |
+
### Total IPs Needed To Be Resolved
|
39 |
+
$ip_totalcount = $wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip WHERE pollip_ip != ''");
|
40 |
+
|
41 |
+
### Check Whether There Is Any Pre Errors
|
42 |
+
$wpdb->show_errors = false;
|
43 |
+
$check_upgrade = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_template_error'");
|
44 |
+
if($check_upgrade) {
|
45 |
+
$error = __('You Had Already Installed WP-Polls Version 2.02.');
|
46 |
+
}
|
47 |
+
if(empty($wpdb->pollsq) || empty($wpdb->pollsa) || empty($wpdb->pollsip)) {
|
48 |
+
$error = __('Please Define The pollsq, pollsa and pollsip in wp-settings.php.');
|
49 |
+
}
|
50 |
+
?>
|
51 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
52 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
53 |
+
<head>
|
54 |
+
<title>WordPress › <?php _e('Upgrading'); ?> › <?php _e('WP-Polls'); ?> 2.02</title>
|
55 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
56 |
+
<style type="text/css" media="screen">
|
57 |
+
@import url( wp-admin.css );
|
58 |
+
</style>
|
59 |
+
</head>
|
60 |
+
<body>
|
61 |
+
<div class="wrap">
|
62 |
+
<h2><?php _e('Upgrading WP-Polls 2.02'); ?></h2>
|
63 |
+
<p><?php _e('This upgrade script will upgrade WP-Polls from version 2.00 or 2.01 to version 2.02 for your Wordpress.'); ?></p>
|
64 |
+
<p>
|
65 |
+
<?php _e('This upgrade script will be doing the following:'); ?><br />
|
66 |
+
<b>»</b> <b>1</b> <?php _e('table will be altered namely <b>pollsip</b>.'); ?><br />
|
67 |
+
<b>»</b> <b>1</b> <?php _e('option will be inserted into the <b>options</b> table.'); ?><br />
|
68 |
+
<b>»</b> <b>1</b> <?php _e('option will be updated from <b>options</b> table.'); ?><br />
|
69 |
+
<b>»</b> <b><?php echo $ip_totalcount; ?></b> <?php _e('IPs will be resolved and updated.'); ?><br />
|
70 |
+
<b>»</b> <b>4</b> <?php _e('tables will be optimized namely <b>pollsq</b>, <b>pollsa</b>, <b>pollsip</b> and <b>options</b>.'); ?><br />
|
71 |
+
</p>
|
72 |
+
<?php
|
73 |
+
if(empty($error)) {
|
74 |
+
if(!empty($_POST['upgrade'])) {
|
75 |
+
// Alter Table
|
76 |
+
$alter_table_count = 0;
|
77 |
+
echo "<p><b>".__('Altering Tables:')."</b>";
|
78 |
+
foreach($alter_table as $altertable) {
|
79 |
+
$wpdb->query($altertable);
|
80 |
+
}
|
81 |
+
$check_pollsip = $wpdb->get_var("SELECT pollip_id FROM $wpdb->pollsip WHERE pollip_host = '' LIMIT 1");
|
82 |
+
if($check_pollsip) {
|
83 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsa</b>) altered.";
|
84 |
+
$alter_table_count++;
|
85 |
+
} else {
|
86 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsip</b>) table NOT altered.</font>";
|
87 |
+
}
|
88 |
+
echo "<br /><b>»</b> <b>$alter_table_count / 1</b> Table Altered.</p>";
|
89 |
+
// Insert Options
|
90 |
+
$insert_options_count = 0;
|
91 |
+
echo "<p><b>".__('Inserting Options:')."</b>";
|
92 |
+
foreach($insert_options as $insertoptions) {
|
93 |
+
$temp_options = $wpdb->query($insertoptions);
|
94 |
+
$temp_option = explode(" ", $insertoptions);
|
95 |
+
$temp_option = $temp_option[6];
|
96 |
+
$temp_option = substr($temp_option, 1, -2);
|
97 |
+
if($temp_options) {
|
98 |
+
echo "<br /><b>»</b> Option (<b>$temp_option</b>) inserted.";
|
99 |
+
$insert_options_count++;
|
100 |
+
} else {
|
101 |
+
echo "<br /><b>»</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT inserted.</font>";
|
102 |
+
}
|
103 |
+
}
|
104 |
+
echo "<br /><b>»</b> <b>$insert_options_count / 1</b> Option Inserted.</p>";
|
105 |
+
// Update Options
|
106 |
+
$update_options_count = 0;
|
107 |
+
echo "<p><b>".__('Updating Options:')."</b>";
|
108 |
+
foreach($update_options as $updateoptions) {
|
109 |
+
$temp_options = $wpdb->query($updateoptions);
|
110 |
+
$temp_option = explode("=", $updateoptions);
|
111 |
+
$temp_option = $temp_option[2];
|
112 |
+
$temp_option = substr($temp_option, 2, -1);
|
113 |
+
if($temp_options) {
|
114 |
+
echo "<br /><b>»</b> Option (<b>$temp_option</b>) updated.";
|
115 |
+
$update_options_count++;
|
116 |
+
} else {
|
117 |
+
echo "<br /><b>»</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT updated.</font>";
|
118 |
+
}
|
119 |
+
}
|
120 |
+
echo "<br /><b>»</b> <b>$update_options_count / 1</b> Option Updated.</p>";
|
121 |
+
// Resolve IPs
|
122 |
+
$ip_count = 0;
|
123 |
+
echo "<p><b>".__('Resolving IPs:')."</b>";
|
124 |
+
$ips_data = $wpdb->get_results("SELECT pollip_id, pollip_ip FROM $wpdb->pollsip WHERE pollip_ip != ''");
|
125 |
+
if($ips_data) {
|
126 |
+
foreach($ips_data as $ip_data) {
|
127 |
+
$pollip_id = intval($ip_data->pollip_id);
|
128 |
+
$pollip_host = gethostbyaddr($ip_data->pollip_ip);
|
129 |
+
$update_ip = $wpdb->query("UPDATE $wpdb->pollsip SET pollip_host = '$pollip_host' WHERE pollip_id = $pollip_id");
|
130 |
+
if($update_ip) {
|
131 |
+
echo "<br /><b>»</b> IP (<b>$ip_data->pollip_ip</b>) resolved.";
|
132 |
+
$ip_count++;
|
133 |
+
} else {
|
134 |
+
echo "<br /><b>»</b> <font color=\"red\">IP (<b>$ip_data->pollip_ip</b>) NOT resolved.</font>";
|
135 |
+
}
|
136 |
+
}
|
137 |
+
} else {
|
138 |
+
echo "<br /><b>»</b> There are no IP to be resolved.";
|
139 |
+
}
|
140 |
+
echo "<br /><b>»</b> <b>$ip_count / $ip_totalcount</b> IPs Resolved.</p>";
|
141 |
+
// Optimize Tables
|
142 |
+
$optimize_table_count = 0;
|
143 |
+
echo "<p><b>".__('Optimizing Tables:')."</b>";
|
144 |
+
$optimize_tables = $wpdb->query("OPTIMIZE TABLE $wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip, $wpdb->options");
|
145 |
+
if($optimize_tables) {
|
146 |
+
echo "<br /><b>»</b> Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) optimized.";
|
147 |
+
$optimize_table_count = 4;
|
148 |
+
} else {
|
149 |
+
echo "<br /><b>»</b> <font color=\"red\">Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) NOT optimized.</font>";
|
150 |
+
}
|
151 |
+
echo "<br /><b>»</b> <b>$optimize_table_count / 4</b> Tables Optimized.</p>";
|
152 |
+
// Check Whether Install Is Successful
|
153 |
+
if($alter_table_count == 1 && $insert_options_count == 1) {
|
154 |
+
echo '<p align="center"><b>'.__('WP-Polls Upgraded Successfully To Version 2.02.').'</b><br />'.__('Please remember to delete this file before proceeding on.').'</p>';
|
155 |
+
}
|
156 |
+
} else {
|
157 |
+
?>
|
158 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
159 |
+
<div align="center"><?php _e('It may take some time for all the ips to be resolved.'); ?><br /><input type="submit" name="upgrade" value="<?php _e('Click Here To Upgrade WP-Polls 2.02'); ?>" class="button"></div>
|
160 |
+
</form>
|
161 |
+
<?php
|
162 |
+
}
|
163 |
+
} else {
|
164 |
+
echo "<p align=\"center\"><font color=\"red\"><b>$error</b></font></p>\n";
|
165 |
+
}
|
166 |
+
?>
|
167 |
+
</div>
|
168 |
+
</body>
|
169 |
+
</html>
|
polls-upgrade.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - Upgrade WP-Polls From 1.0x To 2.02 |
|
14 |
+
| - wp-admin/polls-upgrade.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Require Config
|
21 |
+
require('../wp-config.php');
|
22 |
+
|
23 |
+
### Variables, Variables, Variables
|
24 |
+
$create_table = array();
|
25 |
+
$alter_table = array();
|
26 |
+
$insert_options = array();
|
27 |
+
$error = '';
|
28 |
+
|
29 |
+
### Create Tables (1 Table)
|
30 |
+
$create_table[] = "CREATE TABLE $wpdb->pollsip (".
|
31 |
+
"pollip_id int(10) NOT NULL auto_increment,".
|
32 |
+
"pollip_qid varchar(10) NOT NULL default '',".
|
33 |
+
"pollip_aid varchar(10) NOT NULL default '',".
|
34 |
+
"pollip_ip varchar(100) NOT NULL default '',".
|
35 |
+
"pollip_host VARCHAR(200) NOT NULL default '',".
|
36 |
+
"pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
|
37 |
+
"pollip_user tinytext NOT NULL,".
|
38 |
+
"PRIMARY KEY (pollip_id))";
|
39 |
+
|
40 |
+
### Alter Tables (2 Tables)
|
41 |
+
$alter_table[] = "ALTER TABLE $wpdb->pollsq CHANGE id pollq_id INT(10) NULL AUTO_INCREMENT ,".
|
42 |
+
"CHANGE question pollq_question VARCHAR(200) NOT NULL ,".
|
43 |
+
"CHANGE timestamp pollq_timestamp VARCHAR(20) NOT NULL ,".
|
44 |
+
"CHANGE total_votes pollq_totalvotes INT(10) DEFAULT '0' NOT NULL";
|
45 |
+
$alter_table[] = "ALTER TABLE $wpdb->pollsa CHANGE aid polla_aid INT(10) NOT NULL AUTO_INCREMENT ,".
|
46 |
+
"CHANGE qid polla_qid INT(10) DEFAULT '0' NOT NULL ,".
|
47 |
+
"CHANGE answers polla_answers VARCHAR( 200 ) NOT NULL ,".
|
48 |
+
"CHANGE votes polla_votes INT(10) DEFAULT '0' NOT NULL";
|
49 |
+
|
50 |
+
### Get Lastest Poll ID
|
51 |
+
$poll_latest_id = $wpdb->get_var("SELECT id FROM $wpdb->pollsq ORDER BY id DESC LIMIT 1");
|
52 |
+
if(intval($poll_latest_id) < 1) { $poll_latest_id = 1; }
|
53 |
+
|
54 |
+
### Insert Options (16 Rows)
|
55 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_voteheader', 'Y', 3, '<table width=\\\"100%\\\" border=\\\"0\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\">\r\n<tr>\r\n<td align=\\\"center\\\"><b>%POLL_QUESTION%</b></td>\r\n</tr>', 20, 8, 'Template For Poll''s Question', 8, 'yes');";
|
56 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (124, 0, 'poll_template_votebody', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"poll-%POLL_ID%\\\" value=\\\"%POLL_ANSWER_ID%\\\" /> %POLL_ANSWER%</td>\r\n</tr>', 20, 8, 'Template For Poll''s Answers', 8, 'yes');";
|
57 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (123, 0, 'poll_template_votefooter', 'Y', 3, '<tr>\r\n<td align=\\\"center\\\"><input type=\\\"submit\\\" name=\\\"vote\\\" value=\\\" Vote \\\" class=\\\"Buttons\\\" /><br /><a href=\\\"index.php?pollresult=1\\\">View Results</a></td>\r\n</tr>\r\n</table>', 20, 8, 'Template For Poll''s Voting Footer', 8, 'yes');";
|
58 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultheader', 'Y', 3, '<table width=\\\"100%\\\" border=\\\"0\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\">\r\n<tr>\r\n<td colspan=\\\"2\\\" align=\\\"center\\\"><b>%POLL_QUESTION%</b></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
59 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultbody', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\" width=\\\"70%\\\">%POLL_ANSWER%<br /><img src=\\\"wp-images/pollbar.gif\\\" height=\\\"5\\\" width=\\\"%POLL_ANSWER_IMAGEWIDTH%\\\" alt=\\\"%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\\\" /></td>\r\n<td align=\\\"right\\\" width=\\\"30%\\\"><b>%POLL_ANSWER_PERCENTAGE%%</b></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
60 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultbody2', 'Y', 3, '<tr>\r\n<td align=\\\"left\\\" width=\\\"70%\\\"><i>%POLL_ANSWER%</i><br /><img src=\\\"wp-images/pollbar.gif\\\" height=\\\"5\\\" width=\\\"%POLL_ANSWER_IMAGEWIDTH%\\\" alt=\\\"You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\\\" /></td>\r\n<td align=\\\"right\\\" width=\\\"30%\\\"><i><b>%POLL_ANSWER_PERCENTAGE%%</b></i></td>\r\n</tr>', 20, 8, '', 8, 'yes');";
|
61 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_resultfooter', 'Y', 3, '<tr>\r\n<td colspan=\\\"2\\\" align=\\\"center\\\">Total Votes: <b>%POLL_TOTALVOTES%</b><td>\r\n</tr>\r\n</table>', 20, 8, '', 8, 'yes');";
|
62 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_disable', 'Y', 3, 'Sorry, there are no polls available at the moment.', 20, 8, 'Template For Poll When It Is Disabled', 8, 'yes');";
|
63 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_template_error', 'Y', '3', 'An error has occurred when processing your poll.', '20', '8', 'Template For Poll When An Error Has Occured', '8', 'yes');";
|
64 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_currentpoll', 'Y', 3, '0', 20, 8, 'Current Displayed Poll', 8, 'yes');";
|
65 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_latestpoll', 'Y', 3, '$poll_latest_id', 20, 8, 'The Lastest Poll', 8, 'yes');";
|
66 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_archive_perpage', 'Y', 3, '10', 2, 8, 'Number Of Polls To Display Per Page On The Poll''s Archive', 8, 'no');";
|
67 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_sortby', 'Y', 1, 'polla_aid', 20, 8, 'Sorting Of Poll''s Answers', 8, 'yes');";
|
68 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_sortorder', 'Y', 1, 'asc', 20, 8, 'Sort Order Of Poll''s Answers', 8, 'yes');";
|
69 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_result_sortby', 'Y', 1, 'polla_votes', 20, 8, 'Sorting Of Poll''s Answers Result', 8, 'yes');";
|
70 |
+
$insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'poll_ans_result_sortorder', 'Y', 1, 'desc', 20, 8, 'Sorting Order Of Poll''s Answers Result', 8, 'yes');";
|
71 |
+
|
72 |
+
### Check Whether There Is Any Pre Errors
|
73 |
+
$wpdb->show_errors = false;
|
74 |
+
$check_upgrade = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'");
|
75 |
+
if($check_upgrade) {
|
76 |
+
$error = __('You Had Already Installed WP-Polls.');
|
77 |
+
}
|
78 |
+
if(empty($wpdb->pollsq) || empty($wpdb->pollsa) || empty($wpdb->pollsip)) {
|
79 |
+
$error = __('Please Define The pollsq, pollsa and pollsip in wp-settings.php.');
|
80 |
+
}
|
81 |
+
?>
|
82 |
+
|
83 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
84 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
85 |
+
<head>
|
86 |
+
<title>WordPress › <?php _e('Upgrading'); ?> › <?php _e('WP-Polls'); ?></title>
|
87 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
88 |
+
<style type="text/css" media="screen">
|
89 |
+
@import url( wp-admin.css );
|
90 |
+
</style>
|
91 |
+
</head>
|
92 |
+
<body>
|
93 |
+
<div class="wrap">
|
94 |
+
<h2><?php _e('Upgrading WP-Polls'); ?></h2>
|
95 |
+
<p><?php _e('This upgrade script will upgrade WP-Polls to version 2.0 for your Wordpress.'); ?></p>
|
96 |
+
<p>
|
97 |
+
<?php _e('This upgrade script will be doing the following:'); ?><br />
|
98 |
+
<b>»</b> <b>1</b> <?php _e('table will be created namely <b>pollsip</b>.'); ?><br />
|
99 |
+
<b>»</b> <b>2</b> <?php _e('tables will be altered namely <b>pollsq</b> and <b>pollsa</b>.'); ?><br />
|
100 |
+
<b>»</b> <b>15</b> <?php _e('options will be inserted into the <b>options</b> table.'); ?><br />
|
101 |
+
<b>»</b> <b>4</b> <?php _e('tables will be optimized namely <b>pollsq</b>, <b>pollsa</b>, <b>pollsip</b> and <b>options</b>.'); ?><br />
|
102 |
+
</p>
|
103 |
+
<?php
|
104 |
+
if(empty($error)) {
|
105 |
+
if(!empty($_POST['upgrade'])) {
|
106 |
+
// Create Tables
|
107 |
+
$create_table_count = 0;
|
108 |
+
echo "<p><b>".__('Creating Tables:')."</b>";
|
109 |
+
foreach($create_table as $createtable) {
|
110 |
+
$wpdb->query($createtable);
|
111 |
+
}
|
112 |
+
$check_pollsip = $wpdb->query("SHOW COLUMNS FROM $wpdb->pollsip");
|
113 |
+
if($check_pollsip) {
|
114 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsip</b>) created.";
|
115 |
+
$create_table_count++;
|
116 |
+
} else {
|
117 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsip</b>) table NOT created.</font>";
|
118 |
+
}
|
119 |
+
echo "<br /><b>»</b> <b>$create_table_count / 1</b> Table Created.</p>";
|
120 |
+
// Alter Table
|
121 |
+
$alter_table_count = 0;
|
122 |
+
echo "<p><b>".__('Altering Tables:')."</b>";
|
123 |
+
foreach($alter_table as $altertable) {
|
124 |
+
$wpdb->query($altertable);
|
125 |
+
}
|
126 |
+
$check_pollsq = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq LIMIT 1");
|
127 |
+
$check_pollsa = $wpdb->get_var("SELECT polla_aid FROM $wpdb->pollsa LIMIT 1");
|
128 |
+
if($check_pollsq) {
|
129 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsq</b>) altered.";
|
130 |
+
$alter_table_count++;
|
131 |
+
} else {
|
132 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsip</b>) table NOT altered.</font>";
|
133 |
+
}
|
134 |
+
if($check_pollsa) {
|
135 |
+
echo "<br /><b>»</b> Table (<b>$wpdb->pollsa</b>) altered.";
|
136 |
+
$alter_table_count++;
|
137 |
+
} else {
|
138 |
+
echo "<br /><b>»</b> <font color=\"red\">Table (<b>$wpdb->pollsip</b>) table NOT altered.</font>";
|
139 |
+
}
|
140 |
+
echo "<br /><b>»</b> <b>$alter_table_count / 2</b> Tables Altered.</p>";
|
141 |
+
// Insert Options
|
142 |
+
$insert_options_count = 0;
|
143 |
+
echo "<p><b>".__('Inserting Options:')."</b>";
|
144 |
+
foreach($insert_options as $insertoptions) {
|
145 |
+
$temp_options = $wpdb->query($insertoptions);
|
146 |
+
$temp_option = explode(" ", $insertoptions);
|
147 |
+
$temp_option = $temp_option[6];
|
148 |
+
$temp_option = substr($temp_option, 1, -2);
|
149 |
+
if($temp_options) {
|
150 |
+
echo "<br /><b>»</b> Option (<b>$temp_option</b>) inserted.";
|
151 |
+
$insert_options_count ++;
|
152 |
+
} else {
|
153 |
+
echo "<br /><b>»</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT inserted.</font>";
|
154 |
+
}
|
155 |
+
}
|
156 |
+
echo "<br /><b>»</b> <b>$insert_options_count / 16</b> Options Inserted.</p>";
|
157 |
+
// Optimize Tables
|
158 |
+
$optimize_table_count = 0;
|
159 |
+
echo "<p><b>".__('Optimizing Tables:')."</b>";
|
160 |
+
$optimize_tables = $wpdb->query("OPTIMIZE TABLE $wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip, $wpdb->options");
|
161 |
+
if($optimize_tables) {
|
162 |
+
echo "<br /><b>»</b> Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) optimized.";
|
163 |
+
$optimize_table_count = 4;
|
164 |
+
} else {
|
165 |
+
echo "<br /><b>»</b> <font color=\"red\">Tables (<b>$wpdb->pollsq</b>, <b>$wpdb->pollsa</b>, <b>$wpdb->pollsip</b>, <b>$wpdb->options</b>) NOT optimized.</font>";
|
166 |
+
}
|
167 |
+
echo "<br /><b>»</b> <b>$optimize_table_count / 4</b> Tables Optimized.</p>";
|
168 |
+
// Check Whether Install Is Successful
|
169 |
+
if($create_table_count == 1 && $alter_table_count == 2 && $insert_options_count == 16) {
|
170 |
+
echo '<p align="center"><b>'.__('WP-Polls Upgraded Successfully.').'</b><br />'.__('Please remember to delete this file before proceeding on.').'</p>';
|
171 |
+
}
|
172 |
+
} else {
|
173 |
+
?>
|
174 |
+
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
175 |
+
<div align="center"><input type="submit" name="upgrade" value="<?php _e('Click Here To Upgrade WP-Polls'); ?>" class="button"></div>
|
176 |
+
</form>
|
177 |
+
<?php
|
178 |
+
}
|
179 |
+
} else {
|
180 |
+
echo "<p align=\"center\"><font color=\"red\"><b>$error</b></font></p>\n";
|
181 |
+
}
|
182 |
+
?>
|
183 |
+
</div>
|
184 |
+
</body>
|
185 |
+
</html>
|
polls.php
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP-Polls
|
4 |
+
Plugin URI: http://www.lesterchan.net/portfolio/programming.php
|
5 |
+
Description: Adds A Poll Feature To WordPress
|
6 |
+
Version: 2.02
|
7 |
+
Author: GaMerZ
|
8 |
+
Author URI: http://www.lesterchan.net
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
### Function: Get Poll
|
13 |
+
function get_poll($temp_poll_id = 0) {
|
14 |
+
global $wpdb;
|
15 |
+
// Check Whether Poll Is Disabled
|
16 |
+
if(intval(get_settings('poll_currentpoll')) == -1) {
|
17 |
+
echo stripslashes(get_settings('poll_template_disable'));
|
18 |
+
return;
|
19 |
+
// Poll Is Enabled
|
20 |
+
} else {
|
21 |
+
// Hardcoded Poll ID Is Not Specified
|
22 |
+
if(intval($temp_poll_id) == 0) {
|
23 |
+
// Current Poll ID Is Not Specified
|
24 |
+
if(intval(get_settings('poll_currentpoll')) == 0) {
|
25 |
+
// Get Lastest Poll ID
|
26 |
+
$poll_id = intval(get_settings('poll_latestpoll'));
|
27 |
+
} else {
|
28 |
+
// Get Current Poll ID
|
29 |
+
$poll_id = intval(get_settings('poll_currentpoll'));
|
30 |
+
}
|
31 |
+
// Get Hardcoded Poll ID
|
32 |
+
} else {
|
33 |
+
$poll_id = intval($temp_poll_id);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
// User Click on View Results Link
|
38 |
+
if(intval($_GET['pollresult']) == 1) {
|
39 |
+
display_pollresult($poll_id);
|
40 |
+
// Check Whether User Has Voted
|
41 |
+
} else {
|
42 |
+
// Check Cookie First
|
43 |
+
$voted_cookie = check_voted_cookie($poll_id);
|
44 |
+
if($voted_cookie > 0) {
|
45 |
+
display_pollresult($poll_id, $voted_cookie);
|
46 |
+
// Check IP If Cookie Cannot Be Found
|
47 |
+
} else {
|
48 |
+
$voted_ip = check_voted_ip($poll_id);
|
49 |
+
if($voted_ip > 0) {
|
50 |
+
display_pollresult($poll_id, $voted_ip);
|
51 |
+
// User Never Vote. Display Poll Voting Form
|
52 |
+
} else {
|
53 |
+
display_pollvote($poll_id);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
### Function: Check Voted By Cookie
|
61 |
+
function check_voted_cookie($poll_id) {
|
62 |
+
// 0: False | > 0: True
|
63 |
+
return intval($_COOKIE["voted_$poll_id"]);
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
### Function: Check Voted By IP
|
68 |
+
function check_voted_ip($poll_id) {
|
69 |
+
global $wpdb;
|
70 |
+
// Check IP From IP Logging Database
|
71 |
+
$get_voted_aid = $wpdb->get_var("SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_ip = '".get_ipaddress()."'");
|
72 |
+
// 0: False | > 0: True
|
73 |
+
return intval($get_voted_aid);
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
### Function: Display Voting Form
|
78 |
+
function display_pollvote($poll_id) {
|
79 |
+
global $wpdb;
|
80 |
+
// Get Poll Question Data
|
81 |
+
$poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
|
82 |
+
// Poll Question Variables
|
83 |
+
$poll_question_text = stripslashes($poll_question->pollq_question);
|
84 |
+
$poll_question_id = intval($poll_question->pollq_id);
|
85 |
+
$poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
|
86 |
+
$template_question = stripslashes(get_settings('poll_template_voteheader'));
|
87 |
+
$template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
|
88 |
+
$template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
|
89 |
+
$template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
|
90 |
+
// Get Poll Answers Data
|
91 |
+
$poll_answers = $wpdb->get_results("SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = $poll_question_id ORDER BY ".get_settings('poll_ans_sortby').' '.get_settings('poll_ans_sortorder'));
|
92 |
+
// If There Is Poll Question With Answers
|
93 |
+
if($poll_question && $poll_answers) {
|
94 |
+
// Display Poll Voting Form
|
95 |
+
echo '<form action="'.$_SERVER['REQUEST_URI'].'" name="polls" method="post">'."\n";
|
96 |
+
echo "<input type=\"hidden\" name=\"poll_id\" value=\"$poll_question_id\" />\n";
|
97 |
+
// Print Out Voting Form Header Template
|
98 |
+
echo $template_question;
|
99 |
+
foreach($poll_answers as $poll_answer) {
|
100 |
+
// Poll Answer Variables
|
101 |
+
$poll_answer_id = intval($poll_answer->polla_aid);
|
102 |
+
$poll_answer_text = stripslashes($poll_answer->polla_answers);
|
103 |
+
$poll_answer_votes = intval($poll_answer->polla_votes);
|
104 |
+
$template_answer = stripslashes(get_settings('poll_template_votebody'));
|
105 |
+
$template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
|
106 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
|
107 |
+
$template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
|
108 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", $poll_answer_votes, $template_answer);
|
109 |
+
// Print Out Voting Form Body Template
|
110 |
+
echo $template_answer;
|
111 |
+
}
|
112 |
+
// Voting Form Footer Variables
|
113 |
+
$template_footer = stripslashes(get_settings('poll_template_votefooter'));
|
114 |
+
// Print Out Voting Form Footer Template
|
115 |
+
echo $template_footer;
|
116 |
+
echo "</form>\n";
|
117 |
+
} else {
|
118 |
+
echo stripslashes(get_settings('poll_template_disable'));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
### Function: Display Results Form
|
124 |
+
function display_pollresult($poll_id, $user_voted = 0) {
|
125 |
+
global $wpdb;
|
126 |
+
// Get Poll Question Data
|
127 |
+
$poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
|
128 |
+
// Poll Question Variables
|
129 |
+
$poll_question_text = stripslashes($poll_question->pollq_question);
|
130 |
+
$poll_question_id = intval($poll_question->pollq_id);
|
131 |
+
$poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
|
132 |
+
$template_question = stripslashes(get_settings('poll_template_resultheader'));
|
133 |
+
$template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
|
134 |
+
$template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
|
135 |
+
$template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
|
136 |
+
// Get Poll Answers Data
|
137 |
+
$poll_answers = $wpdb->get_results("SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = $poll_question_id ORDER BY ".get_settings('poll_ans_result_sortby').' '.get_settings('poll_ans_result_sortorder'));
|
138 |
+
// If There Is Poll Question With Answers
|
139 |
+
if($poll_question && $poll_answers) {
|
140 |
+
// Is The Poll Total Votes 0?
|
141 |
+
$poll_totalvotes_zero = true;
|
142 |
+
if($poll_question_totalvotes > 0) {
|
143 |
+
$poll_totalvotes_zero = false;
|
144 |
+
}
|
145 |
+
// Print Out Result Header Template
|
146 |
+
echo $template_question;
|
147 |
+
foreach($poll_answers as $poll_answer) {
|
148 |
+
// Poll Answer Variables
|
149 |
+
$poll_answer_id = intval($poll_answer->polla_aid);
|
150 |
+
$poll_answer_text = stripslashes($poll_answer->polla_answers);
|
151 |
+
$poll_answer_votes = intval($poll_answer->polla_votes);
|
152 |
+
$poll_answer_text = stripslashes($poll_answer->polla_answers);
|
153 |
+
$poll_answer_percentage = 0;
|
154 |
+
$poll_answer_imagewidth = 0;
|
155 |
+
// Calculate Percentage And Image Bar Width
|
156 |
+
if(!$poll_totalvotes_zero) {
|
157 |
+
if($poll_answer_votes > 0) {
|
158 |
+
$poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*100));
|
159 |
+
$poll_answer_imagewidth = round($poll_answer_percentage*0.9);
|
160 |
+
} else {
|
161 |
+
$poll_answer_percentage = 0;
|
162 |
+
$poll_answer_imagewidth = 1;
|
163 |
+
}
|
164 |
+
} else {
|
165 |
+
$poll_answer_percentage = 0;
|
166 |
+
$poll_answer_imagewidth = 1;
|
167 |
+
}
|
168 |
+
// Let User See What Options They Voted
|
169 |
+
if($user_voted == $poll_answer_id) {
|
170 |
+
// Results Body Variables
|
171 |
+
$template_answer = stripslashes(get_settings('poll_template_resultbody2'));
|
172 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
|
173 |
+
$template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
|
174 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", $poll_answer_votes, $template_answer);
|
175 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
176 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
177 |
+
// Print Out Results Body Template
|
178 |
+
echo $template_answer;
|
179 |
+
} else {
|
180 |
+
// Results Body Variables
|
181 |
+
$template_answer = stripslashes(get_settings('poll_template_resultbody'));
|
182 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
|
183 |
+
$template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
|
184 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", $poll_answer_votes, $template_answer);
|
185 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
186 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
187 |
+
// Print Out Results Body Template
|
188 |
+
echo $template_answer;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
// Results Footer Variables
|
192 |
+
$template_footer = stripslashes(get_settings('poll_template_resultfooter'));
|
193 |
+
$template_footer = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_footer);
|
194 |
+
// Print Out Results Footer Template
|
195 |
+
echo $template_footer;
|
196 |
+
} else {
|
197 |
+
echo stripslashes(get_settings('poll_template_disable'));
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
### Function: Vote Poll
|
203 |
+
function vote_poll() {
|
204 |
+
global $wpdb, $user_identity;
|
205 |
+
if(!empty($_POST['vote'])) {
|
206 |
+
$poll_id = intval($_POST['poll_id']);
|
207 |
+
$poll_aid = intval($_POST["poll-$poll_id"]);
|
208 |
+
if($poll_id > 0 && $poll_aid > 0) {
|
209 |
+
$voted_ip = check_voted_ip($poll_id);
|
210 |
+
$voted_cookie = check_voted_cookie($poll_ip);
|
211 |
+
if($voted_ip == 0 && $voted_cookie == 0) {
|
212 |
+
if(!empty($user_identity)) {
|
213 |
+
$pollip_user = addslashes($user_identity);
|
214 |
+
} elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
|
215 |
+
$pollip_user = addslashes($_COOKIE['comment_author_'.COOKIEHASH]);
|
216 |
+
} else {
|
217 |
+
$pollip_user = 'Guest';
|
218 |
+
}
|
219 |
+
$vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
|
220 |
+
if($vote_cookie) {
|
221 |
+
$pollip_ip = get_ipaddress();
|
222 |
+
$pollip_host = gethostbyaddr($pollip_ip);
|
223 |
+
$pollip_timestamp = current_time('timestamp');
|
224 |
+
$vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES(0,$poll_id,$poll_aid,'$pollip_ip','$pollip_host','$pollip_timestamp','$pollip_user')");
|
225 |
+
if($vote_ip) {
|
226 |
+
$vote_a = $wpdb->query("UPDATE $wpdb->pollsa SET polla_votes = (polla_votes+1) WHERE polla_qid = $poll_id AND polla_aid = $poll_aid");
|
227 |
+
if($vote_a) {
|
228 |
+
$vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+1) WHERE pollq_id = $poll_id");
|
229 |
+
} // End if($vote_a)
|
230 |
+
} // End if($vote_ip)
|
231 |
+
} // End if($vote_cookie)
|
232 |
+
}// End if($voted_ip == 0 && $voted_cookie == 0)
|
233 |
+
} // End if(!empty($_POST['vote']))
|
234 |
+
} // End if($poll_id > 0 && $poll_aid > 0)
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
### Function: Get IP Address
|
239 |
+
function get_ipaddress() {
|
240 |
+
if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
|
241 |
+
$ip_address = $_SERVER["REMOTE_ADDR"];
|
242 |
+
} else {
|
243 |
+
$ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
|
244 |
+
}
|
245 |
+
if(strpos($ip_address, ',') !== false) {
|
246 |
+
$ip_address = explode(',', $ip_address);
|
247 |
+
$ip_address = $ip_address[0];
|
248 |
+
}
|
249 |
+
return $ip_address;
|
250 |
+
}
|
251 |
+
?>
|
readme-install.txt
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-> Installation Instructions
|
2 |
+
------------------------------------------------------------------
|
3 |
+
// Open wp-settings.php
|
4 |
+
|
5 |
+
Find:
|
6 |
+
------------------------------------------------------------------
|
7 |
+
$wpdb->postmeta = $table_prefix . 'postmeta';
|
8 |
+
------------------------------------------------------------------
|
9 |
+
Add Below It:
|
10 |
+
------------------------------------------------------------------
|
11 |
+
$wpdb->pollsq = $table_prefix . 'pollsq';
|
12 |
+
$wpdb->pollsa = $table_prefix . 'pollsa';
|
13 |
+
$wpdb->pollsip = $table_prefix . 'pollsip';
|
14 |
+
------------------------------------------------------------------
|
15 |
+
|
16 |
+
|
17 |
+
// Open wp-admin/menu.php
|
18 |
+
|
19 |
+
Find:
|
20 |
+
------------------------------------------------------------------
|
21 |
+
$menu[20] = array(__('Links'), 5, 'link-manager.php');
|
22 |
+
------------------------------------------------------------------
|
23 |
+
Add Below It:
|
24 |
+
------------------------------------------------------------------
|
25 |
+
$menu[21] = array(__('Polls'), 5, 'polls-manager.php');
|
26 |
+
------------------------------------------------------------------
|
27 |
+
|
28 |
+
// Open wp-admin folder
|
29 |
+
|
30 |
+
Put:
|
31 |
+
------------------------------------------------------------------
|
32 |
+
polls-install.php
|
33 |
+
polls-manager.php
|
34 |
+
polls-options.php
|
35 |
+
------------------------------------------------------------------
|
36 |
+
|
37 |
+
|
38 |
+
// Open wp-content/plugins folder
|
39 |
+
|
40 |
+
Put:
|
41 |
+
------------------------------------------------------------------
|
42 |
+
polls.php
|
43 |
+
------------------------------------------------------------------
|
44 |
+
|
45 |
+
// Open Wordpress root folder
|
46 |
+
|
47 |
+
Put:
|
48 |
+
------------------------------------------------------------------
|
49 |
+
wp-polls.php
|
50 |
+
------------------------------------------------------------------
|
51 |
+
|
52 |
+
|
53 |
+
// Open wp-images folder
|
54 |
+
|
55 |
+
Put:
|
56 |
+
------------------------------------------------------------------
|
57 |
+
pollbar.gif
|
58 |
+
------------------------------------------------------------------
|
59 |
+
|
60 |
+
|
61 |
+
// Activate the polls plugin
|
62 |
+
|
63 |
+
|
64 |
+
// Run wp-admin/polls-install.php
|
65 |
+
|
66 |
+
Note:
|
67 |
+
------------------------------------------------------------------
|
68 |
+
Please remember to remove polls-install.php after installation.
|
69 |
+
------------------------------------------------------------------
|
70 |
+
|
71 |
+
|
72 |
+
// Open wp-content/themes/<YOUR THEME NAME>/header.php
|
73 |
+
|
74 |
+
Add on the first line:
|
75 |
+
------------------------------------------------------------------
|
76 |
+
<?php vote_poll(); ?>
|
77 |
+
------------------------------------------------------------------
|
78 |
+
|
79 |
+
Note:
|
80 |
+
------------------------------------------------------------------
|
81 |
+
If you are having problem with the above, try putting it in the
|
82 |
+
wp-content/themes/<YOUR THEME NAME>/index.php instead.
|
83 |
+
------------------------------------------------------------------
|
84 |
+
|
85 |
+
|
86 |
+
// Open wp-content/themes/<YOUR THEME NAME>/sidebar.php
|
87 |
+
|
88 |
+
Add:
|
89 |
+
------------------------------------------------------------------
|
90 |
+
<li>
|
91 |
+
<h2>Polls</h2>
|
92 |
+
<ul><?php get_poll();?></ul>
|
93 |
+
<p><a href="wp-polls.php">Polls Archive</a></p>
|
94 |
+
</li>
|
95 |
+
------------------------------------------------------------------
|
96 |
+
|
97 |
+
Note:
|
98 |
+
------------------------------------------------------------------
|
99 |
+
To show specific poll, use <?php get_poll(<ID>);?> where <ID> is your
|
100 |
+
poll id.
|
101 |
+
------------------------------------------------------------------
|
readme-upgrade.txt
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-> Upgrade Instructions FOr Version 2.0x To Version 2.02
|
2 |
+
------------------------------------------------------------------
|
3 |
+
// Open wp-admin folder
|
4 |
+
|
5 |
+
Put:
|
6 |
+
------------------------------------------------------------------
|
7 |
+
polls-upgrade-202.php
|
8 |
+
------------------------------------------------------------------
|
9 |
+
|
10 |
+
// Run wp-admin/polls-upgrade-202.php
|
11 |
+
|
12 |
+
Note:
|
13 |
+
------------------------------------------------------------------
|
14 |
+
Please remember to remove polls-upgrade-202.php after installation.
|
15 |
+
------------------------------------------------------------------
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
-> Upgrade Instructions For Version 1.0x To Version 2.02
|
27 |
+
------------------------------------------------------------------
|
28 |
+
// Open wp-settings.php
|
29 |
+
|
30 |
+
Find:
|
31 |
+
------------------------------------------------------------------
|
32 |
+
$wpdb->pollsq = $table_prefix . 'pollsq';
|
33 |
+
------------------------------------------------------------------
|
34 |
+
Add Below It:
|
35 |
+
------------------------------------------------------------------
|
36 |
+
$wpdb->pollsip = $table_prefix . 'pollsip';
|
37 |
+
------------------------------------------------------------------
|
38 |
+
|
39 |
+
|
40 |
+
// Open wp-admin folder
|
41 |
+
|
42 |
+
Put/Overwrite:
|
43 |
+
------------------------------------------------------------------
|
44 |
+
polls-upgrade.php
|
45 |
+
polls-manager.php
|
46 |
+
polls-options.php
|
47 |
+
------------------------------------------------------------------
|
48 |
+
|
49 |
+
|
50 |
+
// Open wp-content/plugins folder
|
51 |
+
|
52 |
+
Put/Overwrite:
|
53 |
+
------------------------------------------------------------------
|
54 |
+
polls.php
|
55 |
+
------------------------------------------------------------------
|
56 |
+
|
57 |
+
|
58 |
+
// Open Wordpress root folder
|
59 |
+
|
60 |
+
Put/Overwrite:
|
61 |
+
------------------------------------------------------------------
|
62 |
+
wp-polls.php
|
63 |
+
------------------------------------------------------------------
|
64 |
+
|
65 |
+
|
66 |
+
// Run wp-admin/polls-upgrade.php
|
67 |
+
|
68 |
+
Note:
|
69 |
+
------------------------------------------------------------------
|
70 |
+
Please remember to remove polls-upgrade.php after installation.
|
71 |
+
------------------------------------------------------------------
|
readme.txt
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 -> 17th November 2005
|
8 |
+
--------------------------------------------------
|
9 |
+
Notes -> Minium level required to add/edit/delete polls is 8
|
10 |
+
-> Please backup your database before trying to install this plugin
|
11 |
+
--------------------------------------------------
|
12 |
+
|
13 |
+
|
14 |
+
// Version 2.02a (17-11-2005)
|
15 |
+
- FIXED: poll-install.php And poll-upgrade.php will Now Be Installed/Upgraded To 2.02 Instead Of 2.01
|
16 |
+
|
17 |
+
// Version 2.02 (05-11-2005)
|
18 |
+
- FIXED: Showing 0 Vote On Poll Edit Page
|
19 |
+
- FIXED: Null Vote Being Counted As A Vote
|
20 |
+
- FIXED: Auto Loading Of Poll Option: Polls Per Page In Poll Archive Page Is Now "No"
|
21 |
+
- ADDED: Host Column In Poll IP Table To Prevent Network Lagging When Resolving IP
|
22 |
+
- ADDED: New Poll Error Template
|
23 |
+
|
24 |
+
// Version 2.01 (25-10-2005)
|
25 |
+
- FIXED: Upgrade Script To Insert Lastest Poll ID Of User's Current Polls, Instead Of Poll ID 1
|
26 |
+
- FIXED: Replace All <?= With <?php
|
27 |
+
- FIXED: Added addalshes() To $pollip_user
|
28 |
+
- FIXED: Better Localization Support (80% Done, Will Leave It In The Mean Time)
|
29 |
+
|
30 |
+
// Version 2.0 (20-10-2005)
|
31 |
+
- ADDED: IP Logging
|
32 |
+
- ADDED: Poll Options: Sorting Of Answers In Voting Form
|
33 |
+
- ADDED: Poll Options: Sorting Of Answers In Results View
|
34 |
+
- ADDED: Poll Options: Number Of Polls Per Page In Poll Archive
|
35 |
+
- ADDED: Poll Options: Choose Poll To Display On Index Page
|
36 |
+
- ADDED: Poll Options: Able To Disable Poll With Custom Message
|
37 |
+
- ADDED: Poll Options: Poll Templates
|
38 |
+
- ADDED: Display User's Voted Choice
|
39 |
+
- FIXED: Better Install/Upgrade Script
|
wp-polls.php
ADDED
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
+----------------------------------------------------------------+
|
4 |
+
| |
|
5 |
+
| WordPress 1.5 Plugin: WP-Polls 2.02 |
|
6 |
+
| Copyright (c) 2005 Lester "GaMerZ" Chan |
|
7 |
+
| |
|
8 |
+
| File Written By: |
|
9 |
+
| - Lester "GaMerZ" Chan |
|
10 |
+
| - http://www.lesterchan.net |
|
11 |
+
| |
|
12 |
+
| File Information: |
|
13 |
+
| - Poll Archive |
|
14 |
+
| - wp-polls.php |
|
15 |
+
| |
|
16 |
+
+----------------------------------------------------------------+
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
### Wordpress Header
|
21 |
+
require('wp-blog-header.php');
|
22 |
+
|
23 |
+
### Process Votes
|
24 |
+
vote_poll();
|
25 |
+
|
26 |
+
### Polls Variables
|
27 |
+
$page = intval($_GET['page']);
|
28 |
+
$polls_questions = array();
|
29 |
+
$polls_answers = array();
|
30 |
+
$polls_ip = array();
|
31 |
+
$polls_perpage = intval(get_settings('poll_archive_perpage'));
|
32 |
+
$poll_questions_ids = '0';
|
33 |
+
$poll_voted = false;
|
34 |
+
$poll_voted_aid = 0;
|
35 |
+
$poll_id = 0;
|
36 |
+
|
37 |
+
### Get Total Polls
|
38 |
+
$total_polls = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
|
39 |
+
|
40 |
+
### Checking $page and $offset
|
41 |
+
if (empty($page) || $page == 0) { $page = 1; }
|
42 |
+
if (empty($offset)) { $offset = 0; }
|
43 |
+
|
44 |
+
### Determin $offset
|
45 |
+
$offset = ($page-1) * $polls_perpage;
|
46 |
+
|
47 |
+
### Determine Max Number Of Polls To Display On Page
|
48 |
+
if(($offset + $polls_perpage) > $total_polls) {
|
49 |
+
$max_on_page = $total_polls;
|
50 |
+
} else {
|
51 |
+
$max_on_page = ($offset + $polls_perpage);
|
52 |
+
}
|
53 |
+
|
54 |
+
### Determine Number Of Polls To Display On Page
|
55 |
+
if (($offset + 1) > ($total_polls)) {
|
56 |
+
$display_on_page = $total_polls;
|
57 |
+
} else {
|
58 |
+
$display_on_page = ($offset + 1);
|
59 |
+
}
|
60 |
+
|
61 |
+
### Determing Total Amount Of Pages
|
62 |
+
$total_pages = ceil($total_polls / $polls_perpage);
|
63 |
+
|
64 |
+
### Make Sure Poll Is Not Disabled
|
65 |
+
if(intval(get_settings('poll_currentpoll')) != -1 && $page < 2) {
|
66 |
+
// Hardcoded Poll ID Is Not Specified
|
67 |
+
if(intval($temp_poll_id) == 0) {
|
68 |
+
// Current Poll ID Is Not Specified
|
69 |
+
if(intval(get_settings('poll_currentpoll')) == 0) {
|
70 |
+
// Get Lastest Poll ID
|
71 |
+
$poll_id = intval(get_settings('poll_latestpoll'));
|
72 |
+
} else {
|
73 |
+
// Get Current Poll ID
|
74 |
+
$poll_id = intval(get_settings('poll_currentpoll'));
|
75 |
+
}
|
76 |
+
// Get Hardcoded Poll ID
|
77 |
+
} else {
|
78 |
+
$poll_id = intval($temp_poll_id);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
### Get Poll Questions
|
83 |
+
$questions = $wpdb->get_results("SELECT * FROM $wpdb->pollsq WHERE pollq_id != $poll_id ORDER BY pollq_id DESC LIMIT $offset, $polls_perpage");
|
84 |
+
if($questions) {
|
85 |
+
foreach($questions as $question) {
|
86 |
+
$polls_questions[] = array('id' => intval($question->pollq_id), 'question' => stripslashes($question->pollq_question), 'timestamp' => $question->pollq_timestamp, 'totalvotes' => intval($question->pollq_totalvotes));
|
87 |
+
$poll_questions_ids .= intval($question->pollq_id).', ';
|
88 |
+
}
|
89 |
+
$poll_questions_ids = substr($poll_questions_ids, 0, -2);
|
90 |
+
}
|
91 |
+
|
92 |
+
### Get Poll Answers
|
93 |
+
$answers = $wpdb->get_results("SELECT polla_aid, polla_qid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid IN ($poll_questions_ids) ORDER BY ".get_settings('poll_ans_result_sortby').' '.get_settings('poll_ans_result_sortorder'));
|
94 |
+
if($answers) {
|
95 |
+
foreach($answers as $answer) {
|
96 |
+
$polls_answers[] = array('aid' => intval($answer->polla_aid), 'qid' => intval($answer->polla_qid), 'answers' => stripslashes($answer->polla_answers), 'votes' => intval($answer->polla_votes));
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
### Get Poll IPs
|
101 |
+
$ips = $wpdb->get_results("SELECT pollip_qid, pollip_aid FROM $wpdb->pollsip WHERE pollip_qid IN ($poll_questions_ids) AND pollip_ip = '".get_ipaddress()."'");
|
102 |
+
if($ips) {
|
103 |
+
foreach($ips as $ip) {
|
104 |
+
$polls_ips[] = array('qid' => intval($ip->pollip_qid), 'aid' => intval($ip->pollip_aid));
|
105 |
+
}
|
106 |
+
}
|
107 |
+
### Function: Check Voted To Get Voted Answer
|
108 |
+
function check_voted($poll_id) {
|
109 |
+
global $polls_ips;
|
110 |
+
$temp_voted_aid = 0;
|
111 |
+
if(intval($_COOKIE["voted_$poll_id"]) > 0) {
|
112 |
+
$temp_voted_aid = intval($_COOKIE["voted_$poll_id"]);
|
113 |
+
} else {
|
114 |
+
if($polls_ips) {
|
115 |
+
foreach($polls_ips as $polls_ip) {
|
116 |
+
if($polls_ip['qid'] == $poll_id) {
|
117 |
+
$temp_voted_aid = $polls_ip['aid'];
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
return $temp_voted_aid;
|
123 |
+
}
|
124 |
+
?>
|
125 |
+
<?php get_header(); ?>
|
126 |
+
<div id="content" class="narrowcolumn">
|
127 |
+
<?php
|
128 |
+
if($page < 2) {
|
129 |
+
echo "<!-- <Currrent Poll> -->\n";
|
130 |
+
echo '<h2 class="pagetitle">'.__('Current Poll').'</h2>'."\n";
|
131 |
+
// Current Poll
|
132 |
+
if(intval(get_settings('poll_currentpoll')) == -1) {
|
133 |
+
echo get_settings('poll_template_disable');
|
134 |
+
} else {
|
135 |
+
// User Click on View Results Link
|
136 |
+
if(intval($_GET['pollresult']) == 1) {
|
137 |
+
display_pollresult($poll_id);
|
138 |
+
// Check Whether User Has Voted
|
139 |
+
} else {
|
140 |
+
// Check Cookie First
|
141 |
+
$voted_cookie = check_voted_cookie($poll_id);
|
142 |
+
if($voted_cookie > 0) {
|
143 |
+
display_pollresult($poll_id, $voted_cookie);
|
144 |
+
// Check IP If Cookie Cannot Be Found
|
145 |
+
} else {
|
146 |
+
$voted_ip = check_voted_ip($poll_id);
|
147 |
+
if($voted_ip > 0) {
|
148 |
+
display_pollresult($poll_id, $voted_ip);
|
149 |
+
// User Never Vote. Display Poll Voting Form
|
150 |
+
} else {
|
151 |
+
display_pollvote($poll_id);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
echo "<!-- </Currrent Poll> -->\n";
|
157 |
+
}
|
158 |
+
?>
|
159 |
+
<!-- <Poll Archives> -->
|
160 |
+
<h2 class="pagetitle"><?php _e('Polls Archive'); ?></h2>
|
161 |
+
<?php
|
162 |
+
foreach($polls_questions as $polls_question) {
|
163 |
+
// Is The Poll Total Votes 0?
|
164 |
+
$poll_totalvotes_zero = true;
|
165 |
+
if($polls_question['totalvotes'] > 0) {
|
166 |
+
$poll_totalvotes_zero = false;
|
167 |
+
}
|
168 |
+
// Poll Question Variables
|
169 |
+
$template_question = stripslashes(get_settings('poll_template_resultheader'));
|
170 |
+
$template_question = str_replace("%POLL_QUESTION%", $polls_question['question'], $template_question);
|
171 |
+
$template_question = str_replace("%POLL_ID%", $polls_question['id'], $template_question);
|
172 |
+
$template_question = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_question);
|
173 |
+
// Print Out Result Header Template
|
174 |
+
echo $template_question;
|
175 |
+
foreach($polls_answers as $polls_answer) {
|
176 |
+
if($polls_question['id'] == $polls_answer['qid']) {
|
177 |
+
// Calculate Percentage And Image Bar Width
|
178 |
+
if(!$poll_totalvotes_zero) {
|
179 |
+
if($polls_answer['votes'] > 0) {
|
180 |
+
$poll_answer_percentage = round((($polls_answer['votes']/$polls_question['totalvotes'])*100));
|
181 |
+
$poll_answer_imagewidth = round($poll_answer_percentage*0.9);
|
182 |
+
} else {
|
183 |
+
$poll_answer_percentage = 0;
|
184 |
+
$poll_answer_imagewidth = 1;
|
185 |
+
}
|
186 |
+
} else {
|
187 |
+
$poll_answer_percentage = 0;
|
188 |
+
$poll_answer_imagewidth = 1;
|
189 |
+
}
|
190 |
+
// Let User See What Options They Voted
|
191 |
+
if(check_voted($polls_question['id']) == $polls_answer['aid']) {
|
192 |
+
// Results Body Variables
|
193 |
+
$template_answer = stripslashes(get_settings('poll_template_resultbody2'));
|
194 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
|
195 |
+
$template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
|
196 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
|
197 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
198 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
199 |
+
// Print Out Results Body Template
|
200 |
+
echo $template_answer;
|
201 |
+
} else {
|
202 |
+
// Results Body Variables
|
203 |
+
$template_answer = stripslashes(get_settings('poll_template_resultbody'));
|
204 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
|
205 |
+
$template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
|
206 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
|
207 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
208 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
209 |
+
// Print Out Results Body Template
|
210 |
+
echo $template_answer;
|
211 |
+
}
|
212 |
+
// Delete Away From Array
|
213 |
+
unset($polls_answer['answers']);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
// Results Footer Variables
|
217 |
+
$template_footer = stripslashes(get_settings('poll_template_resultfooter'));
|
218 |
+
$template_footer = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_footer);
|
219 |
+
// Print Out Results Footer Template
|
220 |
+
echo $template_footer;
|
221 |
+
echo "<br /><hr class=\"Divider\" />\n";
|
222 |
+
}
|
223 |
+
?>
|
224 |
+
<!-- </Poll Archives> -->
|
225 |
+
|
226 |
+
<!-- <Paging> -->
|
227 |
+
<?php
|
228 |
+
if($total_polls > 0) {
|
229 |
+
?>
|
230 |
+
<br />
|
231 |
+
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
232 |
+
<tr>
|
233 |
+
<td align="left" width="50%">
|
234 |
+
<?php
|
235 |
+
if($page > 1 && ((($page*$polls_perpage)-($polls_perpage-1)) <= $total_polls)) {
|
236 |
+
echo '<b>«</b> <a href="wp-polls.php?page='.($page-1).'" title="« '.__('Previous Page').'">'.__('Previous Page').'</a>';
|
237 |
+
} else {
|
238 |
+
echo ' ';
|
239 |
+
}
|
240 |
+
?>
|
241 |
+
</td>
|
242 |
+
<td align="right" width="50%">
|
243 |
+
<?php
|
244 |
+
if($page >= 1 && ((($page*$polls_perpage)+1) <= $total_polls)) {
|
245 |
+
echo '<a href="wp-polls.php?page='.($page+1).'" title="'.__('Next Page').' »">'.__('Next Page').'</a> <b>»</b>';
|
246 |
+
} else {
|
247 |
+
echo ' ';
|
248 |
+
}
|
249 |
+
?>
|
250 |
+
</td>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<td colspan="2" align="center">
|
254 |
+
<?php _e('Pages'); ?> (<?echo $total_pages; ?>) :
|
255 |
+
<?php
|
256 |
+
if ($page >= 4) {
|
257 |
+
echo '<b><a href="wp-polls.php?page=1" title="'.__('Go to First Page').'">« '.__('First').'</a></b> ... ';
|
258 |
+
}
|
259 |
+
if($page > 1) {
|
260 |
+
echo ' <b><a href="wp-polls.php?page='.($page-1).'" title="« '.__('Go to Page').' '.($page-1).'">«</a></b> ';
|
261 |
+
}
|
262 |
+
for($i = $page - 2 ; $i <= $page +2; $i++) {
|
263 |
+
if ($i >= 1 && $i <= $total_pages) {
|
264 |
+
if($i == $page) {
|
265 |
+
echo "<b>[$i]</b> ";
|
266 |
+
} else {
|
267 |
+
echo '<a href="wp-polls.php?page='.($i).'" title="'.__('Page').' '.$i.'">'.$i.'</a> ';
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
if($page < $total_pages) {
|
272 |
+
echo ' <b><a href="wp-polls.php?page='.($page+1).'" title="'.__('Go to Page').' '.($page+1).' »">»</a></b> ';
|
273 |
+
}
|
274 |
+
if (($page+2) < $total_pages) {
|
275 |
+
echo ' ... <b><a href="wp-polls.php?page='.($total_pages).'" title="'.__('Go to Last Page').'">'.__('Last').' »</a></b>';
|
276 |
+
}
|
277 |
+
?>
|
278 |
+
</td>
|
279 |
+
</tr>
|
280 |
+
</table>
|
281 |
+
<!-- </Paging> -->
|
282 |
+
<?php
|
283 |
+
}
|
284 |
+
?>
|
285 |
+
</div>
|
286 |
+
<?php
|
287 |
+
get_sidebar();
|
288 |
+
get_footer();
|
289 |
+
?>
|