IP ban expiry times
git-svn-id: file:///home/shish/svn/shimmie2/trunk@140 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									3be41b687a
								
							
						
					
					
						commit
						93bb05abaf
					
				| @ -13,10 +13,12 @@ class RemoveIPBanEvent extends Event { | |||||||
| class AddIPBanEvent extends Event {  | class AddIPBanEvent extends Event {  | ||||||
| 	var $ip; | 	var $ip; | ||||||
| 	var $reason; | 	var $reason; | ||||||
|  | 	var $end; | ||||||
| 
 | 
 | ||||||
| 	public function AddIPBanEvent($ip, $reason) { | 	public function AddIPBanEvent($ip, $reason, $end) { | ||||||
| 		$this->ip = $ip; | 		$this->ip = $ip; | ||||||
| 		$this->reason = $reason; | 		$this->reason = $reason; | ||||||
|  | 		$this->end = $end; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| // }}}
 | // }}}
 | ||||||
| @ -37,8 +39,8 @@ class IPBan extends Extension { | |||||||
| 			global $user; | 			global $user; | ||||||
| 			if($user->is_admin()) { | 			if($user->is_admin()) { | ||||||
| 				if($event->get_arg(0) == "add") { | 				if($event->get_arg(0) == "add") { | ||||||
| 					if(isset($_POST['ip']) && isset($_POST['reason'])) { | 					if(isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) { | ||||||
| 						send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'])); | 						send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $_POST['end'])); | ||||||
| 
 | 
 | ||||||
| 						global $page; | 						global $page; | ||||||
| 						$page->set_mode("redirect"); | 						$page->set_mode("redirect"); | ||||||
| @ -58,7 +60,7 @@ class IPBan extends Extension { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(is_a($event, 'AddIPBanEvent')) { | 		if(is_a($event, 'AddIPBanEvent')) { | ||||||
| 			$this->add_ip_ban($event->ip, $event->reason); | 			$this->add_ip_ban($event->ip, $event->reason, $event->end); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(is_a($event, 'RemoveIPBanEvent')) { | 		if(is_a($event, 'RemoveIPBanEvent')) { | ||||||
| @ -114,14 +116,14 @@ class IPBan extends Extension { | |||||||
| 	public function get_ip_ban($ip) { | 	public function get_ip_ban($ip) { | ||||||
| 		global $database; | 		global $database; | ||||||
| 		// yes, this is "? LIKE var", because ? is the thing with matching tokens
 | 		// yes, this is "? LIKE var", because ? is the thing with matching tokens
 | ||||||
| 		return $database->db->GetRow("SELECT * FROM bans WHERE ? LIKE ip", array($ip)); | 		return $database->db->GetRow("SELECT * FROM bans WHERE ? LIKE ip AND date < now() AND (end > now() OR isnull(end))", array($ip)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public function add_ip_ban($ip, $reason) { | 	public function add_ip_ban($ip, $reason, $end) { | ||||||
| 		global $database; | 		global $database; | ||||||
| 		$database->Execute( | 		$database->Execute( | ||||||
| 				"INSERT INTO bans (ip, reason, date) VALUES (?, ?, now())", | 				"INSERT INTO bans (ip, reason, date, end) VALUES (?, ?, now(), ?)", | ||||||
| 				array($ip, $reason)); | 				array($ip, $reason, $end)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public function remove_ip_ban($ip) { | 	public function remove_ip_ban($ip) { | ||||||
| @ -139,6 +141,7 @@ class IPBan extends Extension { | |||||||
| 				<tr> | 				<tr> | ||||||
| 					<td>{$ban['ip']}</td> | 					<td>{$ban['ip']}</td> | ||||||
| 					<td>{$ban['reason']}</td> | 					<td>{$ban['reason']}</td> | ||||||
|  | 					<td>{$ban['end']}</td> | ||||||
| 					<td> | 					<td> | ||||||
| 						<form action='".make_link("ip_ban/remove")."' method='POST'> | 						<form action='".make_link("ip_ban/remove")."' method='POST'> | ||||||
| 							<input type='hidden' name='ip' value='{$ban['ip']}'> | 							<input type='hidden' name='ip' value='{$ban['ip']}'> | ||||||
| @ -150,12 +153,13 @@ class IPBan extends Extension { | |||||||
| 		} | 		} | ||||||
| 		$html = " | 		$html = " | ||||||
| 			<table border='1'> | 			<table border='1'> | ||||||
| 				<thead><td>IP</td><td>Reason</td><td>Action</td></thead> | 				<thead><td>IP</td><td>Reason</td><td>Until</td><td>Action</td></thead> | ||||||
| 				$h_bans | 				$h_bans | ||||||
| 				<tr> | 				<tr> | ||||||
| 					<form action='".make_link("ip_ban/add")."' method='POST'> | 					<form action='".make_link("ip_ban/add")."' method='POST'> | ||||||
| 						<td><input type='text' name='ip'></td> | 						<td><input type='text' name='ip'></td> | ||||||
| 						<td><input type='text' name='reason'></td> | 						<td><input type='text' name='reason'></td> | ||||||
|  | 						<td><input type='text' name='end'></td> | ||||||
| 						<td><input type='submit' value='Ban'></td> | 						<td><input type='submit' value='Ban'></td> | ||||||
| 					</form> | 					</form> | ||||||
| 				</tr> | 				</tr> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user