Page 4 of 19 FirstFirst ... 2345614 ... LastLast
Results 61 to 80 of 367

Thread: PHP class for communicating with DA

  1. #61
    Join Date
    Jul 2004
    Posts
    73
    How to create user "testuser" via reseller "testreseller" for example?

  2. #62
    Join Date
    Jun 2003
    Posts
    1,471
    Refrence: http://directadmin.com/api.html#create

    PHP Code:
    <?php

    include 'httpsocket.php';
    $Socket = new HTTPSocket;

    $Socket->connect('yoursite.com',2222);
    $Socket->set_login("{admin_username}","{admin_password}");
    // {admin_username} and {admin_password} are not specifically your administrative DA user,
    // but rather the user that you want to own this new user.

    $Socket->query('/CMD_ACCOUNT_USER',
        array(
            
    'username' => ''// The User's username. 4-8 characters, alphanumeric
            
    'email' => ''// A valid email address
            
    'passwd' => ''// The User's password. 5+ characters, ascii
            
    'passwd2' => ''// Password double check. 5+ characters, ascii
            
    'domain' => ''// A valid domain name in the form: domain.com
            
    'package' => ''// One of the User packages created by the Reseller
            
    'ip' => ''// One of the ips which is available for user creation. Only free or shared ips are allowed.
            
    'notify' => 'yes'// yes or no. If yes, an email will be sent to email
            
    'action' => 'create',
            
    'add' => 'Submit'
        
    ));
    $result $Socket->fetch_parsed_body();

    if ( 
    $Socket->get_status_code() != 200 || !empty($result['error']) )
    {
        
    // failure.
        
    echo "Failed to add new user: {$result['error']}<br />{$result['text']}";
    }

    // new user added.
    print_r($result);

    ?>
    Last edited by l0rdphi1; 09-09-2004 at 10:44 AM.
    Installatron Plugin is a native DirectAdmin plugin that provides you and your customers an intuitive interface to install, manage, upgrade, and backup/restore a premier collection of the best applications on the web, all instantly at the click of a button.

    Also: cPanel-to-DA converterBulk Domains and Sub-domain PluginDA User Tool

  3. #63
    Join Date
    Jul 2004
    Posts
    73
    How to check exists user "test" or no?

  4. #64
    Join Date
    Jun 2003
    Posts
    1,471
    RosT,

    You can do the following:[list=1][*]login through the API as test's owner[*]grab the array returned by CMD_API_SHOW_USERS[*]use in_array to test if test exists within the above array[/list=1]
    Phi1.
    Installatron Plugin is a native DirectAdmin plugin that provides you and your customers an intuitive interface to install, manage, upgrade, and backup/restore a premier collection of the best applications on the web, all instantly at the click of a button.

    Also: cPanel-to-DA converterBulk Domains and Sub-domain PluginDA User Tool

  5. #65
    Join Date
    Jul 2004
    Posts
    73
    Thanks.
    An how to get list of all domains in the directadmin database? Not for one user - for all.

  6. #66
    Join Date
    Feb 2004
    Location
    Colorado
    Posts
    4,111
    I don't see any specific comand for this in the api manual.

    So what you can do is get the list of all users, store it as an array. Then have it collect the domains that each owner has and display them. Probably using foreach

    Last edited by jmstacey; 09-10-2004 at 11:26 PM.
    Just do what it takes to make it happen

  7. #67
    Join Date
    Aug 2004
    Posts
    52
    for exp. I have 2 DA servers
    and one database of users (logins, domains and so on)

    user on 1 server created mydomain.com

    Is it possible by using your php-class disallow user on second server create same domain name? ....DA allow because it is not using same DNS

  8. #68
    Join Date
    Jun 2003
    Posts
    1,471
    This PHP class can only communicate with DA's API: www.directadmin.com/api.html

    Can't do what's not there
    Installatron Plugin is a native DirectAdmin plugin that provides you and your customers an intuitive interface to install, manage, upgrade, and backup/restore a premier collection of the best applications on the web, all instantly at the click of a button.

    Also: cPanel-to-DA converterBulk Domains and Sub-domain PluginDA User Tool

  9. #69
    Join Date
    Feb 2004
    Location
    Colorado
    Posts
    4,111
    If you are adding domains through a custom script that you made and not through Da then it would be possible, just not automatically through the api.

    You would have to have your script gather a domain list from both servers and then compare them to the domain trying to be created and if there are any matches fail because of a duplicate.
    Just do what it takes to make it happen

  10. #70
    Join Date
    Jun 2004
    Posts
    122
    Hello,

    It's very good and very easy to install this system. But i've got a little problem, my users register an account, automatically the user is create in directadmin but he is suspended, when the user pay their account with paypal, the account become "unsuspended" automatically, no problem for that. But, i want to send a "welcome message" after unsuspend an account, how I do that ? Thanks. Bye.

  11. #71
    Join Date
    Aug 2004
    Posts
    101

    problem creating a database using API

    Hi

    I'm struggling to create a database using the API.

    I can get a list of existing databases for the user's account, I can create POP mail boxes (this proves my socket and login work correctly) BUT every time I try to create a database i get

    Program Error
    Details: A segmentation fault has occurred
    If I set it up manually with the same name/user/password it works.

    If I attempt to create it when one already exists, it tells me it can't because my quota has been reached (i have max 1 db for this account type).

    I have tried both /CMD_DB and /CMD_API_DATABASES

    Here's the code for my latest attempt:
    • <?php

      include 'httpsocket.php';

      $sock = new HTTPSocket;

      $sock->connect('account ip address',2222);

      $sock->set_login("bloggs","******");

      $sock->set_method('POST');

      $mydata = array(
      'action' => 'create',
      'name' => 'db',
      'user' => 'usr',
      'passwd' => '******');

      $sock->query('/CMD_API_DATABASES',$mydata);

      $result = $sock->fetch_body();

      echo $result;

      ?>


    Whats going wrong?
    Last edited by mike_p; 10-01-2004 at 08:18 AM.
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  12. #72
    Join Date
    Mar 2004
    Posts
    764

    Re: problem creating a database using API

    Originally posted by mike_p
    Hi

    I'm struggling to create a database using the API.

    I can get a list of existing databases for the user's account, I can create POP mail boxes (this proves my socket and login work correctly) BUT every time I try to create a database i get



    If I set it up manually with the same name/user/password it works.

    If I attempt to create it when one already exists, it tells me it can't because my quota has been reached (i have max 1 db for this account type).

    I have tried both /CMD_DB and /CMD_API_POP

    Here's the code for my latest attempt:
    • <?php

      include 'httpsocket.php';

      $sock = new HTTPSocket;

      $sock->connect('account ip address',2222);

      $sock->set_login("bloggs","******");

      $sock->set_method('POST');

      $mydata = array(
      'action' => 'create',
      'name' => 'db',
      'user' => 'usr',
      'passwd' => '******',
      'passwd2'=> '******');

      $sock->query('/CMD_API_POP',$mydata);

      $result = $sock->fetch_body();

      echo $result;

      ?>


    Whats going wrong?
    First I am no expert but I believe you need to use /CMD_API_DATABASES to get this done.

    Kind Regards,
    Onno Vrijburg
    Onno Vrijburg

  13. #73
    Join Date
    Aug 2004
    Posts
    101
    Ooops - that was just a typo from my test to create POP boxes instead! [ I will now edit my original post ].

    But thanks anyway for a quick response.

    Last edited by mike_p; 10-01-2004 at 08:15 AM.
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  14. #74
    Join Date
    Mar 2004
    Posts
    764
    Can you post the code that gives you the segment fault. From your post I read that when you try to create a database you get a segment fault, is this correct? Or do you get the segment fault when you try to create POP accounts?

    Kind Regards,
    Onno Vrijburg
    Onno Vrijburg

  15. #75
    Join Date
    Aug 2004
    Posts
    101
    <?php

    include 'httpsocket.inc';

    $sock = new HTTPSocket;

    $sock->connect('ipaddress',2222);

    $sock->set_login("bloggs","bl0ggs");

    $sock->set_method('POST');

    $mydata = array(
    'action' => 'create',
    'domain' => 'bloggs.com',
    'name' => 'db',
    'user' => 'usr',
    'passwd' => 'bl0ggs',
    'passwd2'=> 'bl0ggs',
    'create' => 'Create'
    );

    $sock->query('/CMD_DB',$mydata);

    $result = $sock->fetch_body();

    echo $result;

    ?>


    The onlything Ive changed here is the ip address.
    Bloggs.com is a dummy account ive set up for testing.
    (DNS is handled by my local hosts file)
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  16. #76
    Join Date
    Mar 2004
    Posts
    764
    Originally posted by mike_p
    <?php

    include 'httpsocket.inc';

    $sock = new HTTPSocket;

    $sock->connect('ipaddress',2222);

    $sock->set_login("bloggs","bl0ggs");

    $sock->set_method('POST');

    $mydata = array(
    'action' => 'create',
    'domain' => 'bloggs.com',
    'name' => 'db',
    'user' => 'usr',
    'passwd' => 'bl0ggs',
    'passwd2'=> 'bl0ggs',
    'create' => 'Create'
    );

    $sock->query('/CMD_DB',$mydata);

    $result = $sock->fetch_body();

    echo $result;

    ?>


    The onlything Ive changed here is the ip address.
    Bloggs.com is a dummy account ive set up for testing.
    (DNS is handled by my local hosts file)

    If you read the API Documentation it says that you should use /CMD_DATABASES or /CMD_API_DATABASES and not /CMD_DB.

    Let me know if this works...
    Onno Vrijburg

  17. #77
    Join Date
    Aug 2004
    Posts
    101
    Thanks but that doesn't seem to give any improvement.

    Could someone who has succeeded please post their code?
    (Ive ended up trying so many different ways my heads now spinning!)

    For the enthusiasts here's my latest attempt using a different account (I don't mind posting account name etc and the DNS is normal)

    • <?php

      include 'httpsocket.inc';

      $sock = new HTTPSocket;

      $sock->connect('is-demo.co.uk',2222);

      $sock->set_login("isdemo","demo99");

      $sock->set_method('POST');

      $mydata = array(
      'action' => 'create',
      // 'domain' => 'is-demo.co.uk',
      'name' => 'db',
      'user' => 'usr',
      'passwd' => 'demo99'
      //'passwd2'=> 'demo99',
      //'create' => 'Create'
      );

      $sock->query('/CMD_API_DATABASES',$mydata);

      $result = $sock->fetch_body();

      echo $result;

      ?>


    Even the password is as-is - but will be changed in a few minutes time.

    Thanks for any further help.
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  18. #78
    Join Date
    Mar 2004
    Posts
    764
    There is also no mention of "domain" or "create" fields in the API Interface for databases.

    Regards,
    Onno
    Onno Vrijburg

  19. #79
    Join Date
    Mar 2004
    Posts
    764
    Ill work on it tonight and post some code later tonight.

    Regards,
    Onno
    Onno Vrijburg

  20. #80
    Join Date
    Aug 2004
    Posts
    101
    There is also no mention of "domain" or "create" fields in the API Interface for databases.
    They're commented out: when uing the /CMD_DB call they are required. By using the CMD_DB I was able to get the list of existing databases.

    Thanks for sticking with it!
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

Page 4 of 19 FirstFirst ... 2345614 ... LastLast

Similar Threads

  1. DA PHP Class with DA API Functions
    By DJVG in forum Scripting / API
    Replies: 14
    Last Post: 01-17-2012, 02:49 PM
  2. different nameserver for each Class C
    By gtgart in forum DNS
    Replies: 2
    Last Post: 11-20-2008, 03:50 PM
  3. Ruby API Class
    By voxxitdesigns in forum Scripting / API
    Replies: 21
    Last Post: 07-31-2008, 07:52 PM
  4. JAVA class for communicating with DA
    By gpfault in forum Scripting / API
    Replies: 0
    Last Post: 03-31-2005, 06:59 PM
  5. Da+php+da Class
    By fusionictnl in forum General Technical Discussion & Troubleshooting
    Replies: 0
    Last Post: 10-27-2004, 02:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •