CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 CREATE/DELETE Directory on AfterInsert or Afterupdate Events [PHP]

Print topic Send  topic

Author Message
feha


Posts: 712
Posted: 04/14/2006, 5:12 AM

I have developed theese functions in order to create dir's for Users/Clients ...
(Part of Vision.To CMS)

  
// =======================================================================================================  
function VISION_TO_CREATE_DIR($dir_name, $use_chmod = 0)  
{  
// by www.vision.to   
$report = "";  
ini_set('display_errors', '0');  
if (!file_exists($dir_name))  
{  
if($use_chmod==1)  
{   
mkdir ($dir_name, 0777);  
}   
else  
{  
mkdir ($dir_name);  
}  
if (file_exists($dir_name))  
{  
$report = "Vision.To CMS : DIR ".$dir_name." has been created!";  
  
$filename = $dir_name."index.php";  
if (!file_exists($filename)) {  
touch($filename); // Create blank file index.php  
if($use_chmod==1)  
{   
chmod($filename,0666);  
}  
}  
$filename = $dir_name."index.html";  
if (!file_exists($filename)) {  
touch($filename); // Create blank file index.html  
if($use_chmod==1)  
{   
chmod($filename,0666);  
}  
}  
$filename = $dir_name."index.htm";  
if (!file_exists($filename)) {  
touch($filename); // Create blank file index.htm  
if($use_chmod==1)  
{   
chmod($filename,0666);  
}  
}  
return $report;  
}  
else  
{  
$report = "Vision.To CMS Error: DIR ".$dir_name." IS NOT created!";  
return $report;  
}  
  
}  
else  
{  
$report = "Vision.To CMS Error: DIR ".$dir_name." already exists!";  
return $report;  
}  
}  
// =======================================================================================================  
function VISION_TO_DELETE_DIR($file,$use_chmod=1)  
{  
	ini_set('display_errors', '0');  
 if (is_dir($file)) {  
  $handle = opendir($file);  
  while($filename = readdir($handle)) {  
   if ($filename != "." && $filename != "..")  
   {  
   VISION_TO_DELETE_DIR($file."/".$filename);  
   }  
  }  
  closedir($handle);  
  if($use_chmod==1)  
  {  
  chmod($file,0777);  
  }  
  rmdir($file);  
 } else {  
  
 if($use_chmod==1)  
  {  
  chmod($file,0666);  
  }  
  unlink($file);  
 }  
}  
// =======================================================================================================   
example
afterinsert ...

VISION_TO_CREATE_DIR("directory_or_username");

the same way you use the function after delete ...

IF server Supports CHMOD than use:
VISION_TO_CREATE_DIR($user_id,1);
Not only creates directory but two files inside it
index.php and index.html

:-)


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
feha


Posts: 712
Posted: 04/14/2006, 5:18 AM

The Delete function deleted all content ... Sub-dirs etc ...
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
feha


Posts: 712
Posted: 04/14/2006, 5:22 AM

I modified sorry it will create three empty files if needed ...

index.php, index.htm and index.html ...

This is to "protect" users files from browsing ...
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.