Wednesday, August 18, 2010

Hide .php extension or Hide PHP Usage using .htaccess

If You may not want other people to know that you are using PHP programming... Here is a easy ways to hide the fact that you're using PHP.
Use another extension than .php for your PHP files... your can use .foo, .blabla, .asp or even .htm and .html (in the later case, PHP parses all the files ending in .html, but it will work fine of course if some of these files are plain HTML; slowdown for parsing plain HTML is not noticeable even on the highest loads thanks to PHP's cache).
This process can be done easily by adding the following line to your .htaccess file in the same directory than your code:
AddType application/x-httpd-php .foo .blabla .asp .htm .html

Send html mail with PHP

$to = 'pleace your mail id here';
$subject =’Place your subject here’;
$random_hash = md5(date('r', time()));
$headers = 'From: '.$my_fname.' '.$my_lname.' ' ."< ".$my_email." >". "\r\n";
$headers .= "Reply-To: ". $my_email. "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$massage='|table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"|
|tr||td|Title :|/td||td|'.$my_title.'|/td||/tr|
|tr||td|First Name :|/td||td|'.$my_fname.'|/td||/tr|
|tr||td|Last Name :|/td||td|'.$my_lname.'|/td||/tr|
@mail( $to, $subject, $massage, $headers );

How to Ignore User Abort ?

When your script is doing something sensible work (like database updating etc.) and you absolutely don't want it to be interrupted by the user pressing the 'Stop' button of his browser. Then just add the following code to your script:


How to show PHP credits?.

Adding ?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000 at the end of the URL of PHP scripts will expose the PHP credits.

Create an image on the fly with the GD library

Run the following code to create an image on the fly:
header ("Content-type: image/png");
$im = @imagecreate (150, 50)
or die ("Sorry Couldn't create image!");
$background_color = imagecolorallocate ($im, 205, 205, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 2, 5, 5, "Your demo text goes here", $text_color);
imagepng ($im);

How to Save bandwidth

To save bandwidth add the following code at the beginning of your PHP page, and then PHP will automatically compress the page to web browsers that support with feature (support in both Internet Explorer and Mozilla Firefox do).
Since HTML can easily be compressed, you can expect to cut down by at least 2/3 the bandwidth used at the expense of some extra load on the server's CPU, but the CPU load difference usually isn't even noticeable.

@ini_set('zlib.output_compression_level', 1);

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off