The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled Perl Code
Posted by: alx | June 29, 2010 @ 6:13am
Perl Code
[
Download
]
#! /usr/bin/perl # load module use DBI; $mins=300; $rate_limit=10; $IP=$ARGV[0]; $current_time = `date +"%Y%m%d%H%M%S"`; $previous_time = `date +"%Y%m%d%H%M%S" -d "$mins minutes ago"`; # connect my $dbh = DBI->connect("DBI:mysql:database=logger;host=localhost", "dbuser", "dbpassword", {'RaiseError' => 1}); # execute SELECT query my $sth = $dbh->prepare("SELECT COUNT(*) FROM access WHERE IP='$IP' AND datetime >= '$previous_time' AND datetime < '$current _time'"); $sth->execute(); $count = $sth->fetchrow_array(); $sth->finish(); $count = "(Couldn't obtain count)" if !defined($count); print $count; # clean up $dbh->disconnect();
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.64 / 8
42 Votes
http://codebin.yi.org/719
page generated in 0.01 seconds