rewrite.php

June 6th, 2012 by Idris

#!/usr/bin/php
<?php

$con=mysql_connect(”localhost”,”coba”,”cobaa”);
$db=mysql_selectdb(”coba”);
$temp = array();
while ( $input = fgets(STDIN) ) {
$status=false;
$temp = split(’ ‘, $input);
$ips = split(’/',$temp[1]);
$ip = $ips[0];
$uri=$temp[0];
$qq=mysql_query(”SELECT ip FROM logon where status=’1′ and ip=’$ip’”);
$dt=mysql_num_rows($qq);
if($dt >= 1)
$status=true;

$host=parse_url($uri, PHP_URL_HOST);
if($host==”202.9.85.3″)
$status=true;

if (strlen(strstr($host,”eepis-its.edu”))>0)
$status=true;

if ($status==true)
{
$output = $temp[0].”\n”;
}
else {
$output = “302:http://galatea.eepis-its.edu/squid/?j=”.base64_encode($ip).”&i=”.base64_encode($uri).”\n”;
}
echo $output;
}

Leave a Reply