Changeset 12943

Show
Ignore:
Timestamp:
05/17/07 15:45:44 (1 year ago)
Author:
GamerZ
Message:

WP-Polls 2.20 RC1

Files:

Legend:

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

    r11193 r12943  
    2424 
    2525 
     26### Variables 
     27$pollip_answers = array(); 
    2628$poll_question_data = $wpdb->get_row("SELECT pollq_multiple, pollq_question, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = $poll_id"); 
    2729$poll_question = stripslashes($poll_question_data->pollq_question); 
     
    3335$poll_totalrecorded = ($poll_registered+$poll_comments+$poll_guest); 
    3436$poll_answers_data = $wpdb->get_results("SELECT polla_aid, polla_answers FROM $wpdb->pollsa WHERE polla_qid = $poll_id ORDER BY ".get_option('poll_ans_sortby').' '.get_option('poll_ans_sortorder')); 
    35 $poll_voters = $wpdb->get_col("SELECT pollip_user FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_user != '".__('Guest', 'wp-polls')."' ORDER BY pollip_user ASC"); 
     37$poll_voters = $wpdb->get_col("SELECT DISTINCT pollip_user FROM $wpdb->pollsip WHERE pollip_qid = $poll_id AND pollip_user != '".__('Guest', 'wp-polls')."' ORDER BY pollip_user ASC"); 
     38$poll_logs_count = $wpdb->get_var("SELECT COUNT(pollip_id) FROM $wpdb->pollsip WHERE pollip_qid = $poll_id"); 
     39 
     40 
     41### Process Filters 
     42if(!empty($_POST['do'])) { 
     43      $registered_sql = ''; 
     44      $comment_sql = ''; 
     45      $guest_sql = ''; 
     46      $users_voted_for_sql = ''; 
     47      $what_user_voted_sql = ''; 
     48      $num_choices_sql = ''; 
     49      $num_choices_sign_sql = ''; 
     50      $order_by = ''; 
     51      switch(intval($_POST['filter'])) { 
     52            case 1: 
     53                  $users_voted_for = intval($_POST['users_voted_for']); 
     54                  $exclude_registered = intval($_POST['exclude_registered']); 
     55                  $exclude_comment = intval($_POST['exclude_comment']); 
     56                  $exclude_guest = intval($_POST['exclude_guest']); 
     57                  $users_voted_for_sql = "AND pollip_aid = $users_voted_for"; 
     58                  if($exclude_registered) { 
     59                        $registered_sql = 'AND pollip_userid = 0'; 
     60                  } 
     61                  if($exclude_comment) { 
     62                        if(!$exclude_registered) { 
     63                              $comment_sql = 'AND pollip_userid > 0'; 
     64                        } else { 
     65                              $comment_sql = 'AND pollip_user = \''.__('Guest', 'wp-polls').'\''; 
     66                        } 
     67                  } 
     68                  if($exclude_guest) { 
     69                        $guest_sql  = 'AND pollip_user != \''.__('Guest', 'wp-polls').'\''; 
     70                  } 
     71                  $order_by = 'pollip_timestamp DESC'; 
     72                  break; 
     73            case 2: 
     74                  $exclude_registered_2 = intval($_POST['exclude_registered_2']); 
     75                  $exclude_comment_2 = intval($_POST['exclude_comment_2']); 
     76                  $num_choices = intval($_POST['num_choices']); 
     77                  $num_choices_sign = addslashes($_POST['num_choices_sign']); 
     78                  switch($num_choices_sign) { 
     79                        case 'more': 
     80                              $num_choices_sign_sql = '>'; 
     81                              break; 
     82                        case 'more_exactly': 
     83                              $num_choices_sign_sql = '>='; 
     84                              break; 
     85                        case 'exactly': 
     86                              $num_choices_sign_sql = '='; 
     87                              break; 
     88                        case 'less_exactly': 
     89                              $num_choices_sign_sql = '<='; 
     90                              break; 
     91                        case 'less': 
     92                              $num_choices_sign_sql = '<'; 
     93                              break; 
     94                  } 
     95                  if($exclude_registered_2) { 
     96                        $registered_sql = 'AND pollip_userid = 0'; 
     97                  } 
     98                  if($exclude_comment_2) { 
     99                        if(!$exclude_registered_2) { 
     100                              $comment_sql = 'AND pollip_userid > 0'; 
     101                        } else { 
     102                              $comment_sql = 'AND pollip_user = \''.__('Guest', 'wp-polls').'\''; 
     103                        } 
     104                  } 
     105                  $guest_sql  = 'AND pollip_user != \''.__('Guest', 'wp-polls').'\''; 
     106                  $num_choices_query = $wpdb->get_col("SELECT pollip_user, COUNT(pollip_ip) AS num_choices FROM $wpdb->pollsip WHERE pollip_qid = $poll_id GROUP BY pollip_ip, pollip_user HAVING num_choices $num_choices_sign_sql $num_choices"); 
     107                  $num_choices_sql = 'AND pollip_user IN (\''.implode('\',\'',$num_choices_query).'\')'; 
     108                  $order_by = 'pollip_user, pollip_ip'; 
     109                  break; 
     110            case 3; 
     111                  $what_user_voted = addslashes($_POST['what_user_voted']); 
     112                  $what_user_voted_sql = "AND pollip_user = '$what_user_voted'"; 
     113                  $order_by = 'pollip_user, pollip_ip'; 
     114                  break; 
     115      } 
     116      $poll_ips = $wpdb->get_results("SELECT $wpdb->pollsip.* FROM $wpdb->pollsip WHERE pollip_qid = $poll_id $users_voted_for_sql $registered_sql $comment_sql $guest_sql $what_user_voted_sql $num_choices_sql ORDER BY $order_by"); 
     117} else { 
     118      $poll_ips = $wpdb->get_results("SELECT pollip_aid, pollip_ip, pollip_host, pollip_timestamp, pollip_user FROM $wpdb->pollsip WHERE pollip_qid = $poll_id ORDER BY pollip_aid ASC, pollip_user ASC LIMIT 100"); 
     119
    36120?> 
    37             <div class="wrap"> 
    38                   <h2><?php _e('Poll\'s Logs', 'wp-polls'); ?></h2> 
    39                   <p><strong><?php echo $poll_question; ?></strong></p> 
    40                   <p> 
    41                         <?php printf(__('There are a total of <strong>%s</strong> recorded votes for this poll.', 'wp-polls'), $poll_totalrecorded); ?><br /> 
    42                         <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by registered users', 'wp-polls'), $poll_registered); ?><br /> 
    43                         <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by comment authors', 'wp-polls'), $poll_comments); ?><br /> 
    44                         <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by guests', 'wp-polls'), $poll_guest); ?> 
    45                   </p> 
    46             </div> 
    47                         <?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>'; } ?> 
    48                         <!-- Users Voted For This Poll --> 
    49                         <?php 
    50                               $poll_ips = $wpdb->get_results("SELECT pollip_aid, pollip_ip, pollip_host, pollip_timestamp, pollip_user FROM $wpdb->pollsip WHERE pollip_qid = $poll_id ORDER BY pollip_aid ASC, pollip_user ASC"); 
    51                               if($poll_totalrecorded > 0) { 
    52                         ?> 
    53                         <form id="poll_logs_form" method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>">  
    54                         <div class="wrap"> 
    55                               <h2><?php _e('Filter Poll\'s Logs', 'wp-polls') ?></h2> 
    56                               <div id="poll_logs_display"> 
    57                                     <table width="50%"  border="0" cellspacing="3" cellpadding="3"> 
    58                                           <tr> 
    59                                                 <td> 
    60                                                       <strong><?php _e('Display All Users That Voted For:', 'wp-polls'); ?></strong> 
    61                                                 </td> 
    62                                                 <td> 
    63                                                       <select name="users_voted_for" size="1"> 
    64                                                             <?php 
    65                                                                   if($poll_answers_data) { 
    66                                                                         foreach($poll_answers_data as $data) { 
    67                                                                               echo '<option value="'.$data->polla_aid.'">'.stripslashes(strip_tags(htmlspecialchars($data->polla_answers))).'</option>'; 
     121<?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>'; } ?> 
     122<div class="wrap"> 
     123      <h2><?php _e('Poll\'s Logs', 'wp-polls'); ?></h2> 
     124      <p><strong><?php echo $poll_question; ?></strong></p> 
     125      <p> 
     126            <?php printf(__('There are a total of <strong>%s</strong> recorded votes for this poll.', 'wp-polls'), $poll_totalrecorded); ?><br /> 
     127            <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by registered users', 'wp-polls'), $poll_registered); ?><br /> 
     128            <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by comment authors', 'wp-polls'), $poll_comments); ?><br /> 
     129            <?php printf(__('<strong>&raquo;</strong> <strong>%s</strong> vote(s) are voted by guests', 'wp-polls'), $poll_guest); ?> 
     130      </p> 
     131</div> 
     132<?php if($poll_totalrecorded > 0) { ?> 
     133<div class="wrap"> 
     134      <h2><?php _e('Filter Poll\'s Logs', 'wp-polls') ?></h2> 
     135      <table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
     136            <tr> 
     137                  <td width="50%"> 
     138                        <form method="post" action="<?php echo htmlspecialchars($base_page); ?>&amp;mode=logs&amp;id=<?php echo $poll_id; ?>"> 
     139                        <p style="display: none;"><input type="hidden" name="filter" value="1" /></p> 
     140                        <table border="0" cellspacing="3" cellpadding="3"> 
     141                              <tr> 
     142                                    <td> 
     143                                          <strong><?php _e('Display All Users That Voted For:', 'wp-polls'); ?></strong> 
     144                                    </td> 
     145                                    <td> 
     146                                          <select name="users_voted_for" size="1"> 
     147                                                <?php 
     148                                                      if($poll_answers_data) { 
     149                                                            foreach($poll_answers_data as $data) { 
     150                                                                  $polla_id = intval($data->polla_aid); 
     151                                                                  $polla_answers = stripslashes(strip_tags(htmlspecialchars($data->polla_answers))); 
     152                                                                  if($polla_id  == $users_voted_for) { 
     153                                                                        echo '<option value="'.$polla_id .'" selected="selected">'.$polla_answers.'</option>'; 
     154                                                                  } else { 
     155                                                                        echo '<option value="'.$polla_id .'">'.$polla_answers.'</option>'; 
     156                                                                  } 
     157                                                                  $pollip_answers[$polla_id] = $polla_answers; 
     158                                                            } 
     159                                                      } 
     160                                                ?> 
     161                                          </select> 
     162                                    </td> 
     163                              </tr> 
     164                              <tr> 
     165                                    <td valign="top"> 
     166                                          <strong><?php _e('Voters To EXCLUDE', 'wp-polls'); ?></strong> 
     167                                    </td> 
     168                                    <td> 
     169                                          <input type="checkbox" id="exclude_registered_1" name="exclude_registered" value="1" <?php checked('1', $exclude_registered); ?> />&nbsp;<label for="exclude_registered_1"><?php _e('Registered Users', 'wp-polls'); ?></label><br /> 
     170                                          <input type="checkbox" id="exclude_comment_1" name="exclude_comment" value="1" <?php checked('1', $exclude_comment); ?> />&nbsp;<label for="exclude_comment_1"><?php _e('Comment Authors', 'wp-polls'); ?></label><br /> 
     171                                          <input type="checkbox" id="exclude_guest_1" name="exclude_guest" value="1" <?php checked('1', $exclude_guest); ?> />&nbsp;<label for="exclude_guest_1"><?php _e('Guests', 'wp-polls'); ?></label> 
     172                                    </td> 
     173                              </tr> 
     174                              <tr> 
     175                                    <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
     176                              </tr> 
     177                        </table> 
     178                        </form> 
     179                  </td> 
     180                  <td width="50%"> 
     181                        <?php if($poll_multiple > 0) { ?> 
     182                              <form method="post" action="<?php echo htmlspecialchars($base_page); ?>&amp;mode=logs&amp;id=<?php echo $poll_id; ?>"> 
     183                              <p style="display: none;"><input type="hidden" name="filter" value="2" /></p> 
     184                              <table border="0" cellspacing="3" cellpadding="3"> 
     185                                    <tr> 
     186                                          <td> 
     187                                                <strong><?php _e('Display Users That Voted For: ', 'wp-polls'); ?></strong> 
     188                                          </td> 
     189                                          <td> 
     190                                                <select name="num_choices_sign" size="1"> 
     191                                                      <option value="more" <?php selected('more', $num_choices_sign); ?>><?php _e('More Than', 'wp-polls'); ?></option> 
     192                                                      <option value="more_exactly" <?php selected('more_exactly', $num_choices_sign); ?>><?php _e('More Than Or Exactly', 'wp-polls'); ?></option> 
     193                                                      <option value="exactly" <?php selected('exactly', $num_choices_sign); ?>><?php _e('Exactly', 'wp-polls'); ?></option> 
     194                                                      <option value="less_exactly" <?php selected('less_exactly', $num_choices_sign); ?>><?php _e('Less Than Or Exactly', 'wp-polls'); ?></option> 
     195                                                      <option value="less" <?php selected('less', $num_choices_sign); ?>><?php _e('Less Than', 'wp-polls'); ?></option> 
     196                                                </select> 
     197                                                &nbsp;&nbsp; 
     198                                                <select name="num_choices" size="1"> 
     199                                                      <?php  
     200                                                            for($i = 1; $i <= $poll_multiple; $i++) { 
     201                                                                  if($i == 1) { 
     202                                                                        echo '<option value="1">'.__('1 Answer', 'wp-polls').'</option>'; 
     203                                                                  } else { 
     204                                                                        if($i == $num_choices) { 
     205                                                                              echo '<option value="'.$i.'" selected="selected">'.sprintf(__('%s Answers', 'wp-polls'), $i).'</option>'; 
     206                                                                        } else { 
     207                                                                              echo '<option value="'.$i.'">'.sprintf(__('%s Answers', 'wp-polls'), $i).'</option>'; 
    68208                                                                        } 
    69209                                                                  } 
    70                                                             ?> 
    71                                                       </select> 
    72                                                 </td> 
    73                                           </tr> 
    74                                           <tr> 
    75                                                 <td valign="top"> 
    76                                                       <strong><?php _e('Voters To Include', 'wp-polls'); ?></strong> 
    77                                                 </td> 
    78                                                 <td> 
    79                                                       <input type="checkbox" name="include_registered" value="1" />&nbsp;<?php _e('Registered Users', 'wp-polls'); ?><br /> 
    80                                                       <input type="checkbox" name="include_comment" value="1" />&nbsp;<?php _e('Comment Authors', 'wp-polls'); ?><br /> 
    81                                                       <input type="checkbox" name="include_guest" value="1" />&nbsp;<?php _e('Guests', 'wp-polls'); ?> 
    82                                                 </td> 
    83                                           </tr> 
    84                                           <tr> 
    85                                                 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
    86                                           </tr> 
    87                                     </table> 
    88                                     <table width="50%"  border="0" cellspacing="3" cellpadding="3"> 
    89                                           <tr> 
    90                                                 <td> 
    91                                                       <strong><?php _e('Display What This User Has Voted:', 'wp-polls'); ?></strong> 
    92                                                 </td> 
    93                                                 <td> 
    94                                                       <select name="what_user_voted" size="1"> 
    95                                                             <?php 
    96                                                                   if($poll_voters) { 
    97                                                                         foreach($poll_voters as $pollip_user) { 
    98                                                                               echo '<option value="'.stripslashes(htmlspecialchars($pollip_user)).'">'.stripslashes(htmlspecialchars($pollip_user)).'</option>'; 
    99                                                                         } 
     210                                                            } 
     211                                                      ?> 
     212                                                </select> 
     213                                          </td> 
     214                                    </tr> 
     215                                    <tr> 
     216                                          <td valign="top"> 
     217                                                <strong><?php _e('Voters To EXCLUDE', 'wp-polls'); ?></strong> 
     218                                          </td> 
     219                                          <td> 
     220                                                <input type="checkbox" id="exclude_registered_2" name="exclude_registered_2" value="1" <?php checked('1', $exclude_registered_2); ?> />&nbsp;<label for="exclude_registered_2"><?php _e('Registered Users', 'wp-polls'); ?></label><br /> 
     221                                                <input type="checkbox" id="exclude_comment_2" name="exclude_comment_2" value="1" <?php checked('1', $exclude_comment_2); ?> />&nbsp;<label for="exclude_comment_2"><?php _e('Comment Authors', 'wp-polls'); ?></label><br /> 
     222                                                <?php _e('Guest will automatically be excluded', 'wp-polls'); ?> 
     223                                          </td> 
     224                                    </tr> 
     225                                    <tr> 
     226                                          <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
     227                                    </tr> 
     228                              </table> 
     229                              </form> 
     230                        <?php } else { ?> 
     231                              &nbsp; 
     232                        <?php } // End if($poll_multiple > -1) ?>                    
     233                  </td> 
     234            </tr> 
     235            <tr> 
     236                  <td> 
     237                        <?php if($poll_voters) { ?> 
     238                        <form method="post" action="<?php echo htmlspecialchars($base_page); ?>&amp;mode=logs&amp;id=<?php echo $poll_id; ?>"> 
     239                        <p style="display: none;"><input type="hidden" name="filter" value="3" /></p> 
     240                        <table border="0" cellspacing="3" cellpadding="3"> 
     241                              <tr> 
     242                                    <td> 
     243                                          <strong><?php _e('Display What This User Has Voted:', 'wp-polls'); ?></strong> 
     244                                    </td> 
     245                                    <td> 
     246                                          <select name="what_user_voted" size="1"> 
     247                                                <?php 
     248                                                      if($poll_voters) { 
     249                                                            foreach($poll_voters as $pollip_user) { 
     250                                                                  if($pollip_user == $what_user_voted) { 
     251                                                                        echo '<option value="'.stripslashes(htmlspecialchars($pollip_user)).'" selected="selected">'.stripslashes(htmlspecialchars($pollip_user)).'</option>'; 
     252                                                                  } else { 
     253                                                                        echo '<option value="'.stripslashes(htmlspecialchars($pollip_user)).'">'.stripslashes(htmlspecialchars($pollip_user)).'</option>'; 
    100254                                                                  } 
    101                                                             ?> 
    102                                                       </select> 
    103                                                 </td> 
    104                                           </tr> 
    105                                           <tr> 
    106                                                 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
    107                                           </tr> 
    108                                     </table> 
    109                                     <?php if($poll_multiple > -1) { ?> 
    110                                     <table width="50%"  border="0" cellspacing="3" cellpadding="3"> 
    111                                           <tr> 
    112                                                 <td> 
    113                                                       <strong><?php _e('Display Users That Voted For: ', 'wp-polls'); ?></strong> 
    114                                                 </td> 
    115                                                 <td> 
    116                                                       <select name="num_choices_sign" size="1"> 
    117                                                             <option value="more"><?php _e('More Than', 'wp-polls'); ?></option> 
    118                                                             <option value="more_exactly"><?php _e('More Than Or Exactly', 'wp-polls'); ?></option> 
    119                                                             <option value="exactly"><?php _e('Exactly', 'wp-polls'); ?></option> 
    120                                                             <option value="less_exactly"><?php _e('Less Than Or Exactly', 'wp-polls'); ?></option> 
    121                                                             <option value="less"><?php _e('Less Than', 'wp-polls'); ?></option> 
    122                                                       </select> 
    123                                                       &nbsp;&nbsp; 
    124                                                       <select name="num_choices" size="1"> 
    125                                                             <?php  
    126                                                                   for($i = 1; $i <= $poll_multiple; $i++) { 
    127                                                                         if($i == 1) { 
    128                                                                               echo '<option value="1">'.__('1 Choice', 'wp-polls').'</option>'; 
    129                                                                         } else { 
    130                                                                               echo '<option value="'.$i.'">'.sprintf(__('%s Choices', 'wp-polls'), $i).'</option>'; 
    131                                                                         } 
    132                                                                   } 
    133                                                             ?> 
    134                                                       </select> 
    135                                                 </td> 
    136                                           </tr> 
    137                                           <tr> 
    138                                                 <td valign="top"> 
    139                                                       <strong><?php _e('Voters To Include', 'wp-polls'); ?></strong> 
    140                                                 </td> 
    141                                                 <td> 
    142                                                       <input type="checkbox" name="include_registered" value="1" />&nbsp;<?php _e('Registered Users', 'wp-polls'); ?><br /> 
    143                                                       <input type="checkbox" name="include_comment" value="1" />&nbsp;<?php _e('Comment Authors', 'wp-polls'); ?><br /> 
    144                                                       <input type="checkbox" name="include_guest" value="1" />&nbsp;<?php _e('Guests', 'wp-polls'); ?> 
    145                                                 </td> 
    146                                           </tr> 
    147                                           <tr> 
    148                                                 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
    149                                           </tr> 
    150                                     </table> 
    151                                     <?php  
    152                                                 }  
     255                                                            } 
     256                                                      } 
     257                                                ?> 
     258                                          </select> 
     259                                    </td> 
     260                              </tr> 
     261                              <tr> 
     262                                    <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Filter', 'wp-polls'); ?>" class="button" /></td> 
     263                              </tr> 
     264                        </table> 
     265                        </form> 
     266                        <?php } else { ?> 
     267                              &nbsp; 
     268                        <?php } // End if($poll_multiple > -1) ?>        
     269                  </td> 
     270                  <td> 
     271                        <input type="button" value="<?php _e('Clear Filter', 'wp-polls'); ?>" onclick="self.location.href = '<?php echo htmlspecialchars($base_page); ?>&amp;mode=logs&amp;id=<?php echo $poll_id; ?>';" class="button" /> 
     272                  </td> 
     273            </tr> 
     274      </table> 
     275</div> 
     276<?php } // End if($poll_totalrecorded > 0) ?> 
     277<div class="wrap"> 
     278      <h2><?php _e('Poll Logs', 'wp-polls'); ?></h2> 
     279      <div id="poll_logs_display"> 
     280            <?php 
     281                  if($poll_ips) { 
     282                        if(empty($_POST['do'])) { 
     283                              echo '<p>'.__('This default filter is limited to display only <strong>100</strong> records.', 'wp-polls').'</p>'; 
     284                        } 
     285                        echo '<table width="100%"  border="0" cellspacing="3" cellpadding="3">'."\n"; 
     286                        $k = 1; 
     287                        $j = 0; 
     288                        $poll_last_aid = -1; 
     289                        if(intval($_POST['filter']) > 1) { 
     290                              echo "<tr class=\"thead\">\n"; 
     291                              echo "<th>".__('Answer', 'wp-polls')."</th>\n"; 
     292                              echo "<th>".__('IP', 'wp-polls')."</th>\n"; 
     293                              echo "<th>".__('Host', 'wp-polls')."</th>\n"; 
     294                              echo "<th>".__('Date', 'wp-polls')."</th>\n"; 
     295                              echo "</tr>\n"; 
     296                              foreach($poll_ips as $poll_ip) { 
     297                                    $pollip_aid = intval($poll_ip->pollip_aid); 
     298                                    $pollip_user = stripslashes($poll_ip->pollip_user); 
     299                                    $pollip_ip = $poll_ip->pollip_ip; 
     300                                    $pollip_host = $poll_ip->pollip_host; 
     301                                    $pollip_date = mysql2date(get_option('date_format').' @ '.get_option('time_format'), gmdate('Y-m-d H:i:s', $poll_ip->pollip_timestamp)); 
     302                                    if($i%2 == 0) { 
     303                                          $style = 'style=\'background-color: none\''; 
     304                                    }  else { 
     305                                          $style = 'style=\'background-color: #eee\''; 
    153306                                    } 
    154                                     ?> 
    155                                           <?php 
    156                                                 if($poll_ips) { 
    157                                                       echo '<table width="100%"  border="0" cellspacing="3" cellpadding="3">'."\n"; 
    158                                                       $k = 1; 
    159                                                       $poll_last_aid = -1; 
    160                                                       foreach($poll_ips as $poll_ip) { 
    161                                                             $pollip_aid = intval($poll_ip->pollip_aid); 
    162                                                             $pollip_user = stripslashes($poll_ip->pollip_user); 
    163                                                             $pollip_ip = $poll_ip->pollip_ip; 
    164                                                             $pollip_host = $poll_ip->pollip_host; 
    165                                                             $pollip_date = mysql2date(get_option('date_format').' @ '.get_option('time_format'), gmdate('Y-m-d H:i:s', $poll_ip->pollip_timestamp)); 
    166                                                             if($pollip_aid != $poll_last_aid) { 
    167                                                                   if($pollip_aid == 0) { 
    168                                                                         echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><strong>$pollip_answers[$pollip_aid]</strong></td>\n</tr>\n"; 
    169                                                                   } else { 
    170                                                                         echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><strong>".__('Answer', 'wp-polls')." $k: $pollip_answers[$pollip_aid]</strong></td>\n</tr>\n"; 
    171                                                                         $k++; 
    172                                                                   } 
    173                                                                   echo "<tr class=\"thead\">\n"; 
    174                                                                   echo "<th>".__('No.', 'wp-polls')."</th>\n"; 
    175                                                                   echo "<th>".__('User', 'wp-polls')."</th>\n"; 
    176                                                                   echo "<th>".__('IP/Host', 'wp-polls')."</th>\n"; 
    177                                                                   echo "<th>".__('Date', 'wp-polls')."</th>\n"; 
    178                                                                   echo "</tr>\n"; 
    179                                                                   $i = 1; 
    180                                                             } 
    181                                                             if($i%2 == 0) { 
    182                                                                   $style = 'style=\'background-color: none\''; 
    183                                                             }  else { 
    184                                                                   $style = 'style=\'background-color: #eee\''; 
    185                                                             } 
    186                                                             echo "<tr $style>\n"; 
    187                                                             echo "<td>$i</td>\n"; 
    188                                                             echo "<td>$pollip_user</td>\n"; 
    189                                                             echo "<td>$pollip_ip / $pollip_host</td>\n"; 
    190                                                             echo "<td>$pollip_date</td>\n"; 
    191                                                             echo "</tr>\n"; 
    192                                                             $poll_last_aid = $pollip_aid; 
    193                                                             $i++; 
    194                                                       } 
    195                                                       echo '</table>'."\n"; 
    196                                                 } 
    197                                           ?> 
    198                               </div> 
    199                               <div id="poll_logs_display_none" style="text-align: center; display: <?php if(!$poll_ips) { echo 'block'; } else { echo 'none'; } ?>;" ><?php _e('No poll logs available for this poll.', 'wp-polls'); ?></div> 
    200                         </div> 
    201                         </form> 
    202             <!-- Delete Poll Logs --> 
    203             <div class="wrap"> 
    204                   <h2><?php _e('Poll Logs', 'wp-polls'); ?></h2> 
    205                   <div align="center" id="poll_logs"> 
    206                         <?php if($poll_ips) { ?> 
    207                               <strong><?php _e('Are You Sure You Want To Delete Logs For This Poll Only?', 'wp-polls'); ?></strong><br /><br /> 
    208                               <input type="checkbox" id="delete_logs_yes" name="delete_logs_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-polls'); ?><br /><br /> 
    209                               <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)); ?>');" /> 
    210                         <?php  
    211                               } else { 
    212                                     _e('No poll logs available for this poll.', 'wp-polls'); 
     307                                    if($pollip_user != $temp_pollip_user) { 
     308                                          echo '<tr style="background-color: #b8d4ff">'."\n"; 
     309                                          echo "<td colspan=\"4\"><strong>".__('User', 'wp-polls')." $k: $pollip_user</strong></td>\n"; 
     310                                          echo '</tr>'; 
     311                                          $k++; 
     312                                    }            
     313                                    echo "<tr $style>\n"; 
     314                                    echo "<td>{$pollip_answers[$pollip_aid]}</td>\n"; 
     315                                    echo "<td>$pollip_ip</td>\n"; 
     316                                    echo "<td>$pollip_host</td>\n"; 
     317                                    echo "<td>$pollip_date</td>\n"; 
     318                                    echo "</tr>\n"; 
     319                                    $temp_pollip_user = $pollip_user;                      
     320                                    $i++; 
     321                                    $j++; 
    213322                              } 
    214                         ?> 
    215                   </div> 
    216                   <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> 
    217             </div> 
     323                        } else { 
     324                              foreach($poll_ips as $poll_ip) { 
     325                                    $pollip_aid = intval($poll_ip->pollip_aid); 
     326                                    $pollip_user = stripslashes($poll_ip->pollip_user); 
     327                                    $pollip_ip = $poll_ip->pollip_ip; 
     328                                    $pollip_host = $poll_ip->pollip_host; 
     329                                    $pollip_date = mysql2date(get_option('date_format').' @ '.get_option('time_format'), gmdate('Y-m-d H:i:s', $poll_ip->pollip_timestamp)); 
     330                                    if($pollip_aid != $poll_last_aid) { 
     331                                          if($pollip_aid == 0) { 
     332                                                echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><strong>$pollip_answers[$pollip_aid]</strong></td>\n</tr>\n"; 
     333                                          } else { 
     334                                                echo "<tr style='background-color: #b8d4ff'>\n<td colspan=\"4\"><strong>".__('Answer', 'wp-polls')." $k: $pollip_answers[$pollip_aid]</strong></td>\n</tr>\n"; 
     335                                                $k++; 
     336                                          } 
     337                                          echo "<tr class=\"thead\">\n"; 
     338                                          echo "<th>".__('No.', 'wp-polls')."</th>\n"; 
     339                                          echo "<th>".__('User', 'wp-polls')."</th>\n"; 
     340                                          echo "<th>".__('IP/Host', 'wp-polls')."</th>\n"; 
     341                                          echo "<th>".__('Date', 'wp-polls')."</th>\n"; 
     342                                          echo "</tr>\n"; 
     343                                          $i = 1; 
     344                                    } 
     345                                    if($i%2 == 0) { 
     346                                          $style = 'style=\'background-color: none\''; 
     347                                    }  else { 
     348                                          $style = 'style=\'background-color: #eee\''; 
     349                                    } 
     350                                    echo "<tr $style>\n"; 
     351                                    echo "<td>$i</td>\n"; 
     352                                    echo "<td>$pollip_user</td>\n"; 
     353                                    echo "<td>$pollip_ip / $pollip_host</td>\n"; 
     354                                    echo "<td>$pollip_date</td>\n"; 
     355                                    echo "</tr>\n"; 
     356                                    $poll_last_aid = $pollip_aid; 
     357                                    $i++; 
     358                                    $j++; 
     359                              } 
     360                        } 
     361                        echo "<tr class=\"thead\">\n"; 
     362                        echo "<td colspan=\"4\">".sprintf(__('Total number of records that matches this filter: <strong>%s</strong>', 'wp-polls'), number_format($j))."</td>"; 
     363                        echo "</tr>\n"; 
     364                        echo '</table>'."\n"; 
     365                  } 
     366            ?> 
     367      </div> 
     368      <?php if(!empty($_POST['do'])) { ?> 
     369            <div id="poll_logs_display_none" style="text-align: center; display: <?php if(!$poll_ips) { echo 'block'; } else { echo 'none'; } ?>;" ><?php _e('No poll logs matches the filter.', 'wp-polls'); ?></div> 
     370      <?php } else { ?> 
     371            <div id="poll_logs_display_none" style="text-align: center; display: <?php if(!$poll_logs_count) { echo 'block'; } else { echo 'none'; } ?>;" ><?php _e('No poll logs available for this poll.', 'wp-polls'); ?></div> 
     372      <?php } ?> 
     373</div> 
     374 
     375<!-- Delete Poll Logs --> 
     376<div class="wrap"> 
     377      <h2><?php _e('Delete Poll Logs', 'wp-polls'); ?></h2> 
     378      <div align="center" id="poll_logs"> 
     379            <?php if($poll_logs_count) { ?> 
     380                  <strong><?php _e('Are You Sure You Want To Delete Logs For This Poll Only?', 'wp-polls'); ?></strong><br /><br /> 
     381                  <input type="checkbox" id="delete_logs_yes" name="delete_logs_yes" value="yes" />&nbsp;<label for="delete_logs_yes"><?php _e('Yes', 'wp-polls'); ?></label><br /><br /> 
     382                  <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)); ?>');" /> 
     383            <?p