root/wp-polls/trunk/polls-manager.php

Revision 49932, 27.5 kB (checked in by GamerZ, 4 weeks ago)

Fixed MYSQL Charset Issue

Line 
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 |                                                                                            |
5 |    WordPress 2.5 Plugin: WP-Polls 2.31                                        |
6 |    Copyright (c) 2008 Lester "GaMerZ" Chan                                    |
7 |                                                                                            |
8 |    File Written By:                                                                    |
9 |    - Lester "GaMerZ" Chan                                                            |
10 |    - http://lesterchan.net                                                            |
11 |                                                                                            |
12 |    File Information:                                                                    |
13 |    - Manage Your Polls                                                                |
14 |    - wp-content/plugins/wp-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('wp-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         // Edit Poll
39         case __('Edit Poll', 'wp-polls'):
40             // Poll ID
41             $pollq_id  = intval($_POST['pollq_id']);
42             // Poll Total Votes
43             $pollq_totalvotes = intval($_POST['pollq_totalvotes']);
44             // Poll Total Voters
45             $pollq_totalvoters = intval($_POST['pollq_totalvoters']);
46             // Poll Question
47             $pollq_question = addslashes(trim($_POST['pollq_question']));
48             // Poll Active
49             $pollq_active = intval($_POST['pollq_active']);
50             // Poll Start Date
51             $edit_polltimestamp = intval($_POST['edit_polltimestamp']);
52             $timestamp_sql = '';
53             if($edit_polltimestamp == 1) {
54                 $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']);
55                 $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']);
56                 $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']);
57                 $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']);
58                 $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']);
59                 $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']);
60                 $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
61                 $timestamp_sql = ", pollq_timestamp = '$pollq_timestamp'";
62                 if($pollq_timestamp > current_time('timestamp')) {
63                     $pollq_active = -1;
64                 }
65             }
66             // Poll End Date
67             $pollq_expiry_no = intval($_POST['pollq_expiry_no']);
68             if($pollq_expiry_no == 1) {
69                 $pollq_expiry = '';
70             } else {
71                 $pollq_expiry_day = intval($_POST['pollq_expiry_day']);
72                 $pollq_expiry_month = intval($_POST['pollq_expiry_month']);
73                 $pollq_expiry_year = intval($_POST['pollq_expiry_year']);
74                 $pollq_expiry_hour = intval($_POST['pollq_expiry_hour']);
75                 $pollq_expiry_minute = intval($_POST['pollq_expiry_minute']);
76                 $pollq_expiry_second = intval($_POST['pollq_expiry_second']);
77                 $pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
78                 if($pollq_expiry <= current_time('timestamp')) {
79                     $pollq_active = 0;
80                 }
81                 if($edit_polltimestamp == 1) {
82                     if($pollq_expiry < $pollq_timestamp) {
83                         $pollq_active = 0;
84                     }
85                 }
86             }
87             // Mutilple Poll
88             $pollq_multiple_yes = intval($_POST['pollq_multiple_yes']);
89             $pollq_multiple = 0;
90             if($pollq_multiple_yes == 1) {
91                 $pollq_multiple = intval($_POST['pollq_multiple']);
92             } else {
93                 $pollq_multiple = 0;
94             }
95             // Update Poll's Question
96             $edit_poll_question = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_question = '$pollq_question', pollq_totalvotes = $pollq_totalvotes, pollq_expiry = '$pollq_expiry', pollq_active = $pollq_active, pollq_multiple = $pollq_multiple, pollq_totalvoters = $pollq_totalvoters $timestamp_sql WHERE pollq_id = $pollq_id");
97             if(!$edit_poll_question) {
98                 $text = '<p style="color: blue">'.sprintf(__('No Changes Had Been Made To Poll\'s Question \'%s\'.', 'wp-polls'), stripslashes($pollq_question)).'</p>';
99             }
100             // Update Polls' Answers
101             $polla_aids = array();
102             $get_polla_aids = $wpdb->get_results("SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = $pollq_id ORDER BY polla_aid ASC");
103             if($get_polla_aids) {
104                 foreach($get_polla_aids as $get_polla_aid) {
105                         $polla_aids[] = intval($get_polla_aid->polla_aid);
106                 }
107                 foreach($polla_aids as $polla_aid) {
108                     $polla_answers = addslashes(trim($_POST['polla_aid-'.$polla_aid]));
109                     $polla_votes = intval($_POST['polla_votes-'.$polla_aid]);
110                     $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");
111                     if(!$edit_poll_answer) {
112                         $text .= '<p style="color: blue">'.sprintf(__('No Changes Had Been Made To Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answers)).'</p>';
113                     } else {
114                         $text .= '<p style="color: green">'.sprintf(__('Poll\'s Answer \'%s\' Edited Successfully.', 'wp-polls'), stripslashes($polla_answers)).'</p>';
115                     }
116                 }
117             } else {
118                 $text .= '<p style="color: red">'.sprintf(__('Invalid Poll \'%s\'.', 'wp-polls'), stripslashes($pollq_question)).'</p>';
119             }
120             // Add Poll Answers (If Needed)
121             $polla_answers_new = $_POST['polla_answers_new'];
122             if(!empty($polla_answers_new)) {
123                 $i = 0;
124                 $polla_answers_new_votes = $_POST['polla_answers_new_votes'];
125                 foreach($polla_answers_new as $polla_answer_new) {
126                     $polla_answer_new = addslashes(trim($polla_answer_new));
127                     if(!empty($polla_answer_new)) {
128                         $polla_answer_new_vote = intval($polla_answers_new_votes[$i]);
129                         $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $pollq_id, '$polla_answer_new', $polla_answer_new_vote)");
130                         if(!$add_poll_answers) {
131                             $text .= '<p style="color: red;">'.sprintf(__('Error In Adding Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answer_new)).'</p>';
132                         } else {
133                             $text .= '<p style="color: green;">'.sprintf(__('Poll\'s Answer \'%s\' Added Successfully.', 'wp-polls'), stripslashes($polla_answer_new)).'</p>';
134                         }
135                     }
136                     $i++;
137                 }
138             }
139             if(empty($text)) {
140                 $text = '<p style="color: green">'.sprintf(__('Poll \'%s\' Edited Successfully.', 'wp-polls'), stripslashes($pollq_question)).'</p>';
141             }
142             // Update Lastest Poll ID To Poll Options
143             $latest_pollid = polls_latest_id();
144             $update_latestpoll = update_option('poll_latestpoll', $latest_pollid);
145             cron_polls_place();
146             break;
147     }
148 }
149
150
151 ### Determines Which Mode It Is
152 switch($mode) {
153     // Poll Logging
154     case 'logs':
155         require('polls-logs.php');
156         break;
157 ?>
158     <?php
159         break;
160     // Edit A Poll
161     case 'edit':
162         $poll_question = $wpdb->get_row("SELECT pollq_question, pollq_timestamp, pollq_totalvotes, pollq_active, pollq_expiry, pollq_multiple, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = $poll_id");
163         $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");
164         $poll_noquestion = $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa WHERE polla_qid = $poll_id");
165         $poll_question_text = stripslashes($poll_question->pollq_question);
166         $poll_totalvotes = intval($poll_question->pollq_totalvote);
167         $poll_timestamp = $poll_question->pollq_timestamp;
168         $poll_active = intval($poll_question->pollq_active);
169         $poll_expiry = trim($poll_question->pollq_expiry);
170         $poll_multiple = intval($poll_question->pollq_multiple);
171         $poll_totalvoters = intval($poll_question->pollq_totalvoters);
172 ?>
173         <script type="text/javascript">
174             /* <![CDATA[*/
175             var total_votes = 0;
176             var total_new_votes = 0;
177             function check_totalvotes() {   
178                 var temp_vote = 0;
179                 total_votes = 0;
180                 <?php
181                     foreach($poll_answers as $poll_answer) {
182                         $polla_aid = intval($poll_answer->polla_aid);
183                         echo "\t\t\t\tif(document.getElementById('polla_votes-$polla_aid')) {\n";
184                         echo "\t\t\t\t\ttemp_vote = parseInt(document.getElementById('polla_votes-$polla_aid').value);\n";
185                         echo "\t\t\t\t\tif(isNaN(temp_vote)) {\n";
186                         echo "\t\t\t\t\t\tdocument.getElementById('polla_votes-$polla_aid').value = 0;\n";
187                         echo "\t\t\t\t\t\ttemp_vote = 0;\n";
188                         echo "\t\t\t\t\t}\n";
189                         echo "\t\t\t\t\ttotal_votes += temp_vote;\n";
190                         echo "\t\t\t\t}\n";
191                     }
192                 ?>
193                 totalvotes();
194             }
195             function check_totalvotes_new() {   
196                 var new_votes = document.getElementsByName("polla_answers_new_votes[]");
197                 var temp_new_vote = 0;
198                 total_new_votes = 0;
199                 for(i = 0; i < new_votes.length; i++) {
200                     temp_new_vote = parseInt(new_votes[i].value);
201                     if(isNaN(temp_new_vote)) {
202                         temp_new_vote = 0;
203                     }
204                     total_new_votes += temp_new_vote;
205                 }
206                 totalvotes();
207             }
208             function totalvotes() {
209                 document.getElementById('pollq_totalvotes').value = (parseInt(total_votes) + parseInt(total_new_votes));
210             }
211             function check_polltimestamp() {
212                 poll_edit_polltimestamp = document.getElementById("edit_polltimestamp").checked;
213                 if(poll_edit_polltimestamp) {
214                     document.getElementById("pollq_timestamp").style.display = 'block';
215                 } else {
216                     document.getElementById("pollq_timestamp").style.display = 'none';
217                 }
218             }
219             function check_pollexpiry() {
220                 pollq_expiry_no = document.getElementById("pollq_expiry_no").checked;
221                 if(pollq_expiry_no) {
222                     document.getElementById("pollq_expiry_timestamp").style.display = 'none';
223                 } else {
224                     document.getElementById("pollq_expiry_timestamp").style.display = 'block';
225                 }
226             }
227             var count_poll_answer = <?php echo $poll_noquestion; ?>;
228             var count_poll_answer_new = 0;
229             function create_poll_answer() {
230                 // Create Elements
231                 var poll_tr = document.createElement("tr");
232                 var poll_td1 = document.createElement("th");
233                 var poll_td2 = document.createElement("td");
234                 var poll_td3 = document.createElement("td");
235                 var poll_answer = document.createElement("input");
236                 var poll_votes = document.createElement("input");
237                 var poll_answer_count = document.createTextNode("<?php _e('Answer', 'wp-polls'); ?> " + (count_poll_answer+1));
238                 var poll_votes_count = document.createTextNode("0 ");
239                 var poll_answer_bold = document.createElement("strong");
240                 var poll_option = document.createElement("option");
241                 var poll_option_text = document.createTextNode((count_poll_answer+1));
242                 count_poll_answer++;
243                 count_poll_answer_new++;
244                 // Elements - Input
245                 poll_answer.setAttribute('type', "text");
246                 poll_answer.setAttribute('name', "polla_answers_new[]");
247                 poll_answer.setAttribute('size', "50");
248                 poll_votes.setAttribute('type', "text");
249                 poll_votes.setAttribute('name', "polla_answers_new_votes[]")
250                 poll_votes.setAttribute('size', "4");
251                 poll_votes.setAttribute('value', "0");
252                 poll_votes.setAttribute('onblur', "check_totalvotes_new();");
253                 // Elements - Options
254                 poll_option.setAttribute('value', count_poll_answer);
255                 poll_option.setAttribute('id', "pollq-multiple-" + (count_poll_answer+1));
256                 // Elements - TD/TR
257                 poll_tr.setAttribute('id', "poll-answer-new-" + count_poll_answer_new);
258                 poll_td1.setAttribute('width', "20%");
259                 poll_td1.setAttribute('scope', "row");
260                 poll_td1.setAttribute('valign', "top");
261                 poll_td2.setAttribute('width', "60%");
262                 poll_td3.setAttribute('width', "20%");
263                 poll_td3.setAttribute('align', "right");
264                 // Appending To Elements
265                 poll_tr.appendChild(poll_td1);
266                 poll_tr.appendChild(poll_td2);
267                 poll_tr.appendChild(poll_td3);
268                 poll_answer_bold.appendChild(poll_answer_count);
269                 poll_td1.appendChild(poll_answer_bold);
270                 poll_td2.appendChild(poll_answer);               
271                 poll_td3.appendChild(poll_votes_count);
272                 poll_td3.appendChild(poll_votes);
273                 poll_option.appendChild(poll_option_text);
274                 document.getElementById("poll_answers").appendChild(poll_tr);
275                 document.getElementById("pollq_multiple").appendChild(poll_option);
276             }
277             function remove_poll_answer() {
278                 if(count_poll_answer_new == 0) {
279                     alert("<?php _e('No more poll\'s answer to be removed.', 'wp-polls'); ?>");
280                 } else {
281                     document.getElementById("poll_answers").removeChild(document.getElementById("poll-answer-new-" + count_poll_answer_new));
282                     document.getElementById("pollq_multiple").removeChild(document.getElementById("pollq-multiple-" + (count_poll_answer+1)));
283                     document.getElementById("pollq_multiple").value = count_poll_answer;
284                     count_poll_answer--;
285                     count_poll_answer_new--;
286                     check_totalvotes_new();
287                 }
288             }
289             function check_pollq_multiple() {
290                 if(parseInt(document.getElementById("pollq_multiple_yes").value) == 1) {
291                     document.getElementById("pollq_multiple").disabled = false;
292                 } else {
293                     document.getElementById("pollq_multiple").value = 1;
294                     document.getElementById("pollq_multiple").disabled = true;
295                 }
296             }
297             /* ]]> */
298         </script>
299
300         <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade">'.stripslashes($text).'</div>'; } else { echo '<div id="message" class="updated" style="display: none;"></div>'; } ?>
301
302         <!-- Edit Poll -->
303         <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
304         <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" />
305         <input type="hidden" name="pollq_active" value="<?php echo $poll_active; ?>" />
306         <div class="wrap">
307             <h2><?php _e('Edit Poll', 'wp-polls'); ?></h2>
308             <!-- Poll Question -->
309             <h3><?php _e('Poll Question', 'wp-polls'); ?></h3>
310             <table class="form-table">
311                 <tr>
312                     <th width="20%" scope="row" valign="top"><?php _e('Question', 'wp-polls') ?></th>
313                     <td width="80%"><input type="text" size="70" name="pollq_question" value="<?php echo htmlspecialchars($poll_question_text); ?>" /></td>
314                 </tr>
315             </table>
316             <!-- Poll Answers -->
317             <h3><?php _e('Poll Answers', 'wp-polls'); ?></h3>
318             <table class="form-table">
319                 <thead>
320                     <tr>
321                         <th width="20%" scope="row" valign="top"><?php _e('Answer No.', 'wp-polls') ?></th>
322                         <th width="60%" scope="row" valign="top"><?php _e('Answer Text', 'wp-polls') ?></th>
323                         <th width="20%" scope="row" valign="top" style="text-align: right;"><?php _e('No. Of Votes', 'wp-polls') ?></th>
324                     </tr>
325                 </thead>
326                 <tbody id="poll_answers">
327                     <?php
328                         $i=1;
329                         $poll_actual_totalvotes = 0;
330                         if($poll_answers) {
331                             $pollip_answers = array();
332                             $pollip_answers[0] = __('Null Votes', 'wp-polls');
333                             foreach($poll_answers as $poll_answer) {
334                                 $polla_aid = intval($poll_answer->polla_aid);
335                                 $polla_answers = stripslashes($poll_answer->polla_answers);
336                                 $polla_votes = intval($poll_answer->polla_votes);
337                                 $pollip_answers[$polla_aid] = $polla_answers;
338                                 echo "<tr id=\"poll-answer-$polla_aid\">\n";
339                                 echo '<th width="20%" scope="row" valign="top">'.sprintf(__('Answer %s', 'wp-polls'), $i).'</th>'."\n";
340                                 echo "<td width=\"60%\"><input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_aid-$polla_aid\" value=\"".htmlspecialchars($polla_answers)."\" />&nbsp;&nbsp;&nbsp;";
341                                 echo "<input type=\"button\" value=\"".__('Delete', 'wp-polls')."\" onclick=\"delete_poll_ans($poll_id, $polla_aid, $polla_votes, '".sprintf(js_escape(__('You are about to delete this poll\'s answer \'%s\'.', 'wp-polls')), js_escape(htmlspecialchars($polla_answers)))."');\" class=\"button\" /></td>\n";
342                                 echo '<td width="20%" align="right">'.number_format_i18n($polla_votes)." <input type=\"text\" size=\"4\" id=\"polla_votes-$polla_aid\" name=\"polla_votes-$polla_aid\" value=\"$polla_votes\" onblur=\"check_totalvotes();\" /></td>\n</tr>\n";
343                                 $poll_actual_totalvotes += $polla_votes;
344                                 $i++;
345                             }
346                         }
347                     ?>
348                 </tbody>
349                 <tbody>
350                     <tr>
351                         <td width="20%">&nbsp;</td>
352                         <td width="60%"><input type="button" value="<?php _e('Add Answer', 'wp-polls') ?>" onclick="create_poll_answer();" class="button" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="<?php _e('Remove Answer', 'wp-polls') ?>" onclick="remove_poll_answer();" class="button" /></td>
353                         <td width="20%" align="right"><strong><?php _e('Total Votes:', 'wp-polls'); ?></strong><strong id="poll_total_votes"><?php echo $poll_actual_totalvotes; ?></strong> <input type="text" size="4" readonly="readonly" id="pollq_totalvotes" name="pollq_totalvotes" value="<?php echo $poll_actual_totalvotes; ?>" onblur="check_totalvotes();" /></td>
354                     </tr>
355                     <tr>
356                         <td width="20%">&nbsp;</td>
357                         <td width="60%">&nbsp;</td>
358                         <td width="20%" align="right"><strong><?php _e('Total Voters:', 'wp-polls'); ?><?php echo number_format_i18n($poll_totalvoters); ?></strong> <input type="text" size="4" name="pollq_totalvoters" value="<?php echo $poll_totalvoters; ?>" /></td>
359                     </tr>
360                 </tbody>
361             </table>
362             <!-- Poll Multiple Answers -->
363             <h3><?php _e('Poll Multiple Answers', 'wp-polls') ?></h3>
364             <table class="form-table">
365                 <tr>
366                     <th width="40%" scope="row" valign="top"><?php _e('Allows Users To Select More Than One Answer?', 'wp-polls'); ?></th>
367                     <td width="60%">
368                         <select name="pollq_multiple_yes" id="pollq_multiple_yes" size="1" onchange="check_pollq_multiple();">
369                             <option value="0"<?php selected('0', $poll_multiple); ?>><?php _e('No', 'wp-polls'); ?></option>
370                             <option value="1"<?php if($poll_multiple > 0) { echo ' selected="selected"'; } ?>><?php _e('Yes', 'wp-polls'); ?></option>
371                         </select>
372                     </td>
373                 </tr>
374                 <tr>
375                     <th width="40%" scope="row" valign="top"><?php _e('Maximum Number Of Selected Answers Allowed?', 'wp-polls') ?></th>
376                     <td width="60%">
377                         <select name="pollq_multiple" id="pollq_multiple" size="1" <?php if($poll_multiple == 0) { echo 'disabled="disabled"'; } ?>>
378                             <?php
379                                 for($i = 1; $i <= $poll_noquestion; $i++) {
380                                     if($poll_multiple > 0 && $poll_multiple == $i) {
381                                         echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
382                                     } else {
383                                         echo "<option value=\"$i\">$i</option>\n";
384                                     }
385                                 }
386                             ?>
387                         </select>
388                     </td>
389                 </tr>
390             </table>
391             <!-- Poll Start/End Date -->
392             <h3><?php _e('Poll Start/End Date', 'wp-polls'); ?></h3>
393             <table class="form-table">
394                 <tr>
395                     <th width="20%" scope="row" valign="top"><?php _e('Start Date/Time', 'wp-polls'); ?></th>
396                     <td width="80%">
397                         <?php echo mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_timestamp)); ?><br />
398                         <input type="checkbox" name="edit_polltimestamp" id="edit_polltimestamp" value="1" onclick="check_polltimestamp()" />&nbsp;<label for="edit_polltimestamp"><?php _e('Edit Start Date/Time', 'wp-polls'); ?></label><br />
399                         <?php poll_timestamp($poll_timestamp, 'pollq_timestamp', 'none'); ?>
400                     </td>
401                 </tr>
402                     <tr>
403                     <th width="20%" scope="row" valign="top"><?php _e('End Date/Time', 'wp-polls'); ?></th>
404                     <td width="80%">
405                         <?php
406                             if(empty($poll_expiry)) {
407                                 _e('This Poll Will Not Expire', 'wp-polls');
408                             } else {
409                                 echo mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_expiry));
410                             }
411                         ?>
412                         <br />
413                         <input type="checkbox" name="pollq_expiry_no" id="pollq_expiry_no" value="1" onclick="check_pollexpiry();" <?php if(empty($poll_expiry)) { echo 'checked="checked"'; } ?> />
414                         <label for="pollq_expiry_no"><?php _e('Do NOT Expire This Poll', 'wp-polls'); ?></label><br />
415                         <div id="pollq_expiry_timestamp" style="display: <?php if(empty($poll_expiry)) { echo 'none'; } else { echo 'block'; } ?>;">
416                         <?php
417                             if(empty($poll_expiry)) {
418                                 poll_timestamp(current_time('timestamp'), 'pollq_expiry');
419                             } else {
420                                 poll_timestamp($poll_expiry, 'pollq_expiry');
421                             }
422                         ?>
423                         </div>
424                     </td>
425                 </tr>
426             </table>
427             <p style="text-align: center;">
428                 <input type="submit" name="do" value="<?php _e('Edit Poll', 'wp-polls'); ?>" class="button" />&nbsp;&nbsp;
429             <?php
430                 if($poll_active == 1) {
431                     $poll_open_display = 'none';
432                     $poll_close_display = 'inline';
433                 } else {
434                     $poll_open_display = 'inline';
435                     $poll_close_display = 'none';
436                 }
437             ?>
438                 <input type="button" class="button" name="do" id="close_poll" value="<?php _e('Close Poll', 'wp-polls'); ?>" onclick="closing_poll(<?php echo $poll_id; ?>, '<?php printf(js_escape(__('You are about to CLOSE this poll \'%s\'.', 'wp-polls')), htmlspecialchars(js_escape($poll_question_text))); ?>');" style="display: <?php echo $poll_close_display; ?>;" />
439                 <input type="button" class="button" name="do" id="open_poll" value="<?php _e('Open Poll', 'wp-polls'); ?>" onclick="opening_poll(<?php echo $poll_id; ?>, '<?php printf(js_escape(__('You are about to OPEN this poll \'%s\'.', 'wp-polls')), htmlspecialchars(js_escape($poll_question_text))); ?>');" style="display: <?php echo $poll_open_display; ?>;" />
440                 &nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" />
441             </p>
442         </div>
443         </form>
444 <?php
445         break;
446     // Main Page
447     default:
448