Jump to content

Creating Folders And Symbolic Links


JustinK101

Recommended Posts

Hello,

 

I am running Linux with PHP5 and cPanel. I need a script which does the following file work:

 

1.) Goes to the root http directory /.

2.) First looks if there is a folder called 'customerXYZ'

3.) If no folder called 'customerXYZ' then create it. ELSE output an error message.

4.) Create a symbolic link from folder 'customerXYZ' to another folder I have already created, lets call it 'software'.

 

If possible but I suspect not, create a subdomain in cPanel with name customerXYZ.mydomain.com which points to the logical folder 'customerXYZ'.

 

Thanks for the help guys.

 

Link to comment
https://forums.phpfreaks.com/topic/89465-creating-folders-and-symbolic-links/
Share on other sites

Here is what I created. Everything works great except the auto create of a cPanel subdomain. I am thinking it can be done using exec("SOME APPLICATION CALL AND ARGUMENTS HERE"). Anybody have ideas?

 

function setup_client($dir_name, $symbolic_link_path) {
		global $error_text;

		$prev_umask = umask(0); 

		try {
			if(@file_exists($dir_name)) {
				throw new Exception("ERROR: Directory '" . $dir_name . "' already exists; cannot create duplicates.\\n\\n" . $error_text);
			}

			if(@!symlink($symbolic_link_path, $dir_name)) {
				throw new Exception("ERROR: Failed to create symbolic link '" . $dir_name . "'.\\n\\n" . $error_text);	
			}
		}
		catch (Exception $e) {
			$msg = new alert($e->getMessage());
			echo $msg->display();
		}

		umask($prev_umask);
	}

Archived

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

×
×
  • 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.