2017 © Pedro Peláez
 

library cpanel-php

Cpanel/WHM API for PHP

image

chrisbjr/cpanel-php

Cpanel/WHM API for PHP

  • Thursday, October 29, 2015
  • by chrisbjr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 45 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

cPanel/WHM API for PHP library

Contents

Installation Guide

To install this package, you can run this code via your terminal, (*1)

    composer require gufy/cpanel-whm:dev-master

Or update your composer.json by adding this line, (*2)

    "gufy/cpanel-php":"~1.0"

Then, run this code, (*3)

    composer update

Usage

For example, if you would like to get list accounts of your whm server, you can do this., (*4)

  <?php
  $cpanel = new \Gufy\CpanelPhp\Cpanel([
      'host'        =>  'https://123.456.789.123:2087', // ip or domain complete with its protocol and port
      'username'    =>  'root', // username of your server, it usually root.
      'auth_type'   =>  'hash', // set 'hash' or 'password'
      'password'    =>  'password', // long hash or your user's password
  ]);

  $accounts = $cpanel->listaccts(); // it will returned as array

Functions

Defining Configuration on constructor

This is the example when you want to define your configuration while creating new object, (*5)

  <?php
  $cpanel = new \Gufy\CpanelPhp\Cpanel([
      'host'        =>  'https://123.456.789.123:2087', // required
      'username'    =>  'root', // required
      'auth_type'   =>  'hash', // optional, default 'hash'
      'password'    =>  'password', // required
  ]);

Usage

For example, you would like to get some list accounts from cPanel/WHM, (*6)

    <?php

    $accounts = $cpanel->listaccts();

    // passing parameters
    $accounts = $cpanel->listaccts(['searchtype'=>'domain', 'search'=>'', 'exact', 'search'=>'helloworld.com']);

For accessing cPanel API 2, you can use this., (*7)

    <?php
    // get bandwidth data of specific cPanel's user
    $data = $cpanel->cpanel('Bandwidth', 'getbwdata', 'username');

    // removing cron line
    $data = $cpanel->cpanel('Cron', 'remove_line', 'username', ['line'=>1]);

The first parameter must be Module you would like to get, second is function name, and the third is username of cPanel's user. There is fourth arguments, when function has some additional arguments, you can pass it there., (*8)

For accessing to cPanel API 1 or cPanel API 2 or UAPI, you can use this., (*9)

    <?php
    // get bandwidth data of specific cPanel's user (using cPanel API 2)
    $data = $cpanel->execute_action('2', 'Bandwidth', 'getbwdata', 'username');

    // removing email address (using UAPI)
    $data = $cpanel->execute_action('3', 'Email', 'delete_pop', 'username', ['email'=>'peter@griffin.com']);

This function is similar to the above, the only difference is that it has added a parameter which indicates the API you want to use (1 = cPanel API 1, 2 = cPanel API 2, 3 = UAPI), the other arguments are the same., (*10)

Overriding current configuration

Somehow, you want to override your current configuration. To do this, here is the code, (*11)

  <?php
  // change username andd (password or hash)
  $cpanel->setAuthorization($username, $password);

  // change host
  $cpanel->setHost($host);

  // change authentication type
  $cpanel->setAuthType($auth_type);

Get defined configuration

After you define some of your configuration, you can get it again by calling this functions, (*12)

  <?php
  // get username
  $cpanel->getUsername();

  // get password
  $cpanel->getPassword();

  // get authentication type
  $cpanel->getAuthType();

  // get host
  $cpanel->getHost();

Feedback and contribution

This package is free and open source, feel free to fork and report some issue to this package. :-). Have fun, (*13)

The Versions

29/10 2015

dev-master

9999999-dev

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mochamad Gufron

29/10 2015

dev-develop

dev-develop

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mochamad Gufron

01/07 2015

v1.0.5

1.0.5.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mochamad Gufron

25/06 2015

v1.0.4

1.0.4.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mochamad Gufron

05/05 2015

v1.0.3

1.0.3.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

by Mochamad Gufron

05/05 2015

v1.0.2

1.0.2.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

by Mochamad Gufron

18/01 2015

v1.0.1

1.0.1.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

by Mochamad Gufron

17/08 2014

v1.0.0

1.0.0.0

Cpanel/WHM API for PHP

  Sources   Download

MIT

The Requires

 

by Mochamad Gufron