Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Create Subdomain With PHP

Discussion in 'General Discussion' started by erictham, Feb 4, 2004.

  1. erictham

    erictham Member

    Joined:
    Jan 3, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    151
    I am thinking to make a code to add in my script (addmember.php) so that upon adding of members, it will go to CPANEL and call for the subdomain and redirect link and create the subdomain $username.domain.com and redirect to http://www.domain.com/username.

    So far i am only to find out till this part:

    http://username:password@domain.com:2082/frontend/x2/subdomain/index.html
    this link allows me to auto login to CPANEL and go to sub domain page.

    Down below is the direct links code to create accounts in WHM

    <?php

    $url = "http://$hostusername:$hostpassword@$hostdomain:2086/scripts/wwwacct?plan=Custom%20Plan&username=$username&password=$password&msel=$plan1&domain=$domainname$domain";
    $lines_array = file($url);
    while (list ($line_num, $line) = each ($lines_array)) {
    if ($line_num=="43"){
    $result = $line;
    $pos2 = strpos($result, " (");
    $pos1 = strpos($result, "| Ip: ");
    $ip_addr = substr($result, $pos1 + 6, $pos2 - ($pos1 + 6));

    $sql = "SELECT * FROM clients WHERE username='$username' AND domainname='$domainname'";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    $id = $myrow["id"];
    $sql = "UPDATE clients SET ipaddress='$ip_addr' WHERE id=$id";
    $result = mysql_query($sql);
    }
    }
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice