Changeset 77
- Timestamp:
- 09/10/25 12:22:02 (4 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dnsbl/DNSBL.pm
r75 r77 242 242 my $rep = shift; 243 243 my $exclude = shift || 'n'; 244 $exclude = 'y' if $exclude eq 'on'; 244 245 my $sth; 245 246 my $rows = 0; … … 253 254 $sth = $dbh->prepare("INSERT INTO iplist (ip,parent,exclude) VALUES ". 254 255 "(?,(SELECT block FROM blocks WHERE block >> ? ORDER BY level DESC LIMIT 1),?)"); 255 $sth->execute($rep, $rep,($exclude ? 'y' : 'n')) or die "couldn't add entry for $rep: ".$dbh->errstr."\n";256 $sth->execute($rep, $rep, $exclude) or die "couldn't add entry for $rep: ".$dbh->errstr."\n"; 256 257 } elsif ($rows == 1) { 257 258 $sth = $dbh->prepare("UPDATE iplist SET count=count+1,". 258 " exclude =".($exclude ? "'y'" : "'n'"). " WHERE ip=?");259 " exclude = ? WHERE ip = ?"); 259 260 $sth->execute($exclude, $rep) or die "couldn't update listing for $rep: ".$dbh->errstr."\n"; 260 261 } else { … … 265 266 my $updsth = $dbh->prepare("UPDATE blocks SET ipcount=(". 266 267 "SELECT count(*) FROM iplist i JOIN blocks b ON b.block=i.parent WHERE i.ip << ? AND i.exclude='n' AND b.exclude='n'". 267 ") WHERE block =?");268 ") WHERE block = ?"); 268 269 while (my ($block) = $sth->fetchrow_array) { 269 270 $updsth->execute($block,$block); … … 410 411 } 411 412 $sth = $dbh->prepare("UPDATE blocks SET exclude = ?, comments = ?, ipcount = ". 412 "(SELECT count(*) FROM iplist WHERE ip << ? ANDexclude='n')".413 "(SELECT count(*) FROM iplist i JOIN blocks b ON b.block=i.parent WHERE i.ip << ? AND i.exclude='n' AND b.exclude='n')". 413 414 " WHERE block = ?"); 414 415 $sth->execute($exclude, $comment, "$block", "$block"); … … 559 560 $sth->execute($container); 560 561 ($bcount,$listme,$bexclude,$listorg) = $sth->fetchrow_array(); 562 $bcount = 0 if !$bcount; 561 563 $bitmask |= $bitfields{$level-1} if $bcount >= $autolist{$masklen}; 562 564 $bitmask |= $bitfields{"block".($level-1)} if $listme;
Note:
See TracChangeset
for help on using the changeset viewer.