WP-Polls - Version 2.11

Version Description

Download this release

Release Info

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

Version 2.11

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.11 |
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,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-Polls 2.11 |
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(site_url + '/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_opera = (navigator.userAgent.indexOf("Opera") > -1);
28
+ var is_being_voted = false;
29
+
30
+
31
+ // When User Vote For Poll
32
+ function poll_vote(current_poll_id) {
33
+ if(!is_being_voted) {
34
+ is_being_voted = true;
35
+ poll_id = current_poll_id;
36
+ poll_form = document.getElementById('polls_form_' + poll_id);
37
+ poll_answer = eval("poll_form.poll_" + poll_id);
38
+ poll_answer_id = 0;
39
+ for(i = 0; i < poll_answer.length; i++) {
40
+ if (poll_answer[i].checked) {
41
+ poll_answer_id = poll_answer[i].value;
42
+ }
43
+ }
44
+ if(poll_answer_id > 0) {
45
+ poll_loading_text();
46
+ poll_process();
47
+ } else {
48
+ alert("Please choose a valid poll answer.");
49
+ }
50
+ } else {
51
+ alert("Your last request is still being processed. Please wait a while ...");
52
+ }
53
+ }
54
+
55
+
56
+ // When User View Poll's Result
57
+ function poll_result(current_poll_id) {
58
+ if(!is_being_voted) {
59
+ is_being_voted = true;
60
+ poll_id = current_poll_id;
61
+ poll_loading_text();
62
+ poll_process_result();
63
+ } else {
64
+ alert("Your last request is still being processed. Please wait a while ...");
65
+ }
66
+ }
67
+
68
+
69
+ // When User View Poll's Voting Booth
70
+ function poll_booth(current_poll_id) {
71
+ if(!is_being_voted) {
72
+ is_being_voted = true;
73
+ poll_id = current_poll_id;
74
+ poll_loading_text();
75
+ poll_process_booth();
76
+ } else {
77
+ alert("Your last request is still being processed. Please wait a while ...");
78
+ }
79
+ }
80
+
81
+
82
+ // Poll Fade In Text
83
+ function poll_fadein_text() {
84
+ if(poll_fadein_opacity == 90) {
85
+ poll_unloading_text();
86
+ }
87
+ if(poll_fadein_opacity < 100) {
88
+ poll_fadein_opacity += 10;
89
+ if(is_opera) {
90
+ poll_fadein_opacity = 100;
91
+ poll_unloading_text();
92
+ } else if(is_ie) {
93
+ document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadein_opacity;
94
+ } else if(is_moz) {
95
+ document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadein_opacity/100);
96
+ }
97
+ setTimeout("poll_fadein_text()", 100);
98
+ } else {
99
+ poll_fadein_opacity = 100;
100
+ is_being_voted = false;
101
+ }
102
+ }
103
+
104
+
105
+ // Poll Loading Text
106
+ function poll_loading_text() {
107
+ document.getElementById('polls-' + poll_id + '-loading').style.display = 'block';
108
+ }
109
+
110
+
111
+ // Poll Finish Loading Text
112
+ function poll_unloading_text() {
113
+ document.getElementById('polls-' + poll_id + '-loading').style.display = 'none';
114
+ }
115
+
116
+
117
+ // Process The Poll
118
+ function poll_process() {
119
+ if(poll_fadeout_opacity > 0) {
120
+ poll_fadeout_opacity -= 10;
121
+ if(is_opera) {
122
+ poll_fadeout_opacity = 0;
123
+ } else if(is_ie) {
124
+ document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
125
+ } else if(is_moz) {
126
+ document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
127
+ }
128
+ setTimeout("poll_process()", 100);
129
+ } else {
130
+ poll_fadeout_opacity = 0;
131
+ polls.setVar("vote", true);
132
+ polls.setVar("poll_id", poll_id);
133
+ polls.setVar("poll_" + poll_id, poll_answer_id);
134
+ polls.method = 'POST';
135
+ polls.element = 'polls-' + poll_id + '-ans';
136
+ polls.onCompletion = poll_fadein_text;
137
+ polls.runAJAX();
138
+ poll_fadein_opacity = 0;
139
+ poll_fadeout_opacity = 100;
140
+ }
141
+ }
142
+
143
+
144
+ // Process Poll's Result
145
+ function poll_process_result() {
146
+ if(poll_fadeout_opacity > 0) {
147
+ poll_fadeout_opacity -= 10;
148
+ if(is_opera) {
149
+ poll_fadeout_opacity = 0;
150
+ } else if(is_ie) {
151
+ document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
152
+ } else if(is_moz) {
153
+ document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
154
+ }
155
+ setTimeout("poll_process_result()", 100);
156
+ } else {
157
+ poll_fadeout_opacity = 0;
158
+ polls.setVar("pollresult", poll_id);
159
+ polls.method = 'GET';
160
+ polls.element = 'polls-' + poll_id + '-ans';
161
+ polls.onCompletion = poll_fadein_text;
162
+ polls.runAJAX();
163
+ poll_fadein_opacity = 0;
164
+ poll_fadeout_opacity = 100;
165
+ }
166
+ }
167
+
168
+
169
+ // Process Poll's Voting Booth
170
+ function poll_process_booth() {
171
+ if(poll_fadeout_opacity > 0) {
172
+ poll_fadeout_opacity -= 10;
173
+ if(is_opera) {
174
+ poll_fadeout_opacity = 0;
175
+ } else if(is_ie) {
176
+ document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity;
177
+ } else if(is_moz) {
178
+ document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100);
179
+ }
180
+ setTimeout("poll_process_booth()", 100);
181
+ } else {
182
+ poll_fadeout_opacity = 0;
183
+ polls.setVar("pollbooth", poll_id);
184
+ polls.method = 'GET';
185
+ polls.element = 'polls-' + poll_id + '-ans';
186
+ polls.onCompletion = poll_fadein_text;
187
+ polls.runAJAX();
188
+ poll_fadein_opacity = 0;
189
+ poll_fadeout_opacity = 100;
190
+ }
191
+ }
polls/polls-manager.php ADDED
@@ -0,0 +1,713 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.11 |
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.11 |
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-widget.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-Polls Widget
4
+ Plugin URI: http://www.lesterchan.net/portfolio/programming.php
5
+ Description: Adds a Sidebar Widget To Display Poll From WP-Polls Plugin
6
+ Version: 2.11
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
+ ### Function: Init WP-Polls Widget
31
+ function widget_polls_init() {
32
+ if (!function_exists('register_sidebar_widget')) {
33
+ return;
34
+ }
35
+
36
+ ### Function: WP-Polls Widget
37
+ function widget_polls($args) {
38
+ extract($args);
39
+ $options = get_option('widget_polls');
40
+ $title = __('Polls');
41
+ if (function_exists('vote_poll') && basename($_SERVER['PHP_SELF']) != 'wp-polls.php') {
42
+ echo $before_widget.$before_title.$title.$after_title;
43
+ get_poll();
44
+ if(intval($options['display_archive']) == 1) {
45
+ echo "<ul>\n<li><a href=\"".get_settings('siteurl')."/wp-content/plugins/polls/wp-polls.php\">Polls Archive</a></li></ul>\n";
46
+ }
47
+ echo $after_widget;
48
+ }
49
+ }
50
+
51
+ ### Function: WP-Polls Widget Options
52
+ function widget_polls_options() {
53
+ global $wpdb;
54
+ $options = get_option('widget_polls');
55
+ $current_poll = get_settings('poll_currentpoll');
56
+ if (!is_array($options)) {
57
+ $options = array('display_archive' => '1');
58
+ }
59
+ if ($_POST['polls-submit']) {
60
+ $poll_currentpoll = intval($_POST['poll_currentpoll']);
61
+ $options['display_archive'] = intval($_POST['polls-displayarchive']);
62
+ update_option('widget_polls', $options);
63
+ update_option('poll_currentpoll', $poll_currentpoll);
64
+ }
65
+ echo '<p style="text-align: left;"><label for="polls-displayarchive">Display Polls Archive Link?</label>&nbsp;&nbsp;&nbsp;'."\n";
66
+ echo '<input type="radio" id="polls-displayarchive" name="polls-displayarchive" value="1"';
67
+ checked(1, intval($options['display_archive']));
68
+ echo ' />&nbsp;Yes&nbsp;&nbsp;&nbsp;<input type="radio" id="polls-displayarchive" name="polls-displayarchive" value="0"';
69
+ checked(0, intval($options['display_archive']));
70
+ echo ' />&nbsp;No</p>'."\n";
71
+ echo '<p style="text-align: left;"><label for="poll_currentpoll">Current Active Poll:</label>&nbsp;&nbsp;&nbsp;'."\n";
72
+ echo '<select id="poll_currentpoll" name="poll_currentpoll" size="1">'."\n";
73
+ echo '<option value="-1"';
74
+ selected(-1, $current_poll);
75
+ echo '>';
76
+ _e('Do NOT Display Poll (Disable)');
77
+ echo '</option>'."\n";
78
+ echo '<option value="-2"';
79
+ selected(-2, $current_poll);
80
+ echo '>';
81
+ _e('Display Random Poll');
82
+ echo '</option>'."\n";
83
+ echo '<option value="0"';
84
+ selected(0, $current_poll);
85
+ echo '>';
86
+ _e('Display Latest Poll');
87
+ echo '</option>'."\n";
88
+ echo '<option value="0">&nbsp;</option>'."\n";
89
+ $polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
90
+ if($polls) {
91
+ foreach($polls as $poll) {
92
+ $poll_question = stripslashes($poll->pollq_question);
93
+ $poll_id = intval($poll->pollq_id);
94
+ if($poll_id == intval($current_poll)) {
95
+ echo "<option value=\"$poll_id\" selected=\"selected\">$poll_question</option>\n";
96
+ } else {
97
+ echo "<option value=\"$poll_id\">$poll_question</option>\n";
98
+ }
99
+ }
100
+ }
101
+ echo '</select>'."\n";
102
+ echo '</p>'."\n";
103
+ echo '<input type="hidden" id="polls-submit" name="polls-submit" value="1" />'."\n";
104
+ }
105
+
106
+ // Register Widgets
107
+ register_sidebar_widget('Polls', 'widget_polls');
108
+ register_widget_control('Polls', 'widget_polls_options', 400, 120);
109
+ }
110
+
111
+
112
+ ### Function: Load The WP-Polls Widget
113
+ add_action('plugins_loaded', 'widget_polls_init');
114
+ ?>
polls/polls.php ADDED
@@ -0,0 +1,616 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.11
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 '<script type="text/javascript">'."\n";
125
+ echo '/* Start Of Javascript Generated By WP-Polls 2.11 */'."\n";
126
+ echo '/* <![CDATA[ */'."\n";
127
+ echo "\t".'if(site_url != \''.get_settings('siteurl').'\') {'."\n";
128
+ echo "\t\t".'var site_url = \''.get_settings('siteurl').'\';'."\n";
129
+ echo "\t".'}'."\n";
130
+ echo '/* ]]> */'."\n";
131
+ echo '/* End Of Javascript Generated By WP-Polls 2.11 */'."\n";
132
+ echo '</script>'."\n";
133
+ echo '<script src="'.get_settings('siteurl').'/wp-includes/js/tw-sack.js" type="text/javascript"></script>'."\n";
134
+ echo '<script src="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-js.js" type="text/javascript"></script>'."\n";
135
+ echo '<link rel="stylesheet" href="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-css.css" type="text/css" media="screen" />'."\n";
136
+ }
137
+
138
+
139
+ ### Function: Check Who Is Allow To Vote
140
+ function check_allowtovote() {
141
+ global $user_ID;
142
+ $user_ID = intval($user_ID);
143
+ $allow_to_vote = intval(get_settings('poll_allowtovote'));
144
+ switch($allow_to_vote) {
145
+ // Guests Only
146
+ case 0:
147
+ if($user_ID > 0) {
148
+ return false;
149
+ }
150
+ return true;
151
+ break;
152
+ // Registered Users Only
153
+ case 1:
154
+ if($user_ID == 0) {
155
+ return false;
156
+ }
157
+ return true;
158
+ break;
159
+ // Registered Users And Guests
160
+ case 2:
161
+ default:
162
+ return true;
163
+ }
164
+ }
165
+
166
+
167
+ ### Funcrion: Check Voted By Cookie Or IP
168
+ function check_voted($poll_id) {
169
+ $check_voted_cookie = check_voted_cookie($poll_id);
170
+ if($check_voted_cookie > 0) {
171
+ return $check_voted_cookie;
172
+ } else {
173
+ $check_voted_ip = check_voted_ip($poll_id);
174
+ if($check_voted_ip > 0) {
175
+ return $check_voted_ip;
176
+ } else {
177
+ return 0;
178
+ }
179
+ }
180
+ return 0;
181
+ }
182
+
183
+
184
+ ### Function: Check Voted By Cookie
185
+ function check_voted_cookie($poll_id) {
186
+ // 0: False | > 0: True
187
+ return intval($_COOKIE["voted_$poll_id"]);
188
+ }
189
+
190
+
191
+ ### Function: Check Voted By IP
192
+ function check_voted_ip($poll_id) {
193
+ global $wpdb;
194
+ // Check IP From IP Logging Database
195
+ $get_voted_aid = $wpdb->get_var("SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_ip = '".get_ipaddress()."'");
196
+ // 0: False | > 0: True
197
+ return intval($get_voted_aid);
198
+ }
199
+
200
+
201
+ ### Function: Display Voting Form
202
+ function display_pollvote($poll_id, $without_poll_title = false) {
203
+ global $wpdb;
204
+ // Temp Poll Result
205
+ $temp_pollvote = '';
206
+ // Get Poll Question Data
207
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
208
+ // Poll Question Variables
209
+ $poll_question_text = stripslashes($poll_question->pollq_question);
210
+ $poll_question_id = intval($poll_question->pollq_id);
211
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
212
+ $template_question = stripslashes(get_settings('poll_template_voteheader'));
213
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
214
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
215
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
216
+ // Get Poll Answers Data
217
+ $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'));
218
+ // If There Is Poll Question With Answers
219
+ if($poll_question && $poll_answers) {
220
+ // Display Poll Voting Form
221
+ if(!$without_poll_title) {
222
+ $temp_pollvote .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
223
+ $temp_pollvote .= "\t<form id=\"polls_form_$poll_question_id\" action=\"$_SERVER[REQUEST_URI]\" method=\"post\">\n";
224
+ $temp_pollvote .= "\t\t<input type=\"hidden\" name=\"poll_id\" value=\"$poll_question_id\" />\n";
225
+ // Print Out Voting Form Header Template
226
+ $temp_pollvote .= "\t\t$template_question\n";
227
+ }
228
+ foreach($poll_answers as $poll_answer) {
229
+ // Poll Answer Variables
230
+ $poll_answer_id = intval($poll_answer->polla_aid);
231
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
232
+ $poll_answer_votes = intval($poll_answer->polla_votes);
233
+ $template_answer = stripslashes(get_settings('poll_template_votebody'));
234
+ $template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
235
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
236
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
237
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
238
+ // Print Out Voting Form Body Template
239
+ $temp_pollvote .= "\t\t$template_answer\n";
240
+ }
241
+ // Determine Poll Result URL
242
+ $poll_result_url = $_SERVER['REQUEST_URI'];
243
+ $poll_result_url = preg_replace('/pollresult=(\d+)/i', 'pollresult='.$poll_question_id, $poll_result_url);
244
+ if(intval($_GET['pollresult']) == 0) {
245
+ if(strpos($poll_result_url, '?') !== false) {
246
+ $poll_result_url = "$poll_result_url&amp;pollresult=$poll_question_id";
247
+ } else {
248
+ $poll_result_url = "$poll_result_url?pollresult=$poll_question_id";
249
+ }
250
+ }
251
+ // Voting Form Footer Variables
252
+ $template_footer = stripslashes(get_settings('poll_template_votefooter'));
253
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
254
+ $template_footer = str_replace("%POLL_RESULT_URL%", $poll_result_url, $template_footer);
255
+ // Print Out Voting Form Footer Template
256
+ $temp_pollvote .= "\t\t$template_footer\n";
257
+ if(!$without_poll_title) {
258
+ $temp_pollvote .= "\t</form>\n";
259
+ $temp_pollvote .= "</div>\n";
260
+ $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";
261
+ }
262
+ } else {
263
+ $temp_pollvote .= stripslashes(get_settings('poll_template_disable'));
264
+ }
265
+ // Return Poll Vote Template
266
+ return $temp_pollvote;
267
+ }
268
+
269
+
270
+ ### Function: Display Results Form
271
+ function display_pollresult($poll_id, $user_voted = 0, $without_poll_title = false) {
272
+ global $wpdb;
273
+ // Temp Poll Result
274
+ $temp_pollresult = '';
275
+ // Most/Least Variables
276
+ $poll_most_answer = '';
277
+ $poll_most_votes = 0;
278
+ $poll_most_percentage = 0;
279
+ $poll_least_answer = '';
280
+ $poll_least_votes = 0;
281
+ $poll_least_percentage = 0;
282
+ // Get Poll Question Data
283
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
284
+ // Poll Question Variables
285
+ $poll_question_text = stripslashes($poll_question->pollq_question);
286
+ $poll_question_id = intval($poll_question->pollq_id);
287
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
288
+ $poll_question_active = intval($poll_question->pollq_active);
289
+ $template_question = stripslashes(get_settings('poll_template_resultheader'));
290
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
291
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
292
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
293
+ // Get Poll Answers Data
294
+ $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'));
295
+ // If There Is Poll Question With Answers
296
+ if($poll_question && $poll_answers) {
297
+ // Is The Poll Total Votes 0?
298
+ $poll_totalvotes_zero = true;
299
+ if($poll_question_totalvotes > 0) {
300
+ $poll_totalvotes_zero = false;
301
+ }
302
+ // Print Out Result Header Template
303
+ if(!$without_poll_title) {
304
+ $temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
305
+ $temp_pollresult .= "\t\t$template_question\n";
306
+ }
307
+ foreach($poll_answers as $poll_answer) {
308
+ // Poll Answer Variables
309
+ $poll_answer_id = intval($poll_answer->polla_aid);
310
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
311
+ $poll_answer_votes = intval($poll_answer->polla_votes);
312
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
313
+ $poll_answer_percentage = 0;
314
+ $poll_answer_imagewidth = 0;
315
+ // Calculate Percentage And Image Bar Width
316
+ if(!$poll_totalvotes_zero) {
317
+ if($poll_answer_votes > 0) {
318
+ $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*100));
319
+ $poll_answer_imagewidth = round($poll_answer_percentage);
320
+ } else {
321
+ $poll_answer_percentage = 0;
322
+ $poll_answer_imagewidth = 1;
323
+ }
324
+ } else {
325
+ $poll_answer_percentage = 0;
326
+ $poll_answer_imagewidth = 1;
327
+ }
328
+ // Let User See What Options They Voted
329
+ if($user_voted == $poll_answer_id) {
330
+ // Results Body Variables
331
+ $template_answer = stripslashes(get_settings('poll_template_resultbody2'));
332
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
333
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
334
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
335
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
336
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
337
+ // Print Out Results Body Template
338
+ $temp_pollresult .= "\t\t$template_answer\n";
339
+ } else {
340
+ // Results Body Variables
341
+ $template_answer = stripslashes(get_settings('poll_template_resultbody'));
342
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
343
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
344
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
345
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
346
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
347
+ // Print Out Results Body Template
348
+ $temp_pollresult .= "\t\t$template_answer\n";
349
+ }
350
+ // Get Most Voted Data
351
+ if($poll_answer_votes > $poll_most_votes) {
352
+ $poll_most_answer = $poll_answer_text;
353
+ $poll_most_votes = $poll_answer_votes;
354
+ $poll_most_percentage = $poll_answer_percentage;
355
+ }
356
+ // Get Least Voted Data
357
+ if($poll_least_votes == 0) {
358
+ $poll_least_votes = $poll_answer_votes;
359
+ }
360
+ if($poll_answer_votes <= $poll_least_votes) {
361
+ $poll_least_answer = $poll_answer_text;
362
+ $poll_least_votes = $poll_answer_votes;
363
+ $poll_least_percentage = $poll_answer_percentage;
364
+ }
365
+ }
366
+ // Results Footer Variables
367
+ if($user_voted > 0 || $poll_question_active == 0 || !check_allowtovote()) {
368
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter'));
369
+ } else {
370
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter2'));
371
+ }
372
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
373
+ $template_footer = str_replace("%POLL_TOTALVOTES%", number_format($poll_question_totalvotes), $template_footer);
374
+ $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
375
+ $template_footer = str_replace("%POLL_MOST_VOTES%", number_format($poll_most_votes), $template_footer);
376
+ $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
377
+ $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
378
+ $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format($poll_least_votes), $template_footer);
379
+ $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
380
+ // Print Out Results Footer Template
381
+ $temp_pollresult .= "\t\t$template_footer\n";
382
+ if(!$without_poll_title) {
383
+ $temp_pollresult .= "</div>\n";
384
+ $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";
385
+ }
386
+ } else {
387
+ $temp_pollresult .= stripslashes(get_settings('poll_template_disable'));
388
+ }
389
+ // Return Poll Result
390
+ return $temp_pollresult;
391
+ }
392
+
393
+
394
+ ### Function: Vote Poll
395
+ add_action('init', 'vote_poll');
396
+ function vote_poll() {
397
+ global $wpdb, $user_identity;
398
+ if(!empty($_POST['vote'])) {
399
+ $poll_id = intval($_POST['poll_id']);
400
+ $poll_aid = intval($_POST["poll_$poll_id"]);
401
+ if($poll_id > 0 && $poll_aid > 0 && check_allowtovote()) {
402
+ $check_voted = check_voted($poll_id);
403
+ if($check_voted == 0) {
404
+ if(!empty($user_identity)) {
405
+ $pollip_user = addslashes($user_identity);
406
+ } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
407
+ $pollip_user = addslashes($_COOKIE['comment_author_'.COOKIEHASH]);
408
+ } else {
409
+ $pollip_user = 'Guest';
410
+ }
411
+ $pollip_ip = get_ipaddress();
412
+ $pollip_host = gethostbyaddr($pollip_ip);
413
+ $pollip_timestamp = current_time('timestamp');
414
+ $poll_logging_method = intval(get_settings('poll_logging_method'));
415
+ switch($poll_logging_method) {
416
+ // Logged By Cookie
417
+ case 1:
418
+ $vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
419
+ break;
420
+ // Logged By IP
421
+ case 2:
422
+ $vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES(0,$poll_id,$poll_aid,'$pollip_ip','$pollip_host','$pollip_timestamp','$pollip_user')");
423
+ break;
424
+ // Logged By Cookie And IP
425
+ case 3:
426
+ $vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
427
+ $vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES(0,$poll_id,$poll_aid,'$pollip_ip','$pollip_host','$pollip_timestamp','$pollip_user')");
428
+ break;
429
+ }
430
+ $vote_a = $wpdb->query("UPDATE $wpdb->pollsa SET polla_votes = (polla_votes+1) WHERE polla_qid = $poll_id AND polla_aid = $poll_aid");
431
+ if($vote_a) {
432
+ $vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+1) WHERE pollq_id = $poll_id");
433
+ if($vote_q) {
434
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id,$poll_aid, 1);
435
+ exit();
436
+ } else {
437
+ _e("Unable To Update Poll Total Votes. Poll ID #$poll_id.");
438
+ exit();
439
+ } // End if($vote_q)
440
+ } else {
441
+ _e("Unable To Update Poll Answer Votes. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
442
+ exit();
443
+ } // End if($vote_a)
444
+ } else {
445
+ _e("You Had Already Voted For This Poll. Poll ID #$poll_id.");
446
+ exit();
447
+ }// End if($check_voted)
448
+ } else {
449
+ _e("Invalid Poll ID Or Poll Answer ID. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
450
+ exit();
451
+ } // End if($poll_id > 0 && $poll_aid > 0)
452
+ } elseif (intval($_GET['pollresult']) > 0) {
453
+ $poll_id = intval($_GET['pollresult']);
454
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id, 0, true);
455
+ exit();
456
+ } elseif (intval($_GET['pollbooth']) > 0) {
457
+ $poll_id = intval($_GET['pollbooth']);
458
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollvote($poll_id, true);
459
+ exit();
460
+ } // End if(!empty($_POST['vote']))
461
+ }
462
+
463
+
464
+ ### Function: Get IP Address
465
+ if(!function_exists('get_ipaddress')) {
466
+ function get_ipaddress() {
467
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
468
+ $ip_address = $_SERVER["REMOTE_ADDR"];
469
+ } else {
470
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
471
+ }
472
+ if(strpos($ip_address, ',') !== false) {
473
+ $ip_address = explode(',', $ip_address);
474
+ $ip_address = $ip_address[0];
475
+ }
476
+ return $ip_address;
477
+ }
478
+ }
479
+
480
+
481
+ ### Function: Place Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
482
+ add_filter('the_content', 'place_poll', '12');
483
+ function place_poll($content){
484
+ $content = preg_replace( "/\[poll=(\d+)\]/ise", "display_poll('\\1')", $content);
485
+ return $content;
486
+ }
487
+
488
+
489
+ ### Function: Display The Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
490
+ function display_poll($poll_id, $display_pollarchive = false){
491
+ if (function_exists('vote_poll')){
492
+ if($display_pollarchive) {
493
+ return get_poll($poll_id, false)."\n".'<p><a href="'.get_settings('siteurl').'/wp-content/plugins/polls/wp-polls.php">Polls Archive</a></p>';
494
+ } else {
495
+ return get_poll($poll_id, false);
496
+ }
497
+ }
498
+ }
499
+
500
+
501
+ ### Function: Get Poll Total Questions
502
+ if(!function_exists('get_pollquestions')) {
503
+ function get_pollquestions() {
504
+ global $wpdb;
505
+ $totalpollq = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
506
+ echo $totalpollq;
507
+ }
508
+ }
509
+
510
+
511
+ ### Function: Get Poll Total Answers
512
+ if(!function_exists('get_pollanswers')) {
513
+ function get_pollanswers() {
514
+ global $wpdb;
515
+ $totalpolla = $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa");
516
+ echo $totalpolla;
517
+ }
518
+ }
519
+
520
+
521
+ ### Function: Get Poll Total Votes
522
+ if(!function_exists('get_pollvotes')) {
523
+ function get_pollvotes() {
524
+ global $wpdb;
525
+ $totalpollip = $wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip");
526
+ echo $totalpollip;
527
+ }
528
+ }
529
+
530
+
531
+ ### Function: Create Poll Tables
532
+ add_action('activate_polls/polls.php', 'create_poll_table');
533
+ function create_poll_table() {
534
+ global $wpdb;
535
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
536
+ // Create Poll Tables (3 Tables)
537
+ $create_table = array();
538
+ $create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
539
+ "pollq_id int(10) NOT NULL auto_increment,".
540
+ "pollq_question varchar(200) NOT NULL default '',".
541
+ "pollq_timestamp varchar(20) NOT NULL default '',".
542
+ "pollq_totalvotes int(10) NOT NULL default '0',".
543
+ "pollq_active tinyint(1) NOT NULL default '1',".
544
+ "PRIMARY KEY (pollq_id))";
545
+ $create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (".
546
+ "polla_aid int(10) NOT NULL auto_increment,".
547
+ "polla_qid int(10) NOT NULL default '0',".
548
+ "polla_answers varchar(200) NOT NULL default '',".
549
+ "polla_votes int(10) NOT NULL default '0',".
550
+ "PRIMARY KEY (polla_aid))";
551
+ $create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (".
552
+ "pollip_id int(10) NOT NULL auto_increment,".
553
+ "pollip_qid varchar(10) NOT NULL default '',".
554
+ "pollip_aid varchar(10) NOT NULL default '',".
555
+ "pollip_ip varchar(100) NOT NULL default '',".
556
+ "pollip_host VARCHAR(200) NOT NULL default '',".
557
+ "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
558
+ "pollip_user tinytext NOT NULL,".
559
+ "PRIMARY KEY (pollip_id))";
560
+ maybe_create_table($wpdb->pollsq, $create_table['pollsq']);
561
+ maybe_create_table($wpdb->pollsa, $create_table['pollsa']);
562
+ maybe_create_table($wpdb->pollsip, $create_table['pollsip']);
563
+ // Check Whether It is Install Or Upgrade
564
+ $first_poll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq LIMIT 1");
565
+ // If Install, Insert 1st Poll Question With 5 Poll Answers
566
+ if(empty($first_poll)) {
567
+ // Insert Poll Question (1 Record)
568
+ $insert_pollq = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (1, 'How Is My Site?', '".current_time('timestamp')."', 0, 1);");
569
+ if($insert_pollq) {
570
+ // Insert Poll Answers (5 Records)
571
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (1, 1, 'Good', 0);");
572
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (2, 1, 'Excellent', 0);");
573
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (3, 1, 'Bad', 0);");
574
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (4, 1, 'Can Be Improved', 0);");
575
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (5, 1, 'No Comments', 0);");
576
+ }
577
+ }
578
+ // Add In Options (16 Records)
579
+ add_option('poll_template_voteheader', '<p align="center"><b>%POLL_QUESTION%</b></p>'.
580
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
581
+ '<ul class="wp-polls-ul">', 'Template For Poll\'s Question');
582
+ 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');
583
+ add_option('poll_template_votefooter', '</ul>'.
584
+ '<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>'.
585
+ '</div>', 'Template For Poll\'s Voting Footer');
586
+ add_option('poll_template_resultheader', '<p align="center"><b>%POLL_QUESTION%</b></p>'.
587
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
588
+ '<ul class="wp-polls-ul">', 'Template For Poll Header');
589
+ 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');
590
+ 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)');
591
+ add_option('poll_template_resultfooter', '</ul>'.
592
+ '<p align="center">Total Votes: <b>%POLL_TOTALVOTES%</b></p>'.
593
+ '</div>', 'Template For Poll Result Footer');
594
+ add_option('poll_template_resultfooter2', '</ul>'.
595
+ '<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>'.
596
+ '</div>', 'Template For Poll Result Footer');
597
+ add_option('poll_template_disable', 'Sorry, there are no polls available at the moment.', 'Template For Poll When It Is Disabled');
598
+ add_option('poll_template_error', 'An error has occurred when processing your poll.', 'Template For Poll When An Error Has Occured');
599
+ add_option('poll_currentpoll', 0, 'Current Displayed Poll');
600
+ add_option('poll_latestpoll', 1, 'The Lastest Poll');
601
+ add_option('poll_archive_perpage', 5, 'Number Of Polls To Display Per Page On The Poll\'s Archive', 'no');
602
+ add_option('poll_ans_sortby', 'polla_aid', 'Sorting Of Poll\'s Answers');
603
+ add_option('poll_ans_sortorder', 'asc', 'Sort Order Of Poll\'s Answers');
604
+ add_option('poll_ans_result_sortby', 'polla_votes', 'Sorting Of Poll\'s Answers Result');
605
+ add_option('poll_ans_result_sortorder', 'desc', 'Sorting Order Of Poll\'s Answers Result');
606
+ // Database Upgrade For WP-Polls 2.1
607
+ add_option('poll_logging_method', '3', 'Logging Method Of User Poll\'s Answer');
608
+ add_option('poll_allowtovote', '2', 'Who Is Allowed To Vote');
609
+ maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE $wpdb->pollsq ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';");
610
+ // Set 'manage_polls' Capabilities To Administrator
611
+ $role = get_role('administrator');
612
+ if(!$role->has_cap('manage_polls')) {
613
+ $role->add_cap('manage_polls');
614
+ }
615
+ }
616
+ ?>
polls/wp-polls.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.11 |
6
+ | Copyright (c) 2005 Lester "GaMerZ" Chan |
7
+ | |
8
+ | File Written By: |
9
+ | - Lester "GaMerZ" Chan |
10
+ | - http://www.lesterchan.net |
11
+ | |
12
+ | File Information: |
13
+ | - Poll Archive |
14
+ | - wp-polls.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Wordpress Header
21
+ require('../../../wp-blog-header.php');
22
+
23
+ ### 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="'.get_settings('siteurl').'/wp-content/plugins/polls/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="'.get_settings('siteurl').'/wp-content/plugins/polls/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="'.get_settings('siteurl').'/wp-content/plugins/polls/wp-polls.php?page=1" title="'.__('Go to First Page').'">&laquo; '.__('First').'</a></b> ... ';
286
+ }
287
+ if($page > 1) {
288
+ echo ' <b><a href="'.get_settings('siteurl').'/wp-content/plugins/polls/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="'.get_settings('siteurl').'/wp-content/plugins/polls/wp-polls.php?page='.($i).'" title="'.__('Page').' '.$i.'">'.$i.'</a> ';
296
+ }
297
+ }
298
+ }
299
+ if($page < $total_pages) {
300
+ echo ' <b><a href="'.get_settings('siteurl').'/wp-content/plugins/polls/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="'.get_settings('siteurl').'/wp-content/plugins/polls/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(); ?>
readme.html ADDED
@@ -0,0 +1,508 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.11 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.11&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.11%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> 8th 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.11 (08-06-2006)</b>
219
+ <ul>
220
+ <li>NEW: You Can Now Place The Poll On The Sidebar As A Widget</li>
221
+ <li>NEW: Moved wp-polls.php To wp-content/plugins/polls/ Folder</li>
222
+ <li>FIXED: AJAX Not Working In Opera Browser</li>
223
+ <li>FIXED: Poll Not Working On Physical Pages That Is Integrated Into WordPress</li>
224
+ </ul>
225
+ </li>
226
+ <li>
227
+ <b>Version 2.1 (01-06-2006)</b>
228
+ <ul>
229
+ <li>NEW: Poll Is Now Using AJAX</li>
230
+ <li>NEW: Ability To Close/Open Poll</li>
231
+ <li>NEW: Added Poll Option For Logging Method</li>
232
+ <li>NEW: Added Poll Option For Who Can Vote</li>
233
+ <li>NEW: Added Poll Results Footer Template Variable (Used When User Click "View Results")</li>
234
+ <li>NEW: Added The Ability To Delete All Poll Logs Or Logs From A Specific Poll</li>
235
+ <li>NEW: Poll Administration Panel And The Code That WP-Polls Generated Is XHTML 1.0 Transitional</li>
236
+ </ul>
237
+ </li>
238
+ <li>
239
+ <b>Version 2.06b (26-04-2006)</b>
240
+ <ul>
241
+ <li>FIXED: Bug In vote_poll();</li>
242
+ </ul>
243
+ </li>
244
+ <li>
245
+ <b>Version 2.06a (02-04-2006)</b>
246
+ <ul>
247
+ <li>FIXED: Random Poll Not Working Correctly</li>
248
+ </ul>
249
+ </li>
250
+ <li>
251
+ <b>Version 2.06 (01-04-2006)</b>
252
+ <ul>
253
+ <li>NEW: Poll Bar Is Slightly Nicer</li>
254
+ <li>NEW: Got Rid Of Tables, Now Using List</li>
255
+ <li>NEW: Added In Most Voted And Least Voted Answer/Votes/Percentage For Individual Poll As Template Variables</li>
256
+ <li>NEW: Display Random Poll Option Under Poll -> Poll Options -> Current Poll</li>
257
+ <li>FIXED: Totally Removed Tables In wp-polls.php</li>
258
+ </ul>
259
+ </li>
260
+ <li>
261
+ <b>Version 2.05 (01-03-2006)</b>
262
+ <ul>
263
+ <li>NEW: Improved On 'manage_polls' Capabilities</li>
264
+ <li>NEW: Neater Structure</li>
265
+ <li>NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin</li>
266
+ <li>NEW: Added Poll Stats Function</li>
267
+ </ul>
268
+ </li>
269
+ <li>
270
+ <b>Version 2.04 (01-02-2006)</b>
271
+ <ul>
272
+ <li>NEW: Added 'manage_polls' Capabilities To Administrator Role</li>
273
+ <li>NEW: [poll=POLL_ID] Tag To Insert Poll Into A Post</li>
274
+ <li>NEW: Ability To Edit Poll's Timestamp</li>
275
+ <li>NEW: Ability To Edit Individual Poll's Answer Votes</li>
276
+ <li>NEW: %POLL_RESULT_URL% To Display Poll's Result URL</li>
277
+ <li>FIXED: Cannot Sent Header Error</li>
278
+ </ul>
279
+ </li>
280
+ <li>
281
+ <b>Version 2.03 (01-01-2006)</b>
282
+ <ul>
283
+ <li>NEW: Compatible With WordPress 2.0 Only</li>
284
+ <li>NEW: Poll Administration Menu Added Automatically Upon Activating The Plugin</li>
285
+ <li>NEW: Removed Add Poll Link From The Administration Menu</li>
286
+ <li>NEW: GPL License Added</li>
287
+ <li>NEW: Page Title Added To wp-polls.php</li>
288
+ </ul>
289
+ </li>
290
+ <li>
291
+ <b>Version 2.02a (17-11-2005)</b>
292
+ <ul>
293
+ <li>FIXED: poll-install.php And poll-upgrade.php will Now Be Installed/Upgraded To 2.02 Instead Of 2.01</li>
294
+ </ul>
295
+ </li>
296
+ <li>
297
+ <b>Version 2.02 (05-11-2005)</b>
298
+ <ul>
299
+ <li>FIXED: Showing 0 Vote On Poll Edit Page</li>
300
+ <li>FIXED: Null Vote Being Counted As A Vote</li>
301
+ <li>FIXED: Auto Loading Of Poll Option: Polls Per Page In Poll Archive Page Is Now "No"</li>
302
+ <li>NEW: Host Column In Poll IP Table To Prevent Network Lagging When Resolving IP</li>
303
+ <li>NEW: New Poll Error Template</li>
304
+ </ul>
305
+ </li>
306
+ <li>
307
+ <b>Version 2.01 (25-10-2005)</b>
308
+ <ul>
309
+ <li>FIXED: Upgrade Script To Insert Lastest Poll ID Of User's Current Polls, Instead Of Poll ID 1</li>
310
+ <li>FIXED: Replace All &lt;?= With &lt;?php</li>
311
+ <li>FIXED: Added addalshes() To $pollip_user</li>
312
+ <li>FIXED: Better Localization Support (80% Done, Will Leave It In The Mean Time)</li>
313
+ </ul>
314
+ </li>
315
+ <li>
316
+ <b>Version 2.0 (20-10-2005)</b>
317
+ <ul>
318
+ <li>NEW: IP Logging</li>
319
+ <li>NEW: Poll Options: Sorting Of Answers In Voting Form</li>
320
+ <li>NEW: Poll Options: Sorting Of Answers In Results View</li>
321
+ <li>NEW: Poll Options: Number Of Polls Per Page In Poll Archive</li>
322
+ <li>NEW: Poll Options: Choose Poll To Display On Index Page</li>
323
+ <li>NEW: Poll Options: Able To Disable Poll With Custom Message</li>
324
+ <li>NEW: Poll Options: Poll Templates</li>
325
+ <li>NEW: Display User's Voted Choice</li>
326
+ <li>FIXED: Better Install/Upgrade Script</li>
327
+ </ul>
328
+ </li>
329
+ </ul>
330
+ </div>
331
+
332
+ <!-- Installation Instructions -->
333
+ <div id="Install" style="display: none;">
334
+ <div class="SubTitle">&raquo; Installation Instructions</div>
335
+ <ol>
336
+ <li>
337
+ Open <b>wp-content/plugins</b> Folder
338
+ </li>
339
+ <li>
340
+ Put:
341
+ <blockquote>Folder: polls</blockquote>
342
+ </li>
343
+ <li>
344
+ <b>Activate</b> WP-Polls Plugin
345
+ </li>
346
+ <li>
347
+ Refer To <b>Usage</b> For Further Instructions
348
+ </li>
349
+ </ol>
350
+ </div>
351
+
352
+ <!-- Upgrade Instructions -->
353
+ <div id="Upgrade" style="display: none;">
354
+ <div class="SubTitle">&raquo; Upgrade Instructions</div>
355
+ <div class="SubSubTitle">From v2.06 To v2.11</div>
356
+ <ol>
357
+ <li>
358
+ <b>Deactivate</b> WP-Polls Plugin
359
+ </li>
360
+ <li>
361
+ Open <b>wp-content/plugins</b> Folder
362
+ </li>
363
+ <li>
364
+ Overwrite:
365
+ <blockquote>Folder: polls</blockquote>
366
+ </li>
367
+ <li>
368
+ Open <b>Root WordPress</b> Folder
369
+ </li>
370
+ <li>
371
+ Delete file if exists:
372
+ <blockquote>File: wp-polls.php</blockquote>
373
+ </li>
374
+ <li>
375
+ <b>Activate</b> WP-Polls Plugin
376
+ </li>
377
+ <li>
378
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
379
+ </li>
380
+ </ol>
381
+ <div class="SubSubTitle">From v1.0x To v2.11</div>
382
+ <ol>
383
+ <li>
384
+ <b>Deactivate</b> WP-Polls Plugin
385
+ </li>
386
+ <li>
387
+ Delete these file if exists:
388
+ <blockquote>
389
+ wp-content/plugins/polls.php<br />
390
+ wp-admin/polls-options.php<br />
391
+ wp-admin/polls-manager.php<br />
392
+ wp-includes/images/pollbar.gif<br />
393
+ wp-polls.php
394
+ </blockquote>
395
+ </li>
396
+ <li>
397
+ Open <b>wp-content/plugins</b> Folder
398
+ </li>
399
+ <li>
400
+ Put:
401
+ <blockquote>Folder: polls</blockquote>
402
+ </li>
403
+ <li>
404
+ <b>Activate</b> WP-Polls Plugin
405
+ </li>
406
+ <li>
407
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
408
+ </li>
409
+ <li>
410
+ Refer To <b>Usage</b> For Further Instructions
411
+ </li>
412
+ </ol>
413
+ </div>
414
+
415
+ <!-- Usage Instructions -->
416
+ <div id="Usage" style="display: none;">
417
+ <div class="SubTitle">&raquo; Usage Instructions</div>
418
+ <div class="SubSubTitle">General Usage</div>
419
+ <ol>
420
+ <li>
421
+ Open <b>wp-content/themes/&lt;YOUR THEME NAME&gt;/sidebar.php</b>
422
+ </li>
423
+ <li>
424
+ Add:
425
+ <blockquote>
426
+ &lt;?php if (function_exists('vote_poll') &amp;&amp; basename($_SERVER['PHP_SELF']) != 'wp-polls.php'): ?&gt;<br />
427
+ &lt;li&gt;<br />
428
+ &nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;<br />
429
+ &nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
430
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;<br />
431
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href="&lt;?php echo get_settings('siteurl'); ?&gt;/wp-content/plugins/polls/wp-polls.php"&gt;Polls Archive&lt;/a&gt;&lt;/li&gt;<br />
432
+ &nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
433
+ &lt;/li&gt;<br />
434
+ &lt;?php endif; ?&gt;
435
+ </blockquote>
436
+ <p>To show specific poll, use &lt;?php get_poll(&lt;ID>);?&gt; where &lt;ID&gt; is your poll id.</p>
437
+ <p>To embed a specific poll in your post, use [poll=&lt;ID>] where &lt;ID&gt; is your poll id.</p>
438
+ </li>
439
+ <li>
440
+ Tutorial On How To Integrate wp-polls.php With Your Theme:
441
+ <blockquote>
442
+ <a href="http://www.lesterchan.net/wordpress/tutorials/integrating/">http://www.lesterchan.net/wordpress/tutorials/integrating/</a>
443
+ </blockquote>
444
+ </li>
445
+ <li>
446
+ Note: In IE, some of the poll's text may appear jagged (this is normal in IE). To solve this issue,
447
+ <ol>
448
+ <li>
449
+ Open <b>poll-css.css</b>
450
+ </li>
451
+ <li>
452
+ Find:
453
+ <blockquote>
454
+ /* background-color: #ffffff; */
455
+ </blockquote>
456
+ </li>
457
+ <li>
458
+ Replace:
459
+ <blockquote>
460
+ background-color: #ffffff;
461
+ </blockquote>
462
+ <p>Where <b>#ffffff</b> should be your background color for the poll.</p>
463
+ </li>
464
+ </ol>
465
+ </li>
466
+ </ol>
467
+ <div class="SubSubTitle">Polls Stats (Outside WP Loop)</div>
468
+ <ul>
469
+ <li>
470
+ To Display <b>Total Polls</b>
471
+ </li>
472
+ <li>
473
+ Use:
474
+ <blockquote>
475
+ &lt;?php if (function_exists('get_pollquestions')): ?&gt;<br />
476
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;<br />
477
+ &lt;?php endif; ?&gt;
478
+ </blockquote>
479
+ </li>
480
+ <li>
481
+ To Display <b>Total Poll Answers</b>
482
+ </li>
483
+ <li>
484
+ Use:
485
+ <blockquote>
486
+ &lt;?php if (function_exists('get_pollanswers')): ?&gt;<br />
487
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;<br />
488
+ &lt;?php endif; ?&gt;
489
+ </blockquote>
490
+ </li>
491
+ <li>
492
+ To Display <b>Total Poll Votes</b>
493
+ </li>
494
+ <li>
495
+ Use:
496
+ <blockquote>
497
+ &lt;?php if (function_exists('get_pollvotes')): ?&gt;<br />
498
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;<br />
499
+ &lt;?php endif; ?&gt;
500
+ </blockquote>
501
+ </li>
502
+ </ul>
503
+ </div>
504
+ </div>
505
+ </div>
506
+ <p id="Copyright">WP-Polls 2.11<br />Copyright &copy; 2006 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
507
+ </body>
508
+ </html>