Jump to content

Createing multipule directorys


tomfmason

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            
                                                                                     

Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.