[add] print flag
|
@ -5,23 +5,28 @@ ip=$2
|
|||
service=$3
|
||||
|
||||
curDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
echo $curDir
|
||||
|
||||
source $curDir/bancount.cfg
|
||||
|
||||
allInfoIp=`geoiplookup $ip`;
|
||||
|
||||
geoip () {
|
||||
geoiplookup $ip | awk -F, '{print $2}' | sed s/\ //
|
||||
echo $allInfoIp | awk -F, '{print $2}' | sed s/\ //
|
||||
}
|
||||
|
||||
countryCode () {
|
||||
echo $allInfoIp $ip | awk -F ": " '{ print $2 }' | awk -F "," '{ print $1 }' | head -n 1
|
||||
}
|
||||
|
||||
case $action in
|
||||
|
||||
ban)
|
||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO bans (ip, service, ban_date, ban_time, country) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip $ip`');"
|
||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO bans (ip, service, ban_date, ban_time, country, countryCode) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip`', '`countryCode`');"
|
||||
|
||||
;;
|
||||
|
||||
unban)
|
||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO unbans (ip, service, unban_date, unban_time, country) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip $ip`');"
|
||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO unbans (ip, service, unban_date, unban_time, country, countryCode) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip`', '`countryCode`');"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -36,4 +41,4 @@ EOF
|
|||
|
||||
;;
|
||||
|
||||
esac
|
||||
esac
|
||||
|
|
|
@ -29,6 +29,7 @@ CREATE TABLE `bans` (
|
|||
`ban_date` varchar(10) DEFAULT NULL,
|
||||
`ban_time` varchar(8) DEFAULT NULL,
|
||||
`country` char(50) NOT NULL DEFAULT 'Martians!',
|
||||
`countryCode` char(3) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
@ -47,6 +48,7 @@ CREATE TABLE `unbans` (
|
|||
`unban_date` varchar(10) DEFAULT NULL,
|
||||
`unban_time` varchar(8) DEFAULT NULL,
|
||||
`country` char(50) DEFAULT NULL,
|
||||
`countryCode` char(3) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
|
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 455 B |
After Width: | Height: | Size: 518 B |
After Width: | Height: | Size: 546 B |
After Width: | Height: | Size: 532 B |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 528 B |
After Width: | Height: | Size: 529 B |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 518 B |
After Width: | Height: | Size: 357 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 486 B |
After Width: | Height: | Size: 457 B |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 413 B |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 535 B |
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 526 B |
After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 459 B |
After Width: | Height: | Size: 528 B |
After Width: | Height: | Size: 513 B |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 546 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 529 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 481 B |
After Width: | Height: | Size: 423 B |
After Width: | Height: | Size: 330 B |
After Width: | Height: | Size: 504 B |
After Width: | Height: | Size: 532 B |
After Width: | Height: | Size: 530 B |
After Width: | Height: | Size: 413 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 526 B |
After Width: | Height: | Size: 526 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 366 B |
After Width: | Height: | Size: 437 B |
After Width: | Height: | Size: 505 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 519 B |
After Width: | Height: | Size: 491 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 529 B |
After Width: | Height: | Size: 401 B |
After Width: | Height: | Size: 470 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 430 B |
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 541 B |
After Width: | Height: | Size: 469 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 520 B |
After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 426 B |
After Width: | Height: | Size: 485 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 521 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 499 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 521 B |
After Width: | Height: | Size: 399 B |