query('DELETE FROM ip_bans WHERE ID='.$_POST['id']); $Bans = $Cache->delete_value('ip_bans'); } else { //Edit & Create, Shared Validation $Val->SetFields('start', '1','regex','You must inculde starting IP address.',array('regex'=>'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i')); $Val->SetFields('end', '1','regex','You must inculde ending IP address.',array('regex'=>'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i')); $Val->SetFields('notes', '1','string','You must inculde a note regarding the reason for the ban.'); $Err=$Val->ValidateForm($_POST); // Validate the form if($Err){ error($Err); } $Notes = db_string($_POST['notes']); $Start = ip2unsigned($_POST['start']); //Sanitized by Validation regex $End = ip2unsigned($_POST['end']); //See above if($_POST['submit'] == 'Edit'){ //Edit if(empty($_POST['id']) || !is_number($_POST['id'])) { error(404); } $DB->query("UPDATE ip_bans SET FromIP=$Start, ToIP='$End', Reason='$Notes' WHERE ID='".$_POST['id']."'"); $Bans = $Cache->get_value('ip_bans'); $Cache->begin_transaction(); $Cache->update_row($_POST['id'], array($_POST['id'], $Start, $End)); $Cache->commit_transaction(); } else { //Create $DB->query("INSERT INTO ip_bans (FromIP, ToIP, Reason) VALUES ('$Start','$End', '$Notes')"); $ID = $DB->inserted_id(); $Bans = $Cache->get_value('ip_bans'); $Bans[$ID] = array($ID, $Start, $End); $Cache->cache_value('ip_bans', $Bans, 0); } } } define('BANS_PER_PAGE', '20'); list($Page,$Limit) = page_limit(BANS_PER_PAGE); $sql = "SELECT SQL_CALC_FOUND_ROWS ID, FromIP, ToIP, Reason FROM ip_bans AS i "; if(!empty($_REQUEST['notes'])) { $sql .= "WHERE Reason LIKE '%".db_string($_REQUEST['notes'])."%' "; } if(!empty($_REQUEST['ip']) && preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $_REQUEST['ip'])) { if (!empty($_REQUEST['notes'])) { $sql .= "AND '".ip2unsigned($_REQUEST['ip'])."' BETWEEN FromIP AND ToIP "; } else { $sql .= "WHERE '".ip2unsigned($_REQUEST['ip'])."' BETWEEN FromIP AND ToIP "; } } $sql .= "ORDER BY FromIP ASC"; $sql .= " LIMIT ".$Limit; $Bans = $DB->query($sql); $DB->query('SELECT FOUND_ROWS()'); list($Results) = $DB->next_record(); $PageLinks=get_pages($Page,$Results,BANS_PER_PAGE,11); show_header('IP Bans'); $DB->set_query_id($Bans); ?>

IP Bans


Manage

next_record()){ $Row = ($Row === 'a' ? 'b' : 'a'); $Start=long2ip($Start); $End=long2ip($End); ?>
Range Notes Submit