WP-Polls - Version 2.10

Version Description

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Polls
Version 2.10
Comparing to
See all releases

Version 2.10

polls/images/loading.gif ADDED
Binary file
polls/images/pollbar.gif ADDED
Binary file
polls/images/pollend.gif ADDED
Binary file
polls/images/pollstart.gif ADDED
Binary file
polls/polls-css.css ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-Polls 2.1 |
5
+ | Copyright (c) 2006 Lester "GaMerZ" Chan |
6
+ | |
7
+ | File Written By: |
8
+ | - Lester "GaMerZ" Chan |
9
+ | - http://www.lesterchan.net |
10
+ | |
11
+ | File Information: |
12
+ | - Polls CSS File |
13
+ | - wp-content/plugins/polls/polls-css.css |
14
+ | |
15
+ +----------------------------------------------------------------+
16
+ */
17
+
18
+
19
+ .wp-polls ul li, wp-polls-ul li, .wp-polls-ans ul li, .post ul li, .post li {
20
+ text-align: left;
21
+ list-style: none;
22
+ }
23
+ .wp-polls ul li:before, wp-polls-ul li, .wp-polls-ans ul li:before, #sidebar ul ul li:before {
24
+ content: '';
25
+ }
26
+ .wp-polls-ans {
27
+ width:100%;
28
+ filter: alpha(opacity=100);
29
+ -moz-opacity: 1;
30
+ opacity: 1;
31
+ /* background-color: #ffffff; */
32
+ }
33
+ .wp-polls-loading {
34
+ display: none;
35
+ text-align: center;
36
+ height: 16px;
37
+ }
polls/polls-js.js ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-Polls 2.1 |
5
+ | Copyright (c) 2006 Lester "GaMerZ" Chan |
6
+ | |
7
+ | File Written By: |
8
+ | - Lester "GaMerZ" Chan |
9
+ | - http://www.lesterchan.net |
10
+ | |
11
+ | File Information: |
12
+ | - Polls Javascript File |
13
+ | - wp-content/plugins/polls/polls-js.js |
14
+ | |
15
+ +----------------------------------------------------------------+
16
+ */
17
+
18
+
19
+ // Variables
20
+ var polls = new sack('index.php');
21
+ var poll_id = 0;
22
+ var poll_answer_id = 0;
23
+ var poll_fadein_opacity = 0;
24
+ var poll_fadeout_opacity = 100;
25
+ var is_ie = (document.all && document.getElementById);
26
+ var is_moz = (!document.all && document.getElementById);
27
+ var is_being_voted = false;
28
+
29
+ // When User Vote For Poll
30
+ function poll_vote(current_poll_id) {
31
+ if(!is_being_voted) {
32
+ is_being_voted = true;
33
+ poll_id = current_poll_id;
34
+ poll_form = document.getElementById('polls_form_' + poll_id);
35
+ poll_answer = eval("poll_form.poll_" + poll_id);
36
+ poll_answer_id = 0;
37
+ for(i = 0; i < poll_answer.length; i++) {
38
+ if (poll_answer[i].checked) {
39
+ poll_answer_id = poll_answer[i].value;
40
+ }
41
+ }
42
+ if(poll_answer_id > 0) {
43
+ poll_loading_text();
44
+ poll_process();
45
+ } else {
46
+ alert("Please choose a valid poll answer.");
47
+ }
48
+ } else {
49
+ alert("Your last request is still being processed. Please wait a while ...");
50
+ }
51
+ }
52
+
53
+
54
+ // When User View Poll's Result
55
+ function poll_result(current_poll_id) {
56
+ if(!is_being_voted) {
57
+ is_being_voted = true;
58
+ poll_id = current_poll_id;
59
+ poll_loading_text();
60
+ poll_process_result();
61
+ } else {
62
+ alert("Your last request is still being processed. Please wait a while ...");
63
+ }
64
+ }
65
+
66
+
67
+ // When User View Poll's Voting Booth
68
+ function poll_booth(current_poll_id) {
69
+ if(!is_being_voted) {
70
+ is_being_voted = true;
71
+ poll_id = current_poll_id;
72
+ poll_loading_text();
73
+ poll_process_booth();
74
+ } else {
75
+ alert("Your last request is still being processed. Please wait a while ...");
76
+ }
77
+ }
78
+
79
+
80
+ // Poll Fade In Text
81
+ function poll_fadein_text() {
82
+ if(poll_fadein_opacity == 90) {
83
+ poll_unloading_text();
84
+ }
85
+ if(poll_fadein_opacity < 100) {
86
+ poll_fadein_opacity += 10;
87
+ if(is_ie) document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadein_opacity;
88
+ if(is_moz) document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadein_opacity/100);
89
+ setTimeout("poll_fadein_text()", 100);
90
+ } else {
91
+ poll_fadein_opacity = 100;
92
+ is_being_voted = false;
93
+ }
94
+ }
95
+
96
+
97
+ // Poll Loading Text
98
+ function poll_loading_text() {
99
+ document.getElementById('polls-' + poll_id + '-loading').style.display = 'block';
100
+ }
101
+
102
+
103
+ // Poll Finish Loading Text
104
+ function poll_unloading_text() {
105
+ document.getElementById('polls-' + poll_id + '-loading').style.display = 'none';
106
+ }
107
+
108
+
109
+ // Process The Poll
110
+ function poll_process() {
111
+ if(poll_fadeout_opacity > 0) {
112
+ poll_fadeout_opacity -= 10;
113
+ if(is_ie) document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
114
+ if(is_moz) document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
115
+ setTimeout("poll_process()", 100);
116
+ } else {
117
+ poll_fadeout_opacity = 0;
118
+ polls.setVar("vote", true);
119
+ polls.setVar("poll_id", poll_id);
120
+ polls.setVar("poll_" + poll_id, poll_answer_id);
121
+ polls.method = 'POST';
122
+ polls.element = 'polls-' + poll_id + '-ans';
123
+ polls.onCompletion = poll_fadein_text;
124
+ polls.runAJAX();
125
+ poll_fadein_opacity = 0;
126
+ poll_fadeout_opacity = 100;
127
+ }
128
+ }
129
+
130
+
131
+ // Process Poll's Result
132
+ function poll_process_result() {
133
+ if(poll_fadeout_opacity > 0) {
134
+ poll_fadeout_opacity -= 10;
135
+ if(is_ie) document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
136
+ if(is_moz) document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
137
+ setTimeout("poll_process_result()", 100);
138
+ } else {
139
+ poll_fadeout_opacity = 0;
140
+ polls.setVar("pollresult", poll_id);
141
+ polls.method = 'GET';
142
+ polls.element = 'polls-' + poll_id + '-ans';
143
+ polls.onCompletion = poll_fadein_text;
144
+ polls.runAJAX();
145
+ poll_fadein_opacity = 0;
146
+ poll_fadeout_opacity = 100;
147
+ }
148
+ }
149
+
150
+
151
+ // Process Poll's Voting Booth
152
+ function poll_process_booth() {
153
+ if(poll_fadeout_opacity > 0) {
154
+ poll_fadeout_opacity -= 10;
155
+ if(is_ie) document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
156
+ if(is_moz) document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
157
+ setTimeout("poll_process_booth()", 100);
158
+ } else {
159
+ poll_fadeout_opacity = 0;
160
+ polls.setVar("pollbooth", poll_id);
161
+ polls.method = 'GET';
162
+ polls.element = 'polls-' + poll_id + '-ans';
163
+ polls.onCompletion = poll_fadein_text;
164
+ polls.runAJAX();
165
+ poll_fadein_opacity = 0;
166
+ poll_fadeout_opacity = 100;
167
+ }
168
+ }
polls/polls-manager.php ADDED
@@ -0,0 +1,713 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.1 |
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
+ | - Manage Your Polls |
14
+ | - wp-content/plugins/polls/polls-manager.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Check Whether User Can Manage Polls
21
+ if(!current_user_can('manage_polls')) {
22
+ die('Access Denied');
23
+ }
24
+
25
+
26
+ ### Variables Variables Variables
27
+ $base_name = plugin_basename('polls/polls-manager.php');
28
+ $base_page = 'admin.php?page='.$base_name;
29
+ $mode = trim($_GET['mode']);
30
+ $poll_id = intval($_GET['id']);
31
+ $poll_aid = intval($_GET['aid']);
32
+
33
+
34
+ ### Form Processing
35
+ if(!empty($_POST['do'])) {
36
+ // Decide What To Do
37
+ switch($_POST['do']) {
38
+ // Add Poll
39
+ case 'Add Poll':
40
+ // Add Poll Question
41
+ $pollq_question = addslashes(trim($_POST['pollq_question']));
42
+ $pollq_timestamp = current_time('timestamp');
43
+ $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollq_question', '$pollq_timestamp', 0, 1)");
44
+ if(!$add_poll_question) {
45
+ $text .= '<font color="red">Error In Adding Poll \''.stripslashes($pollq_question).'\'</font>';
46
+ }
47
+ // Add Poll Answers
48
+ $polla_answers = $_POST['polla_answers'];
49
+ $polla_qid = intval($wpdb->insert_id);
50
+ foreach($polla_answers as $polla_answer) {
51
+ $polla_answer = addslashes(trim($polla_answer));
52
+ $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answer', 0)");
53
+ if(!$add_poll_answers) {
54
+ $text .= '<font color="red">Error In Adding Poll\'s Answer \''.stripslashes($polla_answer).'\'</font>';
55
+ }
56
+ }
57
+ // Update Lastest Poll ID To Poll Options
58
+ $update_latestpoll = update_option('poll_latestpoll', $polla_qid);
59
+ if(!$update_latestpoll) {
60
+ $text .= "<font color=\"red\">There Is An Error Updating The Lastest Poll ID ($polla_qid) To The Poll Option</font>";
61
+ }
62
+ if(empty($text)) {
63
+ $text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Added Successfully</font>';
64
+ }
65
+ break;
66
+ // Edit Poll
67
+ case 'Edit Poll':
68
+ // Update Poll's Question
69
+ $pollq_id = intval($_POST['pollq_id']);
70
+ $pollq_totalvotes = intval($_POST['pollq_totalvotes']);
71
+ $pollq_question = addslashes(trim($_POST['pollq_question']));
72
+ $edit_polltimestamp = intval($_POST['edit_polltimestamp']);
73
+ $timestamp_sql = '';
74
+ if($edit_polltimestamp == 1) {
75
+ $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']);
76
+ $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']);
77
+ $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']);
78
+ $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']);
79
+ $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']);
80
+ $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']);
81
+ $timestamp_sql = ", pollq_timestamp = '".gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year)."'";
82
+ }
83
+
84
+ $edit_poll_question = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_question = '$pollq_question', pollq_totalvotes = $pollq_totalvotes $timestamp_sql WHERE pollq_id = $pollq_id");
85
+ if(!$edit_poll_question) {
86
+ $text = '<font color="blue">No Changes Had Been Made To Poll\'s Title \''.stripslashes($pollq_question).'\'</font>';
87
+ }
88
+ // Update Polls' Answers
89
+ $polla_aids = array();
90
+ $get_polla_aids = $wpdb->get_results("SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = $pollq_id ORDER BY polla_aid ASC");
91
+ if($get_polla_aids) {
92
+ foreach($get_polla_aids as $get_polla_aid) {
93
+ $polla_aids[] = intval($get_polla_aid->polla_aid);
94
+ }
95
+ foreach($polla_aids as $polla_aid) {
96
+ $polla_answers = addslashes(trim($_POST['polla_aid-'.$polla_aid]));
97
+ $polla_votes = intval($_POST['polla_votes-'.$polla_aid]);
98
+ $edit_poll_answer = $wpdb->query("UPDATE $wpdb->pollsa SET polla_answers = '$polla_answers', polla_votes = $polla_votes WHERE polla_qid = $pollq_id AND polla_aid = $polla_aid");
99
+ if(!$edit_poll_answer) {
100
+ $text .= '<br /><font color="blue">No Changes Had Been Made To Poll\'s Answer \''.stripslashes($polla_answers).'\'</font>';
101
+ }
102
+ }
103
+ } else {
104
+ $text .= '<br /><font color="red">Invalid Poll \''.stripslashes($pollq_question).'\'</font>';
105
+ }
106
+ if(empty($text)) {
107
+ $text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Edited Successfully</font>';
108
+ }
109
+ break;
110
+ // Open Poll
111
+ case 'Open Poll':
112
+ $pollq_id = intval($_POST['pollq_id']);
113
+ $pollq_question = addslashes(trim($_POST['pollq_question']));
114
+ $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 1 WHERE pollq_id = $pollq_id;");
115
+ if($close_poll) {
116
+ $text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Is Now Opened</font>';
117
+ } else {
118
+ $text = '<font color="red">Error Opening Poll \''.stripslashes($pollq_question).'\'</font>';
119
+ }
120
+ break;
121
+ // Close Poll
122
+ case 'Close Poll':
123
+ $pollq_id = intval($_POST['pollq_id']);
124
+ $pollq_question = addslashes(trim($_POST['pollq_question']));
125
+ $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 0 WHERE pollq_id = $pollq_id;");
126
+ if($close_poll) {
127
+ $text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Is Now Closed</font>';
128
+ } else {
129
+ $text = '<font color="red">Error Closing Poll \''.stripslashes($pollq_question).'\'</font>';
130
+ }
131
+ break;
132
+ // Delete Poll
133
+ case 'Delete Poll':
134
+ $pollq_id = intval($_POST['pollq_id']);
135
+ $pollq_question = trim($_POST['pollq_question']);
136
+ $delete_poll_question = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE pollq_id = $pollq_id");
137
+ $delete_poll_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_qid = $pollq_id");
138
+ $delete_poll_ip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id");
139
+ $poll_option_lastestpoll = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'");
140
+ if(!$delete_poll_question) {
141
+ $text = '<font color="red">Error In Deleting Poll \''.stripslashes($pollq_question).'\' Question</font>';
142
+ }
143
+ if(!$delete_poll_answers) {
144
+ $text .= '<br /><font color="red">Error In Deleting Poll Answers For \''.stripslashes($pollq_question).'\'</font>';
145
+ }
146
+ if(!$delete_poll_ip) {
147
+ $text .= '<br /><font color="red">Error In Deleting Voted IPs For \''.stripslashes($pollq_question).'\'</font>';
148
+ }
149
+ if(empty($text)) {
150
+ if($poll_option_lastestpoll == $pollq_id) {
151
+ $poll_lastestpoll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq ORDER BY pollq_id DESC LIMIT 1");
152
+ if($poll_lastestpoll) {
153
+ $poll_lastestpoll = intval($poll_lastestpoll);
154
+ update_option('poll_latestpoll', $poll_lastestpoll);
155
+ }
156
+ }
157
+ $text = '<font color="green">Poll \''.stripslashes($pollq_question).'\' Deleted Successfully</font>';
158
+ }
159
+ break;
160
+ // Add Poll's Answer
161
+ case 'Add Answer':
162
+ $polla_qid = intval($_POST['polla_qid']);
163
+ $polla_answers = addslashes(trim($_POST['polla_answers']));
164
+ $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answers', 0)");
165
+ if(!$add_poll_question) {
166
+ $text = '<font color="red">Error In Adding Poll Answer \''.stripslashes($polla_answers).'\'</font>';
167
+ } else {
168
+ $text = '<font color="green">Poll Answer \''.stripslashes($polla_answers).'\' Added Successfully</font>';
169
+ }
170
+ break;
171
+ // Delete Polls Logs
172
+ case 'Delete All Logs':
173
+ if(trim($_POST['delete_logs_yes']) == 'yes') {
174
+ $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip");
175
+ if($delete_logs) {
176
+ $text = '<font color="green">All Polls Logs Have Been Deleted.</font>';
177
+ } else {
178
+ $text = '<font color="red">An Error Has Occured While Deleting All Polls Logs.</font>';
179
+ }
180
+ }
181
+ break;
182
+ // Delete Poll Logs For Individual Poll
183
+ case 'Delete Logs For This Poll Only':
184
+ $pollq_id = intval($_POST['pollq_id']);
185
+ if(trim($_POST['delete_logs_yes']) == 'yes') {
186
+ $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id");
187
+ if($delete_logs) {
188
+ $text = '<font color="green">All Logs For This Poll Has Been Deleted.</font>';
189
+ } else {
190
+ $text = '<font color="red">An Error Has Occured While Deleting All Logs For This Poll.</font>';
191
+ }
192
+ }
193
+ break;
194
+ }
195
+ }
196
+
197
+
198
+ ### Determines Which Mode It Is
199
+ switch($mode) {
200
+ // Add A Poll
201
+ case 'add':
202
+ ?>
203
+ <div class="wrap">
204
+ <h2><?php _e('Add Poll'); ?></h2>
205
+ <?php
206
+ if(isset($_POST['addpollquestion'])) {
207
+ $poll_noquestion = intval($_POST['poll_noquestion']);
208
+ $pollq_question = stripslashes(trim($_POST['pollq_question']));
209
+ ?>
210
+ <form action="<?php echo $base_page; ?>" method="post">
211
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
212
+ <tr>
213
+ <th align="left"><?php _e('Question') ?></th>
214
+ <td><input type="text" size="50" maxlength="200" name="pollq_question" value="<?php echo $pollq_question; ?>" /></td>
215
+ </tr>
216
+ <?php
217
+ for($i=1; $i<=$poll_noquestion; $i++) {
218
+ echo "<tr>\n";
219
+ echo "<th align=\"left\" scope=\"row\">Answers $i:</th>\n";
220
+ echo "<td><input type=\"text\" size=\"30\" maxlength=\"200\" name=\"polla_answers[]\" /></td>\n";
221
+ echo "</tr>\n";
222
+ }
223
+ ?>
224
+ <tr>
225
+ <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Poll'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
226
+ </tr>
227
+ </table>
228
+ </form>
229
+ <?php } else {?>
230
+ <form action="<?php echo $_SERVER['REQUEST_URI']; ?>&amp;mode=add" method="post">
231
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
232
+ <tr>
233
+ <th align="left"><?php _e('Question') ?></th>
234
+ <td><input type="text" size="50" maxlength="200" name="pollq_question" /></td>
235
+ </tr>
236
+ <th align="left"><?php _e('No. Of Answers:') ?></th>
237
+ <td>
238
+ <select size="1" name="poll_noquestion">
239
+ <?php
240
+ for($i=2; $i <= 20; $i++) {
241
+ echo "<option value=\"$i\">$i</option>";
242
+ }
243
+ ?>
244
+ </select>
245
+ </td>
246
+ </tr>
247
+ <tr>
248
+ <td colspan="2" align="center"><input type="submit" name="addpollquestion" value="<?php _e('Add Question'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
249
+ </tr>
250
+ </table>
251
+ </form>
252
+ <?php } ?>
253
+ </div>
254
+ <?php
255
+ break;
256
+ // Edit A Poll
257
+ case 'edit':
258
+ $poll_question = $wpdb->get_row("SELECT pollq_question, pollq_timestamp, pollq_totalvotes, pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
259
+ $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");
260
+ $poll_question_text = stripslashes($poll_question->pollq_question);
261
+ $poll_totalvotes = intval($poll_question->pollq_totalvote);
262
+ $poll_timestamp = $poll_question->pollq_timestamp;
263
+ $poll_active = intval($poll_question->pollq_active);
264
+
265
+ // Edit Timestamp Options
266
+ function poll_timestamp($poll_timestamp) {
267
+ global $month;
268
+ $day = gmdate('j', $poll_timestamp);
269
+ echo '<select name="pollq_timestamp_day" size="1">'."\n";
270
+ for($i = 1; $i <=31; $i++) {
271
+ if($day == $i) {
272
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
273
+ } else {
274
+ echo "<option value=\"$i\">$i</option>\n";
275
+ }
276
+ }
277
+ echo '</select>&nbsp;&nbsp;'."\n";
278
+ $month2 = gmdate('n', $poll_timestamp);
279
+ echo '<select name="pollq_timestamp_month" size="1">'."\n";
280
+ for($i = 1; $i <= 12; $i++) {
281
+ if ($i < 10) {
282
+ $ii = '0'.$i;
283
+ } else {
284
+ $ii = $i;
285
+ }
286
+ if($month2 == $i) {
287
+ echo "<option value=\"$i\" selected=\"selected\">$month[$ii]</option>\n";
288
+ } else {
289
+ echo "<option value=\"$i\">$month[$ii]</option>\n";
290
+ }
291
+ }
292
+ echo '</select>&nbsp;&nbsp;'."\n";
293
+ $year = gmdate('Y', $poll_timestamp);
294
+ echo '<select name="pollq_timestamp_year" size="1">'."\n";
295
+ for($i = 2000; $i <= gmdate('Y'); $i++) {
296
+ if($year == $i) {
297
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
298
+ } else {
299
+ echo "<option value=\"$i\">$i</option>\n";
300
+ }
301
+ }
302
+ echo '</select>&nbsp;@'."\n";
303
+ $hour = gmdate('H', $poll_timestamp);
304
+ echo '<select name="pollq_timestamp_hour" size="1">'."\n";
305
+ for($i = 0; $i < 24; $i++) {
306
+ if($hour == $i) {
307
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
308
+ } else {
309
+ echo "<option value=\"$i\">$i</option>\n";
310
+ }
311
+ }
312
+ echo '</select>&nbsp;:'."\n";
313
+ $minute = gmdate('i', $poll_timestamp);
314
+ echo '<select name="pollq_timestamp_minute" size="1">'."\n";
315
+ for($i = 0; $i < 60; $i++) {
316
+ if($minute == $i) {
317
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
318
+ } else {
319
+ echo "<option value=\"$i\">$i</option>\n";
320
+ }
321
+ }
322
+
323
+ echo '</select>&nbsp;:'."\n";
324
+ $second = gmdate('s', $poll_timestamp);
325
+ echo '<select name="pollq_timestamp_second" size="1">'."\n";
326
+ for($i = 0; $i <= 60; $i++) {
327
+ if($second == $i) {
328
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
329
+ } else {
330
+ echo "<option value=\"$i\">$i</option>\n";
331
+ }
332
+ }
333
+ echo '</select>'."\n";
334
+ }
335
+ ?>
336
+ <script type="text/javascript">
337
+ function check_totalvotes() {
338
+ var total_votes = 0;
339
+ var temp_vote = 0;
340
+ <?php
341
+ foreach($poll_answers as $poll_answer) {
342
+ $polla_aid = intval($poll_answer->polla_aid);
343
+ echo "\t\t\t\ttemp_vote = parseInt(document.getElementById('polla_votes-$polla_aid').value);\n";
344
+ echo "\t\t\t\tif(isNaN(temp_vote)) {\n";
345
+ echo "\t\t\t\tdocument.getElementById('polla_votes-$polla_aid').value = 0;\n";
346
+ echo "\t\t\t\ttemp_vote = 0;\n";
347
+ echo "\t\t\t\t}\n";
348
+ echo "\t\t\t\ttotal_votes += temp_vote;\n";
349
+ }
350
+ ?>
351
+ document.getElementById('pollq_totalvotes').value = parseInt(total_votes);
352
+ }
353
+ </script>
354
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
355
+ <!-- Edit Poll -->
356
+ <div class="wrap">
357
+ <h2><?php _e('Edit Poll'); ?></h2>
358
+ <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
359
+ <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" />
360
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
361
+ <tr>
362
+ <th colspan="2"><?php _e('Question') ?></th>
363
+ </tr>
364
+ <tr>
365
+ <td align="center" colspan="2"><input type="text" size="70" maxlength="200" name="pollq_question" value="<?php echo $poll_question_text; ?>" /></td>
366
+ </tr>
367
+ <tr>
368
+ <th align="left"><?php _e('Answers:') ?></th>
369
+ <th align="right"><?php _e('No. Of Votes') ?></th>
370
+ </tr>
371
+ <?php
372
+ $i=1;
373
+ $poll_actual_totalvotes = 0;
374
+ if($poll_answers) {
375
+ $pollip_answers = array();
376
+ $pollip_answers[0] = __('Null Votes');
377
+ foreach($poll_answers as $poll_answer) {
378
+ $polla_aid = intval($poll_answer->polla_aid);
379
+ $polla_answers = stripslashes($poll_answer->polla_answers);
380
+ $polla_votes = intval($poll_answer->polla_votes);
381
+ $pollip_answers[$polla_aid] = $polla_answers;
382
+ echo "<tr>\n";
383
+ echo "<td align=\"left\">".__('Answer')." $i:&nbsp;&nbsp;&nbsp;<input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_aid-$polla_aid\" value=\"$polla_answers\" />&nbsp;&nbsp;&nbsp;";
384
+ echo "<a href=\"$base_page&amp;mode=deleteans&amp;id=$poll_id&amp;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";
385
+ echo "<td align=\"right\">$polla_votes&nbsp;&nbsp;&nbsp;<input type=\"text\" size=\"4\" maxlength=\"6\" id=\"polla_votes-$polla_aid\" name=\"polla_votes-$polla_aid\" value=\"$polla_votes\" onblur=\"check_totalvotes();\" /></td>\n</tr>\n";
386
+ $poll_actual_totalvotes += $polla_votes;
387
+ $i++;
388
+ }
389
+ }
390
+ ?>
391
+ <tr>
392
+ <td align="right" colspan="2"><b><?php _e('Total Votes'); ?>: <?php echo $poll_actual_totalvotes; ?></b>&nbsp;&nbsp;&nbsp;<input type="text" size="4" maxlength="4" id="pollq_totalvotes" name="pollq_totalvotes" value="<?php echo $poll_actual_totalvotes; ?>" onblur="check_totalvotes();" /></td>
393
+ </tr>
394
+ <tr>
395
+ <td colspan="2"><b><?php _e('Timestamp'); ?></b>:</td>
396
+ </tr>
397
+ <tr>
398
+ <td colspan="2"><input type="checkbox" name="edit_polltimestamp" value="1" />Edit Timestamp<br /><?php poll_timestamp($poll_timestamp); ?><br />Existing Timestamp: <?php echo gmdate('jS F Y @ H:i:s', $poll_timestamp); ?></td>
399
+ </tr>
400
+ <tr>
401
+ <td align="center" colspan="2"><input type="submit" name="do" value="<?php _e('Edit Poll'); ?>" class="button" />&nbsp;&nbsp;
402
+ <?php if($poll_active == 1) { ?>
403
+ <input type="submit" class="button" name="do" value="<?php _e('Close Poll'); ?>" onclick="return confirm('You Are About To Close This Poll \'<?php echo $poll_question_text; ?>\'.')" />
404
+ <?php } else { ?>
405
+ <input type="submit" class="button" name="do" value="<?php _e('Open Poll'); ?>" onclick="return confirm('You Are About To Open This Poll \'<?php echo $poll_question_text; ?>\'.')" />
406
+ <?php } ?>
407
+ &nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
408
+ </tr>
409
+ </table>
410
+ </form>
411
+ </div>
412
+ <!-- Add Poll's Answer -->
413
+ <div class="wrap">
414
+ <h2><?php _e('Add Answer') ?></h2>
415
+ <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>&amp;mode=edit&amp;id=<?php echo $poll_id; ?>" method="post">
416
+ <input type="hidden" name="polla_qid" value="<?php echo $poll_id; ?>" />
417
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
418
+ <tr>
419
+ <td><b><?php _e('Add Answer') ?></b></td>
420
+ <td><input type="text" size="50" maxlength="200" name="polla_answers" /></td>
421
+ </tr>
422
+ <tr>
423
+ <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Answer'); ?>" class="button" /></td>
424
+ </tr>
425
+ </table>
426
+ </form>
427
+ </div>
428
+ <!-- Users Voted For This Poll -->
429
+ <?php
430
+ $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");
431
+ ?>
432
+ <div class="wrap">
433
+ <h2><?php _e('Users Voted For This Poll') ?></h2>
434
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
435
+ <?php
436
+ if($poll_ips) {
437
+ $k = 1;
438
+ $poll_last_aid = -1;
439
+ foreach($poll_ips as $poll_ip) {
440
+ $pollip_aid = intval($poll_ip->pollip_aid);
441
+ $pollip_user = stripslashes($poll_ip->pollip_user);
442
+ $pollip_ip = $poll_ip->pollip_ip;
443
+ $pollip_host = $poll_ip->pollip_host;
444
+ $pollip_date = gmdate("jS F Y @ H:i", $poll_ip->pollip_timestamp);
445
+ if($pollip_aid != $poll_last_aid) {
446
+ if($pollip_aid == 0) {
447
+ echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><b>$pollip_answers[$pollip_aid]</b></td>\n</tr>\n";
448
+ } else {
449
+ echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><b>".__('Answer')." $k: $pollip_answers[$pollip_aid]</b></td>\n</tr>\n";
450
+ $k++;
451
+ }
452
+ echo "<tr>\n";
453
+ echo "<th scope=\"row\">".__('No.')."</th>\n";
454
+ echo "<th scope=\"row\">".__('User')."</th>\n";
455
+ echo "<th scope=\"row\">".__('IP/Host')."</th>\n";
456
+ echo "<th scope=\"row\">".__('Date')."</th>\n";
457
+ echo "</tr>\n";
458
+ $i = 1;
459
+ }
460
+ if($i%2 == 0) {
461
+ $style = 'style=\'background-color: none\'';
462
+ } else {
463
+ $style = 'style=\'background-color: #eee\'';
464
+ }
465
+ echo "<tr $style>\n";
466
+ echo "<td>$i</td>\n";
467
+ echo "<td>$pollip_user</td>\n";
468
+ echo "<td>$pollip_ip / $pollip_host</td>\n";
469
+ echo "<td>$pollip_date</td>\n";
470
+ echo "</tr>\n";
471
+ $poll_last_aid = $pollip_aid;
472
+ $i++;
473
+ }
474
+ } else {
475
+ echo "<tr>\n<td colspan=\"4\" align=\"center\">".__('No IP Has Been Logged Yet.')."</td>\n</tr>\n";
476
+ }
477
+ ?>
478
+ </table>
479
+ </div>
480
+ <!-- Delete Poll Logs -->
481
+ <div class="wrap">
482
+ <h2><?php _e('Poll Logs'); ?></h2>
483
+ <div align="center">
484
+ <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
485
+ <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" />
486
+ <b>Are You Sure You Want To Delete Logs For This Poll Only?</b><br /><br />
487
+ <input type="checkbox" name="delete_logs_yes" value="yes" />&nbsp;Yes<br /><br />
488
+ <input type="submit" name="do" value="Delete Logs For This Poll Only" class="button" onclick="return confirm('You Are About To Delete Logs For This Poll Only.\nThis Action Is Not Reversible.\n\n Choose \'Cancel\' to stop, \'OK\' to delete.')" />
489
+ </form>
490
+ </div>
491
+ <p>Note: If your logging method is by IP and Cookie or by Cookie, users may still be unable to vote if they have voted before as the cookie is still stored in their computer.</p>
492
+ </div>
493
+ <?php
494
+ break;
495
+ // Delete A Poll
496
+ case 'delete':
497
+ $poll_question = $wpdb->get_row("SELECT pollq_question, pollq_totalvotes, pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
498
+ $poll_answers = $wpdb->get_results("SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = $poll_id ORDER BY polla_answers");
499
+ $poll_question_text = stripslashes($poll_question->pollq_question);
500
+ $poll_totalvotes = intval($poll_question->pollq_totalvotes);
501
+ $poll_active = intval($poll_question->pollq_active);
502
+ ?>
503
+ <!-- Delete Poll -->
504
+ <div class="wrap">
505
+ <h2><?php _e('Delete Poll') ?></h2>
506
+ <form action="<?php echo $base_page; ?>" method="post">
507
+ <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" />
508
+ <input type="hidden" name="pollq_question" value="<?php echo $poll_question_text; ?>" />
509
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
510
+ <tr>
511
+ <th colspan="2"><?php _e('Question') ?></th>
512
+ </tr>
513
+ <tr>
514
+ <td colspan="2" align="center"><?php echo $poll_question_text; ?></td>
515
+ </tr>
516
+ <tr>
517
+ <th align="left"><?php _e('Answers') ?></th>
518
+ <th><?php _e('No. Of Votes') ?></th>
519
+ </tr>
520
+ <?php
521
+ $i=1;
522
+ if($poll_answers) {
523
+ foreach($poll_answers as $poll_answer) {
524
+ $polla_answers = stripslashes($poll_answer->polla_answers);
525
+ $polla_votes = intval($poll_answer->polla_votes);
526
+ echo "<tr>\n";
527
+ echo "<td>".__('Answer')." $i:&nbsp;&nbsp;&nbsp;$polla_answers</td>\n";
528
+ echo "<td align=\"center\">$polla_votes</td>\n</tr>\n";
529
+ $i++;
530
+ }
531
+ }
532
+ ?>
533
+ <tr>
534
+ <th colspan="2"><?php _e('Total Votes'); ?>: <?php echo $poll_totalvotes; ?></th>
535
+ </tr>
536
+ <tr>
537
+ <th colspan="2"><?php _e('Status'); ?>: <?php if($poll_active == 1) { _e('Open'); } else { _e('Closed'); } ?></th>
538
+ </tr>
539
+ <tr>
540
+ <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.')" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
541
+ </tr>
542
+ </table>
543
+ </form>
544
+ </div>
545
+ <?php
546
+ break;
547
+ // Delete A Poll Answer
548
+ case 'deleteans':
549
+ $poll_answers = $wpdb->get_row("SELECT polla_votes, polla_answers FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id");
550
+ $polla_votes = intval($poll_answers->polla_votes);
551
+ $polla_answers = stripslashes(trim($poll_answers->polla_answers));
552
+ $delete_polla_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id");
553
+ $update_pollq_totalvotes = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes-$polla_votes) WHERE pollq_id=$poll_id");
554
+ ?>
555
+ <!-- Delete Poll's Answer -->
556
+ <div class="wrap">
557
+ <h2><?php _e('Delete Poll\'s Answer') ?></h2>
558
+ <?php
559
+ if($delete_polla_answers) {
560
+ $text = "<font color=\"green\">Poll Answer '$polla_answers' Deleted Successfully</font>";
561
+ } else {
562
+ $text = "<font color=\"red\">Error In Deleting Poll Answer '$polla_answers'</font>";
563
+ }
564
+ if($update_pollq_totalvotes) {
565
+ $text .= "<br /><font color=\"green\">Poll Question's Total Votes Updated Successfully</font>";
566
+ } else {
567
+ $text .= "<br /><font color=\"blue\">No Changes Had Been Made To The Poll's Total Votes</font>";
568
+ }
569
+ _e($text);
570
+ ?>
571
+ <p><b><a href="<?php echo $base_page; ?>&amp;mode=edit&amp;id=<?php echo $poll_id; ?>"><?php _e('Click here To Go Back To The Poll Edit Page'); ?></a>.</b></p>
572
+ </div>
573
+ <?php
574
+ break;
575
+ // Main Page
576
+ default:
577
+ $polls = $wpdb->get_results("SELECT * FROM $wpdb->pollsq ORDER BY pollq_id DESC");
578
+ $total_ans = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pollsa");
579
+ $total_votes = 0;
580
+ ?>
581
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
582
+ <!-- Manage Polls -->
583
+ <div class="wrap">
584
+ <h2><?php _e('Manage Polls'); ?></h2>
585
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
586
+ <tr>
587
+ <th scope="col"><?php _e('ID'); ?></th>
588
+ <th scope="col"><?php _e('Question'); ?></th>
589
+ <th scope="col"><?php _e('Total Votes'); ?></th>
590
+ <th scope="col"><?php _e('Date Added'); ?></th>
591
+ <th scope="col"><?php _e('Status'); ?></th>
592
+ <th scope="col" colspan="2"><?php _e('Action'); ?></th>
593
+ </tr>
594
+ <?php
595
+ if($polls) {
596
+ $i = 0;
597
+ $current_poll = intval(get_settings('poll_currentpoll'));
598
+ foreach($polls as $poll) {
599
+ $poll_id = intval($poll->pollq_id);
600
+ $poll_question = stripslashes($poll->pollq_question);
601
+ $poll_date = gmdate("jS F Y @ H:i", $poll->pollq_timestamp);
602
+ $poll_totalvotes = intval($poll->pollq_totalvotes);
603
+ $poll_active = intval($poll->pollq_active);
604
+ if($i%2 == 0) {
605
+ $style = 'style=\'background-color: #eee\'';
606
+ } else {
607
+ $style = 'style=\'background-color: none\'';
608
+ }
609
+ if($current_poll > 0) {
610
+ if($current_poll == $poll_id) {
611
+ $style = 'style=\'background-color: #b8d4ff\'';
612
+ }
613
+ } else {
614
+ if($i == 0) {
615
+ $style = 'style=\'background-color: #b8d4ff\'';
616
+ }
617
+ }
618
+ echo "<tr $style>\n";
619
+ echo "<td><b>$poll_id</b></td>\n";
620
+ echo '<td>';
621
+ if($current_poll > 0) {
622
+ if($current_poll == $poll_id) {
623
+ echo '<b>'.__('Displayed:').'</b> ';
624
+ }
625
+ } elseif($current_poll != -1) {
626
+ if($i == 0) {
627
+ echo '<b>'.__('Displayed:').'</b> ';
628
+ }
629
+ }
630
+ echo "$poll_question</td>\n";
631
+ echo "<td>$poll_totalvotes</td>\n";
632
+ echo "<td>$poll_date</td>\n";
633
+ echo '<td>';
634
+ if($poll_active == 1) {
635
+ _e('Open');
636
+ } else {
637
+ _e('Closed');
638
+ }
639
+ echo "</td>\n";
640
+ echo "<td><a href=\"$base_page&amp;mode=edit&amp;id=$poll_id\" class=\"edit\">".__('Edit')."</a></td>\n";
641
+ echo "<td><a href=\"$base_page&amp;mode=delete&amp;id=$poll_id\" class=\"delete\">".__('Delete')."</a></td>\n";
642
+ echo '</tr>';
643
+ $i++;
644
+ $total_votes+= $poll_totalvotes;
645
+
646
+ }
647
+ } else {
648
+ echo '<tr><td colspan="7" align="center"><b>'.__('No Polls Found').'</b></td></tr>';
649
+ }
650
+ ?>
651
+ </table>
652
+ </div>
653
+ <!-- Add A Poll -->
654
+ <div class="wrap">
655
+ <h2><?php _e('Add A Poll'); ?></h2>
656
+ <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>&amp;mode=add" method="post">
657
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
658
+ <tr>
659
+ <th align="left"><?php _e('Question') ?></th>
660
+ <td><input type="text" size="50" maxlength="200" name="pollq_question" /></td>
661
+ </tr>
662
+ <tr>
663
+ <th align="left"><?php _e('No. Of Answers:') ?></th>
664
+ <td>
665
+ <select size="1" name="poll_noquestion">
666
+ <?php
667
+ for($k=2; $k <= 20; $k++) {
668
+ echo "<option value=\"$k\">$k</option>";
669
+ }
670
+ ?>
671
+ </select>
672
+ </td>
673
+ </tr>
674
+ <tr>
675
+ <td colspan="2" align="center"><input type="submit" name="addpollquestion" value="<?php _e('Add Question'); ?>" class="button" /></td>
676
+ </tr>
677
+ </table>
678
+ </form>
679
+ </div>
680
+ <!-- Polls Stats -->
681
+ <div class="wrap">
682
+ <h2><?php _e('Polls Stats'); ?></h2>
683
+ <table border="0" cellspacing="3" cellpadding="3">
684
+ <tr>
685
+ <th align="left"><?php _e('Total Polls:'); ?></th>
686
+ <td align="left"><?php echo $i; ?></td>
687
+ </tr>
688
+ <tr>
689
+ <th align="left"><?php _e('Total Polls\' Answers:'); ?></th>
690
+ <td align="left"><?php echo number_format($total_ans); ?></td>
691
+ </tr>
692
+ <tr>
693
+ <th align="left"><?php _e('Total Votes Casted:'); ?></th>
694
+ <td align="left"><?php echo number_format($total_votes); ?></td>
695
+ </tr>
696
+ </table>
697
+ </div>
698
+
699
+ <!-- Delete Polls Logs -->
700
+ <div class="wrap">
701
+ <h2><?php _e('Polls Logs'); ?></h2>
702
+ <div align="center">
703
+ <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
704
+ <b>Are You Sure You Want To Delete All Polls Logs?</b><br /><br />
705
+ <input type="checkbox" name="delete_logs_yes" value="yes" />&nbsp;Yes<br /><br />
706
+ <input type="submit" name="do" value="Delete All Logs" class="button" onclick="return confirm('You Are About To Delete All Poll Logs.\nThis Action Is Not Reversible.\n\n Choose \'Cancel\' to stop, \'OK\' to delete.')" />
707
+ </form>
708
+ </div>
709
+ <p>Note: If your logging method is by IP and Cookie or by Cookie, users may still be unable to vote if they have voted before as the cookie is still stored in their computer.</p>
710
+ </div>
711
+ <?php
712
+ } // End switch($mode)
713
+ ?>
polls/polls-options.php ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.1 |
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-content/plugins/polls/polls-options.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Check Whether User Can Manage Polls
21
+ if(!current_user_can('manage_polls')) {
22
+ die('Access Denied');
23
+ }
24
+
25
+
26
+ ### Variables Variables Variables
27
+ $base_name = plugin_basename('polls/polls-options.php');
28
+ $base_page = 'admin.php?page='.$base_name;
29
+ $id = intval($_GET['id']);
30
+
31
+
32
+ ### If Form Is Submitted
33
+ if($_POST['Submit']) {
34
+ $poll_ans_sortby = strip_tags(trim($_POST['poll_ans_sortby']));
35
+ $poll_ans_sortorder = strip_tags(trim($_POST['poll_ans_sortorder']));
36
+ $poll_ans_result_sortby = strip_tags(trim($_POST['poll_ans_result_sortby']));
37
+ $poll_ans_result_sortorder = strip_tags(trim($_POST['poll_ans_result_sortorder']));
38
+ $poll_template_voteheader =trim($_POST['poll_template_voteheader']);
39
+ $poll_template_votebody = trim($_POST['poll_template_votebody']);
40
+ $poll_template_votefooter = trim($_POST['poll_template_votefooter']);
41
+ $poll_template_resultheader = trim($_POST['poll_template_resultheader']);
42
+ $poll_template_resultbody = trim($_POST['poll_template_resultbody']);
43
+ $poll_template_resultbody2 = trim($_POST['poll_template_resultbody2']);
44
+ $poll_template_resultfooter = trim($_POST['poll_template_resultfooter']);
45
+ $poll_template_resultfooter2 = trim($_POST['poll_template_resultfooter2']);
46
+ $poll_template_disable = trim($_POST['poll_template_disable']);
47
+ $poll_template_error = trim($_POST['poll_template_error']);
48
+ $poll_archive_perpage = intval($_POST['poll_archive_perpage']);
49
+ $poll_currentpoll = intval($_POST['poll_currentpoll']);
50
+ $poll_logging_method = intval($_POST['poll_logging_method']);
51
+ $poll_allowtovote = intval($_POST['poll_allowtovote']);
52
+ $update_poll_queries = array();
53
+ $update_poll_text = array();
54
+ $update_poll_queries[] = update_option('poll_ans_sortby', $poll_ans_sortby);
55
+ $update_poll_queries[] = update_option('poll_ans_sortorder', $poll_ans_sortorder);
56
+ $update_poll_queries[] = update_option('poll_ans_result_sortby', $poll_ans_result_sortby);
57
+ $update_poll_queries[] = update_option('poll_ans_result_sortorder', $poll_ans_result_sortorder);
58
+ $update_poll_queries[] = update_option('poll_template_voteheader', $poll_template_voteheader);
59
+ $update_poll_queries[] = update_option('poll_template_votebody', $poll_template_votebody);
60
+ $update_poll_queries[] = update_option('poll_template_votefooter', $poll_template_votefooter);
61
+ $update_poll_queries[] = update_option('poll_template_resultheader', $poll_template_resultheader);
62
+ $update_poll_queries[] = update_option('poll_template_resultbody', $poll_template_resultbody);
63
+ $update_poll_queries[] = update_option('poll_template_resultbody2', $poll_template_resultbody2);
64
+ $update_poll_queries[] = update_option('poll_template_resultfooter', $poll_template_resultfooter);
65
+ $update_poll_queries[] = update_option('poll_template_resultfooter2', $poll_template_resultfooter2);
66
+ $update_poll_queries[] = update_option('poll_template_disable', $poll_template_disable);
67
+ $update_poll_queries[] = update_option('poll_template_error', $poll_template_error);
68
+ $update_poll_queries[] = update_option('poll_archive_perpage', $poll_archive_perpage);
69
+ $update_poll_queries[] = update_option('poll_currentpoll', $poll_currentpoll);
70
+ $update_poll_queries[] = update_option('poll_logging_method', $poll_logging_method);
71
+ $update_poll_queries[] = update_option('poll_allowtovote', $poll_allowtovote);
72
+ $update_poll_text[] = __('Sort Poll Answers By Option');
73
+ $update_poll_text[] = __('Sort Order Of Poll Answers Option');
74
+ $update_poll_text[] = __('Sort Poll Results By Option');
75
+ $update_poll_text[] = __('Sort Order Of Poll Results Option');
76
+ $update_poll_text[] = __('Voting Form Header Template');
77
+ $update_poll_text[] = __('Voting Form Body Template');
78
+ $update_poll_text[] = __('Voting Form Footer Template');
79
+ $update_poll_text[] = __('Result Header Template');
80
+ $update_poll_text[] = __('Result Body Template');
81
+ $update_poll_text[] = __('Result Body2 Template');
82
+ $update_poll_text[] = __('Result Footer Template');
83
+ $update_poll_text[] = __('Result Footer2 Template');
84
+ $update_poll_text[] = __('Poll Disabled Template');
85
+ $update_poll_text[] = __('Poll Error Template');
86
+ $update_poll_text[] = __('Archive Polls Per Page Option');
87
+ $update_poll_text[] = __('Current Active Poll Option');
88
+ $update_poll_text[] = __('Logging Method');
89
+ $update_poll_text[] = __('Allow To Vote Option');
90
+ $i=0;
91
+ $text = '';
92
+ foreach($update_poll_queries as $update_poll_query) {
93
+ if($update_poll_query) {
94
+ $text .= '<font color="green">'.$update_poll_text[$i].' '.__('Updated').'</font><br />';
95
+ }
96
+ $i++;
97
+ }
98
+ if(empty($text)) {
99
+ $text = '<font color="red">'.__('No Poll Option Updated').'</font>';
100
+ }
101
+ }
102
+
103
+ ?>
104
+ <script type="text/javascript">
105
+ /* <![CDATA[*/
106
+ function poll_default_templates(template) {
107
+ var default_template;
108
+ switch(template) {
109
+ case "voteheader":
110
+ default_template = "<p align=\"center\"><b>%POLL_QUESTION%</b></p>\n<div id=\"polls-%POLL_ID%-ans\" class=\"wp-polls-ans\">\n<ul class=\"wp-polls-ul\">";
111
+ break;
112
+ case "votebody":
113
+ default_template = "<li><label for=\"poll-answer-%POLL_ANSWER_ID%\"><input type=\"radio\" id=\"poll-answer-%POLL_ANSWER_ID%\" name=\"poll_%POLL_ID%\" value=\"%POLL_ANSWER_ID%\" /> %POLL_ANSWER%</label></li>";
114
+ break;
115
+ case "votefooter":
116
+ default_template = "</ul>\n<p align=\"center\"><input type=\"button\" name=\"vote\" value=\" Vote \" class=\"Buttons\" onclick=\"poll_vote(%POLL_ID%);\" /><br /><a href=\"#ViewPollResults\" onclick=\"poll_result(%POLL_ID%); return false;\" title=\"View Results Of This Poll\">View Results</a></p>\n</div>";
117
+ break;
118
+ case "resultheader":
119
+ default_template = "<p align=\"center\"><b>%POLL_QUESTION%</b></p>\n<div id=\"polls-%POLL_ID%-ans\" class=\"wp-polls-ans\">\n<ul class=\"wp-polls-ul\">";
120
+ break;
121
+ case "resultbody":
122
+ default_template = "<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small><br /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollstart.gif\" height=\"10\" width=\"2\" alt=\"\" /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollbar.gif\" height=\"10\" width=\"%POLL_ANSWER_IMAGEWIDTH%\" alt=\"%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" title=\"%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollend.gif\" height=\"10\" width=\"2\" alt=\"\" /></li>";
123
+ break;
124
+ case "resultbody2":
125
+ default_template = "<li><b><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small></i></b><br /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollstart.gif\" height=\"10\" width=\"2\" alt=\"\" /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollbar.gif\" height=\"10\" width=\"%POLL_ANSWER_IMAGEWIDTH%\" alt=\"You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" title=\"You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)\" /><img src=\"<?php echo get_settings('siteurl'); ?>/wp-content/plugins/polls/images/pollend.gif\" height=\"10\" width=\"2\" alt=\"\" /></li>";
126
+ break;
127
+ case "resultfooter":
128
+ default_template = "</ul>\n<p align=\"center\">Total Votes: <b>%POLL_TOTALVOTES%</b></p>\n</div>";
129
+ break;
130
+ case "resultfooter2":
131
+ default_template = "</ul>\n<p align=\"center\">Total Votes: <b>%POLL_TOTALVOTES%</b><br /><a href=\"#VotePoll\" onclick=\"poll_booth(%POLL_ID%); return false;\" title=\"Vote For This Poll\">Vote</a></p>\n</div>";
132
+ break;
133
+ case "disable":
134
+ default_template = 'Sorry, there are no polls available at the moment.';
135
+ break;
136
+ case "error":
137
+ default_template = 'An error has occurred when processing your poll.';
138
+ break;
139
+ }
140
+ document.getElementById("poll_template_" + template).value = default_template;
141
+ }
142
+ /* ]]> */
143
+ </script>
144
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
145
+ <div class="wrap">
146
+ <h2><?php _e('Poll Options'); ?></h2>
147
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
148
+ <fieldset class="options">
149
+ <legend><?php _e('Sorting Of Poll Answers'); ?></legend>
150
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
151
+ <tr valign="top">
152
+ <th align="left" width="30%"><?php _e('Sort Poll Answers By:'); ?></th>
153
+ <td align="left">
154
+ <select name="poll_ans_sortby" size="1">
155
+ <option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_sortby')); ?>><?php _e('Exact Order'); ?></option>
156
+ <option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
157
+ </select>
158
+ </td>
159
+ </tr>
160
+ <tr valign="top">
161
+ <th align="left" width="30%"><?php _e('Sort Order Of Poll Answers:'); ?></th>
162
+ <td align="left">
163
+ <select name="poll_ans_sortorder" size="1">
164
+ <option value="asc"<?php selected('asc', get_settings('poll_ans_sortorder')); ?>><?php _e('Ascending'); ?></option>
165
+ <option value="desc"<?php selected('desc', get_settings('poll_ans_sortorder')); ?>><?php _e('Descending'); ?></option>
166
+ </select>
167
+ </td>
168
+ </tr>
169
+ </table>
170
+ </fieldset>
171
+ <fieldset class="options">
172
+ <legend><?php _e('Sorting Of Poll Results'); ?></legend>
173
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
174
+ <tr valign="top">
175
+ <th align="left" width="30%"><?php _e('Sort Poll Results By:'); ?></th>
176
+ <td align="left">
177
+ <select name="poll_ans_result_sortby" size="1">
178
+ <option value="polla_votes"<?php selected('polla_votes', get_settings('poll_ans_result_sortby')); ?>><?php _e('Votes'); ?></option>
179
+ <option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_result_sortby')); ?>><?php _e('Exact Order'); ?></option>
180
+ <option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_result_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
181
+ </select>
182
+ </td>
183
+ </tr>
184
+ <tr valign="top">
185
+ <th align="left" width="30%"><?php _e('Sort Order Of Poll Results:'); ?></th>
186
+ <td align="left">
187
+ <select name="poll_ans_result_sortorder" size="1">
188
+ <option value="asc"<?php selected('asc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Ascending'); ?></option>
189
+ <option value="desc"<?php selected('desc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Descending'); ?></option>
190
+ </select>
191
+ </td>
192
+ </tr>
193
+ </table>
194
+ </fieldset>
195
+ <fieldset class="options">
196
+ <legend><?php _e('Allow To Vote'); ?></legend>
197
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
198
+ <tr valign="top">
199
+ <th align="left" width="30%"><?php _e('Who Is Allowed To Vote?'); ?></th>
200
+ <td align="left">
201
+ <select name="poll_allowtovote" size="1">
202
+ <option value="0"<?php selected('0', get_settings('poll_allowtovote')); ?>><?php _e('Guests Only'); ?></option>
203
+ <option value="1"<?php selected('1', get_settings('poll_allowtovote')); ?>><?php _e('Registered Users Only'); ?></option>
204
+ <option value="2"<?php selected('2', get_settings('poll_allowtovote')); ?>><?php _e('Registered Users And Guests'); ?></option>
205
+ </select>
206
+ </td>
207
+ </tr>
208
+ </table>
209
+ </fieldset>
210
+ <fieldset class="options">
211
+ <legend><?php _e('Logging Method'); ?></legend>
212
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
213
+ <tr valign="top">
214
+ <th align="left" width="30%"><?php _e('Poll Logging Method:'); ?></th>
215
+ <td align="left">
216
+ <select name="poll_logging_method" size="1">
217
+ <option value="0"<?php selected('0', get_settings('poll_logging_method')); ?>><?php _e('Do Not Log'); ?></option>
218
+ <option value="1"<?php selected('1', get_settings('poll_logging_method')); ?>><?php _e('Logged By Cookie'); ?></option>
219
+ <option value="2"<?php selected('2', get_settings('poll_logging_method')); ?>><?php _e('Logged By IP'); ?></option>
220
+ <option value="3"<?php selected('3', get_settings('poll_logging_method')); ?>><?php _e('Logged By Cookie And IP'); ?></option>
221
+ </select>
222
+ </td>
223
+ </tr>
224
+ </table>
225
+ </fieldset>
226
+ <fieldset class="options">
227
+ <legend><?php _e('Poll Archive'); ?></legend>
228
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
229
+ <tr valign="top">
230
+ <th align="left" width="30%"><?php _e('Polls Per Page:'); ?></th>
231
+ <td align="left"><input type="text" name="poll_archive_perpage" value="<?php echo intval(get_settings('poll_archive_perpage')); ?>" size="2" /></td>
232
+ </tr>
233
+ </table>
234
+ </fieldset>
235
+ <fieldset class="options">
236
+ <legend><?php _e('Current Active Poll'); ?></legend>
237
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
238
+ <tr valign="top">
239
+ <th align="left" width="30%"><?php _e('Current Active Poll:'); ?></th>
240
+ <td align="left">
241
+ <select name="poll_currentpoll" size="1">
242
+ <option value="-1"<?php selected(-1, get_settings('poll_currentpoll')); ?>><?php _e('Do NOT Display Poll (Disable)'); ?></option>
243
+ <option value="-2"<?php selected(-2, get_settings('poll_currentpoll')); ?>><?php _e('Display Random Poll'); ?></option>
244
+ <option value="0"<?php selected(0, get_settings('poll_currentpoll')); ?>><?php _e('Display Latest Poll'); ?></option>
245
+ <option value="0">&nbsp;</option>
246
+ <?php
247
+ $polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
248
+ if($polls) {
249
+ foreach($polls as $poll) {
250
+ $poll_question = stripslashes($poll->pollq_question);
251
+ $poll_id = intval($poll->pollq_id);
252
+ if($poll_id == intval(get_settings('poll_currentpoll'))) {
253
+ echo "<option value=\"$poll_id\" selected=\"selected\">$poll_question</option>\n";
254
+ } else {
255
+ echo "<option value=\"$poll_id\">$poll_question</option>\n";
256
+ }
257
+ }
258
+ }
259
+ ?>
260
+ </select>
261
+ </td>
262
+ </tr>
263
+ </table>
264
+ </fieldset>
265
+ <fieldset class="options">
266
+ <legend><?php _e('Template Variables'); ?></legend>
267
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
268
+ <tr>
269
+ <td><b>%POLL_ID%</b> - <?php _e('Display the poll\'s ID'); ?></td>
270
+ <td><b>%POLL_ANSWER_ID%</b> - <?php _e('Display the poll\'s answer ID'); ?></td>
271
+ </tr>
272
+ <tr>
273
+ <td><b>%POLL_QUESTION%</b> - <?php _e('Display the poll\'s question'); ?></td>
274
+ <td><b>%POLL_ANSWER%</b> - <?php _e('Display the poll\'s answer'); ?></td>
275
+ </tr>
276
+ <tr>
277
+ <td><b>%POLL_TOTALVOTES%</b> - <?php _e('Display the poll\'s total votes'); ?></td>
278
+ <td><b>%POLL_ANSWER_VOTES%</b> - <?php _e('Display the poll\'s answer votes'); ?></td>
279
+ </tr>
280
+ <tr>
281
+ <td><b>%POLL_RESULT_URL%</b> - <?php _e('Displays URL to poll\'s result'); ?></td>
282
+ <td><b>%POLL_ANSWER_PERCENTAGE%</b> - <?php _e('Display the poll\'s answer percentage'); ?></td>
283
+ </tr>
284
+ <tr>
285
+ <td><b>%POLL_MOST_ANSWER%</b> - <?php _e('Display the poll\'s most voted answer'); ?></td>
286
+ <td><b>%POLL_ANSWER_IMAGEWIDTH%</b> - <?php _e('Display the poll\'s answer image width'); ?></td>
287
+ </tr>
288
+ <tr>
289
+ <td><b>%POLL_MOST_VOTES%</b> - <?php _e('Display the poll\'s answer votes for the most voted answer'); ?></td>
290
+ <td><b>%POLL_LEAST_ANSWER%</b> - <?php _e('Display the poll\'s least voted answer'); ?></td>
291
+ </tr>
292
+ <tr>
293
+ <td><b>%POLL_MOST_PERCENTAGE%</b> - <?php _e('Display the poll\'s answer percentage for the most voted answer'); ?></td>
294
+ <td><b>%POLL_LEAST_VOTES%</b> - <?php _e('Display the poll\'s answer votes for the least voted answer'); ?></td>
295
+ </tr>
296
+ <tr>
297
+ <td>&nbsp;</td>
298
+ <td><b>%POLL_LEAST_PERCENTAGE%</b> - <?php _e('Display the poll\'s answer percentage for the least voted answer'); ?></td>
299
+ </tr>
300
+ </table>
301
+ </fieldset>
302
+ <fieldset class="options">
303
+ <legend><?php _e('Poll Voting Form Templates'); ?></legend>
304
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
305
+ <tr valign="top">
306
+ <td width="30%" align="left">
307
+ <b><?php _e('Voting Form Header:'); ?></b><br /><br /><br />
308
+ <?php _e('Allowed Variables:'); ?><br />
309
+ - %POLL_ID%<br />
310
+ - %POLL_QUESTION%<br />
311
+ - %POLL_TOTALVOTES%<br /><br />
312
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('voteheader');" class="button" />
313
+ </td>
314
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_voteheader" name="poll_template_voteheader"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_voteheader'))); ?></textarea></td>
315
+ </tr>
316
+ <tr valign="top">
317
+ <td width="30%" align="left">
318
+ <b><?php _e('Voting Form Body:'); ?></b><br /><br /><br />
319
+ <?php _e('Allowed Variables:'); ?><br />
320
+ - %POLL_ID%<br />
321
+ - %POLL_ANSWER_ID%<br />
322
+ - %POLL_ANSWER%<br />
323
+ - %POLL_ANSWER_VOTES%<br /><br />
324
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votebody');" class="button" />
325
+ </td>
326
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_votebody" name="poll_template_votebody"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_votebody'))); ?></textarea></td>
327
+ </tr>
328
+ <tr valign="top">
329
+ <td width="30%" align="left">
330
+ <b><?php _e('Voting Form Footer:'); ?></b><br /><br /><br />
331
+ <?php _e('Allowed Variables:'); ?><br />
332
+ - %POLL_ID%<br />
333
+ - %POLL_RESULT_URL%<br /><br />
334
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votefooter');" class="button" />
335
+ </td>
336
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_votefooter" name="poll_template_votefooter"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_votefooter'))); ?></textarea></td>
337
+ </tr>
338
+ </table>
339
+ </fieldset>
340
+ <fieldset class="options">
341
+ <legend><?php _e('Poll Result Templates'); ?></legend>
342
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
343
+ <tr valign="top">
344
+ <td width="30%" align="left">
345
+ <b><?php _e('Result Header:'); ?></b><br /><br /><br />
346
+ <?php _e('Allowed Variables:'); ?><br />
347
+ - %POLL_ID%<br />
348
+ - %POLL_QUESTION%<br />
349
+ - %POLL_TOTALVOTES%<br /><br />
350
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultheader');" class="button" />
351
+ </td>
352
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_resultheader" name="poll_template_resultheader"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_resultheader'))); ?></textarea></td>
353
+ </tr>
354
+ <tr valign="top">
355
+ <td width="30%" align="left">
356
+ <b><?php _e('Result Body:'); ?></b><br /><?php _e('Normal'); ?><br /><br />
357
+ <?php _e('Allowed Variables:'); ?><br />
358
+ - %POLL_ANSWER_ID%<br />
359
+ - %POLL_ANSWER%<br />
360
+ - %POLL_ANSWER_VOTES%<br />
361
+ - %POLL_ANSWER_PERCENTAGE%<br />
362
+ - %POLL_ANSWER_IMAGEWIDTH%<br /><br />
363
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody');" class="button" />
364
+ </td>
365
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_resultbody" name="poll_template_resultbody"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_resultbody'))); ?></textarea></td>
366
+ </tr>
367
+ <tr valign="top">
368
+ <td width="30%" align="left">
369
+ <b><?php _e('Result Body:'); ?></b><br /><?php _e('Displaying Of User\'s Voted Answer'); ?><br /><br />
370
+ <?php _e('Allowed Variables:'); ?><br />
371
+ - %POLL_ANSWER_ID%<br />
372
+ - %POLL_ANSWER%<br />
373
+ - %POLL_ANSWER_VOTES%<br />
374
+ - %POLL_ANSWER_PERCENTAGE%<br />
375
+ - %POLL_ANSWER_IMAGEWIDTH%<br /><br />
376
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody2');" class="button" />
377
+ </td>
378
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_resultbody2" name="poll_template_resultbody2"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_resultbody2'))); ?></textarea></td>
379
+ </tr>
380
+ <tr valign="top">
381
+ <td width="30%" align="left">
382
+ <b><?php _e('Result Footer:'); ?></b><br />Normal<br /><br />
383
+ <?php _e('Allowed Variables:'); ?><br />
384
+ - %POLL_TOTALVOTES%<br />
385
+ - %POLL_MOST_ANSWER%<br />
386
+ - %POLL_MOST_VOTES%<br />
387
+ - %POLL_MOST_PERCENTAGE%<br />
388
+ - %POLL_LEAST_ANSWER%<br />
389
+ - %POLL_LEAST_VOTES%<br />
390
+ - %POLL_LEAST_PERCENTAGE%<br /><br />
391
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultfooter');" class="button" />
392
+ </td>
393
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_resultfooter" name="poll_template_resultfooter"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_resultfooter'))); ?></textarea></td>
394
+ </tr>
395
+ <tr valign="top">
396
+ <td width="30%" align="left">
397
+ <b><?php _e('Result Footer:'); ?></b><br /><?php _e('Displaying Of Vote Poll Link If User Has Not Voted'); ?><br /><br />
398
+ <?php _e('Allowed Variables:'); ?><br />
399
+ - %POLL_ID%<br />
400
+ - %POLL_TOTALVOTES%<br />
401
+ - %POLL_MOST_ANSWER%<br />
402
+ - %POLL_MOST_VOTES%<br />
403
+ - %POLL_MOST_PERCENTAGE%<br />
404
+ - %POLL_LEAST_ANSWER%<br />
405
+ - %POLL_LEAST_VOTES%<br />
406
+ - %POLL_LEAST_PERCENTAGE%<br /><br />
407
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultfooter2');" class="button" />
408
+ </td>
409
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_resultfooter2" name="poll_template_resultfooter2"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_resultfooter2'))); ?></textarea></td>
410
+ </tr>
411
+ </table>
412
+ </fieldset>
413
+ <fieldset class="options">
414
+ <legend><?php _e('Poll Misc Templates'); ?></legend>
415
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
416
+ <tr valign="top">
417
+ <td width="30%" align="left">
418
+ <b><?php _e('Poll Disabled'); ?></b><br /><br /><br />
419
+ <?php _e('Allowed Variables:'); ?><br />
420
+ - N/A<br /><br />
421
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('disable');" class="button" />
422
+ </td>
423
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_disable" name="poll_template_disable"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_disable'))); ?></textarea></td>
424
+ </tr>
425
+ <tr valign="top">
426
+ <td width="30%" align="left">
427
+ <b><?php _e('Poll Error'); ?></b><br /><br /><br />
428
+ <?php _e('Allowed Variables:'); ?><br />
429
+ - N/A<br /><br />
430
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('error');" class="button" />
431
+ </td>
432
+ <td align="left"><textarea cols="80" rows="10" id="poll_template_error" name="poll_template_error"><?php echo htmlspecialchars(stripslashes(get_settings('poll_template_error'))); ?></textarea></td>
433
+ </tr>
434
+ </table>
435
+ </fieldset>
436
+ <div align="center">
437
+ <input type="submit" name="Submit" class="button" value="<?php _e('Update Options'); ?>" />&nbsp;&nbsp;<input type="button" name="cancel" value="Cancel" class="button" onclick="javascript:history.go(-1)" />
438
+ </div>
439
+ </form>
440
+ </div>
polls/polls.php ADDED
@@ -0,0 +1,614 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1
7
+ Author: GaMerZ
8
+ Author URI: http://www.lesterchan.net
9
+ */
10
+
11
+
12
+ /* Copyright 2006 Lester Chan (email : gamerz84@hotmail.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ */
28
+
29
+
30
+ ### Polls Table Name
31
+ $wpdb->pollsq = $table_prefix . 'pollsq';
32
+ $wpdb->pollsa = $table_prefix . 'pollsa';
33
+ $wpdb->pollsip = $table_prefix . 'pollsip';
34
+
35
+
36
+ ### Function: Poll Administration Menu
37
+ add_action('admin_menu', 'poll_menu');
38
+ function poll_menu() {
39
+ if (function_exists('add_menu_page')) {
40
+ add_menu_page(__('Polls'), __('Polls'), 'manage_polls', 'polls/polls-manager.php');
41
+ }
42
+ if (function_exists('add_submenu_page')) {
43
+ add_submenu_page('polls/polls-manager.php', __('Manage Polls'), __('Manage Polls'), 'manage_polls', 'polls/polls-manager.php');
44
+ add_submenu_page('polls/polls-manager.php', __('Poll Options'), __('Poll Options'), 'manage_polls', 'polls/polls-options.php');
45
+ }
46
+ }
47
+
48
+
49
+ ### Function: Get Poll
50
+ function get_poll($temp_poll_id = 0, $display = true) {
51
+ global $wpdb;
52
+ // Poll Result Link
53
+ $pollresult_id = intval($_GET['pollresult']);
54
+ // Check Whether Poll Is Disabled
55
+ if(intval(get_settings('poll_currentpoll')) == -1) {
56
+ if($display) {
57
+ echo stripslashes(get_settings('poll_template_disable'));
58
+ return;
59
+ } else {
60
+ return stripslashes(get_settings('poll_template_disable'));
61
+ }
62
+ // Poll Is Enabled
63
+ } else {
64
+ // Hardcoded Poll ID Is Not Specified
65
+ if(intval($temp_poll_id) == 0) {
66
+ // Random Poll
67
+ if(intval(get_settings('poll_currentpoll')) == -2) {
68
+ $random_poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq ORDER BY RAND() LIMIT 1");
69
+ $poll_id = intval($random_poll_id);
70
+ if($pollresult_id > 0) {
71
+ $poll_id = $pollresult_id;
72
+ } elseif(intval($_POST['poll_id']) > 0) {
73
+ $poll_id = intval($_POST['poll_id']);
74
+ }
75
+ // Current Poll ID Is Not Specified
76
+ } elseif(intval(get_settings('poll_currentpoll')) == 0) {
77
+ // Get Lastest Poll ID
78
+ $poll_id = intval(get_settings('poll_latestpoll'));
79
+ } else {
80
+ // Get Current Poll ID
81
+ $poll_id = intval(get_settings('poll_currentpoll'));
82
+ }
83
+ // Get Hardcoded Poll ID
84
+ } else {
85
+ $poll_id = intval($temp_poll_id);
86
+ }
87
+ }
88
+
89
+ // User Click on View Results Link
90
+ if($pollresult_id == $poll_id) {
91
+ if($display) {
92
+ echo display_pollresult($poll_id);
93
+ return;
94
+ } else {
95
+ return display_pollresult($poll_id);
96
+ }
97
+ // Check Whether User Has Voted
98
+ } else {
99
+ $poll_active = $wpdb->get_var("SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
100
+ $poll_active = intval($poll_active);
101
+ $check_voted = check_voted($poll_id);
102
+ if($check_voted > 0 || $poll_active == 0 || !check_allowtovote()) {
103
+ if($display) {
104
+ echo display_pollresult($poll_id, $check_voted);
105
+ return;
106
+ } else {
107
+ return display_pollresult($poll_id, $check_voted);
108
+ }
109
+ } else {
110
+ if($display) {
111
+ echo display_pollvote($poll_id);
112
+ return;
113
+ } else {
114
+ return display_pollvote($poll_id);
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+
121
+ ### Function: Displays Polls Header
122
+ add_action('wp_head', 'poll_header');
123
+ function poll_header() {
124
+ echo '<link rel="stylesheet" href="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-css.css" type="text/css" media="screen" />'."\n";
125
+ echo '<script src="'.get_settings('siteurl').'/wp-includes/js/tw-sack.js" type="text/javascript"></script>'."\n";
126
+ echo '<script src="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-js.js" type="text/javascript"></script>'."\n";
127
+ echo '<script type="text/javascript">'."\n";
128
+ echo '/* Start Of Javascript Generated By WP-Polls 2.1 */'."\n";
129
+ echo '/* <![CDATA[ */'."\n";
130
+ echo "\t".'var site_url = \''.get_settings('siteurl').'\';'."\n";
131
+ echo '/* ]]> */'."\n";
132
+ echo '/* End Of Javascript Generated By WP-Polls 2.1 */'."\n";
133
+ echo '</script>'."\n";
134
+ }
135
+
136
+
137
+ ### Function: Check Who Is Allow To Vote
138
+ function check_allowtovote() {
139
+ global $user_ID;
140
+ $user_ID = intval($user_ID);
141
+ $allow_to_vote = intval(get_settings('poll_allowtovote'));
142
+ switch($allow_to_vote) {
143
+ // Guests Only
144
+ case 0:
145
+ if($user_ID > 0) {
146
+ return false;
147
+ }
148
+ return true;
149
+ break;
150
+ // Registered Users Only
151
+ case 1:
152
+ if($user_ID == 0) {
153
+ return false;
154
+ }
155
+ return true;
156
+ break;
157
+ // Registered Users And Guests
158
+ case 2:
159
+ default:
160
+ return true;
161
+ }
162
+ }
163
+
164
+
165
+ ### Funcrion: Check Voted By Cookie Or IP
166
+ function check_voted($poll_id) {
167
+ $check_voted_cookie = check_voted_cookie($poll_id);
168
+ if($check_voted_cookie > 0) {
169
+ return $check_voted_cookie;
170
+ } else {
171
+ $check_voted_ip = check_voted_ip($poll_id);
172
+ if($check_voted_ip > 0) {
173
+ return $check_voted_ip;
174
+ } else {
175
+ return 0;
176
+ }
177
+ }
178
+ return 0;
179
+ }
180
+
181
+
182
+ ### Function: Check Voted By Cookie
183
+ function check_voted_cookie($poll_id) {
184
+ // 0: False | > 0: True
185
+ return intval($_COOKIE["voted_$poll_id"]);
186
+ }
187
+
188
+
189
+ ### Function: Check Voted By IP
190
+ function check_voted_ip($poll_id) {
191
+ global $wpdb;
192
+ // Check IP From IP Logging Database
193
+ $get_voted_aid = $wpdb->get_var("SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_ip = '".get_ipaddress()."'");
194
+ // 0: False | > 0: True
195
+ return intval($get_voted_aid);
196
+ }
197
+
198
+
199
+ ### Function: Display Voting Form
200
+ function display_pollvote($poll_id, $without_poll_title = false) {
201
+ global $wpdb;
202
+ // Temp Poll Result
203
+ $temp_pollvote = '';
204
+ // Get Poll Question Data
205
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
206
+ // Poll Question Variables
207
+ $poll_question_text = stripslashes($poll_question->pollq_question);
208
+ $poll_question_id = intval($poll_question->pollq_id);
209
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
210
+ $template_question = stripslashes(get_settings('poll_template_voteheader'));
211
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
212
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
213
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
214
+ // Get Poll Answers Data
215
+ $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'));
216
+ // If There Is Poll Question With Answers
217
+ if($poll_question && $poll_answers) {
218
+ // Display Poll Voting Form
219
+ if(!$without_poll_title) {
220
+ $temp_pollvote .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
221
+ $temp_pollvote .= "\t<form id=\"polls_form_$poll_question_id\" action=\"$_SERVER[REQUEST_URI]\" method=\"post\">\n";
222
+ $temp_pollvote .= "\t\t<input type=\"hidden\" name=\"poll_id\" value=\"$poll_question_id\" />\n";
223
+ // Print Out Voting Form Header Template
224
+ $temp_pollvote .= "\t\t$template_question\n";
225
+ }
226
+ foreach($poll_answers as $poll_answer) {
227
+ // Poll Answer Variables
228
+ $poll_answer_id = intval($poll_answer->polla_aid);
229
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
230
+ $poll_answer_votes = intval($poll_answer->polla_votes);
231
+ $template_answer = stripslashes(get_settings('poll_template_votebody'));
232
+ $template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
233
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
234
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
235
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
236
+ // Print Out Voting Form Body Template
237
+ $temp_pollvote .= "\t\t$template_answer\n";
238
+ }
239
+ // Determine Poll Result URL
240
+ $poll_result_url = $_SERVER['REQUEST_URI'];
241
+ $poll_result_url = preg_replace('/pollresult=(\d+)/i', 'pollresult='.$poll_question_id, $poll_result_url);
242
+ if(intval($_GET['pollresult']) == 0) {
243
+ if(strpos($poll_result_url, '?') !== false) {
244
+ $poll_result_url = "$poll_result_url&amp;pollresult=$poll_question_id";
245
+ } else {
246
+ $poll_result_url = "$poll_result_url?pollresult=$poll_question_id";
247
+ }
248
+ }
249
+ // Voting Form Footer Variables
250
+ $template_footer = stripslashes(get_settings('poll_template_votefooter'));
251
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
252
+ $template_footer = str_replace("%POLL_RESULT_URL%", $poll_result_url, $template_footer);
253
+ // Print Out Voting Form Footer Template
254
+ $temp_pollvote .= "\t\t$template_footer\n";
255
+ if(!$without_poll_title) {
256
+ $temp_pollvote .= "\t</form>\n";
257
+ $temp_pollvote .= "</div>\n";
258
+ $temp_pollvote .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".get_settings('siteurl')."/wp-content/plugins/polls/images/loading.gif\" width=\"16\" height=\"16\" alt=\"".__('Loading')." ...\" title=\"".__('Loading')." ...\" />&nbsp;".__('Loading')." ...</div>\n";
259
+ }
260
+ } else {
261
+ $temp_pollvote .= stripslashes(get_settings('poll_template_disable'));
262
+ }
263
+ // Return Poll Vote Template
264
+ return $temp_pollvote;
265
+ }
266
+
267
+
268
+ ### Function: Display Results Form
269
+ function display_pollresult($poll_id, $user_voted = 0, $without_poll_title = false) {
270
+ global $wpdb;
271
+ // Temp Poll Result
272
+ $temp_pollresult = '';
273
+ // Most/Least Variables
274
+ $poll_most_answer = '';
275
+ $poll_most_votes = 0;
276
+ $poll_most_percentage = 0;
277
+ $poll_least_answer = '';
278
+ $poll_least_votes = 0;
279
+ $poll_least_percentage = 0;
280
+ // Get Poll Question Data
281
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
282
+ // Poll Question Variables
283
+ $poll_question_text = stripslashes($poll_question->pollq_question);
284
+ $poll_question_id = intval($poll_question->pollq_id);
285
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
286
+ $poll_question_active = intval($poll_question->pollq_active);
287
+ $template_question = stripslashes(get_settings('poll_template_resultheader'));
288
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
289
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
290
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
291
+ // Get Poll Answers Data
292
+ $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'));
293
+ // If There Is Poll Question With Answers
294
+ if($poll_question && $poll_answers) {
295
+ // Is The Poll Total Votes 0?
296
+ $poll_totalvotes_zero = true;
297
+ if($poll_question_totalvotes > 0) {
298
+ $poll_totalvotes_zero = false;
299
+ }
300
+ // Print Out Result Header Template
301
+ if(!$without_poll_title) {
302
+ $temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
303
+ $temp_pollresult .= "\t\t$template_question\n";
304
+ }
305
+ foreach($poll_answers as $poll_answer) {
306
+ // Poll Answer Variables
307
+ $poll_answer_id = intval($poll_answer->polla_aid);
308
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
309
+ $poll_answer_votes = intval($poll_answer->polla_votes);
310
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
311
+ $poll_answer_percentage = 0;
312
+ $poll_answer_imagewidth = 0;
313
+ // Calculate Percentage And Image Bar Width
314
+ if(!$poll_totalvotes_zero) {
315
+ if($poll_answer_votes > 0) {
316
+ $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*100));
317
+ $poll_answer_imagewidth = round($poll_answer_percentage);
318
+ } else {
319
+ $poll_answer_percentage = 0;
320
+ $poll_answer_imagewidth = 1;
321
+ }
322
+ } else {
323
+ $poll_answer_percentage = 0;
324
+ $poll_answer_imagewidth = 1;
325
+ }
326
+ // Let User See What Options They Voted
327
+ if($user_voted == $poll_answer_id) {
328
+ // Results Body Variables
329
+ $template_answer = stripslashes(get_settings('poll_template_resultbody2'));
330
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
331
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
332
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
333
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
334
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
335
+ // Print Out Results Body Template
336
+ $temp_pollresult .= "\t\t$template_answer\n";
337
+ } else {
338
+ // Results Body Variables
339
+ $template_answer = stripslashes(get_settings('poll_template_resultbody'));
340
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
341
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
342
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
343
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
344
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
345
+ // Print Out Results Body Template
346
+ $temp_pollresult .= "\t\t$template_answer\n";
347
+ }
348
+ // Get Most Voted Data
349
+ if($poll_answer_votes > $poll_most_votes) {
350
+ $poll_most_answer = $poll_answer_text;
351
+ $poll_most_votes = $poll_answer_votes;
352
+ $poll_most_percentage = $poll_answer_percentage;
353
+ }
354
+ // Get Least Voted Data
355
+ if($poll_least_votes == 0) {
356
+ $poll_least_votes = $poll_answer_votes;
357
+ }
358
+ if($poll_answer_votes <= $poll_least_votes) {
359
+ $poll_least_answer = $poll_answer_text;
360
+ $poll_least_votes = $poll_answer_votes;
361
+ $poll_least_percentage = $poll_answer_percentage;
362
+ }
363
+ }
364
+ // Results Footer Variables
365
+ if($user_voted > 0 || $poll_question_active == 0 || !check_allowtovote()) {
366
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter'));
367
+ } else {
368
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter2'));
369
+ }
370
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
371
+ $template_footer = str_replace("%POLL_TOTALVOTES%", number_format($poll_question_totalvotes), $template_footer);
372
+ $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
373
+ $template_footer = str_replace("%POLL_MOST_VOTES%", number_format($poll_most_votes), $template_footer);
374
+ $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
375
+ $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
376
+ $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format($poll_least_votes), $template_footer);
377
+ $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
378
+ // Print Out Results Footer Template
379
+ $temp_pollresult .= "\t\t$template_footer\n";
380
+ if(!$without_poll_title) {
381
+ $temp_pollresult .= "</div>\n";
382
+ $temp_pollresult .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".get_settings('siteurl')."/wp-content/plugins/polls/images/loading.gif\" width=\"16\" height=\"16\" alt=\"".__('Loading')." ...\" title=\"".__('Loading')." ...\" />&nbsp;".__('Loading')." ...</div>\n";
383
+ }
384
+ } else {
385
+ $temp_pollresult .= stripslashes(get_settings('poll_template_disable'));
386
+ }
387
+ // Return Poll Result
388
+ return $temp_pollresult;
389
+ }
390
+
391
+
392
+ ### Function: Vote Poll
393
+ add_action('init', 'vote_poll');
394
+ function vote_poll() {
395
+ global $wpdb, $user_identity;
396
+ if(!empty($_POST['vote'])) {
397
+ $poll_id = intval($_POST['poll_id']);
398
+ $poll_aid = intval($_POST["poll_$poll_id"]);
399
+ if($poll_id > 0 && $poll_aid > 0 && check_allowtovote()) {
400
+ $check_voted = check_voted($poll_id);
401
+ if($check_voted == 0) {
402
+ if(!empty($user_identity)) {
403
+ $pollip_user = addslashes($user_identity);
404
+ } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
405
+ $pollip_user = addslashes($_COOKIE['comment_author_'.COOKIEHASH]);
406
+ } else {
407
+ $pollip_user = 'Guest';
408
+ }
409
+ $pollip_ip = get_ipaddress();
410
+ $pollip_host = gethostbyaddr($pollip_ip);
411
+ $pollip_timestamp = current_time('timestamp');
412
+ $poll_logging_method = intval(get_settings('poll_logging_method'));
413
+ switch($poll_logging_method) {
414
+ // Logged By Cookie
415
+ case 1:
416
+ $vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
417
+ break;
418
+ // Logged By IP
419
+ case 2:
420
+ $vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES(0,$poll_id,$poll_aid,'$pollip_ip','$pollip_host','$pollip_timestamp','$pollip_user')");
421
+ break;
422
+ // Logged By Cookie And IP
423
+ case 3:
424
+ $vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
425
+ $vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES(0,$poll_id,$poll_aid,'$pollip_ip','$pollip_host','$pollip_timestamp','$pollip_user')");
426
+ break;
427
+ }
428
+ $vote_a = $wpdb->query("UPDATE $wpdb->pollsa SET polla_votes = (polla_votes+1) WHERE polla_qid = $poll_id AND polla_aid = $poll_aid");
429
+ if($vote_a) {
430
+ $vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+1) WHERE pollq_id = $poll_id");
431
+ if($vote_q) {
432
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id,$poll_aid, 1);
433
+ exit();
434
+ } else {
435
+ _e("Unable To Update Poll Total Votes. Poll ID #$poll_id.");
436
+ exit();
437
+ } // End if($vote_q)
438
+ } else {
439
+ _e("Unable To Update Poll Answer Votes. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
440
+ exit();
441
+ } // End if($vote_a)
442
+ } else {
443
+ _e("You Had Already Voted For This Poll. Poll ID #$poll_id.");
444
+ exit();
445
+ }// End if($check_voted)
446
+ } else {
447
+ _e("Invalid Poll ID Or Poll Answer ID. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
448
+ exit();
449
+ } // End if($poll_id > 0 && $poll_aid > 0)
450
+ } elseif (intval($_GET['pollresult']) > 0) {
451
+ $poll_id = intval($_GET['pollresult']);
452
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id, 0, true);
453
+ exit();
454
+ } elseif (intval($_GET['pollbooth']) > 0) {
455
+ $poll_id = intval($_GET['pollbooth']);
456
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollvote($poll_id, true);
457
+ exit();
458
+ } // End if(!empty($_POST['vote']))
459
+ }
460
+
461
+
462
+ ### Function: Get IP Address
463
+ if(!function_exists('get_ipaddress')) {
464
+ function get_ipaddress() {
465
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
466
+ $ip_address = $_SERVER["REMOTE_ADDR"];
467
+ } else {
468
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
469
+ }
470
+ if(strpos($ip_address, ',') !== false) {
471
+ $ip_address = explode(',', $ip_address);
472
+ $ip_address = $ip_address[0];
473
+ }
474
+ return $ip_address;
475
+ }
476
+ }
477
+
478
+
479
+ ### Function: Place Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
480
+ add_filter('the_content', 'place_poll', '12');
481
+ function place_poll($content){
482
+ $content = preg_replace( "/\[poll=(\d+)\]/ise", "display_poll('\\1')", $content);
483
+ return $content;
484
+ }
485
+
486
+
487
+ ### Function: Display The Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
488
+ function display_poll($poll_id, $display_pollarchive = false){
489
+ if (function_exists('vote_poll')){
490
+ if($display_pollarchive) {
491
+ return get_poll($poll_id, false)."\n".'<p><a href="'.get_settings('home').'/wp-polls.php">Polls Archive</a></p>';
492
+ } else {
493
+ return get_poll($poll_id, false);
494
+ }
495
+ }
496
+ }
497
+
498
+
499
+ ### Function: Get Poll Total Questions
500
+ if(!function_exists('get_pollquestions')) {
501
+ function get_pollquestions() {
502
+ global $wpdb;
503
+ $totalpollq = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
504
+ echo $totalpollq;
505
+ }
506
+ }
507
+
508
+
509
+ ### Function: Get Poll Total Answers
510
+ if(!function_exists('get_pollanswers')) {
511
+ function get_pollanswers() {
512
+ global $wpdb;
513
+ $totalpolla = $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa");
514
+ echo $totalpolla;
515
+ }
516
+ }
517
+
518
+
519
+ ### Function: Get Poll Total Votes
520
+ if(!function_exists('get_pollvotes')) {
521
+ function get_pollvotes() {
522
+ global $wpdb;
523
+ $totalpollip = $wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip");
524
+ echo $totalpollip;
525
+ }
526
+ }
527
+
528
+
529
+ ### Function: Create Poll Tables
530
+ add_action('activate_polls/polls.php', 'create_poll_table');
531
+ function create_poll_table() {
532
+ global $wpdb;
533
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
534
+ // Create Poll Tables (3 Tables)
535
+ $create_table = array();
536
+ $create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
537
+ "pollq_id int(10) NOT NULL auto_increment,".
538
+ "pollq_question varchar(200) NOT NULL default '',".
539
+ "pollq_timestamp varchar(20) NOT NULL default '',".
540
+ "pollq_totalvotes int(10) NOT NULL default '0',".
541
+ "pollq_active tinyint(1) NOT NULL default '1',".
542
+ "PRIMARY KEY (pollq_id))";
543
+ $create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (".
544
+ "polla_aid int(10) NOT NULL auto_increment,".
545
+ "polla_qid int(10) NOT NULL default '0',".
546
+ "polla_answers varchar(200) NOT NULL default '',".
547
+ "polla_votes int(10) NOT NULL default '0',".
548
+ "PRIMARY KEY (polla_aid))";
549
+ $create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (".
550
+ "pollip_id int(10) NOT NULL auto_increment,".
551
+ "pollip_qid varchar(10) NOT NULL default '',".
552
+ "pollip_aid varchar(10) NOT NULL default '',".
553
+ "pollip_ip varchar(100) NOT NULL default '',".
554
+ "pollip_host VARCHAR(200) NOT NULL default '',".
555
+ "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
556
+ "pollip_user tinytext NOT NULL,".
557
+ "PRIMARY KEY (pollip_id))";
558
+ maybe_create_table($wpdb->pollsq, $create_table['pollsq']);
559
+ maybe_create_table($wpdb->pollsa, $create_table['pollsa']);
560
+ maybe_create_table($wpdb->pollsip, $create_table['pollsip']);
561
+ // Check Whether It is Install Or Upgrade
562
+ $first_poll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq LIMIT 1");
563
+ // If Install, Insert 1st Poll Question With 5 Poll Answers
564
+ if(empty($first_poll)) {
565
+ // Insert Poll Question (1 Record)
566
+ $insert_pollq = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (1, 'How Is My Site?', '".current_time('timestamp')."', 0, 1);");
567
+ if($insert_pollq) {
568
+ // Insert Poll Answers (5 Records)
569
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (1, 1, 'Good', 0);");
570
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (2, 1, 'Excellent', 0);");
571
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (3, 1, 'Bad', 0);");
572
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (4, 1, 'Can Be Improved', 0);");
573
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (5, 1, 'No Comments', 0);");
574
+ }
575
+ }
576
+ // Add In Options (16 Records)
577
+ add_option('poll_template_voteheader', '<p align="center"><b>%POLL_QUESTION%</b></p>'.
578
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
579
+ '<ul class="wp-polls-ul">', 'Template For Poll\'s Question');
580
+ add_option('poll_template_votebody', '<li><label for="poll-answer-%POLL_ANSWER_ID%"><input type="radio" id="poll-answer-%POLL_ANSWER_ID%" name="poll_%POLL_ID%" value="%POLL_ANSWER_ID%" /> %POLL_ANSWER%</label></li>', 'Template For Poll\'s Answers');
581
+ add_option('poll_template_votefooter', '</ul>'.
582
+ '<p align="center"><input type="button" name="vote" value=" Vote " class="Buttons" onclick="poll_vote(%POLL_ID%);" /><br /><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" title="View Results Of This Poll">View Results</a></p>'.
583
+ '</div>', 'Template For Poll\'s Voting Footer');
584
+ add_option('poll_template_resultheader', '<p align="center"><b>%POLL_QUESTION%</b></p>'.
585
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
586
+ '<ul class="wp-polls-ul">', 'Template For Poll Header');
587
+ add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small><br /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollstart.gif" height="10" width="2" alt="" /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollbar.gif" height="10" width="%POLL_ANSWER_IMAGEWIDTH%" alt="%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)" title="%POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)" /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollend.gif" height="10" width="2" alt="" /></li>', 'Template For Poll Results');
588
+ add_option('poll_template_resultbody2', '<li><b><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small></i></b><br /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollstart.gif" height="10" width="2" alt="" /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollbar.gif" height="10" width="%POLL_ANSWER_IMAGEWIDTH%" alt="You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)" title="You Have Voted For This Choice - %POLL_ANSWER% -> %POLL_ANSWER_PERCENTAGE%% (%POLL_ANSWER_VOTES% Votes)" /><img src="'.get_settings('siteurl').'/wp-content/plugins/polls/images/pollend.gif" height="10" width="2" alt="" /></li>', 'Template For Poll Results (User Voted)');
589
+ add_option('poll_template_resultfooter', '</ul>'.
590
+ '<p align="center">Total Votes: <b>%POLL_TOTALVOTES%</b></p>'.
591
+ '</div>', 'Template For Poll Result Footer');
592
+ add_option('poll_template_resultfooter2', '</ul>'.
593
+ '<p align="center">Total Votes: <b>%POLL_TOTALVOTES%</b><br /><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" title="Vote For This Poll">Vote</a></p>'.
594
+ '</div>', 'Template For Poll Result Footer');
595
+ add_option('poll_template_disable', 'Sorry, there are no polls available at the moment.', 'Template For Poll When It Is Disabled');
596
+ add_option('poll_template_error', 'An error has occurred when processing your poll.', 'Template For Poll When An Error Has Occured');
597
+ add_option('poll_currentpoll', 0, 'Current Displayed Poll');
598
+ add_option('poll_latestpoll', 1, 'The Lastest Poll');
599
+ add_option('poll_archive_perpage', 5, 'Number Of Polls To Display Per Page On The Poll\'s Archive', 'no');
600
+ add_option('poll_ans_sortby', 'polla_aid', 'Sorting Of Poll\'s Answers');
601
+ add_option('poll_ans_sortorder', 'asc', 'Sort Order Of Poll\'s Answers');
602
+ add_option('poll_ans_result_sortby', 'polla_votes', 'Sorting Of Poll\'s Answers Result');
603
+ add_option('poll_ans_result_sortorder', 'desc', 'Sorting Order Of Poll\'s Answers Result');
604
+ // Database Upgrade For WP-Polls 2.1
605
+ add_option('poll_logging_method', '3', 'Logging Method Of User Poll\'s Answer');
606
+ add_option('poll_allowtovote', '2', 'Who Is Allowed To Vote');
607
+ maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE $wpdb->pollsq ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';");
608
+ // Set 'manage_polls' Capabilities To Administrator
609
+ $role = get_role('administrator');
610
+ if(!$role->has_cap('manage_polls')) {
611
+ $role->add_cap('manage_polls');
612
+ }
613
+ }
614
+ ?>
readme.html ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>WP-Polls 2.1 Readme</title>
6
+ <style type="text/css" media="screen">
7
+ /* Default Style */
8
+ BODY {
9
+ font-family: Verdana, Arial;
10
+ font-size: 12px;
11
+ color: #000000;
12
+ background: #FFFFFF;
13
+ }
14
+ P {
15
+ padding-left: 10px;
16
+ }
17
+ BLOCKQUOTE {
18
+ margin: 10px 20px 0px 20px;
19
+ padding: 10px;
20
+ border: 1px solid #8d8d8d;
21
+ background-color: #f5f5f5;
22
+ }
23
+ LI {
24
+ margin-top: 20px;
25
+ }
26
+ UL LI UL LI {
27
+ margin-top: 10px;
28
+ }
29
+ A, A:active, A:link, A:visited {
30
+ color: #2d3a4c;
31
+ text-decoration: none;
32
+ }
33
+ A:hover {
34
+ color: #5577a5;
35
+ text-decoration: underline;
36
+ }
37
+ /* Place Holder Style */
38
+ #Container {
39
+ width: 780px;
40
+ margin-left: auto;
41
+ margin-right: auto;
42
+ }
43
+ #Content {
44
+ background-color: #fafafa;
45
+ border: 1px solid #a2b6cb;
46
+ padding: 10px;
47
+ margin-top: -13px;
48
+ }
49
+ /* Title Style */
50
+ #Title {
51
+ font-family: Verdana, Arial;
52
+ font-size: 22px;
53
+ font-weight: bold;
54
+ color: #389aff;
55
+ border-bottom: 1px solid #389aff;
56
+ margin-bottom: 10px;
57
+ }
58
+ .SubTitle {
59
+ font-family: Verdana, Arial;
60
+ font-size: 18px;
61
+ font-weight: bold;
62
+ color: #5b87b4;
63
+ }
64
+ .SubSubTitle {
65
+ font-family: Verdana, Arial;
66
+ font-size: 14px;
67
+ font-weight: bold;
68
+ color: #73a4d6;
69
+ }
70
+ /* Tabs */
71
+ UL#Tabs {
72
+ font-family: Verdana, Arial;
73
+ font-size: 12px;
74
+ font-weight: bold;
75
+ list-style-type: none;
76
+ padding-bottom: 28px;
77
+ border-bottom: 1px solid #a2b6cb;
78
+ margin-bottom: 12px;
79
+ z-index: 1;
80
+ }
81
+ #Tabs LI.Tab {
82
+ float: right;
83
+ height: 25px;
84
+ background-color: #deedfb;
85
+ margin: 2px 0px 0px 5px;
86
+ border: 1px solid #a2b6cb;
87
+ }
88
+ #Tabs LI.Tab A {
89
+ float: left;
90
+ display: block;
91
+ color: #666666;
92
+ text-decoration: none;
93
+ padding: 5px;
94
+ }
95
+ #Tabs LI.Tab A:hover {
96
+ background-color: #bfe0fe;
97
+ border-bottom: 1px solid #bfe0fe;
98
+ }
99
+ /* Selected Tab */
100
+ #Tabs LI.SelectedTab {
101
+ float: right;
102
+ height: 25px;
103
+ background-color: #fafafa;
104
+ margin: 2px 0px 0px 5px;
105
+ border-top: 1px solid #a2b6cb;
106
+ border-right: 1px solid #a2b6cb;
107
+ border-bottom: 1px solid #fafafa;
108
+ border-left: 1px solid #a2b6cb;
109
+ }
110
+ #Tabs LI.SelectedTab A {
111
+ float: left;
112
+ display: block;
113
+ color: #666666;
114
+ text-decoration: none;
115
+ padding: 5px;
116
+ cursor: default;
117
+ }
118
+ /* Copyright */
119
+ #Copyright {
120
+ text-align: center;
121
+ }
122
+ </style>
123
+ <script type="text/javascript">
124
+ // Index Page
125
+ function index() {
126
+ // Tab
127
+ document.getElementById('IndexTab').className = 'SelectedTab';
128
+ document.getElementById('InstallTab').className = 'Tab';
129
+ document.getElementById('UpgradeTab').className = 'Tab';
130
+ document.getElementById('UsageTab').className = 'Tab';
131
+ // Page
132
+ document.getElementById('Index').style.display= 'block';
133
+ document.getElementById('IndexTab').className = 'SelectedTab';
134
+ document.getElementById('Install').style.display = 'none';
135
+ document.getElementById('Upgrade').style.display = 'none';
136
+ document.getElementById('Usage').style.display = 'none';
137
+ }
138
+ // Installation Page
139
+ function install() {
140
+ // Tab
141
+ document.getElementById('IndexTab').className = 'Tab';
142
+ document.getElementById('InstallTab').className = 'SelectedTab';
143
+ document.getElementById('UpgradeTab').className = 'Tab';
144
+ document.getElementById('UsageTab').className = 'Tab';
145
+ // Page
146
+ document.getElementById('Index').style.display= 'none';
147
+ document.getElementById('Install').style.display = 'block';
148
+ document.getElementById('Upgrade').style.display = 'none';
149
+ document.getElementById('Usage').style.display = 'none';
150
+ }
151
+ // Upgrade Page
152
+ function upgrade() {
153
+ // Tab
154
+ document.getElementById('IndexTab').className = 'Tab';
155
+ document.getElementById('InstallTab').className = 'Tab';
156
+ document.getElementById('UpgradeTab').className = 'SelectedTab';
157
+ document.getElementById('UpgradeTab').href = 'Tab';
158
+ document.getElementById('UsageTab').className = 'Tab';
159
+ // Page
160
+ document.getElementById('Index').style.display= 'none';
161
+ document.getElementById('Install').style.display = 'none';
162
+ document.getElementById('Upgrade').style.display = 'block';
163
+ document.getElementById('Usage').style.display = 'none';
164
+ }
165
+ // Usage Page
166
+ function usage() {
167
+ // Tab
168
+ document.getElementById('IndexTab').className = 'Tab';
169
+ document.getElementById('InstallTab').className = 'Tab';
170
+ document.getElementById('UpgradeTab').className = 'Tab';
171
+ document.getElementById('UsageTab').className = 'SelectedTab';
172
+ // Page
173
+ document.getElementById('Index').style.display= 'none';
174
+ document.getElementById('Install').style.display = 'none';
175
+ document.getElementById('Upgrade').style.display = 'none';
176
+ document.getElementById('Usage').style.display = 'block';
177
+ }
178
+ </script>
179
+ </head>
180
+ <body>
181
+ <div id="Container">
182
+ <!-- Title -->
183
+ <div id="Title">WP-Polls 2.1&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
184
+
185
+ <!-- Tabs -->
186
+ <ul id="Tabs">
187
+ <li id="UsageTab" class="Tab"><a href="#Usage" onclick="usage(); return false;" title="Usage Instructions">Usage</a></li>
188
+ <li id="UpgradeTab" class="Tab"><a href="#Upgrade" onclick="upgrade(); return false;" title="Upgrade Instructions">Upgrade</a></li>
189
+ <li id="InstallTab" class="Tab"><a href="#Installation" onclick="install(); return false;" title="Installation Instructions">Installation</a></li>
190
+ <li id="IndexTab" class="SelectedTab"><a href="#Index" onclick="index(); return false;" title="Index Instructions">Index</a></li>
191
+ </ul>
192
+
193
+ <!-- Content -->
194
+ <div id="Content">
195
+ <!-- Index -->
196
+ <div id="Index">
197
+ <div class="SubTitle">&raquo; Index</div>
198
+ <div class="SubSubTitle">Plugin Information</div>
199
+ <p><b>Author</b><br /><b>&raquo;</b> Lester 'GaMerZ' Chan</p>
200
+ <p>
201
+ <b>EMail:</b><br /><b>&raquo;</b>
202
+ <script type="text/javascript">
203
+ /* <![CDATA[*/
204
+ document.write(' <a href="mailto:gamerz84@hotmail.com?Subject=WP-Polls%202.1%20Support" title="EMail To gamerz84@hotmail.com">gamerz84@hotmail.com</a>');
205
+ /* ]]> */
206
+ </script>
207
+ </p>
208
+ <p><b>Website:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/" title="http://www.lesterchan.net/">http://www.lesterchan.net/</a></p>
209
+ <p><b>Demo:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/blogs" title="http://www.lesterchan.net/blogs">http://www.lesterchan.net/blogs</a></p>
210
+ <p><b>Documentation:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/wiki/wp-polls" title="http://dev.wp-plugins.org/wiki/wp-polls">http://dev.wp-plugins.org/wiki/wp-polls</a></p>
211
+ <p><b>Development:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/browser/wp-polls/" title="http://dev.wp-plugins.org/browser/wp-polls/">http://dev.wp-plugins.org/browser/wp-polls/</a></p>
212
+ <p><b>Support Forums:</b><br /><b>&raquo;</b> <a href="http://forums.lesterchan.net/viewforum.php?f=7" title="http://forums.lesterchan.net/viewforum.php?f=7">http://forums.lesterchan.net/viewforum.php?f=7</a></p>
213
+ <p><b>Updated:</b><br /><b>&raquo;</b> 1st June 2006</p>
214
+ <p><b>Note:</b><br /><b>&raquo;</b> I have changed some of WP-Polls's structure to accommodate AJAX, So if there is any bug, please contact me immediately.</p>
215
+ <div class="SubSubTitle">Changelog</div>
216
+ <ul>
217
+ <li>
218
+ <b>Version 2.1 (01-06-2006)</b>
219
+ <ul>
220
+ <li>NEW: Poll Is Now Using AJAX</li>
221
+ <li>NEW: Ability To Close/Open Poll</li>
222
+ <li>NEW: Added Poll Option For Logging Method</li>
223
+ <li>NEW: Added Poll Option For Who Can Vote</li>
224
+ <li>NEW: Added Poll Results Footer Template Variable (Used When User Click "View Results")</li>
225
+ <li>NEW: Added The Ability To Delete All Poll Logs Or Logs From A Specific Poll</li>
226
+ <li>NEW: Poll Administration Panel And The Code That WP-Polls Generated Is XHTML 1.0 Transitional</li>
227
+ </ul>
228
+ </li>
229
+ <li>
230
+ <b>Version 2.06b (26-04-2006)</b>
231
+ <ul>
232
+ <li>FIXED: Bug In vote_poll();</li>
233
+ </ul>
234
+ </li>
235
+ <li>
236
+ <b>Version 2.06a (02-04-2006)</b>
237
+ <ul>
238
+ <li>FIXED: Random Poll Not Working Correctly</li>
239
+ </ul>
240
+ </li>
241
+ <li>
242
+ <b>Version 2.06 (01-04-2006)</b>
243
+ <ul>
244
+ <li>NEW: Poll Bar Is Slightly Nicer</li>
245
+ <li>NEW: Got Rid Of Tables, Now Using List</li>
246
+ <li>NEW: Added In Most Voted And Least Voted Answer/Votes/Percentage For Individual Poll As Template Variables</li>
247
+ <li>NEW: Display Random Poll Option Under Poll -> Poll Options -> Current Poll</li>
248
+ <li>FIXED: Totally Removed Tables In wp-polls.php</li>
249
+ </ul>
250
+ </li>
251
+ <li>
252
+ <b>Version 2.05 (01-03-2006)</b>
253
+ <ul>
254
+ <li>NEW: Improved On 'manage_polls' Capabilities</li>
255
+ <li>NEW: Neater Structure</li>
256
+ <li>NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin</li>
257
+ <li>NEW: Added Poll Stats Function</li>
258
+ </ul>
259
+ </li>
260
+ <li>
261
+ <b>Version 2.04 (01-02-2006)</b>
262
+ <ul>
263
+ <li>NEW: Added 'manage_polls' Capabilities To Administrator Role</li>
264
+ <li>NEW: [poll=POLL_ID] Tag To Insert Poll Into A Post</li>
265
+ <li>NEW: Ability To Edit Poll's Timestamp</li>
266
+ <li>NEW: Ability To Edit Individual Poll's Answer Votes</li>
267
+ <li>NEW: %POLL_RESULT_URL% To Display Poll's Result URL</li>
268
+ <li>FIXED: Cannot Sent Header Error</li>
269
+ </ul>
270
+ </li>
271
+ <li>
272
+ <b>Version 2.03 (01-01-2006)</b>
273
+ <ul>
274
+ <li>NEW: Compatible With WordPress 2.0 Only</li>
275
+ <li>NEW: Poll Administration Menu Added Automatically Upon Activating The Plugin</li>
276
+ <li>NEW: Removed Add Poll Link From The Administration Menu</li>
277
+ <li>NEW: GPL License Added</li>
278
+ <li>NEW: Page Title Added To wp-polls.php</li>
279
+ </ul>
280
+ </li>
281
+ <li>
282
+ <b>Version 2.02a (17-11-2005)</b>
283
+ <ul>
284
+ <li>FIXED: poll-install.php And poll-upgrade.php will Now Be Installed/Upgraded To 2.02 Instead Of 2.01</li>
285
+ </ul>
286
+ </li>
287
+ <li>
288
+ <b>Version 2.02 (05-11-2005)</b>
289
+ <ul>
290
+ <li>FIXED: Showing 0 Vote On Poll Edit Page</li>
291
+ <li>FIXED: Null Vote Being Counted As A Vote</li>
292
+ <li>FIXED: Auto Loading Of Poll Option: Polls Per Page In Poll Archive Page Is Now "No"</li>
293
+ <li>NEW: Host Column In Poll IP Table To Prevent Network Lagging When Resolving IP</li>
294
+ <li>NEW: New Poll Error Template</li>
295
+ </ul>
296
+ </li>
297
+ <li>
298
+ <b>Version 2.01 (25-10-2005)</b>
299
+ <ul>
300
+ <li>FIXED: Upgrade Script To Insert Lastest Poll ID Of User's Current Polls, Instead Of Poll ID 1</li>
301
+ <li>FIXED: Replace All &lt;?= With &lt;?php</li>
302
+ <li>FIXED: Added addalshes() To $pollip_user</li>
303
+ <li>FIXED: Better Localization Support (80% Done, Will Leave It In The Mean Time)</li>
304
+ </ul>
305
+ </li>
306
+ <li>
307
+ <b>Version 2.0 (20-10-2005)</b>
308
+ <ul>
309
+ <li>NEW: IP Logging</li>
310
+ <li>NEW: Poll Options: Sorting Of Answers In Voting Form</li>
311
+ <li>NEW: Poll Options: Sorting Of Answers In Results View</li>
312
+ <li>NEW: Poll Options: Number Of Polls Per Page In Poll Archive</li>
313
+ <li>NEW: Poll Options: Choose Poll To Display On Index Page</li>
314
+ <li>NEW: Poll Options: Able To Disable Poll With Custom Message</li>
315
+ <li>NEW: Poll Options: Poll Templates</li>
316
+ <li>NEW: Display User's Voted Choice</li>
317
+ <li>FIXED: Better Install/Upgrade Script</li>
318
+ </ul>
319
+ </li>
320
+ </ul>
321
+ </div>
322
+
323
+ <!-- Installation Instructions -->
324
+ <div id="Install" style="display: none;">
325
+ <div class="SubTitle">&raquo; Installation Instructions</div>
326
+ <ol>
327
+ <li>
328
+ Open <b>wp-content/plugins</b> Folder
329
+ </li>
330
+ <li>
331
+ Put:
332
+ <blockquote>Folder: polls</blockquote>
333
+ </li>
334
+ <li>
335
+ Open <b>Root WordPress</b> Folder
336
+ </li>
337
+ <li>
338
+ Put:
339
+ <blockquote>File: wp-polls.php</blockquote>
340
+ </li>
341
+ <li>
342
+ <b>Activate</b> WP-Polls Plugin
343
+ </li>
344
+ <li>
345
+ Refer To <b>Usage</b> For Further Instructions
346
+ </li>
347
+ </ol>
348
+ </div>
349
+
350
+ <!-- Upgrade Instructions -->
351
+ <div id="Upgrade" style="display: none;">
352
+ <div class="SubTitle">&raquo; Upgrade Instructions</div>
353
+ <div class="SubSubTitle">From v2.06 To v2.1</div>
354
+ <ol>
355
+ <li>
356
+ <b>Deactivate</b> WP-Polls Plugin
357
+ </li>
358
+ <li>
359
+ Open <b>wp-content/plugins</b> Folder
360
+ </li>
361
+ <li>
362
+ Overwrite:
363
+ <blockquote>Folder: polls</blockquote>
364
+ </li>
365
+ <li>
366
+ Open <b>Root WordPress</b> Folder
367
+ </li>
368
+ <li>
369
+ Overwrite:
370
+ <blockquote>File: wp-polls.php</blockquote>
371
+ </li>
372
+ <li>
373
+ <b>Activate</b> WP-Polls Plugin
374
+ </li>
375
+ <li>
376
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
377
+ </li>
378
+ </ol>
379
+ <div class="SubSubTitle">From v1.0x To v2.1</div>
380
+ <ol>
381
+ <li>
382
+ <b>Deactivate</b> WP-Polls Plugin
383
+ </li>
384
+ <li>
385
+ Delete these file if exists:
386
+ <blockquote>
387
+ wp-content/plugins/polls.php<br />
388
+ wp-admin/polls-options.php<br />
389
+ wp-admin/polls-manager.php<br />
390
+ wp-includes/images/pollbar.gif<br />
391
+ </blockquote>
392
+ </li>
393
+ <li>
394
+ Open <b>wp-content/plugins</b> Folder
395
+ </li>
396
+ <li>
397
+ Put:
398
+ <blockquote>Folder: polls</blockquote>
399
+ </li>
400
+ <li>
401
+ Open <b>Root WordPress</b> Folder
402
+ </li>
403
+ <li>
404
+ Overwrite:
405
+ <blockquote>File: wp-polls.php</blockquote>
406
+ </li>
407
+ <li>
408
+ <b>Activate</b> WP-Polls Plugin
409
+ </li>
410
+ <li>
411
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
412
+ </li>
413
+ <li>
414
+ Refer To <b>Usage</b> For Further Instructions
415
+ </li>
416
+ </ol>
417
+ </div>
418
+
419
+ <!-- Usage Instructions -->
420
+ <div id="Usage" style="display: none;">
421
+ <div class="SubTitle">&raquo; Usage Instructions</div>
422
+ <div class="SubSubTitle">General Usage</div>
423
+ <ol>
424
+ <li>
425
+ Open <b>wp-content/themes/&lt;YOUR THEME NAME&gt;/sidebar.php</b>
426
+ </li>
427
+ <li>
428
+ Add:
429
+ <blockquote>
430
+ &lt;?php if (function_exists('vote_poll') &amp;&amp; basename($_SERVER['PHP_SELF']) != 'wp-polls.php')): ?&gt;<br />
431
+ &lt;li&gt;<br />
432
+ &nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;<br />
433
+ &nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
434
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;<br />
435
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href="&lt;?php echo get_settings('home'); ?&gt;/wp-polls.php"&gt;Polls Archive&lt;/a&gt;&lt;/li&gt;<br />
436
+ &nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
437
+ &lt;/li&gt;<br />
438
+ &lt;?php endif; ?&gt;
439
+ </blockquote>
440
+ <p>To show specific poll, use &lt;?php get_poll(&lt;ID>);?&gt; where &lt;ID&gt; is your poll id.</p>
441
+ <p>To embed a specific poll in your post, use [poll=&lt;ID>] where &lt;ID&gt; is your poll id.</p>
442
+ </li>
443
+ <li>
444
+ Tutorial On How To Integrate wp-polls.php With Your Theme:
445
+ <blockquote>
446
+ <a href="http://www.lesterchan.net/wordpress/tutorials/integrating/">http://www.lesterchan.net/wordpress/tutorials/integrating/</a>
447
+ </blockquote>
448
+ </li>
449
+ <li>
450
+ Note: In IE, some of the poll's text may appear jagged (this is normal in IE). To solve this issue,
451
+ <ol>
452
+ <li>
453
+ Open <b>poll-css.css</b>
454
+ </li>
455
+ <li>
456
+ Find:
457
+ <blockquote>
458
+ /* background-color: #ffffff; */
459
+ </blockquote>
460
+ </li>
461
+ <li>
462
+ Replace:
463
+ <blockquote>
464
+ background-color: #ffffff;
465
+ </blockquote>
466
+ <p>Where <b>#ffffff</b> should be your background color for the poll.</p>
467
+ </li>
468
+ </ol>
469
+ </li>
470
+ </ol>
471
+ <div class="SubSubTitle">Polls Stats (Outside WP Loop)</div>
472
+ <ul>
473
+ <li>
474
+ To Display <b>Total Polls</b>
475
+ </li>
476
+ <li>
477
+ Use:
478
+ <blockquote>
479
+ &lt;?php if (function_exists('get_pollquestions')): ?&gt;<br />
480
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;<br />
481
+ &lt;?php endif; ?&gt;
482
+ </blockquote>
483
+ </li>
484
+ <li>
485
+ To Display <b>Total Poll Answers</b>
486
+ </li>
487
+ <li>
488
+ Use:
489
+ <blockquote>
490
+ &lt;?php if (function_exists('get_pollanswers')): ?&gt;<br />
491
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;<br />
492
+ &lt;?php endif; ?&gt;
493
+ </blockquote>
494
+ </li>
495
+ <li>
496
+ To Display <b>Total Poll Votes</b>
497
+ </li>
498
+ <li>
499
+ Use:
500
+ <blockquote>
501
+ &lt;?php if (function_exists('get_pollvotes')): ?&gt;<br />
502
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;<br />
503
+ &lt;?php endif; ?&gt;
504
+ </blockquote>
505
+ </li>
506
+ </ul>
507
+ </div>
508
+ </div>
509
+ </div>
510
+ <p id="Copyright">WP-Polls 2.1<br />Copyright &copy; 2006 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
511
+ </body>
512
+ </html>
wp-polls.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.1 |
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(dirname(__FILE__).'/wp-blog-header.php');
22
+
23
+ ### Function: Poll Page Title
24
+ add_filter('wp_title', 'poll_pagetitle');
25
+ function poll_pagetitle($poll_pagetitle) {
26
+ return $poll_pagetitle.' &raquo; Polls';
27
+ }
28
+
29
+ ### Polls Variables
30
+ $page = intval($_GET['page']);
31
+ $polls_questions = array();
32
+ $polls_answers = array();
33
+ $polls_ip = array();
34
+ $polls_perpage = intval(get_settings('poll_archive_perpage'));
35
+ $poll_questions_ids = '0';
36
+ $poll_voted = false;
37
+ $poll_voted_aid = 0;
38
+ $poll_id = 0;
39
+
40
+ ### Get Total Polls
41
+ $total_polls = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
42
+
43
+ ### Checking $page and $offset
44
+ if (empty($page) || $page == 0) { $page = 1; }
45
+ if (empty($offset)) { $offset = 0; }
46
+
47
+ ### Determin $offset
48
+ $offset = ($page-1) * $polls_perpage;
49
+
50
+ ### Determine Max Number Of Polls To Display On Page
51
+ if(($offset + $polls_perpage) > $total_polls) {
52
+ $max_on_page = $total_polls;
53
+ } else {
54
+ $max_on_page = ($offset + $polls_perpage);
55
+ }
56
+
57
+ ### Determine Number Of Polls To Display On Page
58
+ if (($offset + 1) > ($total_polls)) {
59
+ $display_on_page = $total_polls;
60
+ } else {
61
+ $display_on_page = ($offset + 1);
62
+ }
63
+
64
+ ### Determing Total Amount Of Pages
65
+ $total_pages = ceil($total_polls / $polls_perpage);
66
+
67
+ ### Make Sure Poll Is Not Disabled
68
+ if(intval(get_settings('poll_currentpoll')) != -1 && $page < 2) {
69
+ // Hardcoded Poll ID Is Not Specified
70
+ if(intval($temp_poll_id) == 0) {
71
+ // Random Poll
72
+ if(intval(get_settings('poll_currentpoll')) == -2) {
73
+ $random_poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq ORDER BY RAND() LIMIT 1");
74
+ $poll_id = intval($random_poll_id);
75
+ // Current Poll ID Is Not Specified
76
+ } else if(intval(get_settings('poll_currentpoll')) == 0) {
77
+ // Get Lastest Poll ID
78
+ $poll_id = intval(get_settings('poll_latestpoll'));
79
+ } else {
80
+ // Get Current Poll ID
81
+ $poll_id = intval(get_settings('poll_currentpoll'));
82
+ }
83
+ // Get Hardcoded Poll ID
84
+ } else {
85
+ $poll_id = intval($temp_poll_id);
86
+ }
87
+ }
88
+
89
+ ### Get Poll Questions
90
+ $questions = $wpdb->get_results("SELECT * FROM $wpdb->pollsq WHERE pollq_id != $poll_id ORDER BY pollq_id DESC LIMIT $offset, $polls_perpage");
91
+ if($questions) {
92
+ foreach($questions as $question) {
93
+ $polls_questions[] = array('id' => intval($question->pollq_id), 'question' => stripslashes($question->pollq_question), 'timestamp' => $question->pollq_timestamp, 'totalvotes' => intval($question->pollq_totalvotes));
94
+ $poll_questions_ids .= intval($question->pollq_id).', ';
95
+ }
96
+ $poll_questions_ids = substr($poll_questions_ids, 0, -2);
97
+ }
98
+
99
+ ### Get Poll Answers
100
+ $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'));
101
+ if($answers) {
102
+ foreach($answers as $answer) {
103
+ $polls_answers[] = array('aid' => intval($answer->polla_aid), 'qid' => intval($answer->polla_qid), 'answers' => stripslashes($answer->polla_answers), 'votes' => intval($answer->polla_votes));
104
+ }
105
+ }
106
+
107
+ ### Get Poll IPs
108
+ $ips = $wpdb->get_results("SELECT pollip_qid, pollip_aid FROM $wpdb->pollsip WHERE pollip_qid IN ($poll_questions_ids) AND pollip_ip = '".get_ipaddress()."'");
109
+ if($ips) {
110
+ foreach($ips as $ip) {
111
+ $polls_ips[] = array('qid' => intval($ip->pollip_qid), 'aid' => intval($ip->pollip_aid));
112
+ }
113
+ }
114
+ ### Function: Check Voted To Get Voted Answer
115
+ function check_voted_multiple($poll_id) {
116
+ global $polls_ips;
117
+ $temp_voted_aid = 0;
118
+ if(intval($_COOKIE["voted_$poll_id"]) > 0) {
119
+ $temp_voted_aid = intval($_COOKIE["voted_$poll_id"]);
120
+ } else {
121
+ if($polls_ips) {
122
+ foreach($polls_ips as $polls_ip) {
123
+ if($polls_ip['qid'] == $poll_id) {
124
+ $temp_voted_aid = $polls_ip['aid'];
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return $temp_voted_aid;
130
+ }
131
+ ?>
132
+ <?php get_header(); ?>
133
+ <div id="content" class="narrowcolumn">
134
+ <?php
135
+ if($page < 2) {
136
+ echo "<!-- <Currrent Poll> -->\n";
137
+ echo '<h2 class="pagetitle">'.__('Current Poll').'</h2>'."\n";
138
+ // Current Poll
139
+ if(intval(get_settings('poll_currentpoll')) == -1) {
140
+ echo get_settings('poll_template_disable');
141
+ } else {
142
+ // User Click on View Results Link
143
+ if(intval($_GET['pollresult']) == $poll_id) {
144
+ echo display_pollresult($poll_id);
145
+ // Check Whether User Has Voted
146
+ } else {
147
+ $poll_active = $wpdb->get_var("SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
148
+ $poll_active = intval($poll_active);
149
+ $check_voted = check_voted($poll_id);
150
+ if($check_voted > 0 || $poll_active == 0) {
151
+ echo display_pollresult($poll_id, $check_voted);
152
+ } else {
153
+ echo display_pollvote($poll_id);
154
+ }
155
+ }
156
+ }
157
+ echo "<!-- </Currrent Poll> -->\n";
158
+ }
159
+ ?>
160
+ <!-- <Poll Archives> -->
161
+ <h2 class="pagetitle"><?php _e('Polls Archive'); ?></h2>
162
+ <?php
163
+ foreach($polls_questions as $polls_question) {
164
+ // Most/Least Variables
165
+ $poll_most_answer = '';
166
+ $poll_most_votes = 0;
167
+ $poll_most_percentage = 0;
168
+ $poll_least_answer = '';
169
+ $poll_least_votes = 0;
170
+ $poll_least_percentage = 0;
171
+ // Is The Poll Total Votes 0?
172
+ $poll_totalvotes_zero = true;
173
+ if($polls_question['totalvotes'] > 0) {
174
+ $poll_totalvotes_zero = false;
175
+ }
176
+ // Poll Question Variables
177
+ $template_question = stripslashes(get_settings('poll_template_resultheader'));
178
+ $template_question = str_replace("%POLL_QUESTION%", $polls_question['question'], $template_question);
179
+ $template_question = str_replace("%POLL_ID%", $polls_question['id'], $template_question);
180
+ $template_question = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_question);
181
+ // Print Out Result Header Template
182
+ echo $template_question;
183
+ foreach($polls_answers as $polls_answer) {
184
+ if($polls_question['id'] == $polls_answer['qid']) {
185
+ // Calculate Percentage And Image Bar Width
186
+ if(!$poll_totalvotes_zero) {
187
+ if($polls_answer['votes'] > 0) {
188
+ $poll_answer_percentage = round((($polls_answer['votes']/$polls_question['totalvotes'])*100));
189
+ $poll_answer_imagewidth = round($poll_answer_percentage*0.9);
190
+ } else {
191
+ $poll_answer_percentage = 0;
192
+ $poll_answer_imagewidth = 1;
193
+ }
194
+ } else {
195
+ $poll_answer_percentage = 0;
196
+ $poll_answer_imagewidth = 1;
197
+ }
198
+ // Let User See What Options They Voted
199
+ if(check_voted_multiple($polls_question['id']) == $polls_answer['aid']) {
200
+ // Results Body Variables
201
+ $template_answer = stripslashes(get_settings('poll_template_resultbody2'));
202
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
203
+ $template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
204
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
205
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
206
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
207
+ // Print Out Results Body Template
208
+ echo $template_answer;
209
+ } else {
210
+ // Results Body Variables
211
+ $template_answer = stripslashes(get_settings('poll_template_resultbody'));
212
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
213
+ $template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
214
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
215
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
216
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
217
+ // Print Out Results Body Template
218
+ echo $template_answer;
219
+ }
220
+ // Get Most Voted Data
221
+ if($polls_answer['votes'] > $poll_most_votes) {
222
+ $poll_most_answer = $polls_answer['answers'];
223
+ $poll_most_votes = $polls_answer['votes'];
224
+ $poll_most_percentage = $poll_answer_percentage;
225
+ }
226
+ // Get Least Voted Data
227
+ if($poll_least_votes == 0) {
228
+ $poll_least_votes = $polls_answer['votes'];
229
+ }
230
+ if($polls_answer['votes'] <= $poll_least_votes) {
231
+ $poll_least_answer = $polls_answer['answers'];
232
+ $poll_least_votes = $polls_answer['votes'];
233
+ $poll_least_percentage = $poll_answer_percentage;
234
+ }
235
+ // Delete Away From Array
236
+ unset($polls_answer['answers']);
237
+ }
238
+ }
239
+ // Results Footer Variables
240
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter'));
241
+ $template_footer = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_footer);
242
+ $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
243
+ $template_footer = str_replace("%POLL_MOST_VOTES%", number_format($poll_most_votes), $template_footer);
244
+ $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
245
+ $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
246
+ $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format($poll_least_votes), $template_footer);
247
+ $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
248
+ // Print Out Results Footer Template
249
+ echo $template_footer;
250
+ echo "<br />\n";
251
+ }
252
+ ?>
253
+ <!-- </Poll Archives> -->
254
+
255
+ <!-- <Paging> -->
256
+ <?php
257
+ if($total_pages > 1) {
258
+ ?>
259
+ <br />
260
+ <p>
261
+ <span style="float: left;">
262
+ <?php
263
+ if($page > 1 && ((($page*$polls_perpage)-($polls_perpage-1)) <= $total_polls)) {
264
+ echo '<b>&laquo;</b> <a href="wp-polls.php?page='.($page-1).'" title="&laquo; '.__('Previous Page').'">'.__('Previous Page').'</a>';
265
+ } else {
266
+ echo '&nbsp;';
267
+ }
268
+ ?>
269
+ </span>
270
+ <span style="float: right;">
271
+ <?php
272
+ if($page >= 1 && ((($page*$polls_perpage)+1) <= $total_polls)) {
273
+ echo '<a href="wp-polls.php?page='.($page+1).'" title="'.__('Next Page').' &raquo;">'.__('Next Page').'</a> <b>&raquo;</b>';
274
+ } else {
275
+ echo '&nbsp;';
276
+ }
277
+ ?>
278
+ </span>
279
+ </p>
280
+ <br style="clear: both;" />
281
+ <p>
282
+ <?php _e('Pages'); ?> (<?php echo $total_pages; ?>) :
283
+ <?php
284
+ if ($page >= 4) {
285
+ echo '<b><a href="wp-polls.php?page=1" title="'.__('Go to First Page').'">&laquo; '.__('First').'</a></b> ... ';
286
+ }
287
+ if($page > 1) {
288
+ echo ' <b><a href="wp-polls.php?page='.($page-1).'" title="&laquo; '.__('Go to Page').' '.($page-1).'">&laquo;</a></b> ';
289
+ }
290
+ for($i = $page - 2 ; $i <= $page +2; $i++) {
291
+ if ($i >= 1 && $i <= $total_pages) {
292
+ if($i == $page) {
293
+ echo "<b>[$i]</b> ";
294
+ } else {
295
+ echo '<a href="wp-polls.php?page='.($i).'" title="'.__('Page').' '.$i.'">'.$i.'</a> ';
296
+ }
297
+ }
298
+ }
299
+ if($page < $total_pages) {
300
+ echo ' <b><a href="wp-polls.php?page='.($page+1).'" title="'.__('Go to Page').' '.($page+1).' &raquo;">&raquo;</a></b> ';
301
+ }
302
+ if (($page+2) < $total_pages) {
303
+ echo ' ... <b><a href="wp-polls.php?page='.($total_pages).'" title="'.__('Go to Last Page').'">'.__('Last').' &raquo;</a></b>';
304
+ }
305
+ ?>
306
+ </p>
307
+ <!-- </Paging> -->
308
+ <?php
309
+ }
310
+ ?>
311
+ </div>
312
+ <?php get_sidebar(); ?>
313
+ <?php get_footer(); ?>