Page 11 of 19 FirstFirst ... 910111213 ... LastLast
Results 201 to 220 of 369

Thread: PHP class for communicating with DA

  1. #201
    Join Date
    May 2006
    Location
    Nijeveen, the Netherlands
    Posts
    8
    Now, I have this script:

    PHP Code:
    function DACreatePackage($da_packagename,$da_bandwith,$da_quota,$da_vdomains,$da_nemails) {
    $socket = new HTTPSocket

    $socket->connect($c_da_ip,2222); 
    $socket->set_login($c_da_username,$c_da_password); 

    $socket->set_method('POST');
    if(
    $da_nemails == "0") {
    $socket->query('/CMD_API_MANAGE_USER_PACKAGES',
        array(
            
    'packagename' => $da_packagename
            
    'bandwith' => $da_bandwith,
            
    'quota' => $da_quota,
            
    'vdomains' => $da_vdomains
            
    'nsubdomainschecked' => 'checked'
            
    'nemailschecked' => 'checked',     
            
    'nemailfchecked' => 'checked',
            
    'nemailmlchecked' => 'checked',
            
    'nemailrchecked' => 'checked',
            
    'mysqlchecked' => 'checked',
            
    'domainptr' => '5',
            
    'ftpchecked' => 'checked',
            
    'aftpchecked' => '',
            
    'cgichecked' => 'checked',
            
    'sslchecked' => 'checked',
            
    'sshchecked' => '',
            
    'dnscontrolchecked' => 'checked',
            
    'suspendatlimitchecked' => 'checked',
            
    'add' => 'Save'
        
    ));} 
        
    $result $socket->fetch_body();
        return 
    $result;
        } 
    If I run this script the error result is 0, but there's no package created in DA.
    What's wrong with this script?
    Too BiZZy? -> www.2bizzy.nl

  2. #202
    Join Date
    Aug 2005
    Posts
    264
    Don't you need to have something like
    global $c_da_ip, $c_da_username, $c_da_password;
    in there somewhere?

  3. #203
    Join Date
    May 2006
    Location
    Nijeveen, the Netherlands
    Posts
    8
    They were already load from the database like this:

    PHP Code:
    $settings mysql_query("SELECT * FROM settings");
    $s mysql_fetch_assoc($settings);

    $c_da_username $s["c_da_username"];
    $c_da_password $s["c_da_password"];
    $c_da_ip $s["c_da_ip"]; 
    So that's not the problem.
    Too BiZZy? -> www.2bizzy.nl

  4. #204
    Join Date
    Aug 2005
    Posts
    264
    That's not what I mean. It's not a matter of whether or not these variables have valid values or not. What I'm referring to is the 'scope' of these three variables. You have to declare them 'global' inside 'DACreatePackage', otherwise they won't be 'known' inside that function.

    PHP Variable scope: http://us2.php.net/variables.scope
    Last edited by Aspegic; 05-19-2006 at 08:33 AM.

  5. #205
    Join Date
    May 2006
    Location
    Nijeveen, the Netherlands
    Posts
    8
    Now I have this:

    PHP Code:
     function DACreatePackage($da_packagename,$da_bandwith,$da_quota,$da_vdomains,$da_nemails,$da_ip,$da_username,$da_password
    It's working!
    Thnx!
    Too BiZZy? -> www.2bizzy.nl

  6. #206
    Join Date
    Aug 2005
    Posts
    264
    That's another way of getting those variables in there

  7. #207
    Join Date
    Aug 2005
    Location
    Orlando
    Posts
    22
    Originally posted by ryant
    Are you trying to add a domain pointer?
    Yes. That would be correct. Just wanting to add a domain pointer via a form.

    Thanks.
    ---
    Oi!

  8. #208
    Join Date
    Apr 2006
    Location
    Thailand
    Posts
    201
    Wow, it's Great !

  9. #209
    Join Date
    May 2006
    Location
    Nijeveen, the Netherlands
    Posts
    8

    FTP limitations

    Is it possible to add a new FTP account with a space and bandwidth limit?
    Too BiZZy? -> www.2bizzy.nl

  10. #210
    Join Date
    Nov 2005
    Posts
    11
    I believe you can for FTP



    My question is : Using the "Create User" script given to us by the good guys of DA, how can i get the output info returned to me to print, instead of the whole web page. I need to know this as im including pages, and this messes things up

    Cheers people

  11. #211
    Join Date
    May 2006
    Location
    Nijeveen, the Netherlands
    Posts
    8
    You can use the $result

    sample:
    PHP Code:
    echo $result['error']; 
    I've got also a problem. I cant create resellers (the resellers will not be created in DA) with the following script:

    PHP Code:
    //DirectAdmin create reseller
    function DACreateReseller($da_user,$da_email,$da_password,$da_domein,$da_package,$da_ipadres,$da_ip,$da_username,$da_password) {
    //Connectie opzetten
    $socket = new HTTPSocket

    //Inloggen 
    $socket->connect($da_ip,2222); 
    $socket->set_login($da_username,$da_password); 

    $socket->set_method('POST');

    $socket->query('/CMD_API_ACCOUNT_RESELLER',
        array(
            
    'action' => 'create',
            
    'username' => $da_user// The User's username. 4-8 characters, alphanumeric
            
    'email' => $da_email// A valid email address
            
    'passwd' => $da_password// The User's password. 5+ characters, ascii
            
    'passwd2' => $da_password// Password double check. 5+ characters, ascii
            
    'domain' => $da_domein// A valid domain name in the form: domain.com
            
    'package' => $da_package// One of the User packages created by the Reseller
            
    'ip' => $da_ipadres// One of the ips which is available for user creation. Only free or shared ips are allowed.
            
    'notify' => 'no'// yes or no. If yes, an email will be sent to email
            
    'add' => 'Submit' //Submit
        
    ));
        
    $result $socket->fetch_body();
        return 
    $result;
        } 
    What's wrong in this script?
    Too BiZZy? -> www.2bizzy.nl

  12. #212
    Join Date
    Dec 2005
    Location
    Hendrik Ido Ambacht
    Posts
    6
    If i create an user with the api, i can't choose if spamassasin is enabled? Also suspend at limit, cron jobs and system info are off..
    I want to choose if they are on?

    How to fix that?

  13. #213
    Join Date
    Jul 2006
    Posts
    27
    Hey, im new here

    I'm not using your class, its just to much overkill for me and i rather write my own functions. However I do got some API questions.

    Customers can order more than one domain with a package, so I need to create a domainpointer by api after i add the package.

    The package with the standard domain is no problem, however, when I'm trying to add the domainpointer it says:

    Code:
    error=1&text=Could not excute your request&details=You do not own that domain
    The url/api im using:

    "CMD_API_DOMAIN_POINTER?domain=".$huidige."&action=add&from=".$nieuwe."alias=yes";

    Where $huidige is the domain that comes with tha package and the $nieuwe is the domain that should be add as a domainpointer.

    So is this possible to do with admin login or should i use user login?

  14. #214
    Join Date
    Jul 2006
    Location
    St. Louis
    Posts
    1

    add user and reseller

    Would you happen to have a post script written to add
    Resellers?
    An then another for resellers to add users?

  15. #215
    Join Date
    Aug 2006
    Posts
    4
    Originally posted by resolveit
    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
    When I'm trying to use this code, for examples those files:
    da_reseller_ipinfo.php
    da_list_resellers.php
    da_list_admins.php

    I'm gettin' a blank page.
    And yes, I changed the config file.
    How can I fix it ?

  16. #216
    Join Date
    May 2004
    Location
    Spain
    Posts
    207
    I am trying to obtain a listing of the directory of the present user of skin with the following php code (without success):
    PHP Code:
    |$/usr/local/bin/php
    <?php
    include 'httpsocket.inc';
    $Socket = new HTTPSocket;
    $Socket->connect('127.0.0.1',2222);
    $Socket->set_login($_SERVER['USER']);
    $Socket->query('/CMD_API_FILE_MANAGER', array('path' => '/'));
    $result $Socket->fetch_parsed_body();
    if(
    $result) {
        
    parse_str($result$x);
        
    print_r($x);
    } else { echo 
    "result = false"; }
    echo 
    "<br />Done...";
    ?>
    DONE|
    I only obtain the following result:

    Array ( [Array] => )
    Done...

    But when I execute the command 'http://example.com:2222/CMD_API_FILE_MANAGER?path=/' directly on the browser I obtain the correct string:

    %2F%2Ebash%5Flogout=date%3D%31%31%35%34%38%33%31....

    Somebody can say to me that I am making bad?

    Any help will be welcome, I am becoming crazy !

    Ramon

  17. #217
    change:
    PHP Code:
    $Socket->set_login($_SERVER['USER']); 
    to:
    PHP Code:
    $Socket->set_login("|USERNAME|"); 
    As this is DA, not apache, so the $_SERVER array isn't filled (I don't think)

    John

  18. #218
    Join Date
    May 2004
    Location
    Spain
    Posts
    207
    Thanks for the reply John,

    Same wrong result, I have proven with "|USERNAME|", "$_SERVER['REMOTE_USER']", "$_SERVER['USER']", without 'set_login', changing the API call, with GET, with POST,... I don't know that to prove more.

    All the times the same result:

    Array ( [Array] => )

    One array with 4 void elements and 401 http code, I am beginning to suspect that the class 'HTTPSocket' don't work from within of skin or that 'DA' prevents that it works.

    The only way to get the result is including the 'password' field in 'set_login', but this is not a solution when you wish to add some new feature to the skin.

    Somebody has been able to extract some result from within of any skin, calling any function of the API without password field in 'set_login'?

    Can you post any working example?
    Last edited by redesb; 08-30-2006 at 04:19 AM.

  19. #219
    Join Date
    May 2004
    Location
    Spain
    Posts
    207
    After some more tests, I found the problem. The script run without password but only in one new folder not in 'filemanager' folder.

    John, is there any restriction in the 'filemanager' folder that prevent the API call run?

  20. #220
    Yes, the filemanager is chrooted before the skins are processed. This means that when you access /usr/local/bin/php, the chroot makes it /home/username/usr/local/bin/php.

    John

Page 11 of 19 FirstFirst ... 910111213 ... 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
  •