diff --git a/modules/security/bot-blocker.sh b/modules/security/bot-blocker.sh index 359a4a3..62091ca 100755 --- a/modules/security/bot-blocker.sh +++ b/modules/security/bot-blocker.sh @@ -45,13 +45,11 @@ check_apache_config_exists() { if [ ! -d "$conf_dir" ]; then print_warning "Apache config directory doesn't exist: $conf_dir" echo "" - read -p "Create directory? (yes/no): " create_dir - if [ "$create_dir" = "yes" ]; then - mkdir -p "$conf_dir" - print_success "Created directory: $conf_dir" - else + if ! confirm "Create directory?"; then return 1 fi + mkdir -p "$conf_dir" + print_success "Created directory: $conf_dir" fi if [ ! -f "$APACHE_CONF" ]; then @@ -145,8 +143,7 @@ enable_bot_blocking() { if is_bot_blocking_enabled; then print_warning "Bot blocking is already enabled" echo "" - read -p "Re-apply configuration? (yes/no): " reapply - if [ "$reapply" != "yes" ]; then + if ! confirm "Re-apply configuration?"; then return 0 fi disable_bot_blocking_silent @@ -454,25 +451,37 @@ show_menu() { echo "" echo -e "${BOLD}Configuration:${NC}" echo "" - echo " 1) Enable Bot Blocking - Block malicious bots and scrapers" - echo " 2) Disable Bot Blocking - Remove blocking rules" - echo " 3) View Configuration - Show current rules" + echo -e " ${CYAN}1)${NC} Enable Bot Blocking - Block malicious bots and scrapers" + echo -e " ${CYAN}2)${NC} Disable Bot Blocking - Remove blocking rules" + echo -e " ${CYAN}3)${NC} View Configuration - Show current rules" echo "" echo -e "${BOLD}Maintenance:${NC}" echo "" - echo " 4) Test Configuration - Validate Apache syntax" - echo " 5) Manage Backups - View and restore backups" + echo -e " ${CYAN}4)${NC} Test Configuration - Validate Apache syntax" + echo -e " ${CYAN}5)${NC} Manage Backups - View and restore backups" echo "" - echo " 0) Back to Security Menu" + echo -e " ${RED}0)${NC} Back to Security Menu" echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - echo -n "Select option: " + echo -n "Select option (0-5): " } main() { while true; do show_menu - read -r choice + + # Validate choice input + while true; do + read -r choice + + if ! [[ "$choice" =~ ^[0-5]$ ]]; then + echo "" + print_error "Invalid choice. Please enter 0-5" + echo "" + continue + fi + break + done case $choice in 1) enable_bot_blocking ;; @@ -484,11 +493,6 @@ main() { clear exit 0 ;; - *) - echo "" - print_error "Invalid option" - sleep 1 - ;; esac done }