Re: How to make it shorter and better?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: How to make it shorter and better?

From: Sandman <mr@sandman.net>
Date: Sat Apr 29 2006 - 12:03:19 CEST

In article <e2v6ho$ht7$2@news.tiscali.fr>, "AlGorr" <a@a.com> wrote:

> <snip>

It's pretty tight as it is.

# Setup
$ip = $_SERVER["REMOTE_ADDR"];
$timestamp = time()-900;

# Should we die?
$c = mysqlquery("select count(id) from banIP where ip = '$ip'");
list ($count) = mysql_fetch_assoc($c);
if ($count) die;

# Remove old stuff
mysql_query("delete from caspionet where timestamp < $timestamp");

# In Caspionet?
$c = mysqlquery("select count(id) from caspionet where ip = '$ip'");
list ($count) = mysql_fetch_assoc($c);
if (!$count){
    mysql_query("insert into caspionet...");
}

# Who's online?
$ips = mysql_query("select distinct ip from caspionet");
while ($r = mysql_fetch_assoc($ips)){
    print "IP: $r[ip]\n";
}

-- 
Sandman[.net]
Received on Mon May 1 03:07:19 2006