I need that PHP script that was posted (or another one) for selecting certain IPs to show ads to. I want to block mine as well as my school's IPs because some "friends" are threatening to click bomb me.
<?php # These should be the ips you wanna show different ads too ... $block_ips = array( '84.556.78.90', '83.334.54.67', '86.162.24.120' ); # This is the normal advert code that you will display to most people ... $normal_ads = <<<NORMALADS The normal adcode here, with no special syntax NORMALADS; # This is dummy adcode that you display to the ppl in block_ips ... $blocked_ads = <<<BLOCKADS The blocked ads here, with no special syntax BLOCKADS; # This should be called in your code where you want to display the adverts ... function show_appropriate_ads( ) { global $block_ips, $normal_ads, $blocked_ads ; if( $_SERVER['X_FORWARDED_FOR'] ) { if( strpos( $_SERVER['X_FORWARDED_FOR'], ',' ) !== false ) { foreach( split( ',', $_SERVER['X_FORWARDED_FOR'] ) as $ip ) { if( in_array( trim( $ip ), $block_ips ) ) { return $blocked_ads ; } } } } elseif( $_SERVER['REMOTE_ADDR'] ) { if( in_array( $_SERVER['REMOTE_ADDR'], $block_ips ) ) { return $blocked_ads ; } } return $normal_ads ; } ?> <!-- some dummy html to test this shit out --> <html> <body> Welcome to the page ... <div id="ads"><?=show_appropriate_ads( ) ?></div> </body> </html> PHP: aaahhhhh.....
I'm trying to display this on a header php page that is used on the pages across my site, but it appears not to be blocking my IP.