<?php define ('BLACKLIST','black.list'); $list=file(BLACKLIST); foreach ($list as $addr) { $addr=trim($addr); $host_addr=$_SERVER['REMOTE_ADDR']; // Semplice indirizzo IP if ($host_addr==$addr) die ("Your IP is {$addr} and you're not allowed to view this page\n"); // Subnet di classe C else if (preg_match('/(\d+\.\d+\.\d+)\.0\/24/',$addr,$sub)) { $subnet=trim($sub[1]); if (preg_match("/^{$subnet}/",$host_addr)) die ("Your IP is {$host_addr} and you're not allowed to view this page\n"); } // Subnet di classe B else if (preg_match('/(\d+\.\d+)\.0\.0\/16/',$addr,$sub)) { $subnet=trim($sub[1]); if (preg_match("/^{$subnet}/",$host_addr)) die ("Your IP is {$host_addr} and you're not allowed to view this page\n"); } // Subnet di classe A else if (preg_match('/(\d+)\.0\.0\.0\/8/',$addr,$sub)) { $subnet=trim($sub[1]); if (preg_match("/^{$subnet}/",$host_addr)) die ("Your IP is {$host_addr} and you're not allowed to view this page\n"); } } ?>