Changeset 7836

Show
Ignore:
Timestamp:
02/06/07 15:52:12 (18 months ago)
Author:
GamerZ
Message:

WP-Polls 2.15 Second Commit (Stable)

Location:
wp-polls/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • wp-polls/trunk/polls/polls-admin-ajax.php

    r7835 r7836  
    5656                  } 
    5757                  break; 
    58             // Add Poll's Answer 
    59             case __('Add Answer', 'wp-polls'): 
    60                   $polla_qid  = intval($_POST['polla_qid']); 
    61                   $polla_answers = addslashes(trim($_POST['polla_answers'])); 
    62                   $pollq_question = $wpdb->get_var("SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = $pollq_id"); 
    63                   $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answers', 0)"); 
    64                   if(!$add_poll_question) { 
    65                         echo '<p style="color: red;">'.sprintf(__('Error In Adding Poll Answer \'%s\' To \'%s\'', 'wp-polls'), stripslashes($polla_answers), stripslashes($pollq_question)).'</p>'; 
     58            // Delete Poll's Answer 
     59            case __('Delete Poll Answer', 'wp-polls'): 
     60                  $pollq_id  = intval($_POST['pollq_id']); 
     61                  $polla_aid = intval($_POST['polla_aid']); 
     62                  $poll_answers = $wpdb->get_row("SELECT polla_votes, polla_answers FROM $wpdb->pollsa WHERE polla_aid = $polla_aid AND polla_qid = $pollq_id"); 
     63                  $polla_votes = intval($poll_answers->polla_votes); 
     64                  $polla_answers = stripslashes(trim($poll_answers->polla_answers)); 
     65                  $delete_polla_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_aid = $polla_aid AND polla_qid = $pollq_id"); 
     66                  $delete_pollip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id AND pollip_aid = $polla_aid"); 
     67                  $update_pollq_totalvotes = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes-$polla_votes) WHERE pollq_id = $pollq_id"); 
     68                  if($delete_polla_answers) { 
     69                        echo '<p style="color: green;">'.sprintf(__('Poll Answer \'%s\' Deleted Successfully.', 'wp-polls'), $polla_answers).'</p>'; 
    6670                  } else { 
    67                         echo '<p style="color: green;">'.sprintf(__('Poll Answer \'%s\' Added Successfully To \'%s\'', 'wp-polls'), stripslashes($polla_answers), stripslashes($pollq_question)).'</p>'; 
     71                        echo '<p style="color: red;">'.sprintf(__('Error In Deleting Poll Answer \'%s\'.', 'wp-polls'), $polla_answers).'</p>'; 
    6872                  } 
    6973                  break; 
  • wp-polls/trunk/polls/polls-admin-js.php

    r7835 r7836  
    3232var polls_admin = new sack(polls_admin_ajax_url); 
    3333var global_poll_id = 0; 
    34  
     34var global_poll_aid = 0; 
    3535 
    3636// Function: Delete Poll Message 
     
    6262} 
    6363 
    64  
    6564// Function: Delete Poll Logs Message 
    6665function delete_poll_logs_message() { 
    6766      document.getElementById('message').style.display = "block"; 
    6867      Fat.fade_element("message", null, 3000, "#FFFF00"); 
    69       alert("<?php _e('Polls logs processed. Please see the top of this page for the outcome.', 'wp-polls'); ?>"); 
     68      document.getElementById("poll_logs").innerHTML = "<?php _e('No poll logs available.', 'wp-polls'); ?>"; 
    7069} 
    7170 
     
    8786      } 
    8887} 
     88 
     89// Function: Delete Individual Poll Logs Message 
     90function delete_this_poll_logs_message() { 
     91      document.getElementById('message').style.display = "block"; 
     92      Fat.fade_element("message", null, 3000, "#FFFF00"); 
     93      document.getElementById("poll_logs").innerHTML = "<?php _e('No poll logs available for this poll.', 'wp-polls'); ?>"; 
     94} 
     95 
     96// Function: Delete Individual Poll Logs 
     97function delete_this_poll_logs(poll_id, poll_confirm) { 
     98      delete_poll_logs_confirm = confirm(poll_confirm); 
     99      if(delete_poll_logs_confirm) { 
     100            if(document.getElementById("delete_logs_yes").checked == true) { 
     101                  global_poll_id = poll_id; 
     102                  polls_admin.reset(); 
     103                  polls_admin.setVar("do", "<?php _e('Delete Logs For This Poll Only', 'wp-polls'); ?>"); 
     104                  polls_admin.setVar("delete_logs_yes", "yes"); 
     105                  polls_admin.setVar("pollq_id", poll_id); 
     106                  polls_admin.method = 'POST'; 
     107                  polls_admin.element = 'message'; 
     108                  polls_admin.onCompletion = delete_this_poll_logs_message; 
     109                  polls_admin.runAJAX(); 
     110            } else { 
     111                  alert("<?php _e('Please check the \'Yes\' checkbox if you want to delete all logs for this poll ONLY.', 'wp-polls'); ?>"); 
     112            } 
     113      } 
     114} 
     115 
     116// Function: Delete Poll Answer Message 
     117function delete_poll_ans_message() { 
     118      document.getElementById('message').style.display = "block"; 
     119      Fat.fade_element("message", null, 3000, "#FFFF00"); 
     120      Fat.fade_element("poll-answer-" + global_poll_aid, null, 1000, "#FF3333"); 
     121      setTimeout("remove_poll_ans()", 1000); 
     122      poll_total_votes = parseInt(document.getElementById('pollq_totalvotes').value); 
     123      poll_answer_vote = parseInt(document.getElementById("polla_votes-" + global_poll_aid).value); 
     124      poll_total_votes_new = (poll_total_votes - poll_answer_vote); 
     125      if(poll_total_votes_new < 0) { 
     126            poll_total_votes_new = 0; 
     127      } 
     128      document.getElementById('pollq_totalvotes').value = parseInt(poll_total_votes_new); 
     129} 
     130 
     131// Function: Remove Poll From Manage Poll 
     132function remove_poll_ans() { 
     133      document.getElementById("poll_answers").removeChild(document.getElementById("poll-answer-" + global_poll_aid)); 
     134} 
     135 
     136// Function: Delete Poll Answer 
     137function delete_poll_ans(poll_id, poll_aid, poll_confirm) { 
     138      delete_poll_ans_confirm = confirm(poll_confirm); 
     139      if(delete_poll_ans_confirm) { 
     140            global_poll_id = poll_id; 
     141            global_poll_aid = poll_aid; 
     142            polls_admin.reset(); 
     143            polls_admin.setVar("do", "<?php _e('Delete Poll Answer', 'wp-polls'); ?>"); 
     144            polls_admin.setVar("pollq_id", poll_id); 
     145            polls_admin.setVar("polla_aid", poll_aid); 
     146            polls_admin.method = 'POST'; 
     147            polls_admin.element = 'message'; 
     148            polls_admin.onCompletion = delete_poll_ans_message; 
     149            polls_admin.runAJAX(); 
     150      } 
     151} 
     152 
     153// Function: Open Poll Message 
     154function opening_poll_message() { 
     155      document.getElementById('message').style.display = "block"; 
     156      Fat.fade_element("message", null, 3000, "#FFFF00"); 
     157      document.getElementById("open_poll").style.display = "none"; 
     158      document.getElementById("close_poll").style.display = "inline"; 
     159} 
     160 
     161// Function: Open Poll 
     162function opening_poll(poll_id, poll_confirm) { 
     163      open_poll_confirm = confirm(poll_confirm); 
     164      if(open_poll_confirm) { 
     165            global_poll_id = poll_id; 
     166            polls_admin.reset(); 
     167            polls_admin.setVar("do", "<?php _e('Open Poll', 'wp-polls'); ?>"); 
     168            polls_admin.setVar("pollq_id", poll_id); 
     169            polls_admin.method = 'POST'; 
     170            polls_admin.element = 'message'; 
     171            polls_admin.onCompletion = opening_poll_message; 
     172            polls_admin.runAJAX(); 
     173      } 
     174} 
     175 
     176// Function: Close Poll Message 
     177function closing_poll_message() { 
     178      document.getElementById('message').style.display = "block"; 
     179      Fat.fade_element("message", null, 3000, "#FFFF00"); 
     180      document.getElementById("open_poll").style.display = "inline"; 
     181      document.getElementById("close_poll").style.display = "none"; 
     182} 
     183 
     184// Function: Close Poll 
     185function closing_poll(poll_id, poll_confirm) { 
     186      close_poll_confirm = confirm(poll_confirm); 
     187      if(close_poll_confirm) { 
     188            global_poll_id = poll_id; 
     189            polls_admin.reset(); 
     190            polls_admin.setVar("do", "<?php _e('Close Poll', 'wp-polls'); ?>"); 
     191            polls_admin.setVar("pollq_id", poll_id); 
     192            polls_admin.method = 'POST'; 
     193            polls_admin.element = 'message'; 
     194            polls_admin.onCompletion = closing_poll_message; 
     195            polls_admin.runAJAX(); 
     196      } 
     197} 
  • wp-polls/trunk/polls/polls-js.php

    r7835 r7836  
    4848var is_being_voted = false; 
    4949 
    50  
    51 // When User Vote For Poll 
     50// Function: When User Vote For Poll 
    5251function poll_vote(current_poll_id) { 
    5352      if(!is_being_voted) { 
     
    7877} 
    7978 
    80  
    81 // When User View Poll's Result 
     79// Function: When User View Poll's Result 
    8280function poll_result(current_poll_id) { 
    8381      if(!is_being_voted) { 
     
    9189} 
    9290 
    93  
    94 // When User View Poll's Voting Booth 
     91// Function: When User View Poll's Voting Booth 
    9592function poll_booth(current_poll_id) { 
    9693      if(!is_being_voted) { 
     
    104101} 
    105102 
    106  
    107 // Poll Fade In Text 
     103// Function: Poll Fade In Text 
    108104function poll_fadein_text() { 
    109105      if(poll_fadein_opacity == 90) { 
     
    137133} 
    138134 
    139  
    140 // Poll Loading Text 
     135// Function: Poll Loading Text 
    141136function poll_loading_text() { 
    142137      if(poll_show_loading) { 
     
    145140} 
    146141 
    147  
    148 // Poll Finish Loading Text 
     142// Function: Poll Finish Loading Text 
    149143function poll_unloading_text() { 
    150144      if(poll_show_loading) { 
     
    153147} 
    154148 
    155  
    156 // Process The Poll 
     149// Function: Process The Poll 
    157150function poll_process() { 
    158151      if(poll_fadeout_opacity > 0) { 
     
    189182} 
    190183 
    191  
    192 // Process Poll's Result 
     184// Function: Process Poll's Result 
    193185function poll_process_result() { 
    194186      if(poll_fadeout_opacity > 0) { 
     
    223215} 
    224216 
    225  
    226 // Process Poll's Voting Booth 
     217// Function: Process Poll's Voting Booth 
    227218function poll_process_booth() { 
    228219      if(poll_fadeout_opacity > 0) { 
  • wp-polls/trunk/polls/polls-manager.php

    r7835 r7836  
    101101                              if(!$edit_poll_answer) { 
    102102                                    $text .= '<p style="color: blue">'.sprintf(__('No Changes Had Been Made To Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answers)).'</p>'; 
     103                              } else { 
     104                                    $text .= '<p style="color: green">'.sprintf(__('Poll\'s Answer \'%s\' Edited Successfully.', 'wp-polls'), stripslashes($polla_answers)).'</p>'; 
    103105                              } 
    104106                        } 
     
    109111                  $polla_answers_new = $_POST['polla_answers_new']; 
    110112                  if(!empty($polla_answers_new)) { 
     113                        $i = 0; 
     114                        $polla_answers_new_votes = $_POST['polla_answers_new_votes']; 
    111115                        foreach($polla_answers_new as $polla_answer_new) { 
    112116                              $polla_answer_new = addslashes(trim($polla_answer_new)); 
    113117                              if(!empty($polla_answer_new)) { 
    114                                     $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $pollq_id, '$polla_answer_new', 0)"); 
     118                                    $polla_answer_new_vote = intval($polla_answers_new_votes[$i]); 
     119                                    $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $pollq_id, '$polla_answer_new', $polla_answer_new_vote)"); 
    115120                                    if(!$add_poll_answers) { 
    116121                                          $text .= '<p style="color: red;">'.sprintf(__('Error In Adding Poll\'s Answer \'%s\'.', 'wp-polls'), stripslashes($polla_answer_new)).'</p>'; 
     
    119124                                    } 
    120125                              } 
     126                              $i++; 
    121127                        } 
    122128                  } 
     
    147153            <script type="text/javascript"> 
    148154                  /* <![CDATA[*/ 
     155                  var total_votes = 0; 
     156                  var total_new_votes = 0; 
    149157                  function check_totalvotes() {  
    150                         var total_votes = 0; 
    151158                        var temp_vote = 0; 
     159                        total_votes = 0; 
    152160                        <?php 
    153161                              foreach($poll_answers as $poll_answer) { 
    154162                                    $polla_aid = intval($poll_answer->polla_aid); 
    155                                     echo "\t\t\t\ttemp_vote = parseInt(document.getElementById('polla_votes-$polla_aid').value);\n"; 
    156                                     echo "\t\t\t\tif(isNaN(temp_vote)) {\n"; 
    157                                     echo "\t\t\t\tdocument.getElementById('polla_votes-$polla_aid').value = 0;\n"; 
    158                                     echo "\t\t\t\ttemp_vote = 0;\n"; 
     163                                    echo "\t\t\t\tif(document.getElementById('polla_votes-$polla_aid')) {\n"; 
     164                                    echo "\t\t\t\t\ttemp_vote = parseInt(document.getElementById('polla_votes-$polla_aid').value);\n"; 
     165                                    echo "\t\t\t\t\tif(isNaN(temp_vote)) {\n"; 
     166                                    echo "\t\t\t\t\t\tdocument.getElementById('polla_votes-$polla_aid').value = 0;\n"; 
     167                                    echo "\t\t\t\t\t\ttemp_vote = 0;\n"; 
     168                                    echo "\t\t\t\t\t}\n"; 
     169                                    echo "\t\t\t\t\ttotal_votes += temp_vote;\n"; 
    159170                                    echo "\t\t\t\t}\n"; 
    160                                     echo "\t\t\t\ttotal_votes += temp_vote;\n"; 
    161171                              } 
    162172                        ?> 
    163                         document.getElementById('pollq_totalvotes').value = parseInt(total_votes); 
     173                        totalvotes(); 
     174                  } 
     175                  function check_totalvotes_new() {    
     176                        var new_votes = document.getElementsByName("polla_answers_new_votes[]"); 
     177                        var temp_new_vote = 0; 
     178                        total_new_votes = 0; 
     179                        for(i = 0; i < new_votes.length; i++) { 
     180                              temp_new_vote = parseInt(new_votes[i].value); 
     181                              if(isNaN(temp_new_vote)) { 
     182                                    temp_new_vote = 0; 
     183                              } 
     184                              total_new_votes += temp_new_vote; 
     185                        } 
     186                        totalvotes(); 
     187                  } 
     188                  function totalvotes() { 
     189                        document.getElementById('pollq_totalvotes').value = (parseInt(total_votes) + parseInt(total_new_votes)); 
    164190                  } 
    165191                  function check_polltimestamp() { 
     
    199225                        poll_answer.setAttribute('size', "50"); 
    200226                        poll_votes.setAttribute('type', "text"); 
     227                        poll_votes.setAttribute('name', "polla_answers_new_votes[]") 
    201228                        poll_votes.setAttribute('size', "4"); 
    202229                        poll_votes.setAttribute('value', "0"); 
     230                        poll_votes.setAttribute('onblur', "check_totalvotes_new();"); 
    203231                        // Elements - TD/TR 
    204232                        if(count_poll_answer%2 != 0) { poll_tr.style.background = "#eee"; } 
     
    227255                              count_poll_answer--; 
    228256                              count_poll_answer_new--; 
     257                              check_totalvotes_new(); 
    229258                        } 
    230259                  } 
    231260                  /* ]]> */ 
    232261            </script> 
    233             <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.stripslashes($text).'</p></div>'; } ?> 
     262            <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.stripslashes($text).'</p></div>'; } else { echo '<div id="message" class="updated" style="display: none;"></div>'; } ?> 
     263 
    234264            <!-- Edit Poll --> 
    235265            <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post"> 
     
    249279                  <h3><?php _e('Poll Answers', 'wp-polls'); ?></h3> 
    250280                  <table width="100%"  border="0" cellspacing="3" cellpadding="3"> 
    251                         <tbody id="poll_answers"> 
     281                        <thead> 
    252282                              <tr class="thead"> 
    253283                                    <td width="20%"><strong><?php _e('Answer No.:', 'wp-polls') ?></strong></td> 
    254                                     <td width="60%"><strong><?php _e('Answer text:', 'wp-polls') ?></strong></td> 
     284                                    <td width="60%"><strong><?php _e('Answer Text:', 'wp-polls') ?></strong></td> 
    255285                                    <td width="20%" align="right"><strong><?php _e('No. Of Votes', 'wp-polls') ?></strong></td> 
    256286                              </tr> 
     287                        </thead> 
     288                        <tbody id="poll_answers"> 
    257289                              <?php 
    258290                                    $i=1; 
     
    274306                                                echo '<td width="20%"><strong>'.sprintf(__('Answer %s:', 'wp-polls'), $i).'</strong></td>'."\n"; 
    275307                                                echo "<td width=\"60%\"><input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_aid-$polla_aid\" value=\"".htmlspecialchars($polla_answers)."\" />&nbsp;&nbsp;&nbsp;"; 
    276                                                 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:', 'wp-polls')." \'".addslashes(strip_tags($polla_answers))."\'\\n\\n".__('This Action Is Not Reversible. Are you sure?', 'wp-polls')."')\">".__('Delete')."</a></td>\n"; 
     308                                                echo "<input type=\"button\" value=\"".__('Delete', 'wp-polls')."\" onclick=\"delete_poll_ans($poll_id, $polla_aid, '".sprintf(js_escape(__('You are about to delete this poll\'s answer \'%s\'.', 'wp-polls')), htmlspecialchars($polla_answers))."');\" class=\"button\" /></td>\n"; 
    277309                                                echo "<td width=\"20%\" align=\"right\">$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"; 
    278310                                                $poll_actual_totalvotes += $polla_votes; 
     
    281313                                    } 
    282314                              ?> 
    283                               </tbody> 
    284                         <tr> 
    285                               <td width="20%"></td> 
    286                               <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> 
    287                               <td width="20%" align="right"><strong><?php printf(__('Total Votes: %s', 'wp-polls'), $poll_actual_totalvotes); ?></strong> <input type="text" size="4" readonly="true" id="pollq_totalvotes" name="pollq_totalvotes" value="<?php echo $poll_actual_totalvotes; ?>" onblur="check_totalvotes();" /></td> 
    288                         </tr> 
     315                        </tbody> 
     316                        <tfoot> 
     317                              <tr> 
     318                                    <td width="20%"></td> 
     319                                    <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> 
     320                                    <td width="20%" align="right"><strong><?php printf(__('Total Votes: %s', 'wp-polls'), $poll_actual_totalvotes); ?></strong> <input type="text" size="4" readonly="true" id="pollq_totalvotes" name="pollq_totalvotes" value="<?php echo $poll_actual_totalvotes; ?>" onblur="check_totalvotes();" /></td> 
     321                              </tr> 
     322                        </tfoot> 
    289323                  </table> 
    290324                  <!-- Poll Start/End Date --> 
     
    326360                  <p style="text-align: center;"> 
    327361                        <input type="submit" name="do" value="<?php _e('Edit Poll', 'wp-polls'); ?>" class="button" />&nbsp;&nbsp; 
    328                   <?php if($poll_active == 1) { ?> 
    329                         <input type="submit" class="button" name="do" value="<?php _e('Close Poll', 'wp-polls'); ?>" alt="test" onclick="return confirm('<?php _e('You Are About To Close This Poll', 'wp-polls'); ?>.')" /> 
    330                   <?php } else { ?> 
    331                         <input type="submit" class="button" name="do" value="<?php _e('Open Poll', 'wp-polls'); ?>" onclick="return confirm('<?php _e('You Are About To Open This Poll', 'wp-polls'); ?>.')" /> 
    332                   <?php } ?> 
     362                  <?php  
     363                        if($poll_active == 1) {  
     364                              $poll_open_display = 'none'; 
     365                              $poll_close_display = 'inline'; 
     366                        } else { 
     367                              $poll_open_display = 'inline'; 
     368                              $poll_close_display = 'none'; 
     369                        } 
     370                  ?> 
     371                        <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($poll_question_text)); ?>');" style="display: <?php echo $poll_close_display; ?>;" /> 
     372                        <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($poll_question_text)); ?>');" style="display: <?php echo $poll_open_display; ?>;" /> 
    333373                        &nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /> 
    334374                  </p> 
     
    382422                                          } 
    383423                                    } else { 
    384                                           echo "<tr>\n<td colspan=\"4\" align=\"center\">".__('No IP Has Been Logged Yet.', 'wp-polls')."</td>\n</tr>\n"; 
     424                                          echo "<tr>\n<td colspan=\"4\" align=\"center\">".__('No poll logs available for this poll.', 'wp-polls')."</td>\n</tr>\n"; 
    385425                                    } 
    386426                              ?> 
     
    390430            <div class="wrap"> 
    391431                  <h2><?php _e('Poll Logs', 'wp-polls'); ?></h2> 
    392                   <div align="center"> 
    393                         <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post"> 
    394                               <input type="hidden" name="pollq_id" value="<?php echo $poll_id; ?>" /> 
     432                  <div align="center" id="poll_logs"> 
     433                        <?php if($poll_ips) { ?> 
    395434                              <strong><?php _e('Are You Sure You Want To Delete Logs For This Poll Only?', 'wp-polls'); ?></strong><br /><br /> 
    396                               <input type="checkbox" name="delete_logs_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-polls'); ?><br /><br /> 
    397                               <input type="submit" name="do" value="<?php _e('Delete Logs For This Poll Only', 'wp-polls'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Delete Logs For This Poll Only.', 'wp-polls'); ?>\n\n<?php _e('This Action Is Not Reversible. Are you sure?', 'wp-polls'); ?>')" /> 
    398                         </form> 
     435                              <input type="checkbox" id="delete_logs_yes" name="delete_logs_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-polls'); ?><br /><br /> 
     436                              <input type="button" name="do" value="<?php _e('Delete Logs For This Poll Only', 'wp-polls'); ?>" class="button" onclick="delete_this_poll_logs(<?php echo $poll_id; ?>, '<?php printf(js_escape(__('You are about to delete poll logs for this poll \'%s\' ONLY. This action is not reversible.', 'wp-polls')), htmlspecialchars($poll_question_text)); ?>');" /> 
     437                        <?php  
     438                              } else { 
     439                                    _e('No poll logs available for this poll.', 'wp-polls'); 
     440                              } 
     441                        ?> 
    399442                  </div> 
    400443                  <p><?php _e('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.', 'wp-polls'); ?></p> 
    401             </div> 
    402 <?php 
    403             break; 
    404       // Delete A Poll Answer 
    405       case 'deleteans': 
    406             $poll_answers = $wpdb->get_row("SELECT polla_votes, polla_answers FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id"); 
    407             $polla_votes = intval($poll_answers->polla_votes); 
    408             $polla_answers = stripslashes(trim($poll_answers->polla_answers)); 
    409             $delete_polla_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_aid = $poll_aid AND polla_qid = $poll_id"); 
    410             $delete_pollip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_aid = $poll_aid"); 
    411             $update_pollq_totalvotes = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes-$polla_votes) WHERE pollq_id=$poll_id"); 
    412 ?> 
    413             <!-- Delete Poll's Answer --> 
    414             <div class="wrap"> 
    415                   <h2><?php _e('Delete Poll\'s Answer', 'wp-polls') ?></h2> 
    416                   <?php 
    417                         if($delete_polla_answers) { 
    418                               echo "<font color=\"green\">".__('Poll Answer', 'wp-polls')." '$polla_answers' ".__('Deleted Successfully', 'wp-polls')."</font>"; 
    419                         } else { 
    420                               echo "<font color=\"red\">".__('Error In Deleting Poll Answer', 'wp-polls')." '$polla_answers'</font>"; 
    421                         } 
    422                         if($update_pollq_totalvotes) { 
    423                               echo "<br /><font color=\"green\">".__('Poll Question\'s Total Votes Updated Successfully', 'wp-polls')."</font>"; 
    424                         } else { 
    425                               echo "<br /><font color=\"blue\">".__('No Changes Have Been Made To The Poll\'s Total Votes', 'wp-polls')."</font>"; 
    426                         } 
    427                         if($delete_pollip) { 
    428                               echo "<br /><font color=\"green\">".__('Poll IP Logs Updated Successfully', 'wp-polls')."</font>"; 
    429                         } else { 
    430                               echo "<br /><font color=\"blue\">".__('No Changes Have Been Made To The Poll IP Logs', 'wp-polls')."</font>"; 
    431                         } 
    432                   ?> 
    433                   <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', 'wp-polls'); ?></a>.</strong></p> 
    434444            </div> 
    435445<?php 
     
    515525                                          echo "</td>\n"; 
    516526                                          echo "<td><a href=\"$base_page&amp;mode=edit&amp;id=$poll_id\" class=\"edit\">".__('Edit')."</a></td>\n"; 
    517                                           echo "<td><a href=\"#DeletePoll\" onclick=\"delete_poll($poll_id, '".sprintf(js_escape(__('You are about to delete this poll, %s.', 'wp-polls')), $poll_question)."')\" class=\"delete\">".__('Delete')."</a></td>\n"; 
     527                                          echo "<td><a href=\"#DeletePoll\" onclick=\"delete_poll($poll_id, '".sprintf(js_escape(__('You are about to delete this poll, \'%s\'.', 'wp-polls')), $poll_question)."')\" class=\"delete\">".__('Delete')."</a></td>\n"; 
    518528                                          echo '</tr>'; 
    519529                                          $i++; 
     
    549559            <div class="wrap"> 
    550560                  <h2><?php _e('Polls Logs', 'wp-polls'); ?></h2> 
    551                   <div align="center"> 
     561                  <div align="center" id="poll_logs"> 
     562                  <?php 
     563                        $poll_ips = intval($wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip")); 
     564                        if($poll_ips > 0) { 
     565                  ?> 
    552566                        <strong><?php _e('Are You Sure You Want To Delete All Polls Logs?', 'wp-polls'); ?></strong><br /><br /> 
    553567                        <input type="checkbox" name="delete_logs_yes" id="delete_logs_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-polls'); ?><br /><br /> 
    554568                        <input type="button" value="<?php _e('Delete All Logs', 'wp-polls'); ?>" class="button" onclick="delete_poll_logs('<?php echo js_escape(__('You are about to delete all poll logs. This action is not reversible.', 'wp-polls')); ?>');" /> 
     569                  <?php  
     570                        } else { 
     571                              _e('No poll logs available.', 'wp-polls'); 
     572                        } 
     573                  ?> 
    555574                  </div> 
    556575                  <p style="text-align: left;"><?php _e('Note:<br />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.', 'wp-polls'); ?></p> 
  • wp-polls/trunk/polls/polls.php

    r7835 r7836  
    10291029                        $pollip_userid = intval($user_ID); 
    10301030                        $pollip_ip = get_ipaddress(); 
    1031                         $pollip_host = gethostbyaddr($pollip_ip); 
     1031                        $pollip_host = @gethostbyaddr($pollip_ip); 
    10321032                        $pollip_timestamp = current_time('timestamp'); 
    10331033                        // Only Create Cookie If User Choose Logging Method 1 Or 2