Using .htaccess 












Using .htaccess/.htpasswd Password Protection 





Coding Tips 








Uploads and Downloads 



Mail 
see it on this page





Working with Images 


Frequently Requested Website Functionality 
see it on this page
see it on this page
see it on this page
see it on this page










Using PHP 




Website Managment 








Other Tips 









Automated Site Backups
Here is a php script that will create a compressed backup of your website files, creating a different file each day for a month (then start over) so you have 30 days of backups. It will email you with a backup confirmation. Run it every night using cron to kick it off. You should download the backup files from the server on a regular basis.
<?php
$emailaddress = "XXXXXX@yourdomain.com";
$path = "/full_server_path_to_file_goes_here"; // full server path to the directory where you want the backup files (no trailing slash)
// modify the above values to fit your environment
$target = $path . "/backup" . date(d) . ".tar.gz";
if (file_exists($target)) unlink($target);
system("tar --create --preserve --gzip --file=".$target." ~/public_html ~/mail",$result);
$size = filesize($target);
switch ($size) {
case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
case ($size>=1024); $size = round($size/1024) . " KB"; break;
default: $size = $size . " bytes"; break;
}
$message = "The website backup has been run.\n\n";
$message .= "The return code was: " . $result . "\n\n";
$message .= "The file path is: " . $target . "\n\n";
$message .= "Size of the backup: " . $size . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "Website Backup Message" , $message, "From: Website <>");
?>
