Yii 1.1: mpcpanel

class to access cpanel functions - accepts json xml, cpanel 1 and 2 apis
7 followers

MPCpanel

Class to access cpanel apis

It accepts any function of xml/json api, also cpanel api1 and api2

See it on github

Requirements

Install

put the download file under any imported directory

and in you components config file add the component

return array(
       '...'
       'components'=>array(
            '...',//other components
            'cpanel'=>array(
                   'class'=>'MPCpanel',
                    'username'=>'yourUsername',//required
                    'url'=>'http://mydomain.com:2086/',// by default https://127.0.0.1:2087/
                    'auth_type'=>'basic',//accepted = basic or whm
                                         //basic by default
                    'api_type'=>'json',//accepted = json or xml
                                       //json by default
                    'password'=>'myPassword',//required for basic type of authentication
                    'access_key'=>'myBiggggggggggKey',//required for whm type of authentication
            ),
       ),
    );

Usage

$cpanel=Yii::app()->cpanel;
 
    //will use xml/json api
    $cpanel->listaccts();
 
    //will use xml/json api with parameters
    $cpanel->createacct(array('username'=>'myAccount','domain'=>'mydomain.com','password'=>'myPassword'));
 
    //will use cpanel api1 function webalizer, module Stats, no parameters
    $cpanel->webalizer('Stats');
 
    //will use cpanel api1 function adduserdb, module Mysql using parameters (*api1 parameters must be in order and as string) 
    $cpanel->adduserdb('Mysql','mydbname','mydbuser','all');
 
     //will use cpanel api2 function listwebalizer, module Stats
     //to call api2 make sure the second parameter is array, even if empty
    $cpanel->listwebalizer('Stats',array());
 
    //will use cpanel api2 function change_password, module Passwd using parameters (*api2 parameters must be an array using key/values pairs)
    $cpanel->username='client3';
    $cpanel->password='client3Password';
    $cpanel->change_password('Passwd',array('newpass'=>'m1n3wp4$$w0rd','oldpass'=>$cpanel->password));

Resources

Total 2 comments

#16736 report it
Gustavo at 2014/03/23 03:52pm
@Ashish Gupta

you wrote

Yii::app()->user->cpanel

which is not avaliable
try

Yii::app()->cpanel

and you will do fine

#16735 report it
Ashish Gupta at 2014/03/23 03:45pm
cpanel Getting exception

I am getting exception when i am try to include MPCpanel file into component array( 'class'=>'MPCpanel', 'username'=>'yourUsername',//required 'url'=>'http://mydomain.com:2086/',// by default https://127.0.0.1:2087/ 'auth_type'=>'basic',//accepted = basic or whm //basic by default 'api_type'=>'json',//accepted = json or xml //json by default 'password'=>'myPassword',//required for basic type of authentication 'access_key'=>'myBiggggggggggKey',//required for whm type of authentication ),

I am also try to import file which is available in extensions folder

'import'=>array( 'application.models.', 'application.components.', 'application.extensions.MPCpanel', ),

I am getting the error message CException Property "CWebUser.cpanel" is not defined. Please help me I am new in Yii Thank in advance

Leave a comment

Please to leave your comment.

Create extension