Code Monkey home page Code Monkey logo

directadmin's Introduction

DirectAdmin API client

Build Status Coverage Status Scrutinizer SensioLabs Insight GitHub license

This package is no longer supported by the original authors as we no longer use DirectAdmin. The library still worked fine when we left it, use at your own risk. If you want to take over just push your fork to Packagist, it's MIT all the way.

This is a PHP client library to manage DirectAdmin control panel servers. We simply decided to develop this as we needed automation of our own DirectAdmin servers, and the existing implementations were unsupported and incomplete.

API documentation for this project is automatically generated on each push.

Installation

Packagist Packagist

The recommended way to install this library is through Composer:

composer require omines/directadmin

If you're not familiar with composer follow the installation instructions for Linux/Unix/Mac or Windows, and then read the basic usage introduction.

Dependencies

The library uses Guzzle 6 as its HTTP communication layer. PHP versions supported are 5.6, 7.0, 7.1 and hhvm.

Basic usage

To set up the connection use one of the base functions:

use Omines\DirectAdmin\DirectAdmin;

$adminContext = DirectAdmin::connectAdmin('http://hostname:2222', 'admin', 'pass');
$resellerContext = DirectAdmin::connectReseller('http://hostname:2222', 'reseller', 'pass');
$userContext = DirectAdmin::connectUser('http://hostname:2222', 'user', 'pass');

These functions return an AdminContext, ResellerContext, and UserContext respectively exposing the functionality available at the given level. All three extend eachother as DirectAdmin uses a strict is-a model. To act on behalf of a user you can use impersonation calls:

$resellerContext = $adminContext->impersonateReseller($resellerName);
$userContext = $resellerContext->impersonateUser($userName);

Both are essentially the same but mapped to the correct return type. Impersonation is also done implicitly when managing a user's domains:

$domain = $adminContext->getUser('user')->getDomain('example.tld');

This returns, if the domain exists, a Domain instance in the context of its owning user, allowing you to manage its email accounts et al transparently.

Contributions

As the DirectAdmin API keeps expanding pull requests are welcomed, as are requests for specific functionality. Pull requests should in general include proper unit tests for the implemented or corrected functions.

For more information about unit testing see the README.md in the tests folder.

Legal

This software was developed for internal use at Omines Full Service Internetbureau in Eindhoven, the Netherlands. It is shared with the general public under the permissive MIT license, without any guarantee of fitness for any particular purpose. Refer to the included LICENSE file for more details.

The project is not in any way affiliated with JBMC Software or its employees.

directadmin's People

Contributors

barryvdh avatar curry684 avatar imadphp avatar jacobdekeizer avatar mbardelmeijer avatar mvdgeijn avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

directadmin's Issues

Implement "login keys" feature.

The "Login keys" feature is not implemented.

DirectAdmin has a "login key" feature to get access to a user's account, but restrict access to some specified functionality. The feature is described here.

Direct admin No Calc statistics Disk usage after create with Omines

Hi all,
I'm using create hosting by class Omines Direct admin for create multi SUB domain, have a problem occurs, after creating no calculate Disk usage in account Direct Admin. This is my code after create account my Create website using softaculous for install wordpress

`include "vendor/autoload.php";

use Omines\DirectAdmin\DirectAdmin;
$adminContext = DirectAdmin::connectAdmin('http://IP:2222', 'admin', 'password');
$resellerContext = $adminContext->impersonateReseller('admin');

//user, pass hosting for thanha.hoiit.com
$username = 'an'.rand(1, 5);
$password = '123123';
$email = '[email protected]';
$domain = $username.'.abc.com';
$ip = '103.27.239.29';
$package = 'p100';

$resellerContext->createUser($username, $password, $email, $domain, $ip, $package);

include_once('softaculous/sdk/installapi.php');
@set_time_limit(100);

$host = 'http://IP';
$dauser = $username;
$dapass = $password;
$sid = '26';//wordpress
`

This image https://s12.postimg.org/3tqexxqul/2016_12_01_083611.png
Let's see what help I have shortcomings in the code as above or not?

PSR-2 coding standard

@curry684 are you interested in applying the PSR-2 coding standard to this project? If so, i will make a PR with all required changes & include a PHP code style fixer configuration.

Action required: Add a Renovate config

Hi,

You will need to add a config to this repository if you want Renovate to continue creating PRs. Renovate will soon begin skipping all repositories that don't have a valid config found, even if you've received PRs before.

To keep functionality exactly the same, you can add an empty JSON config ({}) to your repo in any of the following files: renovate.json, .github/renovate.json, .renovaterc, .renovaterc.json

Implement get, create and delete of login keys

We should build a feature where we can add/delete/change/list all login keys. As far as I i’ve learned in the past several hours, we’ll have to use the CMD_LOGIN_KEYS command and send it regular requests. It seems that the API command for login keys is intended for something completely different. I’m currently working on this and will update this issue when I figure it out.

Correct way to access log files (or using the invokeGet function)

Hi everyone,

I have been trying to access the log files of a domain for a while now, but since there is no existing function for it I'm using the invokeGet function. However it looks like either the request isn't being executed correctly or I'm using the wrong function.

A bit of code, I tried the SHOW_LOG command taken from the URL but also the LOG_VIEWER taken from the DA website. (https://www.directadmin.com/features.php?id=1360) Both return the same result.

DirectAdmin::connectReseller(env('PANEL_HOST'), env('PANEL_USER'), env('PANEL_PASSWORD'))
            ->impersonateUser($userName)
            ->invokeGet('SHOW_LOG', [
                'domain'    => $domainName,
                'type'      => 'log',
            ]);
DirectAdmin API returned text/html to GET /CMD_API_SHOW_LOG containing
You cannot execute that command
The request you've made cannot be executed because it does not exist in your authority level

I'm not sure if I this is related to the DirectAdmin API or this package, but I'm hoping someone can help me. :)

Is the web server restarted uppon account creation/deletion?

I'm getting "502 Bad Gateway" (nginx ofc), I'd say, half of the time on account creation, and always on account deletion.
The web server being restarted there makes sense, but then how am I supposed to run the rest of the logic in my API, which depends of the data returned by DA?
Appreciate if you guys can provide some insight.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.