Jump to content

Archived

This topic is now archived and is closed to further replies.

tomfmason

Createing multipule directorys

Recommended Posts

I have a script that is a work in progress.This script is for when I purchase a new domain or add a subdomain. So far I the following functions working 

[b]Functions[/b]
[list][*]updates ISC Bind's named.conf and creates a zone file
[*]reloads bind
[*]updates apache's httpd.conf and if need be sets some rewrite rules
[*]creates a directory for the new domain
[*]places a temporary index.php file in the new directory[/list]

Well now what I am wanting to do is when I add a new domain or sub domain I want to create two three directorys. Frist is the man directory then two subdirectorys say
test.mysite.com and two sub dirs like private and public

Any suggestions on how to do this would be great.

here is the createDir function.

[code=php:0]
function createDir() {
   global $domain;
   global $sub_domain;
   
   if (!$sub_domain) {
       $NewDir = mkdir("C:/home/admin/$domain");
   
       if (!$NewDir) {
           $result = "Unable to create the directory. Ether the permissions are not set or the directory already exits";
       }
   }else{
       $NewDir = mkdir("C:/home/admin/$domain/$sub_domain");
   
       if (!$NewDir) {
            $result = "Unable to create the directory. Ether the permissions are not set or the directory already exits";
       }
   }
   return $result;
}[/code]


Now you can see my simple function at the same time I create the domain or sub domain I want to creat two other directorys. Should I just repeat the mkdir three times or is there a better way of doing this?

Any suggestions would be great.

Thanks,
Tom            
                                                                                     

Share this post


Link to post
Share on other sites
here is the fix

[code=php:0]
function createDir() {
  global $domain;
  global $sub_domain;
 
  if (!$sub_domain) {
      $NewDir = mkdir("C:/home/admin/$domain");
 
      if (!$NewDir) {
          $result = "false";
      }else{
          $private = mkdir("C:/home/admin/$domain/private");
          $public = mkdir("C:/home/admin/$domain/public");
          $subs = mkdir("C:/home/admin/$domain/sub_domains");
          if ((!$private) || (!$public) || (!$subs)) {
  $result = "false";
          }else{ 
  $result = "true";
          }  
      }  
  }else{
      $NewDir = mkdir("C:/home/admin/$domain/sub_domains/$sub_domain");
 
      if (!$NewDir) {
          $result = "false";
      }else{
          $private = mkdir("C:/home/admin/$domain/sub_domains/$sub_domain/private");
          $public = mkdir("C:/home/admin/$domain/sub_domains/$sub_domain/public");
          if ((!$private) || (!$public)) {
              $result = "false";
          }else{ 
$result = "true";
          }        
      }   
  }
  return $result;
}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.