If you’d like a record of how many visitors your website has had since going live, this simple PHP code will act as a counter and display it publicly for your users.
<?php
$file = “count.txt”;
$open = fopen($file, “r”);
$size = filesize($file);
$count = fread($open, $size);
$count1 = $count+1;
echo($count1);
fclose($open);
$open = fopen($file, “w”);
fwrite($open, $count1);
fclose($open);
?> |
Just add it to a part of the site where you’d like it displayed.
Demo:
Click Here to View Demo
For more Web Design resources visit Free Website Templates
Deterring problematic visitors to your website and relieveing certain parts of your site from spam can be achieved by adding the following PHP script to the pages where IP blocking is required. In order for this to function correctly however, your pages must be saved with the .php extension rather than .html.
Simply copy this code and paste it into the <HEAD> section of the HTML on your web page. Change the ‘xxx’ areas to the IP addresses you want to block and upload.
<?
$banned[0]=”xxx.xx.xxx.xx”;
$banned[1]=”xxx.xx.xxx.xx”;
$banned[2]=”xxx.xx.xxx.xx”;
$banned[3]=”xxx.xx.xxx.xx”;
if (in_array($_SERVER['REMOTE_ADDR'],$banned))
{
header(”HTTP/1.1 403 Forbidden”);
exit;
}
?> |
For more Web Design resources visit Free Website Templates