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 









Auto Password Change and Email Notification
This script will change your .htpasswd password to a new random password (with encryption) and send an email to notify you of the change. You can run this script automatically using cron at what ever interval you like, or run it manually.
<?php
$filename = "/XXXXXX/.htpasswd"; // the location of your .htpasswd file
$username = "XXXXXXX"; // the username specified in the .htaccess file
$length = "10"; // length of the password
$emailaddress = "you@yourdomain.com"; // email address
// change nothing below this line
// generate password
$spec_charset = array("!","@","#","$","%","^","&","*","_","+"."?","=");
$chars = array();
unset($pass);
for ($i = 1; $i <= $length; $i++) {
for ($i = 48; $i <= 57; $i++) $chars[] = chr($i); // numbers
for ($i = 65; $i <= 90; $i++) $chars[] = chr($i); // upper
for ($i = 97; $i <= 122; $i++) $chars[] = chr($i); // lower
foreach ($spec_charset as $i) $chars[] = $i; // special
for ($i = 1; $i <= $length; $i++) $pass .= $chars[rand(0,count($chars)-1)];
}
// build & write .htpasswd file
$encrypted = crypt($pass);
$output = "$username:$encrypted\n";
if (file_put_contents($filename,$output))
$message = "Your password has been changed to $pass";
else
$message = "There was an error creating your new password";
// send notification
mail($emailaddress,"Password Notification",$message,"From: Website <>");
?>
