Jump to content

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

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.