Skip to content

Instantly share code, notes, and snippets.

@iovar
Created December 16, 2013 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iovar/7991268 to your computer and use it in GitHub Desktop.
Save iovar/7991268 to your computer and use it in GitHub Desktop.
<?php
if ( isset($_POST['input_data']) ){
$input_ip_list = explode ( "\n" , str_replace("\r", "", $_POST['input_data']) );
$selected_ip_list = array();
foreach( $input_ip_list as $line ) {
$new_ip = preg_match('/didn[^0-9a-zA-Z]*t[\s]+pass[\s]+through[\s]+redirect/',$line);
if ( $new_ip ){
$line_as_array = preg_split("/[\s\t]+/", $line);
$selected_ip_list[] = $line_as_array[2];
}
}
}
include 'template.php';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ip filter page</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<?php if( isset( $selected_ip_list ) && ! empty( $selected_ip_list ) ): ?>
<h2> <?php echo count( $selected_ip_list) ; ?> ip's match your criteria </h2>
<ul class="list-group">
<?php foreach( $selected_ip_list as $single_ip ) : ?>
<li class="list-group-item"><?php echo $single_ip; ?></li>
<?php endforeach; ?>
<?php elseif( isset( $selected_ip_list ) && empty( $selected_ip_list ) ): ?>
<h2> No ip's matched your criteria! </h2>
<?php endif; ?>
<h3>
Enter data to be filtered:
</h3>
<form action="./" method="POST" >
<textarea class="form-control" rows="8" name="input_data"></textarea>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment