Page 5 of 19 FirstFirst ... 3456715 ... LastLast
Results 81 to 100 of 369

Thread: PHP class for communicating with DA

  1. #81
    Join Date
    Aug 2004
    Posts
    101
    Originally posted by resolveit
    Ill work on it tonight and post some code later tonight.

    Regards,
    Onno
    Thanks - thats very kind of you.
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  2. #82
    Join Date
    Mar 2004
    Posts
    764
    Well, I can report that I have it working. I want to complete a couple more API commands and will then release the interface, including forms and calls to the API. I will do this tonight so everybody can use it as they see fit.

    Kind Regards,
    Onno Vrijburg
    Onno Vrijburg

  3. #83
    Join Date
    Aug 2004
    Posts
    101
    Thanks
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  4. #84
    Join Date
    Mar 2004
    Posts
    764
    Here is what I have so far. I am making this available as open source and would appreciate it if other people woud contribute by building some of the classes or by fixing bugs in the code.

    I am fully aware that the code is not 100% and some results are not shown (could use help on this) but at least most of the completed classes work well.


    Content of the ZIP file
    /code - classes for the API
    /config - Configuration file (admin userID, password ...)
    /forms - Forms for entering data (links 1-1 to API classes)
    /protocol - httpsocket Class


    Kind Regards,
    Onno Vrijburg
    Attached Files Attached Files
    Onno Vrijburg

  5. #85
    Join Date
    Jun 2003
    Posts
    1,471
    Excellent package you have there, Onno. Your open-source package will be a HUGE help to those who are just getting started with DA's API.

    Cheers!
    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

  6. #86
    Join Date
    Aug 2004
    Posts
    101
    1/ Thanks for that Onno.

    Most functions seem to work for me.... except it still refuses to create a database! Your function reports that it worked OK - when it doesn't!

    I get the feeling there is a bug in my system somewhere.

    ----------------------------------------
    2/There are a couple of changes I would suggest to improve the output of some of the functions
    eg for

    da_list_accounts.php

    i would replace

    echo $result;

    with

    foreach ($result['list'] as $key => $value) {
    echo "$key : $value<br />\n";
    }

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

  7. #87
    Join Date
    Oct 2004
    Location
    The Netherlands
    Posts
    15
    Hi there.

    I'm having the same problem as mike_p, and I'm also using the exact same code that's been posted here (which is correct according to the API definitions here on da.com).

    If anyone has any more suggestions they'd be very welcome.

    edit: I'm also on DA 1.23

    Paul van der Walt
    Last edited by toothbrush; 10-21-2004 at 08:40 AM.

  8. #88
    Join Date
    Mar 2004
    Posts
    764
    This seems to be a problem in DA 1.23. I have just tried it on a box running DA 1.22 and it works, on another box running DA 1.23 it does not work.

    DASupport can you confirm that this is a problem in DA 1.23? Or help us solve the problem.

    Kind Regards,
    Onno Vrijburg
    Onno Vrijburg

  9. #89
    Join Date
    Aug 2004
    Posts
    101
    I had the problem before I upgraded to v1.23 (as well as after!).

    Does the API use the same system to connect to the database as the main DirectAdmin app? I'm wondering whether it may be a MySQL client library version issue.

    i.e. the mysql_connect function is deprecated in later versions
    and mysql_real_connect function takes different parameters depending on the version.
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  10. #90
    Join Date
    Oct 2004
    Location
    The Netherlands
    Posts
    15
    Not sure, could be. Did minimal research on the 'segmentation fault' error, found this bugreport: http://bugs.php.net/bug.php?id=25400, that doesn't seem to be useful except that it's MySQL's fault. The version mentioned there is 4.0.14, I have version 4.0.16.

    I find it very strange, I'm still getting that error even though I'm trying to fake a POST command which is essentially identical to the one used in the DA control panel (i.e. not using the API). Unfortunately I don't have any ideas.
    Paul van der Walt

  11. #91
    Join Date
    Aug 2004
    Posts
    101
    Onno -

    If you have a box on which it works and one where it doesn't, could you please compare the mysql client libraries in use on each?

    Perhaps there is a conflict depending on whether you use the
    mysql-shared-compat or the mysql-shared libraries.
    On my server I've got the shared-compat libraries. (MySQL-shared-compat-4.0.16)

    Mike
    Mike
    ... an impresssed DA user, slowly gaining experience over the years...

  12. #92
    Join Date
    Oct 2004
    Location
    The Netherlands
    Posts
    15
    Hi. I had a slight problem with the CMD_API_SHOW_USER_DOMAINS api. The problem is this: the api definition says that the return will be in the form of Array(domain.com,domain1.com) etc, and this is true when I open http://adminuser:adminpass@mydomain....NS?user=myuser. I then get the following:

    Code:
    userdomain.com=14.6848:unlimited:1.86753:4.5522:0:no:unlimited:ON:ON:ON:
    The funny thing is that when I use the http socket library to access the api the same is returned, but with the format "userdomain_com" as the variable name in the array. Very strange. So for example this code:

    PHP Code:
    $listSocket = new HTTPSocket;

    $listSocket->connect($siteurl,$siteport);
    $listSocket->set_login($adminusername,$adminpassword);

    $listSocket->query('/CMD_API_SHOW_USER_DOMAINS',array('user'=>'myuser'));

    $listresult $listSocket->fetch_parsed_body();
    print_r($listresult); 
    ...I get the following output:

    Code:
    Array
    (
    [userdomain_com] => 14.3521:unlimited:1.86654:4.48669:0:no:unlimited:ON:ON:ON:
    )
    Does anyone have any idea why this is? I have implemented a workaround but would still like to know the reason.

    Thanks,
    Paul van der Walt

  13. #93
    Join Date
    Jun 2003
    Posts
    1,471
    I believe PHP's parse_str function replaces periods with underscores.

    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

  14. #94
    Join Date
    Oct 2004
    Location
    The Netherlands
    Posts
    15
    Originally posted by l0rdphi1
    I believe PHP's parse_str function replaces periods with underscores.

    Phi1.
    PHP.net:
    Note that variables cannot contain a DOT (.) in PHP. So, DOT will be replaced by underscore. e.g. variables like "variable.something" will be converted into "variable_something".
    Great, a logical explanation
    Paul van der Walt

  15. #95
    Join Date
    Sep 2003
    Posts
    97
    I have
    PHP Code:
    <?php

    include 'httpsocket.php';

    $sock = new HTTPSocket;

    $sock->connect('p44.org',2222);
    $sock->set_login('admin','passs');

    $sock->query('/CMD_API_SHOW_ALL_USERS');
    $result $sock->fetch_parsed_body();

    foreach (
    $result as $user) {
    echo 
    "$user <br />";
    }

    ?>
    and I know I screwed up something, anyone with a spare second wanna help? i want to list all users without the array crap showing.
    Useful Links: [:: Intro to Unix :: Direct Admin Support ::]
    Web programing/design: [:: PHPFreaks :: W3 :: Good Tutorials ::]

  16. #96
    Join Date
    Oct 2004
    Location
    The Netherlands
    Posts
    15
    PHP Code:
    ...
    foreach (
    $result as $user) {
    echo 
    "$user <br />";
    }
    ... 
    I have a feeling the foreach needs the following changes:

    PHP Code:
    foreach ($result['list'] as $key => $user) {
    echo 
    "$user <br />";

    Give that a try and tell me what happens HTH
    Paul van der Walt

  17. #97
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    1,055
    Problem:

    Authentication doesn't work when having special characters like:

    < or + or / or -

    A lot of passwords on my server have those characters and is accepted by DA.

    But when using the DA Class it isn't working at all. Somehow DA or the API translates it the wrong way.

    Please can someone verify this by just using a password with a < or a + or something or both :P

    Thx!

  18. #98
    Join Date
    Jun 2003
    Posts
    1,471
    Hello,

    Looking at my source, passwords as passed to DA like this:
    $array_headers['Authorization'] = 'Basic '.base64_encode("$this->remote_uname:$this->remote_passwd");
    That's a pretty standard format, so I'm not sure where the problem is. Perhaps this is a problem with DA? Or you're doing something silly?

    I'd confirm right now if I wasn't so busy

    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

  19. #99
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    1,055
    I have tested it with curl_exec and it goes exactly the same way wrong.

    Edit: I have changed the password without those characters and it goes great!

    So there's definitly something wrong with the encoding procedure. Or DA's way of translating the passwords out of the headers!
    Last edited by fusionictnl; 10-27-2004 at 03:16 AM.

  20. #100
    Join Date
    Jun 2004
    Location
    Gdynia [Poland]
    Posts
    39

    Angry

    PHP Code:
    <pre><?
    ob_start
    ();
    include 
    'httpsocket.php';

    include 
    'funkcje.php';

    polaczenie();

    $da = new HTTPSocket;

    $da->connect('thc.net.pl','2222');
    $da->set_login('admin','***');
    $sql "SELECT login FROM thc_konta WHERE oplacone = '0' AND powiadomiony = '1'";
    $r zapytanie($sql);
     while(
    $w mysql_fetch_assoc($r))

    {
        
    $tab = array ('location' => '/CMD_SELECT_USERS',
              
    'suspend' => 'Suspend',
              
    'select' => "$w[login]");
        
    $da->query('/CMD_SELECT_USERS'$tab); 
    print_r($da);
        
    $rez $da->fetch_parsed_body();
        
    $r2 $da -> fetch_body();
        echo 
    $r2;
        
    ?>
        <br><hr><b> <? echo $w[login];?> </b>
        <?
        print_r
    ($rez);
        if( !empty(
    $rez[error]))
        {
        echo 
    "User ".$w[login]." nadal ma konto<br>";
        }
        else
        {
        echo 
    "User ".$w[login]." ma zablokowane konto :-) <br>";
        }
    }
    echo 
    "<br> Lacznie : ".mysql_num_rows($r);

    ob_end_flush();
    ?>
    result is:
    httpsocket Object
    (
    [version] => 2.3
    [method] => GET
    [remote_host] => thc.net.pl
    [remote_port] => 2222
    [remote_uname] => admin
    [remote_passwd] => ***
    [result] => HTTP/1.1 404 Not found
    Server: DirectAdmin Daemon v1.23.1 Registered to Piotr Kloc
    Content-Type: text/html

    Error: document not found

    [result_header] => HTTP/1.1 404 Not found
    Server: DirectAdmin Daemon v1.23.1 Registered to Piotr Kloc
    Content-Type: text/html
    [result_body] => Error: document not found

    [bind_host] =>
    [error] => Array
    (
    )

    [query_cache] => Array
    (
    [0] => GET /CMD_SELECT_USERS?location=%2FCMD_SELECT_USERS&suspend=Suspend&select=gigi1990 HTTP/1.0
    User-Agent: HTTPSocket/2.3
    Host: thc.net.pl:2222
    Accept: */*
    Connection: Keep-Alive
    Authorization: Basic YWRtaW46dGdpNUFwZUY=


    [1] => GET //CMD_SELECT_USERS HTTP/1.0
    User-Agent: HTTPSocket/2.3
    Host: thc.net.pl:2222
    Accept: */*
    Connection: Keep-Alive
    Authorization: Basic YWRtaW46dGdpNUFwZUY=


    )

    [doFollowLocationHeader] => 1
    )
    Error: document not found
    wft? :|

Page 5 of 19 FirstFirst ... 3456715 ... LastLast

Similar Threads

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