One of the functions that might be very useful for web development is to create a protected folder on the fly so you can upload files for example without worrying that anyone can access these files.
/**
* Create .htaccess protected folder
*
* @param $folder folder path
* @return
**/
function smkdir($folder){
if (!is_dir($folder)) {
mkdir($folder,0777);
}
if (!$handle = fopen($folder.”.htaccess”, ‘a’)) {
echo “Impossible d’ouvrir le fichier ($filename)”;
exit;
}
$protect = “AuthType Basic
AuthName “No access”
AuthUserFile .htnopasswd
AuthGroupFile /dev/null
Require valid-user
“;
fwrite($handle, $protect);
fclose($handle);
}
This function could be also useful to create folder with a specified home page inside or redirection. To use it, imagine we want to install an application that create alphabetic folders to organize projects or other.
/**
* Check if fonts folder isn’t created and create it.
*
* @param $base base path to create folder inside
* @return
**/
function install_check($base)
{
if (!is_dir($base)) {
smkdir($base);
for($i = 65; $i
Hope it could be helpful
Tags: No Tags





December 13th, 2005 at 11:03 am
Hi
Can you help me regarding the code.Its urgent
Thanks
December 13th, 2005 at 6:49 pm
How can I help you ? the code is working, check the source of this page you’ll find the code between
Sorry i didn’t fix all my blogs yet.