WP-Polls - Version 2.12

Version Description

Download this release

Release Info

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

Version 2.12

polls/images/loading.gif ADDED
Binary file
polls/images/pollbg.gif ADDED
Binary file
polls/polls-css.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-Polls 2.12 |
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 {
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
+ }
38
+ .wp-polls-image {
39
+ border: 0px;
40
+ }
41
+ .wp-polls .pollbar-css {
42
+ margin:1px;
43
+ font-size:6px;
44
+ line-height:8px;
45
+ height:8px;
46
+ background: #d8e1eb;
47
+ border:1px solid #c8c8c8;
48
+ }
49
+ .wp-polls .pollbar-image {
50
+ margin:1px;
51
+ font-size:6px;
52
+ line-height:8px;
53
+ height:8px;
54
+ background-image: url('images/pollbg.gif');
55
+ border:1px solid #c8c8c8;
56
+ }
polls/polls-js.js ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-Polls 2.12 |
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(ajax_url);
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.12 |
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(unhtmlentities(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(unhtmlentities(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(unhtmlentities(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(unhtmlentities(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(unhtmlentities(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(unhtmlentities(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 = unhtmlentities(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(unhtmlentities(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 htmlentities($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>'.stripslashes($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 htmlentities($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 = htmlentities(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"><strong><?php _e('Total Votes'); ?>: <?php echo $poll_actual_totalvotes; ?></strong>&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"><strong><?php _e('Timestamp'); ?></strong>:</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><strong><?php _e('Add Answer') ?></strong></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\"><strong>$pollip_answers[$pollip_aid]</strong></td>\n</tr>\n";
448
+ } else {
449
+ echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><strong>".__('Answer')." $k: $pollip_answers[$pollip_aid]</strong></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
+ <strong>Are You Sure You Want To Delete Logs For This Poll Only?</strong><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 htmlentities($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><strong><?php _e('You Are About To Delete This Poll'); ?> '<?php echo $poll_question_text; ?>'</strong></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><strong><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>.</strong></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>'.stripslashes($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><strong>$poll_id</strong></td>\n";
620
+ echo '<td>';
621
+ if($current_poll > 0) {
622
+ if($current_poll == $poll_id) {
623
+ echo '<strong>'.__('Displayed:').'</strong> ';
624
+ }
625
+ } elseif($current_poll != -1) {
626
+ if($i == 0) {
627
+ echo '<strong>'.__('Displayed:').'</strong> ';
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"><strong>'.__('No Polls Found').'</strong></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
+ <strong>Are You Sure You Want To Delete All Polls Logs?</strong><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,513 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Polls 2.12 |
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_archive_url = strip_tags(trim($_POST['poll_archive_url']));
50
+ $poll_archive_show = intval($_POST['poll_archive_show']);
51
+ $poll_currentpoll = intval($_POST['poll_currentpoll']);
52
+ $poll_logging_method = intval($_POST['poll_logging_method']);
53
+ $poll_allowtovote = intval($_POST['poll_allowtovote']);
54
+ $update_poll_queries = array();
55
+ $update_poll_text = array();
56
+ $update_poll_queries[] = update_option('poll_ans_sortby', $poll_ans_sortby);
57
+ $update_poll_queries[] = update_option('poll_ans_sortorder', $poll_ans_sortorder);
58
+ $update_poll_queries[] = update_option('poll_ans_result_sortby', $poll_ans_result_sortby);
59
+ $update_poll_queries[] = update_option('poll_ans_result_sortorder', $poll_ans_result_sortorder);
60
+ $update_poll_queries[] = update_option('poll_template_voteheader', $poll_template_voteheader);
61
+ $update_poll_queries[] = update_option('poll_template_votebody', $poll_template_votebody);
62
+ $update_poll_queries[] = update_option('poll_template_votefooter', $poll_template_votefooter);
63
+ $update_poll_queries[] = update_option('poll_template_resultheader', $poll_template_resultheader);
64
+ $update_poll_queries[] = update_option('poll_template_resultbody', $poll_template_resultbody);
65
+ $update_poll_queries[] = update_option('poll_template_resultbody2', $poll_template_resultbody2);
66
+ $update_poll_queries[] = update_option('poll_template_resultfooter', $poll_template_resultfooter);
67
+ $update_poll_queries[] = update_option('poll_template_resultfooter2', $poll_template_resultfooter2);
68
+ $update_poll_queries[] = update_option('poll_template_disable', $poll_template_disable);
69
+ $update_poll_queries[] = update_option('poll_template_error', $poll_template_error);
70
+ $update_poll_queries[] = update_option('poll_archive_perpage', $poll_archive_perpage);
71
+ $update_poll_queries[] = update_option('poll_archive_url', $poll_archive_url);
72
+ $update_poll_queries[] = update_option('poll_archive_show', $poll_archive_show);
73
+ $update_poll_queries[] = update_option('poll_currentpoll', $poll_currentpoll);
74
+ $update_poll_queries[] = update_option('poll_logging_method', $poll_logging_method);
75
+ $update_poll_queries[] = update_option('poll_allowtovote', $poll_allowtovote);
76
+ $update_poll_text[] = __('Sort Poll Answers By Option');
77
+ $update_poll_text[] = __('Sort Order Of Poll Answers Option');
78
+ $update_poll_text[] = __('Sort Poll Results By Option');
79
+ $update_poll_text[] = __('Sort Order Of Poll Results Option');
80
+ $update_poll_text[] = __('Voting Form Header Template');
81
+ $update_poll_text[] = __('Voting Form Body Template');
82
+ $update_poll_text[] = __('Voting Form Footer Template');
83
+ $update_poll_text[] = __('Result Header Template');
84
+ $update_poll_text[] = __('Result Body Template');
85
+ $update_poll_text[] = __('Result Body2 Template');
86
+ $update_poll_text[] = __('Result Footer Template');
87
+ $update_poll_text[] = __('Result Footer2 Template');
88
+ $update_poll_text[] = __('Poll Disabled Template');
89
+ $update_poll_text[] = __('Poll Error Template');
90
+ $update_poll_text[] = __('Archive Polls Per Page Option');
91
+ $update_poll_text[] = __('Polls Archive URL Option');
92
+ $update_poll_text[] = __('Show Polls Achive Link Option');
93
+ $update_poll_text[] = __('Current Active Poll Option');
94
+ $update_poll_text[] = __('Logging Method');
95
+ $update_poll_text[] = __('Allow To Vote Option');
96
+ $i=0;
97
+ $text = '';
98
+ foreach($update_poll_queries as $update_poll_query) {
99
+ if($update_poll_query) {
100
+ $text .= '<font color="green">'.$update_poll_text[$i].' '.__('Updated').'</font><br />';
101
+ }
102
+ $i++;
103
+ }
104
+ if(empty($text)) {
105
+ $text = '<font color="red">'.__('No Poll Option Updated').'</font>';
106
+ }
107
+ }
108
+
109
+ ?>
110
+ <script type="text/javascript">
111
+ /* <![CDATA[*/
112
+ function poll_default_templates(template) {
113
+ var default_template;
114
+ switch(template) {
115
+ case "voteheader":
116
+ default_template = "<p style=\"text-align: center;\"><strong>%POLL_QUESTION%</strong></p>\n<div id=\"polls-%POLL_ID%-ans\" class=\"wp-polls-ans\">\n<ul class=\"wp-polls-ul\">";
117
+ break;
118
+ case "votebody":
119
+ 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>";
120
+ break;
121
+ case "votefooter":
122
+ default_template = "</ul>\n<p style=\"text-align: center;\"><input type=\"button\" name=\"vote\" value=\" Vote \" class=\"Buttons\" onclick=\"poll_vote(%POLL_ID%);\" /></p>\n<p style=\"text-align: center;\"><a href=\"#ViewPollResults\" onclick=\"poll_result(%POLL_ID%); return false;\" title=\"View Results Of This Poll\">View Results</a></p>\n</div>";
123
+ break;
124
+ case "resultheader":
125
+ default_template = "<p style=\"text-align: center;\"><strong>%POLL_QUESTION%</strong></p>\n<div id=\"polls-%POLL_ID%-ans\" class=\"wp-polls-ans\">\n<ul class=\"wp-polls-ul\">";
126
+ break;
127
+ case "resultbody":
128
+ default_template = "<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small><div class=\"pollbar-image\" style=\"width: %POLL_ANSWER_IMAGEWIDTH%%;\" title=\"%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% Votes)\"></div></li>";
129
+ break;
130
+ case "resultbody2":
131
+ default_template = "<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small></i></strong><div class=\"pollbar-image\" style=\"width: %POLL_ANSWER_IMAGEWIDTH%%;\" title=\"You Have Voted For This Choice - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% Votes)\"></div></li>";
132
+ break;
133
+ case "resultfooter":
134
+ default_template = "</ul>\n<p style=\"text-align: center;\">Total Votes: <strong>%POLL_TOTALVOTES%</strong></p>\n</div>";
135
+ break;
136
+ case "resultfooter2":
137
+ default_template = "</ul>\n<p style=\"text-align: center;\">Total Votes: <strong>%POLL_TOTALVOTES%</strong></p>\n<p style=\"text-align: center;\"><a href=\"#VotePoll\" onclick=\"poll_booth(%POLL_ID%); return false;\" title=\"Vote For This Poll\">Vote</a></p>\n</div>";
138
+ break;
139
+ case "disable":
140
+ default_template = 'Sorry, there are no polls available at the moment.';
141
+ break;
142
+ case "error":
143
+ default_template = 'An error has occurred when processing your poll.';
144
+ break;
145
+ }
146
+ document.getElementById("poll_template_" + template).value = default_template;
147
+ }
148
+ /* ]]> */
149
+ </script>
150
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
151
+ <div class="wrap">
152
+ <h2><?php _e('Poll Options'); ?></h2>
153
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
154
+ <fieldset class="options">
155
+ <legend><?php _e('Sorting Of Poll Answers'); ?></legend>
156
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
157
+ <tr valign="top">
158
+ <th align="left" width="30%"><?php _e('Sort Poll Answers By:'); ?></th>
159
+ <td align="left">
160
+ <select name="poll_ans_sortby" size="1">
161
+ <option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_sortby')); ?>><?php _e('Exact Order'); ?></option>
162
+ <option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
163
+ </select>
164
+ </td>
165
+ </tr>
166
+ <tr valign="top">
167
+ <th align="left" width="30%"><?php _e('Sort Order Of Poll Answers:'); ?></th>
168
+ <td align="left">
169
+ <select name="poll_ans_sortorder" size="1">
170
+ <option value="asc"<?php selected('asc', get_settings('poll_ans_sortorder')); ?>><?php _e('Ascending'); ?></option>
171
+ <option value="desc"<?php selected('desc', get_settings('poll_ans_sortorder')); ?>><?php _e('Descending'); ?></option>
172
+ </select>
173
+ </td>
174
+ </tr>
175
+ </table>
176
+ </fieldset>
177
+ <fieldset class="options">
178
+ <legend><?php _e('Sorting Of Poll Results'); ?></legend>
179
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
180
+ <tr valign="top">
181
+ <th align="left" width="30%"><?php _e('Sort Poll Results By:'); ?></th>
182
+ <td align="left">
183
+ <select name="poll_ans_result_sortby" size="1">
184
+ <option value="polla_votes"<?php selected('polla_votes', get_settings('poll_ans_result_sortby')); ?>><?php _e('Votes'); ?></option>
185
+ <option value="polla_aid"<?php selected('polla_aid', get_settings('poll_ans_result_sortby')); ?>><?php _e('Exact Order'); ?></option>
186
+ <option value="polla_answers"<?php selected('polla_answers', get_settings('poll_ans_result_sortby')); ?>><?php _e('Alphabetical Order'); ?></option>
187
+ </select>
188
+ </td>
189
+ </tr>
190
+ <tr valign="top">
191
+ <th align="left" width="30%"><?php _e('Sort Order Of Poll Results:'); ?></th>
192
+ <td align="left">
193
+ <select name="poll_ans_result_sortorder" size="1">
194
+ <option value="asc"<?php selected('asc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Ascending'); ?></option>
195
+ <option value="desc"<?php selected('desc', get_settings('poll_ans_result_sortorder')); ?>><?php _e('Descending'); ?></option>
196
+ </select>
197
+ </td>
198
+ </tr>
199
+ </table>
200
+ </fieldset>
201
+ <fieldset class="options">
202
+ <legend><?php _e('Allow To Vote'); ?></legend>
203
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
204
+ <tr valign="top">
205
+ <th align="left" width="30%"><?php _e('Who Is Allowed To Vote?'); ?></th>
206
+ <td align="left">
207
+ <select name="poll_allowtovote" size="1">
208
+ <option value="0"<?php selected('0', get_settings('poll_allowtovote')); ?>><?php _e('Guests Only'); ?></option>
209
+ <option value="1"<?php selected('1', get_settings('poll_allowtovote')); ?>><?php _e('Registered Users Only'); ?></option>
210
+ <option value="2"<?php selected('2', get_settings('poll_allowtovote')); ?>><?php _e('Registered Users And Guests'); ?></option>
211
+ </select>
212
+ </td>
213
+ </tr>
214
+ </table>
215
+ </fieldset>
216
+ <fieldset class="options">
217
+ <legend><?php _e('Logging Method'); ?></legend>
218
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
219
+ <tr valign="top">
220
+ <th align="left" width="30%"><?php _e('Poll Logging Method:'); ?></th>
221
+ <td align="left">
222
+ <select name="poll_logging_method" size="1">
223
+ <option value="0"<?php selected('0', get_settings('poll_logging_method')); ?>><?php _e('Do Not Log'); ?></option>
224
+ <option value="1"<?php selected('1', get_settings('poll_logging_method')); ?>><?php _e('Logged By Cookie'); ?></option>
225
+ <option value="2"<?php selected('2', get_settings('poll_logging_method')); ?>><?php _e('Logged By IP'); ?></option>
226
+ <option value="3"<?php selected('3', get_settings('poll_logging_method')); ?>><?php _e('Logged By Cookie And IP'); ?></option>
227
+ <option value="4"<?php selected('4', get_settings('poll_logging_method')); ?>><?php _e('Logged By Username'); ?></option>
228
+ </select>
229
+ </td>
230
+ </tr>
231
+ </table>
232
+ </fieldset>
233
+ <fieldset class="options">
234
+ <legend><?php _e('Poll Archive'); ?></legend>
235
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
236
+ <tr valign="top">
237
+ <th align="left" width="30%"><?php _e('Polls Per Page:'); ?></th>
238
+ <td align="left"><input type="text" name="poll_archive_perpage" value="<?php echo intval(get_settings('poll_archive_perpage')); ?>" size="2" /></td>
239
+ </tr>
240
+ <tr valign="top">
241
+ <th align="left" width="30%"><?php _e('Polls Archive URL:'); ?></th>
242
+ <td align="left"><input type="text" name="poll_archive_url" value="<?php echo get_settings('poll_archive_url'); ?>" size="50" /></td>
243
+ </tr>
244
+ <tr valign="top">
245
+ <th align="left" width="30%"><?php _e('Display Polls Archive Link Below Poll?'); ?></th>
246
+ <td align="left">
247
+ <select name="poll_archive_show" size="1">
248
+ <option value="0"<?php selected('0', get_settings('poll_archive_show')); ?>><?php _e('No'); ?></option>
249
+ <option value="1"<?php selected('1', get_settings('poll_archive_show')); ?>><?php _e('Yes'); ?></option>
250
+ </select>
251
+ </td>
252
+ </tr>
253
+ </table>
254
+ </fieldset>
255
+ <fieldset class="options">
256
+ <legend><?php _e('Current Active Poll'); ?></legend>
257
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
258
+ <tr valign="top">
259
+ <th align="left" width="30%"><?php _e('Current Active Poll:'); ?></th>
260
+ <td align="left">
261
+ <select name="poll_currentpoll" size="1">
262
+ <option value="-1"<?php selected(-1, get_settings('poll_currentpoll')); ?>><?php _e('Do NOT Display Poll (Disable)'); ?></option>
263
+ <option value="-2"<?php selected(-2, get_settings('poll_currentpoll')); ?>><?php _e('Display Random Poll'); ?></option>
264
+ <option value="0"<?php selected(0, get_settings('poll_currentpoll')); ?>><?php _e('Display Latest Poll'); ?></option>
265
+ <option value="0">&nbsp;</option>
266
+ <?php
267
+ $polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
268
+ if($polls) {
269
+ foreach($polls as $poll) {
270
+ $poll_question = stripslashes($poll->pollq_question);
271
+ $poll_id = intval($poll->pollq_id);
272
+ if($poll_id == intval(get_settings('poll_currentpoll'))) {
273
+ echo "<option value=\"$poll_id\" selected=\"selected\">$poll_question</option>\n";
274
+ } else {
275
+ echo "<option value=\"$poll_id\">$poll_question</option>\n";
276
+ }
277
+ }
278
+ }
279
+ ?>
280
+ </select>
281
+ </td>
282
+ </tr>
283
+ </table>
284
+ </fieldset>
285
+ <fieldset class="options">
286
+ <legend><?php _e('Template Variables'); ?></legend>
287
+ <table width="100%" border="0" cellspacing="0" cellpadding="5">
288
+ <tr>
289
+ <td>
290
+ <strong>%POLL_ID%</strong><br />
291
+ <?php _e('Display the poll\'s ID'); ?>
292
+ </td>
293
+ <td>
294
+ <strong>%POLL_ANSWER_ID%</strong><br />
295
+ <?php _e('Display the poll\'s answer ID'); ?>
296
+ </td>
297
+ </tr>
298
+ <tr>
299
+ <td>
300
+ <strong>%POLL_QUESTION%</strong><br />
301
+ <?php _e('Display the poll\'s question'); ?>
302
+ </td>
303
+ <td>
304
+ <strong>%POLL_ANSWER%</strong><br />
305
+ <?php _e('Display the poll\'s answer'); ?>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td>
310
+ <strong>%POLL_TOTALVOTES%</strong><br />
311
+ <?php _e('Display the poll\'s total votes'); ?>
312
+ </td>
313
+ <td>
314
+ <strong>%POLL_ANSWER_TEXT%</strong><br />
315
+ <?php _e('Display the poll\'s answer without HTML formatting.'); ?>
316
+ </td>
317
+ </tr>
318
+ <tr>
319
+ <td>
320
+ <strong>%POLL_RESULT_URL%</strong><br />
321
+ <?php _e('Displays URL to poll\'s result'); ?>
322
+ </td>
323
+ <td>
324
+ <strong>%POLL_ANSWER_VOTES%</strong><br />
325
+ <?php _e('Display the poll\'s answer votes'); ?>
326
+ </td>
327
+ </tr>
328
+ <tr>
329
+ <td>
330
+ <strong>%POLL_MOST_ANSWER%</strong><br />
331
+ <?php _e('Display the poll\'s most voted answer'); ?>
332
+ </td>
333
+ <td>
334
+ <strong>%POLL_ANSWER_PERCENTAGE%</strong><br />
335
+ <?php _e('Display the poll\'s answer percentage'); ?>
336
+ </td>
337
+ </tr>
338
+ <tr>
339
+ <td>
340
+ <strong>%POLL_MOST_VOTES%</strong><br />
341
+ <?php _e('Display the poll\'s answer votes for the most voted answer'); ?>
342
+ </td>
343
+ <td>
344
+ <strong>%POLL_ANSWER_IMAGEWIDTH%</strong><br />
345
+ <?php _e('Display the poll\'s answer image width'); ?>
346
+ </td>
347
+ </tr>
348
+ <tr>
349
+ <td>
350
+ <strong>%POLL_MOST_PERCENTAGE%</strong><br />
351
+ <?php _e('Display the poll\'s answer percentage for the most voted answer'); ?>
352
+ </td>
353
+ <td>
354
+ <strong>%POLL_LEAST_ANSWER%</strong><br />
355
+ <?php _e('Display the poll\'s least voted answer'); ?>
356
+ </td>
357
+ </tr>
358
+ <tr>
359
+ <td>&nbsp;</td>
360
+ <td><strong>%POLL_LEAST_VOTES%</strong><br />
361
+ <?php _e('Display the poll\'s answer votes for the least voted answer'); ?>
362
+ </td>
363
+ </tr>
364
+ <tr>
365
+ <td>&nbsp;</td>
366
+ <td>
367
+ <strong>%POLL_LEAST_PERCENTAGE%</strong><br />
368
+ <?php _e('Display the poll\'s answer percentage for the least voted answer'); ?>
369
+ </td>
370
+ </tr>
371
+ </table>
372
+ </fieldset>
373
+ <fieldset class="options">
374
+ <legend><?php _e('Poll Voting Form Templates'); ?></legend>
375
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
376
+ <tr valign="top">
377
+ <td width="30%" align="left">
378
+ <strong><?php _e('Voting Form Header:'); ?></strong><br /><br /><br />
379
+ <?php _e('Allowed Variables:'); ?><br />
380
+ - %POLL_ID%<br />
381
+ - %POLL_QUESTION%<br />
382
+ - %POLL_TOTALVOTES%<br /><br />
383
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('voteheader');" class="button" />
384
+ </td>
385
+ <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>
386
+ </tr>
387
+ <tr valign="top">
388
+ <td width="30%" align="left">
389
+ <strong><?php _e('Voting Form Body:'); ?></strong><br /><br /><br />
390
+ <?php _e('Allowed Variables:'); ?><br />
391
+ - %POLL_ID%<br />
392
+ - %POLL_ANSWER_ID%<br />
393
+ - %POLL_ANSWER%<br />
394
+ - %POLL_ANSWER_VOTES%<br /><br />
395
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votebody');" class="button" />
396
+ </td>
397
+ <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>
398
+ </tr>
399
+ <tr valign="top">
400
+ <td width="30%" align="left">
401
+ <strong><?php _e('Voting Form Footer:'); ?></strong><br /><br /><br />
402
+ <?php _e('Allowed Variables:'); ?><br />
403
+ - %POLL_ID%<br />
404
+ - %POLL_RESULT_URL%<br /><br />
405
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('votefooter');" class="button" />
406
+ </td>
407
+ <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>
408
+ </tr>
409
+ </table>
410
+ </fieldset>
411
+ <fieldset class="options">
412
+ <legend><?php _e('Poll Result Templates'); ?></legend>
413
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
414
+ <tr valign="top">
415
+ <td width="30%" align="left">
416
+ <strong><?php _e('Result Header:'); ?></strong><br /><br /><br />
417
+ <?php _e('Allowed Variables:'); ?><br />
418
+ - %POLL_ID%<br />
419
+ - %POLL_QUESTION%<br />
420
+ - %POLL_TOTALVOTES%<br /><br />
421
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultheader');" class="button" />
422
+ </td>
423
+ <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>
424
+ </tr>
425
+ <tr valign="top">
426
+ <td width="30%" align="left">
427
+ <strong><?php _e('Result Body:'); ?></strong><br /><?php _e('Normal'); ?><br /><br />
428
+ <?php _e('Allowed Variables:'); ?><br />
429
+ - %POLL_ANSWER_ID%<br />
430
+ - %POLL_ANSWER%<br />
431
+ - %POLL_ANSWER_TEXT%<br />
432
+ - %POLL_ANSWER_VOTES%<br />
433
+ - %POLL_ANSWER_PERCENTAGE%<br />
434
+ - %POLL_ANSWER_IMAGEWIDTH%<br /><br />
435
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody');" class="button" />
436
+ </td>
437
+ <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><br />If you want to use CSS instead of image, just change class="pollbar-image" to class="pollbar-css". You can configure the CSS in polls-css.css</td>
438
+ </tr>
439
+ <tr valign="top">
440
+ <td width="30%" align="left">
441
+ <strong><?php _e('Result Body:'); ?></strong><br /><?php _e('Displaying Of User\'s Voted Answer'); ?><br /><br />
442
+ <?php _e('Allowed Variables:'); ?><br />
443
+ - %POLL_ANSWER_ID%<br />
444
+ - %POLL_ANSWER%<br />
445
+ - %POLL_ANSWER_TEXT%<br />
446
+ - %POLL_ANSWER_VOTES%<br />
447
+ - %POLL_ANSWER_PERCENTAGE%<br />
448
+ - %POLL_ANSWER_IMAGEWIDTH%<br /><br />
449
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultbody2');" class="button" />
450
+ </td>
451
+ <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><br />If you want to use CSS instead of image, just change class="pollbar-image" to class="pollbar-css". You can configure the CSS in polls-css.css</td>
452
+ </tr>
453
+ <tr valign="top">
454
+ <td width="30%" align="left">
455
+ <strong><?php _e('Result Footer:'); ?></strong><br />Normal<br /><br />
456
+ <?php _e('Allowed Variables:'); ?><br />
457
+ - %POLL_TOTALVOTES%<br />
458
+ - %POLL_MOST_ANSWER%<br />
459
+ - %POLL_MOST_VOTES%<br />
460
+ - %POLL_MOST_PERCENTAGE%<br />
461
+ - %POLL_LEAST_ANSWER%<br />
462
+ - %POLL_LEAST_VOTES%<br />
463
+ - %POLL_LEAST_PERCENTAGE%<br /><br />
464
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultfooter');" class="button" />
465
+ </td>
466
+ <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>
467
+ </tr>
468
+ <tr valign="top">
469
+ <td width="30%" align="left">
470
+ <strong><?php _e('Result Footer:'); ?></strong><br /><?php _e('Displaying Of Vote Poll Link If User Has Not Voted'); ?><br /><br />
471
+ <?php _e('Allowed Variables:'); ?><br />
472
+ - %POLL_ID%<br />
473
+ - %POLL_TOTALVOTES%<br />
474
+ - %POLL_MOST_ANSWER%<br />
475
+ - %POLL_MOST_VOTES%<br />
476
+ - %POLL_MOST_PERCENTAGE%<br />
477
+ - %POLL_LEAST_ANSWER%<br />
478
+ - %POLL_LEAST_VOTES%<br />
479
+ - %POLL_LEAST_PERCENTAGE%<br /><br />
480
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('resultfooter2');" class="button" />
481
+ </td>
482
+ <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>
483
+ </tr>
484
+ </table>
485
+ </fieldset>
486
+ <fieldset class="options">
487
+ <legend><?php _e('Poll Misc Templates'); ?></legend>
488
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
489
+ <tr valign="top">
490
+ <td width="30%" align="left">
491
+ <strong><?php _e('Poll Disabled'); ?></strong><br /><br /><br />
492
+ <?php _e('Allowed Variables:'); ?><br />
493
+ - N/A<br /><br />
494
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('disable');" class="button" />
495
+ </td>
496
+ <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>
497
+ </tr>
498
+ <tr valign="top">
499
+ <td width="30%" align="left">
500
+ <strong><?php _e('Poll Error'); ?></strong><br /><br /><br />
501
+ <?php _e('Allowed Variables:'); ?><br />
502
+ - N/A<br /><br />
503
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template'); ?>" onclick="javascript: poll_default_templates('error');" class="button" />
504
+ </td>
505
+ <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>
506
+ </tr>
507
+ </table>
508
+ </fieldset>
509
+ <div align="center">
510
+ <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)" />
511
+ </div>
512
+ </form>
513
+ </div>
polls/polls-widget.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.12
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
+ global $in_pollsarchive;
39
+ extract($args);
40
+ $options = get_option('widget_polls');
41
+ $title = htmlspecialchars($options['title']);
42
+ if (function_exists('vote_poll') && !$in_pollsarchive) {
43
+ echo $before_widget.$before_title.$title.$after_title;
44
+ get_poll();
45
+ display_polls_archive_link();
46
+ echo $after_widget;
47
+ }
48
+ }
49
+
50
+ ### Function: WP-Polls Widget Options
51
+ function widget_polls_options() {
52
+ global $wpdb;
53
+ $options = get_option('widget_polls');
54
+ $current_poll = get_settings('poll_currentpoll');
55
+ if (!is_array($options)) {
56
+ $options = array('title' => 'Polls');
57
+ }
58
+ if ($_POST['polls-submit']) {
59
+ $poll_currentpoll = intval($_POST['poll_currentpoll']);
60
+ $poll_archive_show = intval($_POST['poll_archive_show']);
61
+ $options['title'] = strip_tags(stripslashes($_POST['polls-title']));
62
+ update_option('widget_polls', $options);
63
+ update_option('poll_currentpoll', $poll_currentpoll);
64
+ update_option('poll_archive_show', $poll_archive_show);
65
+ }
66
+ echo '<p style="text-align: left;"><label for="polls-title">Widget Title:</label>&nbsp;&nbsp;&nbsp;<input type="text" id="polls-title" name="polls-title" value="'.htmlspecialchars($options['title']).'" />'."\n";
67
+ echo '<p style="text-align: left;"><label for="polls-displayarchive">Display Polls Archive Link?</label>&nbsp;&nbsp;&nbsp;'."\n";
68
+ echo '<select id="polls-displayarchive" name="poll_archive_show" size="1">'."\n";
69
+ echo '<option value="0"';
70
+ selected('0', get_settings('poll_archive_show'));
71
+ echo '>';
72
+ _e('No');
73
+ echo '</option>'."\n";
74
+ echo '<option value="1"';
75
+ selected('1', get_settings('poll_archive_show'));
76
+ echo '>';
77
+ _e('Yes');
78
+ echo '</option>'."\n";
79
+ echo '</select></p>'."\n";
80
+ echo '<p style="text-align: left;"><label for="poll_currentpoll">Current Active Poll:</label>&nbsp;&nbsp;&nbsp;'."\n";
81
+ echo '<select id="poll_currentpoll" name="poll_currentpoll" size="1">'."\n";
82
+ echo '<option value="-1"';
83
+ selected(-1, $current_poll);
84
+ echo '>';
85
+ _e('Do NOT Display Poll (Disable)');
86
+ echo '</option>'."\n";
87
+ echo '<option value="-2"';
88
+ selected(-2, $current_poll);
89
+ echo '>';
90
+ _e('Display Random Poll');
91
+ echo '</option>'."\n";
92
+ echo '<option value="0"';
93
+ selected(0, $current_poll);
94
+ echo '>';
95
+ _e('Display Latest Poll');
96
+ echo '</option>'."\n";
97
+ echo '<option value="0">&nbsp;</option>'."\n";
98
+ $polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
99
+ if($polls) {
100
+ foreach($polls as $poll) {
101
+ $poll_question = stripslashes($poll->pollq_question);
102
+ $poll_id = intval($poll->pollq_id);
103
+ if($poll_id == intval($current_poll)) {
104
+ echo "<option value=\"$poll_id\" selected=\"selected\">$poll_question</option>\n";
105
+ } else {
106
+ echo "<option value=\"$poll_id\">$poll_question</option>\n";
107
+ }
108
+ }
109
+ }
110
+ echo '</select>'."\n";
111
+ echo '</p>'."\n";
112
+ echo '<input type="hidden" id="polls-submit" name="polls-submit" value="1" />'."\n";
113
+ }
114
+
115
+ // Register Widgets
116
+ register_sidebar_widget('Polls', 'widget_polls');
117
+ register_widget_control('Polls', 'widget_polls_options', 400, 150);
118
+ }
119
+
120
+
121
+ ### Function: Load The WP-Polls Widget
122
+ add_action('plugins_loaded', 'widget_polls_init');
123
+ ?>
polls/polls.php ADDED
@@ -0,0 +1,994 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.12
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, $polls_loaded;
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
+ // Assign All Loaded Poll To $polls_loaded
90
+ if(empty($polls_loaded)) {
91
+ $polls_loaded = array();
92
+ }
93
+ if(!in_array($poll_id, $polls_loaded)) {
94
+ $polls_loaded[] = $poll_id;
95
+ }
96
+
97
+ // User Click on View Results Link
98
+ if($pollresult_id == $poll_id) {
99
+ if($display) {
100
+ echo display_pollresult($poll_id);
101
+ return;
102
+ } else {
103
+ return display_pollresult($poll_id);
104
+ }
105
+ // Check Whether User Has Voted
106
+ } else {
107
+ $poll_active = $wpdb->get_var("SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
108
+ $poll_active = intval($poll_active);
109
+ $check_voted = check_voted($poll_id);
110
+ if($check_voted > 0 || $poll_active == 0 || !check_allowtovote()) {
111
+ if($display) {
112
+ echo display_pollresult($poll_id, $check_voted);
113
+ return;
114
+ } else {
115
+ return display_pollresult($poll_id, $check_voted);
116
+ }
117
+ } else {
118
+ if($display) {
119
+ echo display_pollvote($poll_id);
120
+ return;
121
+ } else {
122
+ return display_pollvote($poll_id);
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+
129
+ ### Function: Displays Polls Header
130
+ add_action('wp_head', 'poll_header');
131
+ function poll_header() {
132
+ if(strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') === false) {
133
+ $ajax_url = $_SERVER['SCRIPT_NAME'];
134
+ } else {
135
+ $ajax_url = $_SERVER['PHP_SELF'];
136
+ }
137
+ echo '<script type="text/javascript">'."\n";
138
+ echo '/* Start Of Javascript Generated By WP-Polls 2.12 */'."\n";
139
+ echo '/* <![CDATA[ */'."\n";
140
+ echo "\t".'if(site_url != \''.get_settings('siteurl').'\' || ajax_url != \''.$ajax_url.'\') {'."\n";
141
+ echo "\t\t".'var site_url = \''.get_settings('siteurl').'\';'."\n";
142
+ echo "\t\t".'var ajax_url = \''.$ajax_url.'\';'."\n";
143
+ echo "\t".'}'."\n";
144
+ echo '/* ]]> */'."\n";
145
+ echo '/* End Of Javascript Generated By WP-Polls 2.12 */'."\n";
146
+ echo '</script>'."\n";
147
+ echo '<script src="'.get_settings('siteurl').'/wp-includes/js/tw-sack.js" type="text/javascript"></script>'."\n";
148
+ echo '<script src="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-js.js" type="text/javascript"></script>'."\n";
149
+ echo '<link rel="stylesheet" href="'.get_settings('siteurl').'/wp-content/plugins/polls/polls-css.css" type="text/css" media="screen" />'."\n";
150
+ }
151
+
152
+
153
+ ### Function: Check Who Is Allow To Vote
154
+ function check_allowtovote() {
155
+ global $user_ID;
156
+ $user_ID = intval($user_ID);
157
+ $allow_to_vote = intval(get_settings('poll_allowtovote'));
158
+ switch($allow_to_vote) {
159
+ // Guests Only
160
+ case 0:
161
+ if($user_ID > 0) {
162
+ return false;
163
+ }
164
+ return true;
165
+ break;
166
+ // Registered Users Only
167
+ case 1:
168
+ if($user_ID == 0) {
169
+ return false;
170
+ }
171
+ return true;
172
+ break;
173
+ // Registered Users And Guests
174
+ case 2:
175
+ default:
176
+ return true;
177
+ }
178
+ }
179
+
180
+
181
+ ### Funcrion: Check Voted By Cookie Or IP
182
+ function check_voted($poll_id) {
183
+ $poll_logging_method = intval(get_settings('poll_logging_method'));
184
+ switch($poll_logging_method) {
185
+ // Do Not Log
186
+ case 0:
187
+ return 0;
188
+ break;
189
+ // Logged By Cookie
190
+ case 1:
191
+ return check_voted_cookie($poll_id);
192
+ break;
193
+ // Logged By IP
194
+ case 2:
195
+ return check_voted_ip($poll_id);
196
+ break;
197
+ // Logged By Cookie And IP
198
+ case 3:
199
+ $check_voted_cookie = check_voted_cookie($poll_id);
200
+ if($check_voted_cookie > 0) {
201
+ return $check_voted_cookie;
202
+ } else {
203
+ return check_voted_ip($poll_id);
204
+ }
205
+ break;
206
+ // Logged By Username
207
+ case 4:
208
+ return check_voted_username($poll_id);
209
+ break;
210
+ }
211
+ }
212
+
213
+
214
+ ### Function: Check Voted By Cookie
215
+ function check_voted_cookie($poll_id) {
216
+ // 0: False | > 0: True
217
+ return intval($_COOKIE["voted_$poll_id"]);
218
+ }
219
+
220
+
221
+ ### Function: Check Voted By IP
222
+ function check_voted_ip($poll_id) {
223
+ global $wpdb;
224
+ // Check IP From IP Logging Database
225
+ $get_voted_aid = $wpdb->get_var("SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_ip = '".get_ipaddress()."'");
226
+ // 0: False | > 0: True
227
+ return intval($get_voted_aid);
228
+ }
229
+
230
+
231
+ ### Function: Check Voted By Username
232
+ function check_voted_username($poll_id) {
233
+ global $wpdb, $user_ID;
234
+ // Check IP If User Is Guest
235
+ if ($user_ID == 0) {
236
+ return check_voted_ip($poll_id);
237
+ }
238
+ $pollsip_userid = intval($user_ID);
239
+ // Check User ID From IP Logging Database
240
+ $get_voted_aid = $wpdb->get_var("SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_userid = $pollsip_userid");
241
+ // 0: False | > 0: True
242
+ return intval($get_voted_aid);
243
+ }
244
+
245
+
246
+ ### Function: Display Voting Form
247
+ function display_pollvote($poll_id, $without_poll_title = false) {
248
+ global $wpdb;
249
+ // Temp Poll Result
250
+ $temp_pollvote = '';
251
+ // Get Poll Question Data
252
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
253
+ // Poll Question Variables
254
+ $poll_question_text = stripslashes($poll_question->pollq_question);
255
+ $poll_question_id = intval($poll_question->pollq_id);
256
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
257
+ $template_question = stripslashes(get_settings('poll_template_voteheader'));
258
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
259
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
260
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
261
+ // Get Poll Answers Data
262
+ $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'));
263
+ // If There Is Poll Question With Answers
264
+ if($poll_question && $poll_answers) {
265
+ // Display Poll Voting Form
266
+ if(!$without_poll_title) {
267
+ $temp_pollvote .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
268
+ $temp_pollvote .= "\t<form id=\"polls_form_$poll_question_id\" action=\"$_SERVER[REQUEST_URI]\" method=\"post\">\n";
269
+ $temp_pollvote .= "\t\t<p><input type=\"hidden\" name=\"poll_id\" value=\"$poll_question_id\" /></p>\n";
270
+ // Print Out Voting Form Header Template
271
+ $temp_pollvote .= "\t\t$template_question\n";
272
+ }
273
+ foreach($poll_answers as $poll_answer) {
274
+ // Poll Answer Variables
275
+ $poll_answer_id = intval($poll_answer->polla_aid);
276
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
277
+ $poll_answer_votes = intval($poll_answer->polla_votes);
278
+ $template_answer = stripslashes(get_settings('poll_template_votebody'));
279
+ $template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
280
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
281
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
282
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
283
+ // Print Out Voting Form Body Template
284
+ $temp_pollvote .= "\t\t$template_answer\n";
285
+ }
286
+ // Determine Poll Result URL
287
+ $poll_result_url = $_SERVER['REQUEST_URI'];
288
+ $poll_result_url = preg_replace('/pollresult=(\d+)/i', 'pollresult='.$poll_question_id, $poll_result_url);
289
+ if(intval($_GET['pollresult']) == 0) {
290
+ if(strpos($poll_result_url, '?') !== false) {
291
+ $poll_result_url = "$poll_result_url&amp;pollresult=$poll_question_id";
292
+ } else {
293
+ $poll_result_url = "$poll_result_url?pollresult=$poll_question_id";
294
+ }
295
+ }
296
+ // Voting Form Footer Variables
297
+ $template_footer = stripslashes(get_settings('poll_template_votefooter'));
298
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
299
+ $template_footer = str_replace("%POLL_RESULT_URL%", $poll_result_url, $template_footer);
300
+ // Print Out Voting Form Footer Template
301
+ $temp_pollvote .= "\t\t$template_footer\n";
302
+ if(!$without_poll_title) {
303
+ $temp_pollvote .= "\t</form>\n";
304
+ $temp_pollvote .= "</div>\n";
305
+ $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')." ...\" class=\"wp-polls-image\" />&nbsp;".__('Loading')." ...</div>\n";
306
+ }
307
+ } else {
308
+ $temp_pollvote .= stripslashes(get_settings('poll_template_disable'));
309
+ }
310
+ // Return Poll Vote Template
311
+ return $temp_pollvote;
312
+ }
313
+
314
+
315
+ ### Function: Display Results Form
316
+ function display_pollresult($poll_id, $user_voted = 0, $without_poll_title = false) {
317
+ global $wpdb;
318
+ // Temp Poll Result
319
+ $temp_pollresult = '';
320
+ // Most/Least Variables
321
+ $poll_most_answer = '';
322
+ $poll_most_votes = 0;
323
+ $poll_most_percentage = 0;
324
+ $poll_least_answer = '';
325
+ $poll_least_votes = 0;
326
+ $poll_least_percentage = 0;
327
+ // Get Poll Question Data
328
+ $poll_question = $wpdb->get_row("SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id LIMIT 1");
329
+ // Poll Question Variables
330
+ $poll_question_text = stripslashes($poll_question->pollq_question);
331
+ $poll_question_id = intval($poll_question->pollq_id);
332
+ $poll_question_totalvotes = intval($poll_question->pollq_totalvotes);
333
+ $poll_question_active = intval($poll_question->pollq_active);
334
+ $template_question = stripslashes(get_settings('poll_template_resultheader'));
335
+ $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
336
+ $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
337
+ $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
338
+ // Get Poll Answers Data
339
+ $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'));
340
+ // If There Is Poll Question With Answers
341
+ if($poll_question && $poll_answers) {
342
+ // Is The Poll Total Votes 0?
343
+ $poll_totalvotes_zero = true;
344
+ if($poll_question_totalvotes > 0) {
345
+ $poll_totalvotes_zero = false;
346
+ }
347
+ // Print Out Result Header Template
348
+ if(!$without_poll_title) {
349
+ $temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
350
+ $temp_pollresult .= "\t\t$template_question\n";
351
+ }
352
+ foreach($poll_answers as $poll_answer) {
353
+ // Poll Answer Variables
354
+ $poll_answer_id = intval($poll_answer->polla_aid);
355
+ $poll_answer_text = stripslashes($poll_answer->polla_answers);
356
+ $poll_answer_votes = intval($poll_answer->polla_votes);
357
+ $poll_answer_percentage = 0;
358
+ $poll_answer_imagewidth = 0;
359
+ // Calculate Percentage And Image Bar Width
360
+ if(!$poll_totalvotes_zero) {
361
+ if($poll_answer_votes > 0) {
362
+ $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*100));
363
+ $poll_answer_imagewidth = round($poll_answer_percentage);
364
+ } else {
365
+ $poll_answer_percentage = 0;
366
+ $poll_answer_imagewidth = 1;
367
+ }
368
+ } else {
369
+ $poll_answer_percentage = 0;
370
+ $poll_answer_imagewidth = 1;
371
+ }
372
+ // Let User See What Options They Voted
373
+ if($user_voted == $poll_answer_id) {
374
+ // Results Body Variables
375
+ $template_answer = stripslashes(get_settings('poll_template_resultbody2'));
376
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
377
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
378
+ $template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($poll_answer_text)), $template_answer);
379
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
380
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
381
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
382
+ // Print Out Results Body Template
383
+ $temp_pollresult .= "\t\t$template_answer\n";
384
+ } else {
385
+ // Results Body Variables
386
+ $template_answer = stripslashes(get_settings('poll_template_resultbody'));
387
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
388
+ $template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
389
+ $template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($poll_answer_text)), $template_answer);
390
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format($poll_answer_votes), $template_answer);
391
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
392
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
393
+ // Print Out Results Body Template
394
+ $temp_pollresult .= "\t\t$template_answer\n";
395
+ }
396
+ // Get Most Voted Data
397
+ if($poll_answer_votes > $poll_most_votes) {
398
+ $poll_most_answer = $poll_answer_text;
399
+ $poll_most_votes = $poll_answer_votes;
400
+ $poll_most_percentage = $poll_answer_percentage;
401
+ }
402
+ // Get Least Voted Data
403
+ if($poll_least_votes == 0) {
404
+ $poll_least_votes = $poll_answer_votes;
405
+ }
406
+ if($poll_answer_votes <= $poll_least_votes) {
407
+ $poll_least_answer = $poll_answer_text;
408
+ $poll_least_votes = $poll_answer_votes;
409
+ $poll_least_percentage = $poll_answer_percentage;
410
+ }
411
+ }
412
+ // Results Footer Variables
413
+ if($user_voted > 0 || $poll_question_active == 0 || !check_allowtovote()) {
414
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter'));
415
+ } else {
416
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter2'));
417
+ }
418
+ $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
419
+ $template_footer = str_replace("%POLL_TOTALVOTES%", number_format($poll_question_totalvotes), $template_footer);
420
+ $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
421
+ $template_footer = str_replace("%POLL_MOST_VOTES%", number_format($poll_most_votes), $template_footer);
422
+ $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
423
+ $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
424
+ $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format($poll_least_votes), $template_footer);
425
+ $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
426
+ // Print Out Results Footer Template
427
+ $temp_pollresult .= "\t\t$template_footer\n";
428
+ if(!$without_poll_title) {
429
+ $temp_pollresult .= "</div>\n";
430
+ $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')." ...\" class=\"wp-polls-image\" />&nbsp;".__('Loading')." ...</div>\n";
431
+ }
432
+ } else {
433
+ $temp_pollresult .= stripslashes(get_settings('poll_template_disable'));
434
+ }
435
+ // Return Poll Result
436
+ return $temp_pollresult;
437
+ }
438
+
439
+
440
+ ### Function: Vote Poll
441
+ add_action('init', 'vote_poll');
442
+ function vote_poll() {
443
+ global $wpdb, $user_identity, $user_ID;
444
+ if(!empty($_POST['vote'])) {
445
+ $poll_id = intval($_POST['poll_id']);
446
+ $poll_aid = intval($_POST["poll_$poll_id"]);
447
+ if($poll_id > 0 && $poll_aid > 0 && check_allowtovote()) {
448
+ $check_voted = check_voted($poll_id);
449
+ if($check_voted == 0) {
450
+ if(!empty($user_identity)) {
451
+ $pollip_user = addslashes($user_identity);
452
+ } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
453
+ $pollip_user = addslashes($_COOKIE['comment_author_'.COOKIEHASH]);
454
+ } else {
455
+ $pollip_user = 'Guest';
456
+ }
457
+ $pollip_userid = intval($user_ID);
458
+ $pollip_ip = get_ipaddress();
459
+ $pollip_host = gethostbyaddr($pollip_ip);
460
+ $pollip_timestamp = current_time('timestamp');
461
+ // Only Create Cookie If User Choose Logging Method 1 Or 2
462
+ $poll_logging_method = intval(get_settings('poll_logging_method'));
463
+ if($poll_logging_method == 1 || $poll_logging_method == 3) {
464
+ $vote_cookie = setcookie("voted_".$poll_id, $poll_aid, time() + 30000000, COOKIEPATH);
465
+ }
466
+ // Log Ratings No Matter What
467
+ $vote_ip = $wpdb->query("INSERT INTO $wpdb->pollsip VALUES (0, $poll_id, $poll_aid, '$pollip_ip', '$pollip_host', '$pollip_timestamp', '$pollip_user', $pollip_userid)");
468
+ $vote_a = $wpdb->query("UPDATE $wpdb->pollsa SET polla_votes = (polla_votes+1) WHERE polla_qid = $poll_id AND polla_aid = $poll_aid");
469
+ if($vote_a) {
470
+ $vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+1) WHERE pollq_id = $poll_id");
471
+ if($vote_q) {
472
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id,$poll_aid, 1);
473
+ exit();
474
+ } else {
475
+ _e("Unable To Update Poll Total Votes. Poll ID #$poll_id.");
476
+ exit();
477
+ } // End if($vote_q)
478
+ } else {
479
+ _e("Unable To Update Poll Answer Votes. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
480
+ exit();
481
+ } // End if($vote_a)
482
+ } else {
483
+ _e("You Had Already Voted For This Poll. Poll ID #$poll_id.");
484
+ exit();
485
+ }// End if($check_voted)
486
+ } else {
487
+ _e("Invalid Poll ID Or Poll Answer ID. Poll ID #$poll_id, Poll Answer ID #$poll_aid.");
488
+ exit();
489
+ } // End if($poll_id > 0 && $poll_aid > 0)
490
+ } elseif (intval($_GET['pollresult']) > 0) {
491
+ $poll_id = intval($_GET['pollresult']);
492
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollresult($poll_id, 0, true);
493
+ exit();
494
+ } elseif (intval($_GET['pollbooth']) > 0) {
495
+ $poll_id = intval($_GET['pollbooth']);
496
+ echo "<ul class=\"wp-polls-ul\">\n".display_pollvote($poll_id, true);
497
+ exit();
498
+ } // End if(!empty($_POST['vote']))
499
+ }
500
+
501
+
502
+ ### Function: Get IP Address
503
+ if(!function_exists('get_ipaddress')) {
504
+ function get_ipaddress() {
505
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
506
+ $ip_address = $_SERVER["REMOTE_ADDR"];
507
+ } else {
508
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
509
+ }
510
+ if(strpos($ip_address, ',') !== false) {
511
+ $ip_address = explode(',', $ip_address);
512
+ $ip_address = $ip_address[0];
513
+ }
514
+ return $ip_address;
515
+ }
516
+ }
517
+
518
+
519
+ ### Function: Place Polls Archive In Content
520
+ add_filter('the_content', 'place_pollsarchive', '7');
521
+ function place_pollsarchive($content){
522
+ $content = preg_replace( "/\[page_polls\]/ise", "polls_archive()", $content);
523
+ return $content;
524
+ }
525
+
526
+
527
+ ### Function: Place Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
528
+ add_filter('the_content', 'place_poll', '7');
529
+ function place_poll($content){
530
+ $content = preg_replace( "/\[poll=(\d+)\]/ise", "display_poll('\\1')", $content);
531
+ return $content;
532
+ }
533
+
534
+
535
+ ### Function: Display The Poll In Content (By: Robert Accettura Of http://robert.accettura.com/)
536
+ function display_poll($poll_id){
537
+ return get_poll($poll_id, false);
538
+ }
539
+
540
+
541
+ ### Function: Get Poll Total Questions
542
+ if(!function_exists('get_pollquestions')) {
543
+ function get_pollquestions($display = true) {
544
+ global $wpdb;
545
+ $totalpollq = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
546
+ if($display) {
547
+ echo number_format($totalpollq);
548
+ } else {
549
+ return number_format($totalpollq);
550
+ }
551
+ }
552
+ }
553
+
554
+
555
+ ### Function: Get Poll Total Answers
556
+ if(!function_exists('get_pollanswers')) {
557
+ function get_pollanswers($display = true) {
558
+ global $wpdb;
559
+ $totalpolla = $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa");
560
+ if($display) {
561
+ echo number_format($totalpolla);
562
+ } else {
563
+ return number_format($totalpolla);
564
+ }
565
+ }
566
+ }
567
+
568
+
569
+ ### Function: Get Poll Total Votes
570
+ if(!function_exists('get_pollvotes')) {
571
+ function get_pollvotes($display = true) {
572
+ global $wpdb;
573
+ $totalpollip = $wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip");
574
+ if($display) {
575
+ echo number_format($totalpollip);
576
+ } else {
577
+ return number_format($totalpollip);
578
+ }
579
+ }
580
+ }
581
+
582
+
583
+ ### Un HTML Entities
584
+ function unhtmlentities($string) {
585
+ $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
586
+ $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
587
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
588
+ $trans_tbl = array_flip($trans_tbl);
589
+ return strtr($string, $trans_tbl);
590
+ }
591
+
592
+
593
+ ### Function: Check Voted To Get Voted Answer
594
+ function check_voted_multiple($poll_id) {
595
+ global $polls_ips;
596
+ $temp_voted_aid = 0;
597
+ if(intval($_COOKIE["voted_$poll_id"]) > 0) {
598
+ $temp_voted_aid = intval($_COOKIE["voted_$poll_id"]);
599
+ } else {
600
+ if($polls_ips) {
601
+ foreach($polls_ips as $polls_ip) {
602
+ if($polls_ip['qid'] == $poll_id) {
603
+ $temp_voted_aid = $polls_ip['aid'];
604
+ }
605
+ }
606
+ }
607
+ }
608
+ return $temp_voted_aid;
609
+ }
610
+
611
+
612
+ ### Function: Polls Archive Link
613
+ function polls_archive_link($page) {
614
+ $current_url = $_SERVER['REQUEST_URI'];
615
+ $curren_pollpage = intval($_GET['poll_page']);
616
+ $polls_archive_url = preg_replace('/poll_page=(\d+)/i', 'poll_page='.$page, $current_url);
617
+ if($curren_pollpage == 0) {
618
+ if(strpos($current_url, '?') !== false) {
619
+ $polls_archive_url = "$polls_archive_url&amp;poll_page=$page";
620
+ } else {
621
+ $polls_archive_url = "$polls_archive_url?poll_page=$page";
622
+ }
623
+ }
624
+ return $polls_archive_url;
625
+ }
626
+
627
+
628
+ ### Function: Displays Polls Archive Link
629
+ function display_polls_archive_link($display = true) {
630
+ if(intval(get_settings('poll_archive_show')) == 1) {
631
+ if($display) {
632
+ echo "<ul>\n<li><a href=\"".get_settings('poll_archive_url')."\">Polls Archive</a></li></ul>\n";
633
+ } else{
634
+ return "<ul>\n<li><a href=\"".get_settings('poll_archive_url')."\">Polls Archive</a></li></ul>\n";
635
+ }
636
+ }
637
+ }
638
+
639
+
640
+ ### Function: Display Polls Archive
641
+ function polls_archive() {
642
+ global $wpdb, $polls_ips, $in_pollsarchive;
643
+ // Polls Variables
644
+ $in_pollsarchive = true;
645
+ $page = intval($_GET['poll_page']);
646
+ $polls_questions = array();
647
+ $polls_answers = array();
648
+ $polls_ip = array();
649
+ $polls_perpage = intval(get_settings('poll_archive_perpage'));
650
+ $poll_questions_ids = '0';
651
+ $poll_voted = false;
652
+ $poll_voted_aid = 0;
653
+ $poll_id = 0;
654
+ $pollsarchive_output = '';
655
+
656
+ // Get Total Polls
657
+ $total_polls = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
658
+
659
+ // Checking $page and $offset
660
+ if (empty($page) || $page == 0) { $page = 1; }
661
+ if (empty($offset)) { $offset = 0; }
662
+
663
+ // Determin $offset
664
+ $offset = ($page-1) * $polls_perpage;
665
+
666
+ // Determine Max Number Of Polls To Display On Page
667
+ if(($offset + $polls_perpage) > $total_polls) {
668
+ $max_on_page = $total_polls;
669
+ } else {
670
+ $max_on_page = ($offset + $polls_perpage);
671
+ }
672
+
673
+ // Determine Number Of Polls To Display On Page
674
+ if (($offset + 1) > ($total_polls)) {
675
+ $display_on_page = $total_polls;
676
+ } else {
677
+ $display_on_page = ($offset + 1);
678
+ }
679
+
680
+ // Determing Total Amount Of Pages
681
+ $total_pages = ceil($total_polls / $polls_perpage);
682
+
683
+ // Make Sure Poll Is Not Disabled
684
+ if(intval(get_settings('poll_currentpoll')) != -1 && $page < 2) {
685
+ // Hardcoded Poll ID Is Not Specified
686
+ if(intval($temp_poll_id) == 0) {
687
+ // Random Poll
688
+ if(intval(get_settings('poll_currentpoll')) == -2) {
689
+ $random_poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq ORDER BY RAND() LIMIT 1");
690
+ $poll_id = intval($random_poll_id);
691
+ // Current Poll ID Is Not Specified
692
+ } else if(intval(get_settings('poll_currentpoll')) == 0) {
693
+ // Get Lastest Poll ID
694
+ $poll_id = intval(get_settings('poll_latestpoll'));
695
+ } else {
696
+ // Get Current Poll ID
697
+ $poll_id = intval(get_settings('poll_currentpoll'));
698
+ }
699
+ // Get Hardcoded Poll ID
700
+ } else {
701
+ $poll_id = intval($temp_poll_id);
702
+ }
703
+ }
704
+
705
+ // Get Poll Questions
706
+ $questions = $wpdb->get_results("SELECT * FROM $wpdb->pollsq WHERE pollq_id != $poll_id ORDER BY pollq_id DESC LIMIT $offset, $polls_perpage");
707
+ if($questions) {
708
+ foreach($questions as $question) {
709
+ $polls_questions[] = array('id' => intval($question->pollq_id), 'question' => stripslashes($question->pollq_question), 'timestamp' => $question->pollq_timestamp, 'totalvotes' => intval($question->pollq_totalvotes));
710
+ $poll_questions_ids .= intval($question->pollq_id).', ';
711
+ }
712
+ $poll_questions_ids = substr($poll_questions_ids, 0, -2);
713
+ }
714
+
715
+ // Get Poll Answers
716
+ $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'));
717
+ if($answers) {
718
+ foreach($answers as $answer) {
719
+ $polls_answers[] = array('aid' => intval($answer->polla_aid), 'qid' => intval($answer->polla_qid), 'answers' => stripslashes($answer->polla_answers), 'votes' => intval($answer->polla_votes));
720
+ }
721
+ }
722
+
723
+ // Get Poll IPs
724
+ $ips = $wpdb->get_results("SELECT pollip_qid, pollip_aid FROM $wpdb->pollsip WHERE pollip_qid IN ($poll_questions_ids) AND pollip_ip = '".get_ipaddress()."'");
725
+ if($ips) {
726
+ foreach($ips as $ip) {
727
+ $polls_ips[] = array('qid' => intval($ip->pollip_qid), 'aid' => intval($ip->pollip_aid));
728
+ }
729
+ }
730
+
731
+ // Current Poll
732
+ if($page < 2) {
733
+ $pollsarchive_output .= '<h2>'.__('Current Poll').'</h2>'."\n";
734
+ // Current Poll
735
+ if(intval(get_settings('poll_currentpoll')) == -1) {
736
+ $pollsarchive_output .= get_settings('poll_template_disable');
737
+ } else {
738
+ // User Click on View Results Link
739
+ if(intval($_GET['pollresult']) == $poll_id) {
740
+ $pollsarchive_output .= display_pollresult($poll_id);
741
+ // Check Whether User Has Voted
742
+ } else {
743
+ $poll_active = $wpdb->get_var("SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
744
+ $poll_active = intval($poll_active);
745
+ $check_voted = check_voted($poll_id);
746
+ if($check_voted > 0 || $poll_active == 0) {
747
+ $pollsarchive_output .= display_pollresult($poll_id, $check_voted);
748
+ } else {
749
+ $pollsarchive_output .= display_pollvote($poll_id);
750
+ }
751
+ }
752
+ }
753
+ }
754
+ // Poll Archives
755
+ $pollsarchive_output .= "<h2>".__('Polls Archive')."</h2>\n";
756
+ $pollsarchive_output .= "<div class=\"wp-polls\">\n";
757
+ foreach($polls_questions as $polls_question) {
758
+ // Most/Least Variables
759
+ $poll_most_answer = '';
760
+ $poll_most_votes = 0;
761
+ $poll_most_percentage = 0;
762
+ $poll_least_answer = '';
763
+ $poll_least_votes = 0;
764
+ $poll_least_percentage = 0;
765
+ // Is The Poll Total Votes 0?
766
+ $poll_totalvotes_zero = true;
767
+ if($polls_question['totalvotes'] > 0) {
768
+ $poll_totalvotes_zero = false;
769
+ }
770
+ // Poll Question Variables
771
+ $template_question = stripslashes(get_settings('poll_template_resultheader'));
772
+ $template_question = str_replace("%POLL_QUESTION%", $polls_question['question'], $template_question);
773
+ $template_question = str_replace("%POLL_ID%", $polls_question['id'], $template_question);
774
+ $template_question = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_question);
775
+ // Print Out Result Header Template
776
+ $pollsarchive_output .= $template_question;
777
+ foreach($polls_answers as $polls_answer) {
778
+ if($polls_question['id'] == $polls_answer['qid']) {
779
+ // Calculate Percentage And Image Bar Width
780
+ if(!$poll_totalvotes_zero) {
781
+ if($polls_answer['votes'] > 0) {
782
+ $poll_answer_percentage = round((($polls_answer['votes']/$polls_question['totalvotes'])*100));
783
+ $poll_answer_imagewidth = round($poll_answer_percentage*0.9);
784
+ } else {
785
+ $poll_answer_percentage = 0;
786
+ $poll_answer_imagewidth = 1;
787
+ }
788
+ } else {
789
+ $poll_answer_percentage = 0;
790
+ $poll_answer_imagewidth = 1;
791
+ }
792
+ // Let User See What Options They Voted
793
+ if(check_voted_multiple($polls_question['id']) == $polls_answer['aid']) {
794
+ // Results Body Variables
795
+ $template_answer = stripslashes(get_settings('poll_template_resultbody2'));
796
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
797
+ $template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
798
+ $template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($polls_answer['answers'])), $template_answer);
799
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
800
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
801
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
802
+ // Print Out Results Body Template
803
+ $pollsarchive_output .= $template_answer;
804
+ } else {
805
+ // Results Body Variables
806
+ $template_answer = stripslashes(get_settings('poll_template_resultbody'));
807
+ $template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
808
+ $template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
809
+ $template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($polls_answer['answers'])), $template_answer);
810
+ $template_answer = str_replace("%POLL_ANSWER_VOTES%", $polls_answer['votes'], $template_answer);
811
+ $template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
812
+ $template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
813
+ // Print Out Results Body Template
814
+ $pollsarchive_output .= $template_answer;
815
+ }
816
+ // Get Most Voted Data
817
+ if($polls_answer['votes'] > $poll_most_votes) {
818
+ $poll_most_answer = $polls_answer['answers'];
819
+ $poll_most_votes = $polls_answer['votes'];
820
+ $poll_most_percentage = $poll_answer_percentage;
821
+ }
822
+ // Get Least Voted Data
823
+ if($poll_least_votes == 0) {
824
+ $poll_least_votes = $polls_answer['votes'];
825
+ }
826
+ if($polls_answer['votes'] <= $poll_least_votes) {
827
+ $poll_least_answer = $polls_answer['answers'];
828
+ $poll_least_votes = $polls_answer['votes'];
829
+ $poll_least_percentage = $poll_answer_percentage;
830
+ }
831
+ // Delete Away From Array
832
+ unset($polls_answer['answers']);
833
+ }
834
+ }
835
+ // Results Footer Variables
836
+ $template_footer = stripslashes(get_settings('poll_template_resultfooter'));
837
+ $template_footer = str_replace("%POLL_TOTALVOTES%", $polls_question['totalvotes'], $template_footer);
838
+ $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
839
+ $template_footer = str_replace("%POLL_MOST_VOTES%", number_format($poll_most_votes), $template_footer);
840
+ $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
841
+ $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
842
+ $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format($poll_least_votes), $template_footer);
843
+ $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
844
+ // Print Out Results Footer Template
845
+ $pollsarchive_output .= $template_footer;
846
+ }
847
+ $pollsarchive_output .= "</div>\n";
848
+
849
+ // Polls Archive Paging
850
+ if($total_pages > 1) {
851
+ // Output Previous Page
852
+ $pollsarchive_output .= "<p>\n";
853
+ $pollsarchive_output .= "<span style=\"float: left;\">\n";
854
+ if($page > 1 && ((($page*$polls_perpage)-($polls_perpage-1)) <= $total_polls)) {
855
+ $pollsarchive_output .= '<strong>&laquo;</strong> <a href="'.polls_archive_link($page-1).'" title="&laquo; '.__('Previous Page').'">'.__('Previous Page').'</a>';
856
+ } else {
857
+ $pollsarchive_output .= '&nbsp;';
858
+ }
859
+ $pollsarchive_output .= "</span>\n";
860
+ // Output Next Page
861
+ $pollsarchive_output .= "<span style=\"float: right;\">\n";
862
+ if($page >= 1 && ((($page*$polls_perpage)+1) <= $total_polls)) {
863
+ $pollsarchive_output .= '<a href="'.polls_archive_link($page+1).'" title="'.__('Next Page').' &raquo;">'.__('Next Page').'</a> <strong>&raquo;</strong>';
864
+ } else {
865
+ $pollsarchive_output .= '&nbsp;';
866
+ }
867
+ $pollsarchive_output .= "</span>\n";
868
+ // Output Pages
869
+ $pollsarchive_output .= "</p>\n";
870
+ $pollsarchive_output .= "<br style=\"clear: both;\" />\n";
871
+ $pollsarchive_output .= "<p style=\"text-align: center;\">\n";
872
+ $pollsarchive_output .= __('Pages')." ($total_pages) : ";
873
+ if ($page >= 4) {
874
+ $pollsarchive_output .= '<strong><a href="'.polls_archive_link(1).'" title="'.__('Go to First Page').'">&laquo; '.__('First').'</a></strong> ... ';
875
+ }
876
+ if($page > 1) {
877
+ $pollsarchive_output .= ' <strong><a href="'.polls_archive_link($page-1).'" title="&laquo; '.__('Go to Page').' '.($page-1).'">&laquo;</a></strong> ';
878
+ }
879
+ for($i = $page - 2 ; $i <= $page +2; $i++) {
880
+ if ($i >= 1 && $i <= $total_pages) {
881
+ if($i == $page) {
882
+ $pollsarchive_output .= "<strong>[$i]</strong> ";
883
+ } else {
884
+ $pollsarchive_output .= '<a href="'.polls_archive_link($i).'" title="'.__('Page').' '.$i.'">'.$i.'</a> ';
885
+ }
886
+ }
887
+ }
888
+ if($page < $total_pages) {
889
+ $pollsarchive_output .= ' <strong><a href="'.polls_archive_link($page+1).'" title="'.__('Go to Page').' '.($page+1).' &raquo;">&raquo;</a></strong> ';
890
+ }
891
+ if (($page+2) < $total_pages) {
892
+ $pollsarchive_output .= ' ... <strong><a href="'.polls_archive_link($total_pages).'" title="'.__('Go to Last Page').'">'.__('Last').' &raquo;</a></strong>';
893
+ }
894
+ $pollsarchive_output .= "</p>\n";
895
+ }
896
+
897
+ // Output Polls Archive Page
898
+ return $pollsarchive_output;
899
+ }
900
+
901
+
902
+ ### Function: Create Poll Tables
903
+ add_action('activate_polls/polls.php', 'create_poll_table');
904
+ function create_poll_table() {
905
+ global $wpdb;
906
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
907
+ // Create Poll Tables (3 Tables)
908
+ $create_table = array();
909
+ $create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
910
+ "pollq_id int(10) NOT NULL auto_increment,".
911
+ "pollq_question varchar(200) NOT NULL default '',".
912
+ "pollq_timestamp varchar(20) NOT NULL default '',".
913
+ "pollq_totalvotes int(10) NOT NULL default '0',".
914
+ "pollq_active tinyint(1) NOT NULL default '1',".
915
+ "PRIMARY KEY (pollq_id))";
916
+ $create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (".
917
+ "polla_aid int(10) NOT NULL auto_increment,".
918
+ "polla_qid int(10) NOT NULL default '0',".
919
+ "polla_answers varchar(200) NOT NULL default '',".
920
+ "polla_votes int(10) NOT NULL default '0',".
921
+ "PRIMARY KEY (polla_aid))";
922
+ $create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (".
923
+ "pollip_id int(10) NOT NULL auto_increment,".
924
+ "pollip_qid varchar(10) NOT NULL default '',".
925
+ "pollip_aid varchar(10) NOT NULL default '',".
926
+ "pollip_ip varchar(100) NOT NULL default '',".
927
+ "pollip_host VARCHAR(200) NOT NULL default '',".
928
+ "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
929
+ "pollip_user tinytext NOT NULL,".
930
+ "pollip_userid int(10) NOT NULL default '0',".
931
+ "PRIMARY KEY (pollip_id))";
932
+ maybe_create_table($wpdb->pollsq, $create_table['pollsq']);
933
+ maybe_create_table($wpdb->pollsa, $create_table['pollsa']);
934
+ maybe_create_table($wpdb->pollsip, $create_table['pollsip']);
935
+ // Check Whether It is Install Or Upgrade
936
+ $first_poll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq LIMIT 1");
937
+ // If Install, Insert 1st Poll Question With 5 Poll Answers
938
+ if(empty($first_poll)) {
939
+ // Insert Poll Question (1 Record)
940
+ $insert_pollq = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (1, 'How Is My Site?', '".current_time('timestamp')."', 0, 1);");
941
+ if($insert_pollq) {
942
+ // Insert Poll Answers (5 Records)
943
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (1, 1, 'Good', 0);");
944
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (2, 1, 'Excellent', 0);");
945
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (3, 1, 'Bad', 0);");
946
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (4, 1, 'Can Be Improved', 0);");
947
+ $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (5, 1, 'No Comments', 0);");
948
+ }
949
+ }
950
+ // Add In Options (16 Records)
951
+ add_option('poll_template_voteheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
952
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
953
+ '<ul class="wp-polls-ul">', 'Template For Poll\'s Question');
954
+ 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');
955
+ add_option('poll_template_votefooter', '</ul>'.
956
+ '<p style="text-align: center;"><input type="button" name="vote" value=" Vote " class="Buttons" onclick="poll_vote(%POLL_ID%);" onkeypress="poll_result(%POLL_ID%);" /></p>'.
957
+ '<p style="text-align: center;"><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" onkeypress="poll_result(%POLL_ID%); return false;" title="View Results Of This Poll">View Results</a></p>'.
958
+ '</div>', 'Template For Poll\'s Voting Footer');
959
+ add_option('poll_template_resultheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
960
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
961
+ '<ul class="wp-polls-ul">', 'Template For Poll Header');
962
+ add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small><div class="pollbar-image" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% Votes)"></div></li>', 'Template For Poll Results');
963
+ add_option('poll_template_resultbody2', '<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%)</small></i></strong><div class="pollbar-image" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="You Have Voted For This Choice - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% Votes)"></div></li>', 'Template For Poll Results (User Voted)');
964
+ add_option('poll_template_resultfooter', '</ul>'.
965
+ '<p style="text-align: center;">Total Votes: <strong>%POLL_TOTALVOTES%</strong></p>'.
966
+ '</div>', 'Template For Poll Result Footer');
967
+ add_option('poll_template_resultfooter2', '</ul>'.
968
+ '<p style="text-align: center;">Total Votes: <strong>%POLL_TOTALVOTES%</strong></p>'.
969
+ '<p style="text-align: center;"><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" onkeypress="poll_booth(%POLL_ID%); return false;" title="Vote For This Poll">Vote</a></p>'.
970
+ '</div>', 'Template For Poll Result Footer');
971
+ add_option('poll_template_disable', 'Sorry, there are no polls available at the moment.', 'Template For Poll When It Is Disabled');
972
+ add_option('poll_template_error', 'An error has occurred when processing your poll.', 'Template For Poll When An Error Has Occured');
973
+ add_option('poll_currentpoll', 0, 'Current Displayed Poll');
974
+ add_option('poll_latestpoll', 1, 'The Lastest Poll');
975
+ add_option('poll_archive_perpage', 5, 'Number Of Polls To Display Per Page On The Poll\'s Archive', 'no');
976
+ add_option('poll_ans_sortby', 'polla_aid', 'Sorting Of Poll\'s Answers');
977
+ add_option('poll_ans_sortorder', 'asc', 'Sort Order Of Poll\'s Answers');
978
+ add_option('poll_ans_result_sortby', 'polla_votes', 'Sorting Of Poll\'s Answers Result');
979
+ add_option('poll_ans_result_sortorder', 'desc', 'Sorting Order Of Poll\'s Answers Result');
980
+ // Database Upgrade For WP-Polls 2.1
981
+ add_option('poll_logging_method', '3', 'Logging Method Of User Poll\'s Answer');
982
+ add_option('poll_allowtovote', '2', 'Who Is Allowed To Vote');
983
+ maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE $wpdb->pollsq ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';");
984
+ // Database Upgrade For WP-Polls 2.12
985
+ maybe_add_column($wpdb->pollsip, 'pollip_userid', "ALTER TABLE $wpdb->pollsip ADD pollip_userid INT( 10 ) NOT NULL DEFAULT '0';");
986
+ add_option('poll_archive_url', get_settings('siteurl').'/pollsarchive/', 'Polls Archive URL');
987
+ add_option('poll_archive_show', 1, 'Show Polls Archive?');
988
+ // Set 'manage_polls' Capabilities To Administrator
989
+ $role = get_role('administrator');
990
+ if(!$role->has_cap('manage_polls')) {
991
+ $role->add_cap('manage_polls');
992
+ }
993
+ }
994
+ ?>
readme.html ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.12 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.12&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.12%20Support" title="EMail To gamerz84@hotmail.com">gamerz84@hotmail.com</a>');
205
+ /* ]]> */
206
+ </script>
207
+ </p>
208
+ <p><b>Website:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/" title="http://www.lesterchan.net/">http://www.lesterchan.net/</a></p>
209
+ <p><b>Demo:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/blogs" title="http://www.lesterchan.net/blogs">http://www.lesterchan.net/blogs</a></p>
210
+ <p><b>Documentation:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/wiki/wp-polls" title="http://dev.wp-plugins.org/wiki/wp-polls">http://dev.wp-plugins.org/wiki/wp-polls</a></p>
211
+ <p><b>Development:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/browser/wp-polls/" title="http://dev.wp-plugins.org/browser/wp-polls/">http://dev.wp-plugins.org/browser/wp-polls/</a></p>
212
+ <p><b>Support Forums:</b><br /><b>&raquo;</b> <a href="http://forums.lesterchan.net/viewforum.php?f=7" title="http://forums.lesterchan.net/viewforum.php?f=7">http://forums.lesterchan.net/viewforum.php?f=7</a></p>
213
+ <p><b>Updated:</b><br /><b>&raquo;</b> 1st October 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.12 (01-10-2006)</b>
219
+ <ul>
220
+
221
+ <li>NEW: Polls Archive Is Now Embedded Into A Page, And Hence No More Integrating Of Polls Archive</li>
222
+ <li>NEW: WP-Polls Is Now Using DIV To Display The Poll's Results Instead Of The Image Bar</li>
223
+ <li>NEW: Added Widget Title Option To WP-Polls Widget</li>
224
+ <li>NEW: Ability To Logged By UserName</li>
225
+ <li>NEW: Added CSS Class 'wp-polls-image' To All IMG Tags</li>
226
+ <li>FIXED: If Site URL Doesn't Match WP Option's Site URL, WP-Polls Will Not Work</li>
227
+ </ul>
228
+ </li>
229
+ <li>
230
+ <b>Version 2.11 (08-06-2006)</b>
231
+ <ul>
232
+ <li>NEW: You Can Now Place The Poll On The Sidebar As A Widget</li>
233
+ <li>NEW: Moved wp-polls.php To wp-content/plugins/polls/ Folder</li>
234
+ <li>FIXED: AJAX Not Working In Opera Browser</li>
235
+ <li>FIXED: Poll Not Working On Physical Pages That Is Integrated Into WordPress</li>
236
+ </ul>
237
+ </li>
238
+ <li>
239
+ <b>Version 2.1 (01-06-2006)</b>
240
+ <ul>
241
+ <li>NEW: Poll Is Now Using AJAX</li>
242
+ <li>NEW: Ability To Close/Open Poll</li>
243
+ <li>NEW: Added Poll Option For Logging Method</li>
244
+ <li>NEW: Added Poll Option For Who Can Vote</li>
245
+ <li>NEW: Added Poll Results Footer Template Variable (Used When User Click "View Results")</li>
246
+ <li>NEW: Added The Ability To Delete All Poll Logs Or Logs From A Specific Poll</li>
247
+ <li>NEW: Poll Administration Panel And The Code That WP-Polls Generated Is XHTML 1.0 Transitional</li>
248
+ </ul>
249
+ </li>
250
+ <li>
251
+ <b>Version 2.06b (26-04-2006)</b>
252
+ <ul>
253
+ <li>FIXED: Bug In vote_poll();</li>
254
+ </ul>
255
+ </li>
256
+ <li>
257
+ <b>Version 2.06a (02-04-2006)</b>
258
+ <ul>
259
+ <li>FIXED: Random Poll Not Working Correctly</li>
260
+ </ul>
261
+ </li>
262
+ <li>
263
+ <b>Version 2.06 (01-04-2006)</b>
264
+ <ul>
265
+ <li>NEW: Poll Bar Is Slightly Nicer</li>
266
+ <li>NEW: Got Rid Of Tables, Now Using List</li>
267
+ <li>NEW: Added In Most Voted And Least Voted Answer/Votes/Percentage For Individual Poll As Template Variables</li>
268
+ <li>NEW: Display Random Poll Option Under Poll -> Poll Options -> Current Poll</li>
269
+ <li>FIXED: Totally Removed Tables In wp-polls.php</li>
270
+ </ul>
271
+ </li>
272
+ <li>
273
+ <b>Version 2.05 (01-03-2006)</b>
274
+ <ul>
275
+ <li>NEW: Improved On 'manage_polls' Capabilities</li>
276
+ <li>NEW: Neater Structure</li>
277
+ <li>NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin</li>
278
+ <li>NEW: Added Poll Stats Function</li>
279
+ </ul>
280
+ </li>
281
+ <li>
282
+ <b>Version 2.04 (01-02-2006)</b>
283
+ <ul>
284
+ <li>NEW: Added 'manage_polls' Capabilities To Administrator Role</li>
285
+ <li>NEW: [poll=POLL_ID] Tag To Insert Poll Into A Post</li>
286
+ <li>NEW: Ability To Edit Poll's Timestamp</li>
287
+ <li>NEW: Ability To Edit Individual Poll's Answer Votes</li>
288
+ <li>NEW: %POLL_RESULT_URL% To Display Poll's Result URL</li>
289
+ <li>FIXED: Cannot Sent Header Error</li>
290
+ </ul>
291
+ </li>
292
+ <li>
293
+ <b>Version 2.03 (01-01-2006)</b>
294
+ <ul>
295
+ <li>NEW: Compatible With WordPress 2.0 Only</li>
296
+ <li>NEW: Poll Administration Menu Added Automatically Upon Activating The Plugin</li>
297
+ <li>NEW: Removed Add Poll Link From The Administration Menu</li>
298
+ <li>NEW: GPL License Added</li>
299
+ <li>NEW: Page Title Added To wp-polls.php</li>
300
+ </ul>
301
+ </li>
302
+ <li>
303
+ <b>Version 2.02a (17-11-2005)</b>
304
+ <ul>
305
+ <li>FIXED: poll-install.php And poll-upgrade.php will Now Be Installed/Upgraded To 2.02 Instead Of 2.01</li>
306
+ </ul>
307
+ </li>
308
+ <li>
309
+ <b>Version 2.02 (05-11-2005)</b>
310
+ <ul>
311
+ <li>FIXED: Showing 0 Vote On Poll Edit Page</li>
312
+ <li>FIXED: Null Vote Being Counted As A Vote</li>
313
+ <li>FIXED: Auto Loading Of Poll Option: Polls Per Page In Poll Archive Page Is Now "No"</li>
314
+ <li>NEW: Host Column In Poll IP Table To Prevent Network Lagging When Resolving IP</li>
315
+ <li>NEW: New Poll Error Template</li>
316
+ </ul>
317
+ </li>
318
+ <li>
319
+ <b>Version 2.01 (25-10-2005)</b>
320
+ <ul>
321
+ <li>FIXED: Upgrade Script To Insert Lastest Poll ID Of User's Current Polls, Instead Of Poll ID 1</li>
322
+ <li>FIXED: Replace All &lt;?= With &lt;?php</li>
323
+ <li>FIXED: Added addalshes() To $pollip_user</li>
324
+ <li>FIXED: Better Localization Support (80% Done, Will Leave It In The Mean Time)</li>
325
+ </ul>
326
+ </li>
327
+ <li>
328
+ <b>Version 2.0 (20-10-2005)</b>
329
+ <ul>
330
+ <li>NEW: IP Logging</li>
331
+ <li>NEW: Poll Options: Sorting Of Answers In Voting Form</li>
332
+ <li>NEW: Poll Options: Sorting Of Answers In Results View</li>
333
+ <li>NEW: Poll Options: Number Of Polls Per Page In Poll Archive</li>
334
+ <li>NEW: Poll Options: Choose Poll To Display On Index Page</li>
335
+ <li>NEW: Poll Options: Able To Disable Poll With Custom Message</li>
336
+ <li>NEW: Poll Options: Poll Templates</li>
337
+ <li>NEW: Display User's Voted Choice</li>
338
+ <li>FIXED: Better Install/Upgrade Script</li>
339
+ </ul>
340
+ </li>
341
+ </ul>
342
+ </div>
343
+
344
+ <!-- Installation Instructions -->
345
+ <div id="Install" style="display: none;">
346
+ <div class="SubTitle">&raquo; Installation Instructions</div>
347
+ <ol>
348
+ <li>
349
+ Open <b>wp-content/plugins</b> Folder
350
+ </li>
351
+ <li>
352
+ Put:
353
+ <blockquote>Folder: polls</blockquote>
354
+ </li>
355
+ <li>
356
+ <b>Activate</b> WP-Polls Plugin
357
+ </li>
358
+ <li>
359
+ Refer To <b>Usage</b> For Further Instructions
360
+ </li>
361
+ </ol>
362
+ </div>
363
+
364
+ <!-- Upgrade Instructions -->
365
+ <div id="Upgrade" style="display: none;">
366
+ <div class="SubTitle">&raquo; Upgrade Instructions</div>
367
+ <div class="SubSubTitle">From v2.1x To v2.12</div>
368
+ <ol>
369
+ <li>
370
+ <b>Deactivate</b> WP-Polls Plugin
371
+ </li>
372
+ <li>
373
+ Open <b>wp-content/plugins</b> Folder
374
+ </li>
375
+ <li>
376
+ Overwrite:
377
+ <blockquote>Folder: polls</blockquote>
378
+ </li>
379
+ <li>
380
+ Open <b>wp-content/plugins/polls</b> Folder
381
+ </li>
382
+ <li>
383
+ Delete file if exists:
384
+ <blockquote>
385
+ File: wp-polls.php<br />
386
+ File: images/pollbar.gif<br />
387
+ File: images/pollend.gif<br />
388
+ File: images/pollstart.gif
389
+ </blockquote>
390
+ </li>
391
+ <li>
392
+ Open <b>Root WordPress</b> Folder
393
+ </li>
394
+ <li>
395
+ Delete file if exists:
396
+ <blockquote>File: wp-polls.php</blockquote>
397
+ </li>
398
+ <li>
399
+ <b>Activate</b> WP-Polls Plugin
400
+ </li>
401
+ <li>
402
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
403
+ </li>
404
+ <li>
405
+ Refer To <b>Usage</b> For Further Instructions
406
+ </li>
407
+ </ol>
408
+ <div class="SubSubTitle">From v2.06 To v2.12</div>
409
+ <ol>
410
+ <li>
411
+ <b>Deactivate</b> WP-Polls Plugin
412
+ </li>
413
+ <li>
414
+ Open <b>wp-content/plugins</b> Folder
415
+ </li>
416
+ <li>
417
+ Overwrite:
418
+ <blockquote>Folder: polls</blockquote>
419
+ </li>
420
+ <li>
421
+ Open <b>Root WordPress</b> Folder
422
+ </li>
423
+ <li>
424
+ Delete file if exists:
425
+ <blockquote>File: wp-polls.php</blockquote>
426
+ </li>
427
+ <li>
428
+ <b>Activate</b> WP-Polls Plugin
429
+ </li>
430
+ <li>
431
+ Go to 'WP-Admin -> Polls -> Polls Options' and restore all the template variables to <b>Default</b>
432
+ </li>
433
+ <li>
434
+ Refer To <b>Usage</b> For Further Instructions
435
+ </li>
436
+ </ol>
437
+ </div>
438
+
439
+ <!-- Usage Instructions -->
440
+ <div id="Usage" style="display: none;">
441
+ <div class="SubTitle">&raquo; Usage Instructions</div>
442
+ <div class="SubSubTitle">General Usage (Without Widget)</div>
443
+ <ol>
444
+ <li>
445
+ Open <b>wp-content/themes/&lt;YOUR THEME NAME&gt;/sidebar.php</b>
446
+ </li>
447
+ <li>
448
+ Add:
449
+ <blockquote>
450
+ &lt;?php if (function_exists('vote_poll') &amp;&amp; !$in_pollsarchive): ?&gt;<br />
451
+ &lt;li&gt;<br />
452
+ &nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;<br />
453
+ &nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
454
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;<br />
455
+ &nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
456
+ &nbsp;&nbsp;&nbsp;&lt;?php display_polls_archive_link(); ?&gt;<br />
457
+ &lt;/li&gt;<br />
458
+ &lt;?php endif; ?&gt;
459
+ </blockquote>
460
+ <p>To show specific poll, use &lt;?php get_poll(<b>2</b>);?&gt; where <b>2</b> is your poll id.</p>
461
+ <p>To embed a specific poll in your post, use [poll=<b>2</b>] where <b>2</b> is your poll id.</p>
462
+ </li>
463
+ <li>
464
+ Scroll down for instructions on how to create a <b>Polls Archive</b>.
465
+ </li>
466
+ </ol>
467
+ <div class="SubSubTitle">General Usage (With Widget)</div>
468
+ <ol>
469
+ <li>
470
+ <b>Activate</b> WP-Polls Widget Plugin
471
+ </li>
472
+ <li>
473
+ Go to 'WP-Admin -> Presentation -> Sidebar Widgets'
474
+ </li>
475
+ <li>
476
+ <b>Drag</b> the Polls Widget to your sidebar
477
+ </li>
478
+ <li>
479
+ You can <b>configure</b> the Polls Widget by clicking on the configure icon
480
+ </li>
481
+ <li>
482
+ Click 'Save changes'
483
+ </li>
484
+ <li>
485
+ Scroll down for instructions on how to create a <b>Polls Archive</b>.
486
+ </li>
487
+ </ol>
488
+ <div class="SubSubTitle">Polls Archive</div>
489
+ <ol>
490
+ <li>
491
+ Go to 'WP-Admin -> Write -> Write Page'
492
+ </li>
493
+ <li>
494
+ Type any title you like in the post's title area
495
+ </li>
496
+ <li>
497
+ Type '<b>[page_polls]</b>' in the post's content area (without the quotes)
498
+ </li>
499
+ <li>
500
+ Type '<b>pollsarchive</b>' in the post's slug area (without the quotes)
501
+ </li>
502
+ <li>
503
+ Click 'Publish'
504
+ </li>
505
+ <li>
506
+ If you <b>ARE NOT</b> using nice permalinks, you need to go to 'WP-Admin -> Polls -> Poll Option' and under '<b>Poll Archive -> Polls Archive URL</b>', you need to fill in the URL to the Polls Archive Page you created above.
507
+ </li>
508
+ </ol>
509
+ <div class="SubSubTitle">Note</div>
510
+ <ul>
511
+ <li>
512
+ In IE, some of the poll's text may appear jagged (this is normal in IE). To solve this issue,
513
+ <ol>
514
+ <li>
515
+ Open <b>poll-css.css</b>
516
+ </li>
517
+ <li>
518
+ Find:
519
+ <blockquote>
520
+ /* background-color: #ffffff; */
521
+ </blockquote>
522
+ </li>
523
+ <li>
524
+ Replace:
525
+ <blockquote>
526
+ background-color: #ffffff;
527
+ </blockquote>
528
+ <p>Where <b>#ffffff</b> should be your background color for the poll.</p>
529
+ </li>
530
+ </ol>
531
+ </li>
532
+ </ul>
533
+ <div class="SubSubTitle">Polls Stats (Outside WP Loop)</div>
534
+ <ul>
535
+ <li>
536
+ To Display <b>Total Polls</b>
537
+ </li>
538
+ <li>
539
+ Use:
540
+ <blockquote>
541
+ &lt;?php if (function_exists('get_pollquestions')): ?&gt;<br />
542
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;<br />
543
+ &lt;?php endif; ?&gt;
544
+ </blockquote>
545
+ </li>
546
+ <li>
547
+ To Display <b>Total Poll Answers</b>
548
+ </li>
549
+ <li>
550
+ Use:
551
+ <blockquote>
552
+ &lt;?php if (function_exists('get_pollanswers')): ?&gt;<br />
553
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;<br />
554
+ &lt;?php endif; ?&gt;
555
+ </blockquote>
556
+ </li>
557
+ <li>
558
+ To Display <b>Total Poll Votes</b>
559
+ </li>
560
+ <li>
561
+ Use:
562
+ <blockquote>
563
+ &lt;?php if (function_exists('get_pollvotes')): ?&gt;<br />
564
+ &nbsp;&nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;<br />
565
+ &lt;?php endif; ?&gt;
566
+ </blockquote>
567
+ </li>
568
+ </ul>
569
+ </div>
570
+ </div>
571
+ </div>
572
+ <p id="Copyright">WP-Polls 2.12<br />Copyright &copy; 2006 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
573
+ </body>
574
+ </html>