plugins/admin/UserManager.php
changeset 1170 71cb87b7dc3f
parent 1141 5a858d6f3634
child 1175 1e2c9819ede3
equal deleted inserted replaced
1169:d5474f54a525 1170:71cb87b7dc3f
   588                   <a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'UserManager&action=deny&user='.rawurlencode($row['edit_summary']).'&logid='.$row['time_id'], true).'">' . $lang->get('acpum_btn_activate_deny') . '</a>
   588                   <a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'UserManager&action=deny&user='.rawurlencode($row['edit_summary']).'&logid='.$row['time_id'], true).'">' . $lang->get('acpum_btn_activate_deny') . '</a>
   589                 </td>
   589                 </td>
   590               </tr>';
   590               </tr>';
   591       }
   591       }
   592       echo '</table>';
   592       echo '</table>';
       
   593       echo '</div>';
   593     }
   594     }
   594     $db->free_result();
   595     $db->free_result();
   595   }
   596   }
   596   
   597   
       
   598   acp_usermanager_lockouts();
   597 }
   599 }
   598 
   600 
   599 /**
   601 /**
   600  * Smart form class for the user manager.
   602  * Smart form class for the user manager.
   601  * @package Enano
   603  * @package Enano
  1219     return $parsed;
  1221     return $parsed;
  1220   }
  1222   }
  1221   
  1223   
  1222 }
  1224 }
  1223 
  1225 
  1224 ?>
  1226 function acp_usermanager_lockouts($homewrap = false)
       
  1227 {
       
  1228   global $db, $session, $paths, $template, $plugins; // Common objects
       
  1229   global $lang;
       
  1230   
       
  1231   // Locked out users
       
  1232   
       
  1233   if ( !empty($_GET['clear_lockout']) && is_valid_ip($_GET['clear_lockout']) )
       
  1234   {
       
  1235     $ip = $db->escape($_GET['clear_lockout']);
       
  1236     $q = $db->sql_query('DELETE FROM ' . table_prefix . "lockout WHERE ipaddr = '$ip' AND timestamp > ( " . time() . " - (" . getConfig('lockout_duration', 15) . "*60) );");
       
  1237     if ( !$q )
       
  1238       $db->_die();
       
  1239     
       
  1240     echo '<div class="info-box">' . $lang->get('acphome_msg_lockout_clear_success', array('ip' => htmlspecialchars($ip))) . '</div>';
       
  1241   }
       
  1242   
       
  1243   $q = $db->sql_query('SELECT COUNT(id) AS fail_count, ipaddr, username, timestamp FROM ' . table_prefix . "lockout\n"
       
  1244                     . "  WHERE timestamp > ( " . time() . " - " . intval(getConfig('lockout_duration', 15)) . "*60 ) GROUP BY ipaddr ORDER BY COUNT(id) DESC, timestamp DESC;");
       
  1245   if ( !$q )
       
  1246     $db->_die();
       
  1247   
       
  1248   if ( $db->numrows() > 0 )
       
  1249   {
       
  1250     if ( $homewrap )
       
  1251       echo '<div class="acphome-box notice">';
       
  1252     echo '<h3>' . $lang->get('acphome_msg_users_locked_out') . '</h3>';
       
  1253     echo '<p>' . $lang->get('acphome_msg_users_locked_out_hint') . '</p>';
       
  1254     
       
  1255     ?>
       
  1256     <div class="tblholder" style="margin-bottom: 10px;">
       
  1257     <table width="100%" cellspacing="1" cellpadding="4">
       
  1258       <tr>
       
  1259         <th><?php echo $lang->get('acphome_th_locked_out_ip'); ?></th>
       
  1260         <th><?php echo $lang->get('acphome_th_locked_out_username'); ?></th>
       
  1261         <th><?php echo $lang->get('acphome_th_locked_out_status'); ?></th>
       
  1262         <th><?php echo $lang->get('acphome_th_locked_out_time'); ?></th>
       
  1263         <th></th>
       
  1264       </tr>
       
  1265     <?php
       
  1266     
       
  1267     while ( $row = $db->fetchrow() )
       
  1268     {
       
  1269       echo '<tr>';
       
  1270       echo '<td class="row1">' . htmlspecialchars($row['ipaddr']) . '</td>';
       
  1271       echo '<td class="row2">' . htmlspecialchars($row['username']) . '</td>';
       
  1272       // status
       
  1273       echo '<td class="row1" style="text-align: center;">' .
       
  1274             ( $row['fail_count'] >= getConfig('lockout_threshold', 5)
       
  1275                 ? '<b>' . $lang->get('acphome_lbl_locked_out_banned') . '</b>'
       
  1276                 : $lang->get('acphome_lbl_locked_out_warned', array('fail_count' => $row['fail_count']))
       
  1277             )
       
  1278             . '</td>';
       
  1279       // time left
       
  1280       if ( $row['fail_count'] >= getConfig('lockout_threshold', 5) )
       
  1281       {
       
  1282         $expire_time = $row['timestamp'] + ( getConfig('lockout_duration', 15) * 60 );
       
  1283         $time_left = round(($expire_time - time()) / 60);
       
  1284         $minutes = $time_left == 1 ? $lang->get('etc_unit_minute') : $lang->get('etc_unit_minutes');
       
  1285         echo '<td class="row2" style="text-align: center;">' . "$time_left $minutes" . '</td>';
       
  1286       }
       
  1287       else
       
  1288       {
       
  1289         echo '<td class="row2" style="text-align: center;">&ndash;</td>';
       
  1290       }
       
  1291       // action
       
  1292       $btn_text = $row['fail_count'] >= getConfig('lockout_threshold', 5) ? $lang->get('acphome_btn_lockout_unblock') : $lang->get('acphome_btn_lockout_clear');
       
  1293       echo '<td class="row1" style="text-align: center;"><a href="#" onclick="ajaxPage(\'' . $paths->nslist['Admin'] . 'UserManager\', \'clear_lockout=' . htmlspecialchars($row['ipaddr']) . '\'); return false;">' . $btn_text . '</a></td>';
       
  1294       echo '</tr>';
       
  1295     }
       
  1296     echo '</table>';
       
  1297     echo '</div>';
       
  1298     if ( $homewrap )
       
  1299       echo '</div>';
       
  1300   }
       
  1301   
       
  1302   $db->free_result();
       
  1303 }