Tag: script Archives Not Just A Random Blog

07/05/2011

Hiding Email Addresses

by Cyle — Categories: php, tools — Tags: , , 2 Comments

Spam bots and email harvesting bots crawl web sites to find email addresses. It is important to hide the email addresses on your site. The best way of doing this is to turn the email address into an image.
Example:

How it Works

The PHP script uses the GD image library and converts text into an image. Since bots cannot “read” images, it cannot get your email address. When I want my email address to appear I use the <img> tag like so <img src="http://www.cconoly.com/blog/email.php?text=cconoly@cconoly.com">. The text is sent to a PHP file which takes the text and parameters like text size and angle and converts to an image. Read More » »

06/21/2011

Measuring Execution Time With PHP

by Cyle — Categories: php — Tags: , , , , 1 Comment

Some websites have how long it took to execute the website near the bottom of their pages. This can be entertaining, but it also servers another important purpose. I often use it to see if one of my pages is taking too long to load or hanging. To use this simple script, place this code at the top of your script:

<?php
function getCurTime()
    {
    $time = explode (' ',microtime());
    return(double) $time[0] + $time[1];
    }
$startTime = getCurTime();
?>

And this at the bottom of your script:

<?php
$endTime = getCurTime();
echo "Time to Execute = ".number_format(($endTime - $startTime),2)." seconds";
?>

You can change the “2″ in the number_format() function to however many decimal places you want. Below it is set to 6. If you notice your webpage taking too long to load, but not sure what piece is holding it up, you can move the script to the middle of the script or somewhere else and try to narrow it down that way.

Below is the same script but instead of measuring the execution time for the entire page, it just calculates the time it takes to execute the content of this blog post.

Time to Execute = 0.000018 seconds

06/02/2011

PHP Updating Copyright Script

by Cyle — Categories: php — Tags: , , , Leave a comment

Most all websites have a copyright disclaimer at the bottom of the page, but having a copyright line that is out of date can make a website look as if it is rarely updated. This simple php script keeps the copyright year current.

1
2
3
< ?php
echo '&copy; '.date("Y").' - Website Name';
?>

The code above Read More » »

© 2013 Not Just A Random Blog All rights reserved - Theme by ([][]) TwoBeers