DA PHP Class with DA API Functions

DJVG

Verified User
Joined
Aug 14, 2008
Messages
25
Hi,

First, don't look at my english, i'm from the Netherlands and my english is not that good.

This week, i started writing an Class that translate all the API functies off directadmin to PHP.

You can see the first start (some functions are not ready yet!) here: SEE IT!

Is this an good start?

I will update the .phps file as much as possible

If this class is ready, it will be public accessable.

All comments, positive or negative, I will understand and adapt within the script.

I use HTTP Socket written by Phi1 'l0rdphi1' Stier.

Greetz,
DJVG
 
Last edited:
Hi there
This is a nice idea, i like it :)

Im going to go on from your class.

Nice job,
Sky
 
Little Bump!

Today class updated!

For url, see my first post!

DJVG
 
I think the author updated this php class without adding comment on this thread.

I seam to remenber this class whas not a big.

Its a nice job now.
 
well not everything is available yet, for example the email forwarders...

Here are the 4 actions possible dealing with email froward :
PHP:
    // list of email forwarders
    function CMD_API_EMAIL_FORWARDERS($domain) {
        if($this->_empty($domain)) {
            return 'fieldempty';
        }elseif(!$this->DOMAIN_EXISTS($domain)) {
            return 'domainnotexists';
        }else{
            $query = array(
                        'domain'    =>    $domain
                        );
            $this->socket->query('/CMD_API_EMAIL_FORWARDERS', $query);

            $result = $this->socket->fetch_parsed_body();
            return $result;
        }
    }
    // add email forwarder
    function CMD_API_EMAIL_CREATE_FORWARDERS($domain, $user, $email) {
        if($this->_empty($domain) || $this->_empty($user) || $this->_empty($email)) {
            return 'fieldempty';
        }elseif(!$this->DOMAIN_EXISTS($domain)) {
            return 'domainnotexists';
        }else{
            $query = array(
                        'action'    =>    'create',
                        'domain'    =>    $domain,
                        'email'    =>    $email,
                        'user'        =>    $user
                        );
            $this->socket->query('/CMD_API_EMAIL_FORWARDERS', $query);
            $result = $this->socket->fetch_parsed_body();

            if($result['error'] == 0) {
                return 'succes';
            }else{
                return 'failed';
            }
        }
    }
    // modify email forwarder
    function CMD_API_EMAIL_MODIFY_FORWARDERS($domain, $user, $email) {
        if($this->_empty($domain) || $this->_empty($user) || $this->_empty($email)) {
            return 'fieldempty';
        }elseif(!$this->DOMAIN_EXISTS($domain)) {
            return 'domainnotexists';
        }else{
            $query = array(
                        'action'    =>    'modify',
                        'domain'    =>    $domain,
                        'email'    =>    $email,
                        'user'        =>    $user
                        );
            $this->socket->query('/CMD_API_EMAIL_FORWARDERS', $query);
            $result = $this->socket->fetch_parsed_body();

            if($result['error'] == 0) {
                return 'succes';
            }else{
                return 'failed';
            }
        }
    }
    // delete email forwarder
    function CMD_API_EMAIL_DELETE_FORWARDERS($domain, $user) {
        if($this->_empty($domain) || $this->_empty($user)) {
            return 'fieldempty';
        }elseif(!$this->DOMAIN_EXISTS($domain)) {
            return 'domainnotexists';
        }else{
            $query = array(
                        'action'    =>    'delete',
                        'domain'    =>    $domain,
                        'select0'        =>    $user
                        );
            $this->socket->query('/CMD_API_EMAIL_FORWARDERS', $query);
            $result = $this->socket->fetch_parsed_body();

            if($result['error'] == 0) {
                return 'succes';
            }else{
                return 'failed';
            }
        }
    }

Just add that in the class.

Paste that before this string : // Subfunctions needed by functions:

Its not artwork, but it works.

Sky
 
Hello

Nice work there.

Just to say that there are a fiew more function's out there (like forward email for ex.) that have not been integrated into that api.html page.

It would also be pretty nice to have comments on every function so that any good Editor can parse that and give us the params infos needed + hints.

Thx for sharing.
Sky
 
Back
Top