Download the PHP package tallesairan/cpanel without Composer
On this page you can find all versions of the php package tallesairan/cpanel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tallesairan/cpanel
More information about tallesairan/cpanel
Files in tallesairan/cpanel
Package cpanel
Short Description This class allows developers to execute various functions of the cPanel UAPI and APIv2 directly from their PHP applications
License MIT
Homepage https://github.com/tallesairan/cpanel
Informations about the package cpanel
cPanel UAPI + APIv2 PHP Wrapper
The cPanel
class is a PHP library designed to interact with cPanel APIs, a popular web hosting management platform. This class allows developers to execute various functions of the cPanel UAPI and APIv2 directly from their PHP applications. With the ability to use a proxy and an advanced system of cookies and logs, this class offers enhanced flexibility and security for developers.
This class can help improve productivity in several ways:
-
Task Automation: The class enables developers to automate cPanel tasks, such as managing email accounts, domains, and databases, directly from their PHP applications.
-
Application Integration: The class makes it easy to integrate cPanel with custom applications, allowing developers to manage cPanel resources directly from their systems.
-
Proxy Management: The ability to use a proxy and an advanced system of cookies and logs allows developers to access cPanel from multiple locations and IPs, improving security and flexibility.
- Programmatic Control: The class provides a programmatic way to interact with cPanel APIs, allowing developers to create customized and efficient solutions for managing web hosting.
By utilizing the cPanel
class, developers can streamline their hosting management operations and improve integration between cPanel and their custom applications, increasing productivity and simplifying the workflow.
Installation via composer
Add it to your project via composer using:
composer require tallesairan/cpanel
Examples
- Simple Login and List files without proxy
`
- Simple Login and list_files with Proxy:
`
- Simple Login and File Upload
`
- Simple Login and File Extract
`
- Simple Login and new ftp account
`
- Create sub domain
`
- Manage Email
`
- Manage Database
`
Doubts ?
Guide to Replacing cPanel API 1 Functions with UAPI Equivalents
This document lists the UAPI functions which replace previously-deprecated cPanel API 1 functions. We introduced UAPI in cPanel & WHM version 11.42. As we developed additional UAPI functions, we created equivalents to some cPanel API 1 functions. Beginning with cPanel & WHM version 82, we started development for new UAPI modules and functions. These new modules and functions replace any cPanel API 1 functions without a current equivalent.
We are actively removing the cPanel API 1 functions beginning in cPanel & WHM version 88. We strongly recommend that anyone using a cPanel API 1 function use a UAPI function instead.
Replace cPanel API 1 functions with UAPI equivalents
To retrieve a list of cPanel API 1 functions that custom integrations call your system, call the following WHM API 1 functions:
The following examples display code from a cPanel API 1 function and its UAPI equivalent. Click the tab below that corresponds to your chosen development language.
Note:
The examples below compare the cPanel API 1 SetLang::setlang function and the UAPI Locale::set_locale function.
LiveAPI PHP Class
cPanel API 1 function
UAPI Function
Note:
For more information, read our Guide to the LiveAPI System.
For more information about how to replace a cPanel API 1 function with a UAPI function, read our Replace a cPanel API 1 Function With a UAPI Function documentation.
UAPI functions and legacy equivalents
The following tables list the UAPI functions that we added starting in cPanel & WHM version 82. The tables also list their cPanel API 1 equivalent functions.
For a complete list of UAPI functions and cPanel API 1 functions, read our Guide to UAPI and Guide to cPanel API 1 documentation.
Fileman
cPanel API 1 Functions | UAPI Functions |
---|---|
Fileman::restoredb |
Backup::restore_databases |
Fileman::restorefiles |
Backup::restore_files |
Fileman::restoreaf |
MySQL®
cPanel API 1 Functions | UAPI Functions |
---|---|
Mysql::listdbs |
Mysql::listdbsopt |
Mysql::number_of_dbs |
Mysql::list_databases |
Mysql::routines |
Mysql::list_routines |
Mysql::listusers |
Mysql::listusersopt |
Mysql::number_of_users |
Mysql::list_users |
Mysql::updateprivs |
Mysql::update_privileges |
Example For using uapi from cpanel documentation
cPanel API 1 function
UAPI Function
For more read at Guide to Replacing cPanel API 1 Functions with UAPI Equivalents
UAPI Docs UAPI Complete Docs
API
Description
The cPanel
class provides an interface to interact with cPanel's UAPI and APIv2. It supports using proxies, and has an advanced system for handling cookies and logs.
Class Properties
$host
- Type:
string
- The cPanel host URL.
$port
- Type:
integer
- The cPanel host port.
$username
- Type:
string
- The cPanel account username.
$password
- Type:
string
- The cPanel account password.
$log
- Type:
boolean
- Indicates whether logging is enabled.
$cFile
- Type:
string
- The cookie file path.
$curlfile
- Type:
string
- The log file path.
$emailArray, $cpsess, $homepage, $exPage
- These private properties are not currently used in the class.
$ips
- Type:
array
- An array of proxy IPs.
$useragent
- Type:
string
- The user agent string to use for HTTP requests.
$current_ip
- Type:
string
- The current IP address for the session.
$useProxy
- Type:
boolean
- Indicates whether to use a proxy or not.
Class Methods
__construct
- Parameters:
string
$usernamestring
$passwordstring
$hostinteger
$port (default: 2083)boolean
$log (default: false)boolean
$useProxy (default: false)array
$proxies (default: [])
- Initializes the
cPanel
class with the provided parameters.
getRandomProxy
- Return:
string
-
Returns a random proxy from the list of proxies.
Request
- Parameters:
[type]
$urlarray
$params (default: [])
- Return:
mixed
- Description: Handles an HTTP request to the cPanel server. If
$params
is set, it will be a POST request. This method is private and used internally within the class.
signIn
- Parameters: None
- Return:
void
- Description: Starts a session at the cPanel server. This method is private and called during the initialization of the
cPanel
class. It sets the$cpsess
,$homepage
, and$exPage
properties of the class based on the response from the cPanel server.
execute
- Parameters:
string
$apistring
$modulestring
$functionarray
$parameters (default: [])
- Return:
void
- Description: Executes the specified function using the given API type (api2 or uapi), module, and function, with the provided parameters. Calls either the
api2
oruapi
method based on the API type.
uapi
- Parameters:
[type]
$module[type]
$functionarray
$parameters (default: [])
- Return:
void
- Description: Executes a UAPI function with the given module, function, and parameters. If the function is 'upload_files', the files are sent as an array of parameters. Returns a JSON decoded response from the cPanel server.
api2
- Parameters:
string
$modulestring
$functionarray
$parameters (default: [])
- Return:
string
- Description: Executes an APIv2 function with the provided module, function, and parameters. Builds the APIv2 request URL and returns a JSON decoded response from the cPanel server.
slugify
- Parameters:
string
$text
- Return:
void
- Description: A simple function to convert a given string into a slug (a URL-friendly version of the string). The function replaces non-letter or non-digit characters with hyphens, transliterates the text to ASCII, removes unwanted characters, trims hyphens from the beginning and end of the string, and converts the text to lowercase. If the resulting slug is empty, the function returns 'n-a'.
How to contribute
- Create a fork, make changes and send a pull request.
- Raise a issue
RoadMap
- getSessionUrl() => Returns the current logged in session url
Based On
Built from an abandoned project myPHPnotes/Cpanel
License
Licensed under Apache 2.0. You can check its details here.