Page 17 of 19 FirstFirst ... 71516171819 LastLast
Results 321 to 340 of 367

Thread: PHP class for communicating with DA

  1. #321
    Join Date
    Nov 2011
    Posts
    7
    Hello,
    anybody could make php that will create domains from a file txt, for example i need to add 50domains, is it possible?
    cheers.

  2. #322
    Join Date
    Jun 2009
    Posts
    557
    Yes it is possible.

  3. #323
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Quote Originally Posted by qlwik View Post
    Hello,
    anybody could make php that will create domains from a file txt, for example i need to add 50domains, is it possible?
    cheers.
    Hello,

    Feel free to PM me, if you need my assistance.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  4. #324
    Join Date
    Feb 2012
    Posts
    4
    hi, is there i class for list received emails in a pop account??
    i asked also here:
    http://www.directadmin.com/forum/showthread.php?t=42749

  5. #325
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Read this http://php.net/manual/en/book.imap.php, that's what you might need to look at.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  6. #326
    Join Date
    Aug 2012
    Posts
    6

    Question Error when extract file

    Hi everyone,
    I have trouble when extract file using CMD_API_FILE_MANAGER. Here is my code:
    PHP Code:
        include('httpsocket.php');
        
    // init
        
    $username 'user';
        
    $domain 'domain.com';
        
    $pass 'password';
        
    $path "/domains/".$domain."/public_html/myfile.tar.gz";
        
        
    $sock = new HTTPSocket;
        
        
    $sock->connect($domain2222);
        
    $sock->set_login($username$pass);
        
        
    $data = array(
            
    'path' => $path,
            
    'action' => 'extract',
            
    'page' => 2
        
    );
        
        
    $sock->query('/CMD_API_FILE_MANAGER'$data);
        
    $result $sock->fetch_parsed_body();
        
    print_r($result); 
    The error is: You must enter a valid directory.
    With the same path, i run code to set file permission, and it run ok.
    Please help me, thank so much!

  7. #327
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    I guess documentation here http://www.directadmin.com/features.php?id=652 is missing one detail directory where to extract files, so your request should look like the following:

    PHP Code:
        $data = array( 
            
    'path' => $path
            
    'directory' => '/',
            
    'action' => 'extract'
            
    'page' => 
        
    ); 
    Note, you might need to change directory to whatever you want, so try different values here.

    We should bring this to John's attention.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  8. #328
    Join Date
    Aug 2012
    Posts
    6

    Smile

    Thanks a lot, zEitEr! It's work!!! Have a nice day!

  9. #329
    Join Date
    Aug 2012
    Posts
    6

    Question Upload file with method "POST"

    Hi,
    I try to upload file to my host with method POST. As below:
    PHP Code:
        include('httpsocket.php');
        
    // init
        
    $username 'user';
        
    $domain 'domain.com';
        
    $pass 'password';
        
    $path "/domains/".$domain."/public_html/";
        
    $file "myfile.zip";
        
        
    $sock = new HTTPSocket;
        
        
    $sock->connect($domain2222);
        
    $sock->set_login($username$pass);
        
    $sock->set_method('POST');
        
        
    $data = array(
            
    'enctype' => "multipart/form-data",
            
    'action' => 'upload',
            
    'path' => $path,
            
    'file1' => $file
        
    );
        
        
    $sock->query('/CMD_API_FILE_MANAGER'$data);
        
    $result $sock->fetch_parsed_body();
        
    print_r($result); 
    When i run this code, the output is (in 'httpsocket.php'):

    + Undefined offset: 1 in list($this->result_header,$this->result_body) = preg_split("/\r\n\r\n/",$this->result,2);
    + Undefined offset: 1 in list($key,$value) = preg_split("/: /",$pair,2);

    In 'httpsocket.php', with POST, value of $this->result is only 'HTTP/1.1 200 OK' so $this->result_body is null and print_r($result); return an empty array.
    But with GET, $this->result has full value.

    What's wrong in this case? Do i make something wrong? Please help me. Thanks!

  10. #330
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    1. To upload file you should use only POST
    2. Make sure, your script finds $file, you might need to put here a full path to the file.
    3. I guess you need to send in file1 not a path to the file, but it's content:

    Upload a file:
    method must be POST
    enctype="multipart/form-data" .. must encode it properly.
    action=upload
    path=/path/you're/uploadingto
    file1=filename
    ... this isn't straight forward, you'll need to lookup up how a browser sends/encodes the files to duplicate this.
    so read the content of the file, encode it and only then send it.

    See this http://www.php.net/manual/en/functio...open.php#62380 as it might help you to attach a file into your request.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  11. #331
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    I've just uploaded a file and here is the debug output from Directadmin, I've got this result:

    Code:
    Post string: MAX_FILE_SIZE=10485760&action=upload&file1=/home/tmp/my_file1.tar.gzE0ChMS&file2=/home/tmp/my_file2.tar.gz0qS2n0&path=/private
    So, anyway you should use full path to the file and locate it in place accessible by directadmin (here it is /home/tmp/).
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  12. #332
    Join Date
    May 2012
    Posts
    7

    Check port and using SSL for DirectAdmin

    I'm create plugin for Direсtаdmin using httpsосket.php.
    Can i know port, and use the Secure Sockets Layer (SSL) in Direсtаdmin using API, that does not define clearly.
    And not parce direсtаdmin.conf. In advance thanks for the help

    P.S. I'm sorry for my English.

  13. #333
    Join Date
    Jul 2013
    Posts
    6
    Hi all!
    Some code here:

    public function fetchQuotas($domain = null){
    $domain = $this->getDomain($domain);

    $this->sock->query('/CMD_API_POP', array(
    'action' => 'list',
    'type' => 'quota',
    'domain' => $domain
    ));
    $row = $this->sock->fetch_parsed_body();
    if (is_array($row)){
    foreach ($row as &$item) parse_str($item, $item);
    if (empty($item) || !is_array($item) || !isset($item['quota'])){
    $row = array();
    }
    } else {
    $row = array();
    }

    return $row;
    }

    /**
    * Get the quota and usage for a user
    * @param string $user
    * @param string $domain
    * @return array for example array(usage=>3412,quota=>123543), both are in bytes
    */
    public function fetchUserQuota($user, $domain = null){
    $limit = $this->fetchLimit($domain);
    return (isset($limit[$user]) ? $limit[$user] : array());
    }

    That is an example of how to get quota and usage for a user.
    But how get the limit for a user? (how many letters sent already and limit)
    Thank you!

  14. #334
    Join Date
    Jun 2008
    Posts
    2

    API with PHP script now working | user level

    Hello

    I hope u can help me

    i'v try everything google search, forum search and nothing

    i have a shred server with Directadmin control panel user level
    i want to delete and add or edit a dns A record
    i try this:
    http://forum.directadmin.com/showthread.php?t=258
    http://www.directadmin.com/features.php?id=504

    1. do i need to have any port open from my server end?
    2. it's possible to do any API connection with an User Level?
    3. when i try to run the script, the page is loading for 1 minuet or so an then error couldn't show page.

    please help me.

    Thank You.

  15. #335
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Quote Originally Posted by DiSHi View Post
    1. do i need to have any port open from my server end?
    No, if it's already open. I guess you would not access Directadmin in a browser if it were closed. Anyway it's a good idea to doublecheck.

    Quote Originally Posted by DiSHi View Post
    2. it's possible to do any API connection with an User Level?
    Yes.

    Quote Originally Posted by DiSHi View Post
    3. when i try to run the script, the page is loading for 1 minuet or so an then error couldn't show page.
    You probably need to enable debugging in your PHP script, and see errors; and check of course logs /var/log/directadmin/ for details.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  16. #336
    nobaloney's Avatar
    nobaloney is offline NoBaloney Internet Svcs - In Memoriam †
    Join Date
    Jun 2003
    Location
    California
    Posts
    26,123
    @DiSHi:

    Do you have your own server? Or a user account from a hosting provider, on which you have only user level? If you only have user level access on a server managed by your provider it's possible they don't allow DNS control; check with them.

    @zEitEr:

    I'm getting the impression from DiSHi's post that he only has user level. Which would mean he cannot get to the logs.

    Jeff
    +1 951 643-5345
    Third-Party DirectAdmin administration and support
    Dedicated Servers, Dedicated Reseller Accounts
    NoBaloney Internet Services div. Qnito Incorporated
    848 North Rainbow Blvd., Suite #3789
    Las Vegas, NV 89107-1103

  17. #337
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Quote Originally Posted by DiSHi View Post
    please help me.

    Thank You.
    It's solved now. The user DiSHi has now a working solution written by me as a commerce service.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  18. #338
    Join Date
    Jul 2014
    Posts
    2

    Change user’s password API

    I sent a request via API with "Post" method and with query('/CMD_API_USER_PASSWD', array( 'username' => “demo1”, 'passwd' => “123456789”, 'passwd2' => “123456789” )), then I received a response result “error=1&text=Unable to change password&details=&#34&#34 is an invalid username”.
    I also have try with “CMD_API_SHOW_ALL_USERS” API and it execute successful with response result “list[]=demo1&list[]=demo2&list[]=demo3&list[]=demo4&list[]=demo5&list[]=demo6&list[]=demo7&list[]=demo8&list[]=demo9&list[]=market2”
    Please check out and show me to solve my trouble.
    Thanks!

  19. #339
    Join Date
    Aug 2014
    Posts
    2
    So does this class still work with the latest DirectAdmin (despite the latest update being in 2005)?

    And can I use this to create a backup using the "Create/Restore Backups" option in DA via a cronjob? I was thinking of doing it with cURL but if this can do it that would be easier I guess.

    I must note I host a single website in a shared hosting environment and I'm just a user.

  20. #340
    Join Date
    Aug 2014
    Posts
    2
    Figured it out, thanks for the class .

    PHP Code:
    <?php
    $domain 
    "domain";
    $user   "username";
    $pass   "password";

    include 
    'httpsocket.php';

    $sock = new HTTPSocket;
    $sock->connect($domain,2223);

    $sock->set_login($user,$pass);

    $sock->set_method('POST');

    $sock->query('/CMD_SITE_BACKUP',
        array(
            
    'domain'  => $domain,
            
    'action'  => 'backup',
            
    'select0' => 'domain',
            
    'select1' => 'subdomain',
            
    'select2' => 'email',
            
    'select3' => 'forwarder',
            
    'select4' => 'autoresponder',
            
    'select5' => 'vacation',
            
    'select6' => 'list',
            
    'select7' => 'emailsettings',
            
    'select8' => 'ftp',
            
    'select9' => 'ftpsettings',
            
    'select10' => 'database'
        
    ));
    $result $sock->fetch_body();

    if (
    strpos($result,'Backup creation added to queue') !== false) {
        echo 
    'success';
    } else {
        echo 
    'fail';
    }

    ?>

Page 17 of 19 FirstFirst ... 71516171819 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
  •