Subdomains Through The PHP SCRIPT ?

phpdeveloper83

New member
Joined
Jan 23, 2012
Messages
1
Dear All ,

I want to make sub-domains using php scripts . Means i dont want use control panel .
I want help from you guys .

Thanks in advance from my heart.


Awaiting your response.

Thanks and Regards
Jai
 
You can use PHP API (search on the forum)

here the one for subdomain:

Code:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('localhost',2222);

$sock->set_login("admin|user","admin_password");

$sock->set_method('POST');

$sock->query('/CMD_API_SUBDOMAINS',
        array(
                'action' => 'create',
                'domain' => 'MAINDOMAIN',
                'subdomain' => 'SUBDOMAIN_NAME',
                'create' => 'Create'
    ));

$result = $sock->fetch_body();

?>

Hope it help.

Regards
 
Hi everyone,

I want to create a php script to my client which allow to create a subdomain from wordpress. But I have problem in first step. This is my code:
Code:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('127.0.0.1',2222);

$sock->set_login("admin","password");

$sock->set_method('POST');

$sock->query('/CMD_SUBDOMAIN',array( 'action' => 'create',
'domain' => 'directadmin.pl', 'subdomain' => 'test.directadmin.pl' ));


?>

No error no results in directadmin. What is wrong ?

Kind regards
 
Hello,

There might be numerous reasons on that. Then it should be "admin|user" where both admin and user should present (of course you should replace admin with a real name of your re-seller if it differs from admin and replace user with a real name of domain's owner).

p.s. You missing:

PHP:
$result = $sock->fetch_body();

update it with:


PHP:
$result = $sock->fetch_body();
var_dump($result);

to see results.
 
I have another problem. Let say I create a php script under directadmin.com domain. When I run that script a subdomain ex. php.directadmin.com is create in /home/user/domains/directadmin.com not in /home/user/domains/php.directadmin.com why ?

Kind regards
 
That's how Directadmin works. Add a sub-domain as a regular domain if you want a separate public_html directory.
 
Back
Top