Calling PHP in HTML

Hi all

I am trying to block certain IP addresses from countries that are continually hitting my blog that are inappropriate if you know what I mean. I have done a lot of searching and have found some php code that works. I am trying to embed that code into my blogger html code since blogger isn’t a huge fan of php. I have uploaded my php file to a host and it runs when I go to its direct URL but will not run when referencing it in the html.

Here is the php code for blocking the IP:

[php]

<?php // The blacklisted ips. $denied_ips = array( '127.0.0.1', '67.220.200.75' ); // The function to get the visitor's IP. function getUserIP() { //check ip from share internet if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } //to check ip is pass from proxy elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } //The user $visitorIp = getUserIP(); // Now let's search if this IP is blackliated $status = array_search($visitorIp, $denied_ips); // Let's check if $status has a true OR false value. if($status !== false) { echo "YOUR IP HAS BEEN BANNED."; // header("Location: http://zombo.com"); exit; } ?>
    </body>
[/php]

Here is the code for my html that I am trying to embed it with:

<script src='http://paganica.co.nf/BlogspotIPblocker.php' type='text/javascript'/>

<script language ='javascript' SRC='http://paganica.co.nf/BlogspotIPblocker.php' TYPE='text/javascript'></script>

I have tried placing either of those lines right above my tag in my html file for my blog and have had no luck.
This seems to be the code that everyone has recommended when embedding php into blogger but has not worked for me. What am I doing wrong?

This will not work. Your server must be configured to run PHP in the html extension.

See

probably a job for .htaccess
blocking individual IP’s like so:

deny from 111.222.333.444

or a range like so

deny from 111.222.333.444/999

:wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service