Archive for December, 2008

How Do You Cope With Data Loss?

29 December 2008

A while ago I bought an USB flash drive. Lately, I’ve been storing some materials for a new site, and some other important data (such as a site engine in development). I had no backup anywhere, and a couple of days ago, it crashed. It just crashed, and all my data was gone down the drain.

accident

Years ago, I learned to save all my projects every few steps, again after some data loss. Right now, I will learn to always backup everything, not just stuff on my USB flash drive.

Include Remote Files With PHP

22 December 2008

If you have a script on a remote server and you are using PHP5, then you will not be able to use include() or require().

I learned that while trying to include a script on a subdomain (for speed).

The only solution is to use the file_get_contents() function instead.

That’s all. Your remote inclusion will now work.

Also view official documentation.

Harvest Emails From Text File

21 December 2008

You might have a text file with a lot of emails, extracted from a mail client or a CSV file created with some script.

Nonetheless, you want to extract all the valid email addresses (user@domain.ext) from the file. Pass this function a file

(you can rename it to .php, or .txt, or .csv) and it will extract all addresses.

function extract_emails_from($string) {
preg_match_all("/[._a-zA-Z0-9-]+@[._a-zA-Z0-9-]+/i", $string, $matches);
return $matches[0];
}

Usage:

<?php
extract_emails_from('myfile.txt');
?>

CSS Neon Menu

20 December 2008

The following menu was created yesterday while I was too tired to work, but too active to go to sleep. I thought it might be a good addition to my blog and someone could use it for navigation. No backlink is necessary.

neon-menu-preview

Download: CSS Neon Menu

PHP Random Images With Links

19 December 2008

I’ve been trying to enhance one of my current themes with a dynamic header. The header was supposed to show different images with different links to section of the blog. While searching on the internet for a viable PHP array randomizer function, this is what I ended up with. It works perfectly.

Download: PHP Random Images

Get Adobe Flash playerPlugin by wpburn.com wordpress themes