Changeset 7835

Show
Ignore:
Timestamp:
02/06/07 11:30:54 (1 year ago)
Author:
GamerZ
Message:

WP-Polls 2.15 First Commit (Unstable)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wp-polls/trunk/polls/polls-css.css

    r7675 r7835  
    22+----------------------------------------------------------------+ 
    33|                                                                                                                                         | 
    4 |     WordPress 2.0 Plugin: WP-Polls 2.14                                                           | 
     4|     WordPress 2.0 Plugin: WP-Polls 2.15                                                           | 
    55|     Copyright (c) 2006 Lester "GaMerZ" Chan                                                   | 
    66|                                                                                                                                         | 
     
    2020      text-align: left; 
    2121      background-image: none; 
     22      display: block; 
    2223} 
    2324.wp-polls ul, .wp-polls-ul, .wp-polls-ans ul  { 
  • wp-polls/trunk/polls/polls-js.php

    r7504 r7835  
    33+----------------------------------------------------------------+ 
    44|                                                                                                                                         | 
    5 |     WordPress 2.1 Plugin: WP-Polls 2.14                                                           | 
     5|     WordPress 2.1 Plugin: WP-Polls 2.15                                                           | 
    66|     Copyright (c) 2007 Lester "GaMerZ" Chan                                                   | 
    77|                                                                                                                                         | 
     
    1212|     File Information:                                                                                                 | 
    1313|     - Polls Javascript File                                                                                     | 
    14 |     - wp-content/plugins/polls/polls-js.js                                                        | 
     14|     - wp-content/plugins/polls/polls-js.php                                                       | 
    1515|                                                                                                                                         | 
    1616+----------------------------------------------------------------+ 
     
    2727      $polls_ajax_url  = substr($polls_ajax_url, 0, -1); 
    2828} 
     29 
     30### Get Poll AJAX Style 
     31$poll_ajax_style = get_option('poll_ajax_style'); 
    2932?> 
    3033 
     
    3841var poll_fadein_opacity = 0; 
    3942var poll_fadeout_opacity = 100; 
     43var poll_show_loading = <?php echo intval($poll_ajax_style['loading']); ?>; 
     44var poll_show_fading = <?php echo intval($poll_ajax_style['fading']); ?>; 
    4045var is_ie = (document.all && document.getElementById); 
    4146var is_moz = (!document.all && document.getElementById); 
     
    111116                  poll_unloading_text(); 
    112117            } else if(is_ie) { 
    113                   document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadein_opacity; 
     118                  if(poll_show_fading) { 
     119                        document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadein_opacity; 
     120                  } else { 
     121                        poll_fadein_opacity = 100; 
     122                        poll_unloading_text(); 
     123                  } 
    114124            } else       if(is_moz) { 
    115                   document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadein_opacity/100); 
     125                  if(poll_show_fading) { 
     126                        document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadein_opacity/100); 
     127                  } else { 
     128                        poll_fadein_opacity = 100; 
     129                        poll_unloading_text(); 
     130                  } 
    116131            } 
    117132            setTimeout("poll_fadein_text()", 100);  
     
    125140// Poll Loading Text 
    126141function poll_loading_text() { 
    127       document.getElementById('polls-' + poll_id + '-loading').style.display = 'block'; 
     142      if(poll_show_loading) { 
     143            document.getElementById('polls-' + poll_id + '-loading').style.display = 'block'; 
     144      } 
    128145} 
    129146 
     
    131148// Poll Finish Loading Text 
    132149function poll_unloading_text() { 
    133       document.getElementById('polls-' + poll_id + '-loading').style.display = 'none'; 
     150      if(poll_show_loading) { 
     151            document.getElementById('polls-' + poll_id + '-loading').style.display = 'none'; 
     152      } 
    134153} 
    135154 
     
    142161                  poll_fadeout_opacity = 0; 
    143162            } else if(is_ie) { 
    144                   document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     163                  if(poll_show_fading) { 
     164                        document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     165                  } else { 
     166                        poll_fadeout_opacity = 0; 
     167                  } 
    145168            } else if(is_moz) { 
    146                   document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     169                  if(poll_show_fading) { 
     170                        document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     171                  } else { 
     172                        poll_fadeout_opacity = 0; 
     173                  } 
    147174            } 
    148175            setTimeout("poll_process()", 100);  
     
    170197                  poll_fadeout_opacity = 0; 
    171198            } else if(is_ie) { 
    172                   document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     199                  if(poll_show_fading) { 
     200                        document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     201                  } else { 
     202                        poll_fadeout_opacity = 0; 
     203                  } 
    173204            } else if(is_moz) { 
    174                   document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     205                  if(poll_show_fading) { 
     206                        document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     207                  } else { 
     208                        poll_fadeout_opacity = 0; 
     209                  } 
    175210            } 
    176211            setTimeout("poll_process_result()", 100);  
     
    196231                  poll_fadeout_opacity = 0; 
    197232            } else if(is_ie) { 
    198                   document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     233                  if(poll_show_fading) { 
     234                        document.getElementById('polls-' + poll_id + '-ans').filters.alpha.opacity = poll_fadeout_opacity; 
     235                  } else { 
     236                        poll_fadeout_opacity = 0; 
     237                  } 
    199238            } else if(is_moz) { 
    200                   document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     239                  if(poll_show_fading) { 
     240                        document.getElementById('polls-' + poll_id + '-ans').style.MozOpacity = (poll_fadeout_opacity/100); 
     241                  } else { 
     242                        poll_fadeout_opacity = 0; 
     243                  } 
    201244            } 
    202245            setTimeout("poll_process_booth()", 100);  
  • wp-polls/trunk/polls/polls-manager.php

    r7633 r7835  
    33+----------------------------------------------------------------+ 
    44|                                                                                                                                         | 
    5 |     WordPress 2.1 Plugin: WP-Polls 2.14                                                           | 
     5|     WordPress 2.1 Plugin: WP-Polls 2.15                                                           | 
    66|     Copyright (c) 2007 Lester "GaMerZ" Chan                                                   | 
    77|                                                                                                                                         | 
     
    3636      // Decide What To Do 
    3737      switch($_POST['do']) { 
    38             // Add Poll 
    39             case __('Add Poll', 'wp-polls'): 
    40                   // Add Poll Question 
     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 Question 
    4145                  $pollq_question = addslashes(trim($_POST['pollq_question'])); 
     46                  // Poll Active 
     47                  $pollq_active = intval($_POST['pollq_active']); 
     48                  // Poll Start Date 
     49                  $edit_polltimestamp = intval($_POST['edit_polltimestamp']); 
    4250                  $timestamp_sql = ''; 
    43                   $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); 
    44                   $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); 
    45                   $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); 
    46                   $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); 
    47                   $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); 
    48                   $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); 
    49                   $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); 
    50                   if($pollq_timestamp > current_time('timestamp')) { 
    51                         $pollq_active = -1; 
    52                   } else { 
    53                         $pollq_active = 1; 
    54                   } 
     51                  if($edit_polltimestamp == 1) { 
     52                        $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); 
     53                        $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); 
     54                        $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); 
     55                        $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); 
     56                        $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); 
     57                        $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); 
     58                        $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); 
     59                        $timestamp_sql = ", pollq_timestamp = '$pollq_timestamp'"; 
     60                        if($pollq_timestamp > current_time('timestamp')) { 
     61                              $pollq_active = -1; 
     62                        } 
     63                  } 
     64                  // Poll End Date 
    5565                  $pollq_expiry_no = intval($_POST['pollq_expiry_no']); 
    5666                  if($pollq_expiry_no == 1) { 
     
    6777                              $pollq_active = 0; 
    6878                        } 
    69                   } 
    70                   $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollq_question', '$pollq_timestamp', 0, $pollq_active, '$pollq_expiry')"); 
    71                   if(!$add_poll_question) { 
    72                         $text .= '<font color="red">'.sprintf(__('Error In Adding Poll \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; 
    73                   } 
    74                   // Add Poll Answers 
    75                   $polla_answers = $_POST['polla_answers']; 
    76                   $polla_qid = intval($wpdb->insert_id); 
    77                   foreach($polla_answers as $polla_answer) { 
    78                         $polla_answer = addslashes(trim($polla_answer)); 
    79                         $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answer', 0)"); 
    80                         if(!$add_poll_answers) { 
    81                               $text .= '<font color="red">'.sprintf(__('Error In Adding Poll\'s Answer \'%s\'', 'wp-polls'), stripslashes($polla_answer)).'</font>'; 
    82                         } 
    83                   } 
    84                   // Update Lastest Poll ID To Poll Options 
    85                   $latest_pollid = polls_latest_id(); 
    86                   $update_latestpoll = update_option('poll_latestpoll', $latest_pollid); 
    87                   if(empty($text)) { 
    88                         $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Added Successfully', 'wp-polls').'</font>'; 
    89                   } 
    90                   break; 
    91             // Edit Poll 
    92             case __('Edit Poll', 'wp-polls'): 
    93                   // Update Poll's Question 
    94                   $pollq_id  = intval($_POST['pollq_id']); 
    95                   $pollq_totalvotes = intval($_POST['pollq_totalvotes']); 
    96                   $pollq_question = addslashes(trim($_POST['pollq_question'])); 
    97                   $edit_polltimestamp = intval($_POST['edit_polltimestamp']); 
    98                   $timestamp_sql = ''; 
    99                   $pollq_active = 1; 
    100                   if($edit_polltimestamp == 1) { 
    101                         $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); 
    102                         $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); 
    103                         $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); 
    104                         $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); 
    105                         $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); 
    106                         $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); 
    107                         $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); 
    108                         $timestamp_sql = ", pollq_timestamp = '$pollq_timestamp'"; 
    109                         if($pollq_timestamp > current_time('timestamp')) { 
    110                               $pollq_active = -1; 
    111                         } 
    112                   } 
    113                   $pollq_expiry_no = intval($_POST['pollq_expiry_no']); 
    114                   if($pollq_expiry_no == 1) { 
    115                         $pollq_expiry = ''; 
    116                   } else { 
    117                         $pollq_expiry_day = intval($_POST['pollq_expiry_day']); 
    118                         $pollq_expiry_month = intval($_POST['pollq_expiry_month']); 
    119                         $pollq_expiry_year = intval($_POST['pollq_expiry_year']); 
    120                         $pollq_expiry_hour = intval($_POST['pollq_expiry_hour']); 
    121                         $pollq_expiry_minute = intval($_POST['pollq_expiry_minute']); 
    122                         $pollq_expiry_second = intval($_POST['pollq_expiry_second']); 
    123                         $pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year); 
    124                         if($pollq_expiry <= current_time('timestamp')) { 
    125                               $pollq_active = 0; 
    126                         } 
    12779                        if($edit_polltimestamp == 1) { 
    12880                              if($pollq_expiry < $pollq_timestamp) { 
     
    13183                        } 
    13284                  } 
     85                  // Update Poll's Question 
    13386                  $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 $timestamp_sql WHERE pollq_id = $pollq_id"); 
    13487                  if(!$edit_poll_question) { 
    135                         $text = '<font color="blue">'.__('No Changes Had Been Made To Poll\'s Title', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; 
     88                        $text = '<p style="color: blue">'.sprintf(__('No Changes Had Been Made To Poll\'s Question \'%s\'.', 'wp-polls'), stripslashes($pollq_question)).'</p>'; 
    13689                  } 
    13790                  // Update Polls' Answers 
     
    147100                              $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"); 
    148101                              if(!$edit_poll_answer) { 
    149                                     $text .= '<br /><font color="blue">'.__('No Changes Had Been Made To Poll\'s Answer', 'wp-polls').' \''.stripslashes($polla_answers).'\'</font>'; 
     102                                    $text .= '<p style="color: blue">'.sprintf(__('No Changes Had Been Made To Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answers)).'</p>'; 
    150103                              } 
    151104                        } 
    152105                  } else { 
    153                         $text .= '<br /><font color="red">'.__('Invalid Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; 
     106                        $text .= '<p style="color: red">'.sprintf(__('Invalid Poll \'%s\'.', 'wp-polls'), stripslashes($pollq_question)).'</p>'; 
     107                  } 
     108                  // Add Poll Answers (If Needed) 
     109                  $polla_answers_new = $_POST['polla_answers_new']; 
     110                  if(!empty($polla_answers_new)) { 
     111                        foreach($polla_answers_new as $polla_answer_new) { 
     112                              $polla_answer_new = addslashes(trim($polla_answer_new)); 
     113                              if(!empty($polla_answer_new)) { 
     114                                    $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $pollq_id, '$polla_answer_new', 0)"); 
     115                                    if(!$add_poll_answers) { 
     116                                          $text .= '<p style="color: red;">'.sprintf(__('Error In Adding Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answer_new)).'</p>'; 
     117                                    } else { 
     118                                          $text .= '<p style="color: green;">'.sprintf(__('Poll\'s Answer \'%s\' Added Successfully.', 'wp-polls'), stripslashes($polla_answer_new)).'</p>'; 
     119                                    } 
     120                              } 
     121                        } 
    154122                  } 
    155123                  if(empty($text)) { 
    156                         $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Edited Successfully', 'wp-polls').'</font>'; 
     124                        $text = '<p style="color: green">'.sprintf(__('Poll \'%s\' Edited Successfully.', 'wp-polls'), stripslashes($pollq_question)).'</p>'; 
    157125                  } 
    158126                  // Update Lastest Poll ID To Poll Options 
     
    160128                  $update_latestpoll = update_option('poll_latestpoll', $latest_pollid); 
    161129                  break; 
    162             // Open Poll 
    163             case __('Open Poll', 'wp-polls'): 
    164                   $pollq_id  = intval($_POST['pollq_id']); 
    165                   $pollq_question = addslashes(trim($_POST['pollq_question'])); 
    166                   $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 1 WHERE pollq_id = $pollq_id;"); 
    167                   if($close_poll) { 
    168                         $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Is Now Opened', 'wp-polls').'</font>'; 
    169                   } else { 
    170                         $text = '<font color="red">'.__('Error Opening Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; 
    171                   } 
    172                   break; 
    173             // Close Poll 
    174             case __('Close Poll', 'wp-polls'): 
    175                   $pollq_id  = intval($_POST['pollq_id']); 
    176                   $pollq_question = addslashes(trim($_POST['pollq_question'])); 
    177                   $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 0 WHERE pollq_id = $pollq_id;"); 
    178                   if($close_poll) { 
    179                         $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Is Now Closed', 'wp-polls').'</font>'; 
    180                   } else { 
    181                         $text = '<font color="red">'.__('Error Closing Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; 
    182                   } 
    183                   break; 
    184             // Delete Poll 
    185             case __('Delete Poll', 'wp-polls'): 
    186                   $pollq_id  = intval($_POST['pollq_id']); 
    187                   $pollq_question = trim($_POST['pollq_question']); 
    188                   $delete_poll_question = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE pollq_id = $pollq_id"); 
    189                   $delete_poll_answers =  $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_qid = $pollq_id"); 
    190                   $delete_poll_ip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id"); 
    191                   $poll_option_lastestpoll = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'"); 
    192                   if(!$delete_poll_question) { 
    193                         $text = '<font color="red">'.sprintf(__('Error In Deleting Poll \'%s\' Question', 'wp-polls'), stripslashes($pollq_question)).'</font>'; 
    194                   }  
    195                   if(!$delete_poll_answers) { 
    196                         $text .= '<br /><font color="blue">'.sprintf(__('No Poll Answers For \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; 
    197                   } 
    198                   if(!$delete_poll_ip) { 
    199                         $text .= '<br /><font color="blue">'.sprintf(__('No Voted IPs For \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; 
    200                   } 
    201                   if(empty($text)) { 
    202                         $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Deleted Successfully', 'wp-polls').'</font>'; 
    203                   } 
    204                   // Update Lastest Poll ID To Poll Options 
    205                   $latest_pollid = polls_latest_id(); 
    206                   $update_latestpoll = update_option('poll_latestpoll', $latest_pollid); 
    207                   break; 
    208             // Add Poll's Answer 
    209             case __('Add Answer', 'wp-polls'): 
    210                   $polla_qid  = intval($_POST['polla_qid']); 
    211                   $polla_answers = addslashes(trim($_POST['polla_answers'])); 
    212                   $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answers', 0)"); 
    213                   if(!$add_poll_question) { 
    214                         $text = '<font color="red">'.sprintf(__('Error In Adding Poll Answer \'%s\'', 'wp-polls'), stripslashes($polla_answers)).'</font>'; 
    215                   } else { 
    216                         $text = '<font color="green">'.__('Poll Answer', 'wp-polls').' \''.stripslashes($polla_answers).'\' '.__('Added Successfully', 'wp-polls').'</font>'; 
    217                   } 
    218                   break; 
    219             // Delete Polls Logs 
    220             case __('Delete All Logs', 'wp-polls'): 
    221                   if(trim($_POST['delete_logs_yes']) == 'yes') { 
    222                         $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip"); 
    223                         if($delete_logs) { 
    224                               $text = '<font color="green">'.__('All Polls Logs Have Been Deleted.', 'wp-polls').'</font>'; 
    225                         } else { 
    226                               $text = '<font color="red">'.__('An Error Has Occured While Deleting All Polls Logs.', 'wp-polls').'</font>'; 
    227                         } 
    228                   } 
    229                   break; 
    230             // Delete Poll Logs For Individual Poll 
    231             case __('Delete Logs For This Poll Only', 'wp-polls'): 
    232                   $pollq_id  = intval($_POST['pollq_id']); 
    233                   if(trim($_POST['delete_logs_yes']) == 'yes') { 
    234                         $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id"); 
    235                         if($delete_logs) { 
    236                               $text = '<font color="green">'.__('All Logs For This Poll Have Been Deleted.', 'wp-polls').'</font>'; 
    237                         } else { 
    238                               $text = '<font color="red">'.__('An Error Has Occured While Deleting All Logs For This Poll.', 'wp-polls').'</font>'; 
    239                         } 
    240                   } 
    241                   break; 
    242             //  Uninstall WP-Polls (By: Philippe Corbes) 
    243             case __('UNINSTALL Polls', 'wp-polls') : 
    244                   if(trim($_POST['uninstall_poll_yes']) == 'yes') { 
    245                         echo '<div id="message" class="updated fade"><p>'; 
    246                         $polls_tables = array($wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip); 
    247                         foreach($polls_tables as $table) { 
    248                               $wpdb->query("DROP TABLE {$table}"); 
    249                               echo '<font color="green">'; 
    250                               printf(__('Table "%s" Has Been Dropped.', 'wp-polls'), "<strong><em>{$table}</em></strong>"); 
    251                               echo '</font><br />'; 
    252                         } 
    253                         $polls_settings = array('poll_template_voteheader', 'poll_template_votebody', 'poll_template_votefooter', 'poll_template_resultheader', 
    254                         'poll_template_resultbody', 'poll_template_resultbody2', 'poll_template_resultfooter', 'poll_template_resultfooter2',  
    255                         'poll_template_disable', 'poll_template_error', 'poll_currentpoll', 'poll_latestpoll',  
    256                         'poll_archive_perpage', 'poll_ans_sortby', 'poll_ans_sortorder', 'poll_ans_result_sortby',  
    257                         'poll_ans_result_sortorder', 'poll_logging_method', 'poll_allowtovote', 'poll_archive_show', 
    258                         'poll_archive_url', 'poll_bar', 'poll_close'); 
    259                         foreach($polls_settings as $setting) { 
    260                               $delete_setting = delete_option($setting); 
    261                               if($delete_setting) { 
    262                                     echo '<font color="green">'; 
    263                                     printf(__('Setting Key \'%s\' Has been Errased.', 'wp-polls'), "<strong><em>{$setting}</em></strong>"); 
    264                               } else { 
    265                                     echo '<font color="red">'; 
    266                                     printf(__('Error Deleting Setting Key \'%s\'.', 'wp-polls'), "<strong><em>{$setting}</em></strong>"); 
    267                               } 
    268                               echo '</font><br />'; 
    269                         } 
    270                         echo '</p></div>';  
    271                         $mode = 'end-UNINSTALL'; 
    272                   } 
    273                   break; 
    274130      } 
    275131} 
     
    278134### Determines Which Mode It Is 
    279135switch($mode) { 
    280       // Add A Poll 
    281       case 'add': 
    282 ?> 
    283             <script type="text/javascript"> 
    284                   /* <![CDATA[*/ 
    285                   function check_pollexpiry() { 
    286                         poll_expiry = document.getElementById("pollq_expiry_no").checked; 
    287                         if(poll_expiry) { 
    288                               document.getElementById("pollq_expiry").style.display = 'none'; 
    289                         } else { 
    290                               document.getElementById("pollq_expiry").style.display = 'block'; 
    291                         } 
    292                   } 
    293                   /* ]]> */ 
    294             </script> 
    295             <div class="wrap"> 
    296                         <h2><?php _e('Add Poll', 'wp-polls'); ?></h2> 
    297                         <?php 
    298                         if(isset($_POST['addpollquestion'])) { 
    299                               $poll_noquestion = intval($_POST['poll_noquestion']); 
    300                               $pollq_question = stripslashes(trim($_POST['pollq_question']));    
    301                         ?> 
    302                         <form action="<?php echo $base_page; ?>" method="post"> 
    303                               <table width="100%"  border="0" cellspacing="3" cellpadding="3"> 
    304                                     <tr class="thead"> 
    305                                           <th align="left"><?php _e('Question', 'wp-polls') ?></th> 
    306                                           <td><input type="text" size="50" maxlength="200" name="pollq_question" value="<?php echo htmlspecialchars($pollq_question); ?>" /></td> 
    307                                     </tr> 
    308                                     <?php 
    309                                           $count = 0; 
    310                                           for($i=1; $i<=$poll_noquestion; $i++) { 
    311                                                 if($i%2 == 0) { 
    312                                                       $style = 'style=\'background-color: #eee;\'';                                                                                                    
    313                                                 }  else { 
    314                                                       $style = 'style=\'background: none;\'';    
    315                                                 } 
    316                                                 echo "<tr $style>\n"; 
    317                                                 echo "<th align=\"left\" scope=\"row\">Answers $i:</th>\n"; 
    318                                                 echo "<td><input type=\"text\" size=\"30\" maxlength=\"200\" name=\"polla_answers[]\" /></td>\n"; 
    319                                                 echo "</tr>\n"; 
    320                                                 $count++; 
    321                                           } 
    322                                     ?> 
    323                                     <tr style="<?php if($count%2 == 0) { echo 'background: none;'; }  else { echo 'background-color: #eee;' ;} $count++; ?>"> 
    324                                           <th align="left"><?php _e('Start Date/Time:', 'wp-polls') ?></th> 
    325                                           <td> 
    326                                                 <?php 
    327                                                       poll_timestamp(current_time('timestamp')); 
    328                                                 ?> 
    329                                           </td> 
    330                                     </tr> 
    331                                     <tr style="<?php if($count%2 == 0) { echo 'background: none;'; }  else { echo 'background-color: #eee;' ;} ?>"> 
    332                                           <th valign="top" align="left"><?php _e('End Date/Time:', 'wp-polls') ?></th> 
    333                                           <td> 
    334                                                 <input type="checkbox" name="pollq_expiry_no" id="pollq_expiry_no" value="1" checked="checked" onclick="check_pollexpiry();" />&nbsp;&nbsp;<label for="pollq_expiry_no"><?php _e('Do NOT Expire This Poll', 'wp-polls'); ?></label> 
    335                                                 <?php 
    336                                                       poll_timestamp(current_time('timestamp'), 'pollq_expiry', 'none'); 
    337                                                 ?> 
    338                                           </td> 
    339                                     </tr> 
    340                                     <tr> 
    341                                           <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Poll', 'wp-polls'); ?>"  class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></td> 
    342                                     </tr> 
    343                               </table> 
    344                         </form> 
    345                         <?php } else {?> 
    346                         <form action="<?php echo $_SERVER['REQUEST_URI']; ?>&amp;mode=add" method="post"> 
    347                               <table width="100%"  border="0" cellspacing="3" cellpadding="3"> 
    348                                     <tr> 
    349                                           <th align="left"><?php _e('Question', 'wp-polls') ?></th> 
    350                                           <td><input type="text" size="50" maxlength="200" name="pollq_question" /></td> 
    351                                     </tr> 
    352                                     <tr> 
    353                                           <th align="left"><?php _e('No. Of Answers:', 'wp-polls') ?></th> 
    354                                           <td> 
    355                                                       <select size="1" name="poll_noquestion"> 
    356                                                                   <?php 
    357                                                                   for($i=2; $i <= 20; $i++) { 
    358                                                                         echo "<option value=\"$i\">$i</option>"; 
    359                                                                   } 
    360                                                                   ?> 
    361                                                       </select> 
    362                                           </td> 
    363                                     </tr> 
    364                                     <tr> 
    365                                           <td colspan="2" align="center"><input type="submit" name="addpollquestion" value="<?php _e('Add Question', 'wp-polls'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></td> 
    366                                     </tr> 
    367                               </table> 
    368                         </form> 
    369                         <?php } ?> 
    370             </div> 
    371 <?php 
    372             break; 
    373136      // Edit A Poll 
    374137      case 'edit': 
    375138            $poll_question = $wpdb->get_row("SELECT pollq_question, pollq_timestamp, pollq_totalvotes, pollq_active, pollq_expiry FROM $wpdb->pollsq WHERE pollq_id = $poll_id"); 
    376139            $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"); 
     140            $poll_noquestion = $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa WHERE polla_qid = $poll_id"); 
    377141            $poll_question_text = stripslashes($poll_question->pollq_question); 
    378142            $poll_totalvotes = intval($poll_question->pollq_totalvote); 
     
    407171                        } 
    408172                  } 
     173                  function check_pollexpiry() { 
     174                        pollq_expiry_no = document.getElementById("pollq_expiry_no").checked; 
     175                        if(pollq_expiry_no) { 
     176                              document.getElementById("pollq_expiry_timestamp").style.display = 'none'; 
     177                        } else { 
     178                              document.getElementById("pollq_expiry_timestamp").style.display = 'block'; 
     179                        } 
     180                  } 
     181                  var count_poll_answer = <?php echo $poll_noquestion; ?>; 
     182                  var count_poll_answer_new = 0; 
     183                  function create_poll_answer() { 
     184                        // Create Elements 
     185                        var poll_tr = document.createElement("tr"); 
     186                        var poll_td1 = document.createElement("td"); 
     187                        var poll_td2 = document.createElement("td"); 
     188                        var poll_td3 = document.createElement("td"); 
     189                        var poll_answer = document.createElement("input"); 
     190                        var poll_votes = document.createElement("input"); 
     191                        var poll_answer_count = document.createTextNode("<?php _e('Answer', 'wp-polls'); ?> " + (count_poll_answer+1) + ":"); 
     192                        var poll_votes_count = document.createTextNode("0 "); 
     193                        var poll_answer_bold = document.createElement("strong"); 
     194                        count_poll_answer++; 
     195                        count_poll_answer_new++; 
     196                        // Elements - Input 
     197                        poll_answer.setAttribute('type', "text"); 
     198                        poll_answer.setAttribute('name', "polla_answers_new[]"); 
     199                        poll_answer.setAttribute('size', "50"); 
     200                        poll_votes.setAttribute('type', "text"); 
     201                        poll_votes.setAttribute('size', "4"); 
     202                        poll_votes.setAttribute('value', "0"); 
     203                        // Elements - TD/TR 
     204                        if(count_poll_answer%2 != 0) { poll_tr.style.background = "#eee"; } 
     205                        poll_tr.setAttribute('id', "poll-answer-new-" + count_poll_answer_new); 
     206                        poll_td1.setAttribute('width', "20%"); 
     207                        poll_td2.setAttribute('width', "60%"); 
     208                        poll_td3.setAttribute('width', "10%"); 
     209                        poll_td3.setAttribute('align', "right"); 
     210                        //<input type=\"text\" size=\"4\" id=\"polla_votes-$polla_aid\" name=\"polla_votes-$polla_aid\" value=\"$polla_votes\" onblur=\"check_totalvotes();\" 
     211                        // Appending To Elements 
     212                        poll_tr.appendChild(poll_td1); 
     213                        poll_tr.appendChild(poll_td2); 
     214                        poll_tr.appendChild(poll_td3); 
     215                        poll_answer_bold.appendChild(poll_answer_count); 
     216                        poll_td1.appendChild(poll_answer_bold); 
     217                        poll_td2.appendChild(poll_answer);                     
     218                        poll_td3.appendChild(poll_votes_count); 
     219                        poll_td3.appendChild(poll_votes); 
     220                        document.getElementById("poll_answers").appendChild(poll_tr); 
     221                  } 
     222                  function remove_poll_answer() { 
     223                        if(count_poll_answer_new == 0) { 
     224                              alert("<?php _e('No more poll\'s answer to be removed.', 'wp-polls'); ?>"); 
     225                        } else { 
     226                              document.getElementById("poll_answers").removeChild(document.getElementById("poll-answer-new-" + count_poll_answer_new)); 
     227                              count_poll_answer--; 
     228                              count_poll_answer_new--; 
     229                        } 
     230                  } 
    409231                  /* ]]> */ 
    410232            </script> 
    411233            <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.stripslashes($text).'</p></div>'; } ?> 
    412234            <!-- Edit Poll --> 
     235            <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post"> 
     236            <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" /> 
     237            <input type="hidden" name="pollq_active" value="<?php echo $poll_active; ?>" /> 
    413238            <div class="wrap"> 
    414239                  <h2><?php _e('Edit Poll', 'wp-polls'); ?></h2> 
    415                   <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post"> 
    416                         <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" /> 
    417                         <table width="100%"  border="0" cellspacing="3" cellpadding="3"> 
    418                               <tr> 
    419                                     <th colspan="2"><?php _e('Question', 'wp-polls') ?></th> 
    420                               </tr> 
    421                               <tr> 
    422                                     <td align="center" colspan="2"><input type="text" size="70" maxlength="200" name="pollq_question" value="<?php echo htmlspecialchars($poll_question_text); ?>" /></td> 
    423                               </tr> 
    424                               <tr> 
    425                                     <th align="left"><?php _e('Answers:', 'wp-polls') ?></th> 
    426                                     <th align="right"><?php _e('No. Of Votes', 'wp-polls') ?></th> 
     240                  <!-- Poll Question --> 
     241                  <h3><?php _e('Poll Question', 'wp-polls'); ?></h3> 
     242                  <table width="100%"  border="0" cellspacing="3" cellpadding="3"> 
     243                        <tr style="background-color: #eee;"> 
     244                              <td width="20%"><strong><?php _e('Question', 'wp-polls') ?></strong>&