Jump to content


Photo

Createing multipule directorys


  • Please log in to reply
1 reply to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 August 2006 - 11:51 AM

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 

Functions
  • 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

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.

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;
}


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            
                                                                                     


Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 August 2006 - 12:41 PM

here is the fix

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;
}

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users