= $IPs[0] AND $IP <= $IPs[1]) { // yourls_die ( "Your IP has been blacklisted.", "Black list",403); echo "
Your IP has been blacklisted.
"; die(); } } } // Add admin page function ludo_blacklist_ip_add_page () { yourls_register_plugin_page( 'ludo_blacklist_ip', 'Blacklist IPs', 'ludo_blacklist_ip_do_page' ); } // Display admin page function ludo_blacklist_ip_do_page () { if( isset( $_POST['action'] ) && $_POST['action'] == 'blacklist_ip' ) { ludo_blacklist_ip_process (); } else { ludo_blacklist_ip_form (); } } // Display form to administrate blacklisted IPs list function ludo_blacklist_ip_form () { $nonce = yourls_create_nonce( 'blacklist_ip' ) ; $liste_ip = yourls_get_option ('ludo_blacklist_ip_liste','Enter IP addresses here, one entry per line'); if ($liste_ip != 'Enter IP addresses here, one entry per line' ) $liste_ip_display = implode ( "\r\n" , unserialize ( $liste_ip ) ); else $liste_ip_display=$liste_ip; echo <<BlackList IPs

Blacklist following IPs (one range or IP per line, no wildcards allowed) :

I suggest to add here IPs that you saw adding bulk URL. It is your own responsibility to check the use of the IPs you block. WARNING : erroneous entries may create unexpected behaviours, please double-check before validation.

Examples :

HTML; } // Update blacklisted IPs list function ludo_blacklist_ip_process () { // Check nonce yourls_verify_nonce( 'blacklist_ip' ) ; // Check if the answer is correct. $IP_Form = explode ( "\r\n" , $_POST['blacklist_form'] ) ; if (! is_array ($IP_Form) ) { echo "Bad answer, Blacklist not updated"; die (); } $boucle = 0; foreach ($IP_Form as $value) { $Retour = ludo_blacklist_ip_Analyze_IP ( $value ) ; if ( $Retour != "NULL" ) { $IPList[$boucle++] = $Retour ; } } // Update list yourls_update_option ( 'ludo_blacklist_ip_liste', serialize ( $IPList ) ); echo "Black list updated. New blacklist is " ; if ( count ( $IPList ) == 0 ) echo "empty."; else { echo ":
"; foreach ($IPList as $value) echo $value."
"; } }