Web Hosting Talk







View Full Version : Automated Sub-Domain Setup


BNL989
04-05-2005, 02:46 PM
Hi,

I'm not sure if this is the correct area to post my question. I have a website where I would like to be able to let people specify their own subdomain (ie. myname.Companyname.com)

The domain should be created automatically for them where they can then login and being using the site right away. I have seen this done with a websites so I know that it is possible.

We have our own server which is Windows 2003 and the website is developed in PHP and PostgreSQL.

Does anyone know of a way that this can be done? I've read a few posts on how it is possible using Linux or Unix but so far haven't come across anything in a windows enviroment.

Thanks for the help!

dnguyen
04-08-2005, 09:15 PM
Give a a beer, I show you how :) (Joking) I also want to know to :)

Dylanz0r
04-08-2005, 09:22 PM
humms..

You'de need to chown the zonefile(s) for the specific domain to allow the script to write to it..

Add a simple form which adds a redirect rule for the added sub domain, to your .htaccess file.. might do.

This is just off the top of my head..

=-D
04-09-2005, 11:16 AM
hehe, first thing that comes off my head is if u use a control panel like cpanel installed on the server then u can use CURL top automate sub domain creation.

otherwise you'll need to do some fancy updating to the dns and apache config files.

:D gl!

UrlGuy
04-09-2005, 01:27 PM
If you need for cPanel I got that in PHP somewhere.. :)

orbitz
04-09-2005, 02:08 PM
Originally posted by UrlGuy
If you need for cPanel I got that in PHP somewhere.. :)

may I see the code urlguy

UrlGuy
04-09-2005, 02:40 PM
Make this sub.php:






<?php
include("settings.php");

$cpaneluser="user";
$cpanelpass="pass";
$domain="domain.com";
$subd="subdomaintoadd";
$cpanel_skin="x";



$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd";

$result = subd(localhost,2082,$cpaneluser,$cpanelpass,$request);

$show = strip_tags($result);

?>







Make this settings.php:




<?php
function subd($host,$port,$ownername,$passw,$request) {
global $email,$password;



$sock = fsockopen(localhost,2082);

if(!$sock)

{

print('Socket error');

exit();

}

$authstr = "$cpaneluser:$cpanelpass";

$pass = base64_encode($authstr);

$in = "GET $request\r\n";

$in .= "HTTP/1.0\r\n";

$in .= "Host:$domain\r\n";

$in .= "Authorization: Basic $pass\r\n";

$in .= "\r\n";

fputs($sock, $in);
while (!feof($sock)) {

$result .= fgets ($sock,128);

}
fclose( $sock );

return $result;

}

?>






I have made it working b4.
Should work... not tested.. if not working reply with failure notice and ill give it another try...

orbitz
04-09-2005, 04:12 PM
thanks urgly,

I just wanted to see it. i have DirectAdmin :)