Empty commit

This commit is contained in:
Git 2012-07-22 08:00:16 +00:00
parent 3ada9b8640
commit 5f8c596d41
4 changed files with 95 additions and 3 deletions

View File

@ -82,6 +82,11 @@
'sticky' => $Sticky == 1
);
}
// ...And an extra one to catch the last category.
if (!empty($JsonForums) && !empty($JsonCategory)) {
$JsonCategory['forums'] = $JsonForums;
$JsonCategories[] = $JsonCategory;
}
print json_encode(
array(

View File

@ -265,7 +265,9 @@
//TODO: Clean up db table ip_bans.
include("managers/bans.php");
break;
case 'quick_ban':
include("misc/quick_ban.php");
break;
//Data
case 'registration_log':
include('data/registration_log.php');

View File

@ -0,0 +1,24 @@
<?php
if(!check_perms('admin_manage_ipbans')) { error(403); }
if(isset($_GET['perform'])) {
if($_GET['perform'] == 'delete') {
if(!is_number($_GET['id']) || $_GET['id'] == ''){ error(0); }
$DB->query('DELETE FROM ip_bans WHERE ID='.$_GET['id']);
$Bans = $Cache->delete_value('ip_bans');
}
elseif($_GET['perform'] == 'create') {
$Notes = db_string($_GET['notes']);
$IP = ip2unsigned($_GET['ip']); //Sanitized by Validation regex
$DB->query("INSERT INTO ip_bans
(FromIP, ToIP, Reason) VALUES
('$IP','$IP', '$Notes')");
$ID = $DB->inserted_id();
$Bans = $Cache->get_value('ip_bans');
$Bans[$ID] = array($ID, $Start, $End);
$Cache->cache_value('ip_bans', $Bans, 0);
}
}
?>

View File

@ -29,7 +29,45 @@
<script type="text/javascript">
function ShowIPs(rowname) {
$('tr[name="'+rowname+'"]').toggle();
}
function Ban(ip, id, elemID) {
var notes = prompt("Enter notes for this ban");
if(notes != null && notes.length > 0) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById(elemID).innerHTML = "<strong>[Banned]</strong>";
}
}
xmlhttp.open("GET","tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes,true);
xmlhttp.send();
}
}
/*
function UnBan(ip, id, elemID) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById(elemID).innerHTML = "Ban";
document.getElementById(elemID).onClick = function() { Ban(ip, id, elemID); return false;};
}
}
xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id="+id,true);
xmlhttp.send();
}
*/
</script>
<div class="thin">
<?
@ -92,6 +130,8 @@ function ShowIPs(rowname) {
<td>Elapsed</td>
</tr>
<?
$counter = 0;
$IPs = array();
$Results = $DB->to_array();
foreach($Results as $Index => $Result) {
list($IP, $StartTime, $EndTime, $UserIDs, $UserStartTimes, $UserEndTimes, $Usernames, $UsersEnabled, $UsersDonor, $UsersWarned) = $Result;
@ -111,8 +151,28 @@ function ShowIPs(rowname) {
?>
<tr class="rowa">
<td>
<?=$IP?> (<?=get_cc($IP)?>) <br />
<?=get_host($IP)?>
<?=$IP?> (<?=get_cc($IP)?>)
<?
if(!isset($IPs[$IP])) {
$sql = "SELECT ID, FromIP, ToIP FROM ip_bans WHERE '".ip2unsigned($IP)."' BETWEEN FromIP AND ToIP LIMIT 1";
$DB->query($sql);
if($DB->record_count() > 0) {
$IPs[$IP] = true;
?>
<strong>[Banned]
<? }
else {
$IPs[$IP] = false; ?>
<a id="<?=$counter?>" href="#" onclick="Ban('<?=$IP?>', '<?=$ID?>', '<?=$counter?>'); this.onclick=null;return false;">[Ban]</a>
<? }
$counter++;
}
?>
<br />
<?=get_host($IP)?>
<?=($HasDupe ?
'<a href="#" onclick="ShowIPs('.$Index.'); return false;">('.count($UserIDs).')</a>'
: '(0)')?></td>
@ -149,3 +209,4 @@ function ShowIPs(rowname) {
<?
show_footer();
?>