View Full Version : is it possible to automate multiple subdomains
daustin
10-13-2006, 11:35 PM
is it possible to automate multiple subdomains with hostmonster.
I want to be able to create subdomains based upon names in a SQL db, for example- JohnDoe.mydomain.com. Is there a method of doing this on a hosted site such as hostmonster? I assume hostmonster is using virtual hosting to setup user's sites. Is my request possible without setting-up my own Apache Server?
Thanks,
Dave
danforth
10-14-2006, 06:47 AM
I don't know about creating a sub-domain, but php could create a folder and any files you want it it. Go to php.net (http://php.net) and enter 'create_file' into their 'search functions' search box. There are example of how to use this function there.:rolleyes:
karimali831
10-14-2006, 06:50 AM
Sudomains totally free to use >> go to www.yoursite.com/cpanel and login... Then click on "subdomains" fill in information you want for your subdomain and if the page don't load up, this means you must edit in your server ".htacess." and this can be located from your public_html folder >> what ever you named the subdomain.
I suggest danforth's method. Assuming the users are registering somewhere on your site, in this script include a function that creates that new folder.
Not sure what you want to do with these new subdomains though?
WannabeArtist
10-14-2006, 09:02 AM
I think it might be possible to create a php script that automatically submits the setup info for the new subdomain to the cpanel, but I'm not exactly sure how you would go at this about it, as you would have to make the script log in with your admin data first.
The pages you would have to make the script load are
For the subdomain: http://<yourdomain>:2082/frontend/xpevolution/subdomain/doadddomain.php?domain=<newsubdomain>&rootdomain=<yourdomain>
For the FTP account: http://<yourdomain>:2082/frontend/xpevolution/ftp/doaddftp.php?login=<username>&password=<password>"a=unlimited&homedir=/home/<yourmainuser>/public_html/<subdomain>
Submitting the info on those two URLs would set up a new subdomain and a new FTP account locked to the directory of the new subdomain.
Update: Ok, I've tried setting up a simple php script that does what you want, and it works, so here's the jist, quite simple really.
<?php
// Define your cpanel login here
$mainuser = 'coolthin';
$mainpass = 'secretpass';
$maindomain = 'coolthing.com';
// Define the data for the new subdomain here
$newuser = 'sub1';
$newpass = '1234';
$newquota = 'unlimited';
// Load the page to set up the sudomain
$createSubResult = implode( '', file ('http://'.$mainuser.':'.$mainpass.'@'.$maindomain.':2082/frontend/xpevolution/subdomain/doadddomain.php?domain='.$newuser.'&rootdomain='.$maindomain));
// Load the page to set up the new FTP account
$createFTPResult = implode( '', file ('http://'.$mainuser.':'.$mainpass.'@'.$maindomain.':2082/frontend/xpevolution/ftp/doaddftp.php?login='.$newuser.'&password='.$newpass.'"a='.$newquota.'&homedir=/home/'.$mainuser.'/public_html/'.$newuser));
// Here you should probably include a check to see if everything went ok
// Use $createSubResult and $createFTPResult for that as it is the html output of the cpanel page
// We're done, here you can output the confirmation for the new user
echo "Success! You now have a new subdomain with us. Please allow a couple of hours for your fresh adress to go live while the changes propagate through the internet";
?>
danforth
10-15-2006, 04:39 AM
Didn't think of having the PHP access the cpanal. Great coding!;) I will save it for future use. You never know when you will want something like this...
virtualahmad
10-15-2006, 02:34 PM
wow... im impressed... i have absolutely no need for this, but i want to use it.
Good job.
nerdykit
04-18-2007, 11:03 PM
I tried the clever php script posted several replies above and found that it didn't work unless I shortened down the ftp creator's final bit to just &homedir=/newdomain instead of the full path that is created there. Then it works just fine.
I'm in the process of working it out as a full script but it DOES work almost as posted.
KMyers
05-27-2007, 10:45 PM
Any Update to this script, I see one large problem that I dont know how to work arround... The Subdomain is set up perfectly, However the FTP Account is allways set up with Root access (/) and unlimited storage
ivanmack
10-23-2007, 08:09 PM
i'm really looking for a script like that, i really need it for a small free subdomain host... i really like hostmonster and i don't want to get a VPS... any well built source codes? And is there a possible to add email account creation... Would be a great source, subdomain, ftp and email... Like every user would want... Thanks for the support by now!
Depeche1
10-29-2007, 07:14 PM
Wow that is awesome man, I ushually never use PHP but that thing is so cool I am saving it just in case.
Depeche
10-31-2007, 03:30 PM
Warning: file(http://...@domain.com:2082/frontend/xpevolution/subdomain/doadddomain.php?domain=sub1&rootdomain=domain.com) [function.file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/account/public_html/site/free.php on line 14
Warning: implode() [function.implode]: Bad arguments. in /home/account/public_html/site/free.php on line 14
Warning: file(http://...@domain.com:2082/frontend/xpevolution/ftp/doaddftp.php?login=sub1&password=1234"a=unlimited&homedir=/home/account/public_html/sub1) [function.file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/sdthrdsc/public_html/depechedesign/free.php on line 17
Warning: implode() [function.implode]: Bad arguments. in /home/account/public_html/site/free.php on line 17
Success! You now have a new subdomain with us. Please allow a couple of hours for your fresh adress to go live while the changes propagate through the internet
I get this error any help? Also I want it max of 10 MB storage with the ftp account to only allow at that area and no where else.
Depeche
11-01-2007, 12:39 PM
Anyone out there to help?
Use this one:
<?php
if (isset($create)) {
$login = "cpaneluser";
$pass = "cpanelpassword";
$domain = "domain.com";
$output = fopen ("http://$login:$pass@www.$domain:2082/frontend/hostmonster/subdomain/doadddomain.html?domain=$subdomain&rootdomain=$domain&dir=public_html/$subdomain", "r");
$output = fopen ("http://$login:$pass@www.$domain:2082/frontend/hostmonster/ftp/doaddftp.html?login=$subdomain&password=$ftppass&homedir=public_html/$subdomain"a=10", "r");
print ("Subdomain Created.<br>\n");
print ("You can now access it at <a href=\"http://$subdomain.$domain\">http://$subdomain.$domain</a><br>\n");
print ("You also have ftp access. Log in at <a href=\"ftp://ftp.$domain\">ftp://ftp.$domain</a> with the username $subdomain@$domain and the password $ftppass\n");
} else {
?>
<html>
<head>
<title>Automatic Subdomain Creator</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="<?php print($_SERVER['PHP_SELF']); ?>">
Subdomain: <input name="subdomain" type="text"><br>
Password: <input name="ftppass" type="password"><br>
<input name="create" type=submit value="Create">
</form>
<?php
}
?>
Depeche
11-01-2007, 02:04 PM
I did. I dumped my cache too. It will not redirect me. Am I supposed to put just the prefix or the whole thing. http://test.mydomain.com??
I did. I dumped my cache too. It will not redirect me. Am I supposed to put just the prefix or the whole thing. http://test.mydomain.com??
Just the prefix. This code works just fine for me...
You need to be using this right here
<?php
if (isset($create)) {
$login = "cpaneluser";
$pass = "cpanelpassword";
$domain = "domain.com";
$output = fopen ("http://$login:$pass@www.$domain:2082/frontend/hostmonster/subdomain/doadddomain.html?domain=$subdomain&rootdomain=$domain&dir=public_html/$subdomain", "r");
$output = fopen ("http://$login:$pass@www.$domain:2082/frontend/hostmonster/ftp/doaddftp.html?login=$subdomain&password=$ftppass&homedir=public_html/$subdomain"a=10", "r");
print ("Subdomain Created.<br>\n");
print ("You can now access it at <a href=\"http://$subdomain.$domain\">http://$subdomain.$domain</a><br>\n");
print ("You also have ftp access. Log in at <a href=\"ftp://ftp.$domain\">ftp://ftp.$domain</a> with the username $subdomain@$domain and the password $ftppass\n");
} else {
?>
<html>
<head>
<title>Automatic Subdomain Creator</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="<?php print($_SERVER['PHP_SELF']); ?>">
Subdomain: <input name="subdomain" type="text"><br>
Password: <input name="ftppass" type="password"><br>
<input name="create" type=submit value="Create">
</form>
<?php
}
?>
Depeche
11-01-2007, 02:07 PM
I put:
SUBDOMAIN :Form Box : test
PASSWORD : Form Box: pass
Then i click "Create" and it blanks the form boxes.
I go to my cPanel to see if it was created. But it's not.
I put:
SUBDOMAIN :Form Box : test
PASSWORD : Form Box: pass
Then i click "Create" and it blanks the form boxes.
I go to my cPanel to see if it was created.
I'm pretty sure that the password needs to be longer than 4 characters
Depeche
11-02-2007, 11:34 AM
Still doesn't work. It's on my add-on domain under a sub-domain.
Still doesn't work. It's on my add-on domain under a sub-domain.
I don't know what you're doing wrong. That exact script works just fine for me.
Are you getting any error messages?
Depeche
11-02-2007, 01:00 PM
It shows:
Subdomain: test
Password: thepassword
(Create)
I click create. Everything becomes blank.
Not supposed to be in cgi-bin right?
No it's not supposed to be in the cgi-bin. Also you did fill out the login info right?
This part with YOUR info
$login = "cpaneluser";
$pass = "cpanelpassword";
$domain = "domain.com";
Depeche
11-02-2007, 01:47 PM
No, I never put it in cgi-bin. And yes I did that part.
$login = "cpaneluser";
$pass = "cpanelpassword";
$domain = "domain.com";
Then I don't know what's wrong. I put that script into my public_html and in an add-on domain called sub.php and went to that page and it works.
Make sure that sub-domain doesn't already exist, that the password is longer than 5 characters, no spaces or special characters and the code is exactly what I have above.
hwystitch
11-03-2007, 05:03 PM
I have modified atomicmail to work on hostmonster, I also added the feature to set up a ftp account and subdomain at the same time as the email account is created.the scripts are in the attachment. you can preview it here.http://www.hwyman.com/test/addftpsub.php
features include:
check for exsisting email account.
check for special characters in name.
password confirmation.
sets up a ftp account with the same size storage as the email account.
(I can modify this to allow different sizes if desired.)
sets up a subdomain with the same name as the email account.
ftp account uses the email address as login and the same password as email.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.