cpanelinc / xmlapi-php Goto Github PK
View Code? Open in Web Editor NEWA PHP Class for Interacting with cPanel's XML-API
A PHP Class for Interacting with cPanel's XML-API
Hi All,
Thanks for this library.
I've created a system, it runs in-house in the company I work for, it manages 200k+ domains, a portion
of these domains are delegated to a cpanel/whm instance - about 30k of 'em; interaction is via
cpanel api2 ( xmlapi-php ) .. we have been facing a problem where in many instances
the DNS Edit ( read and edit ) falls to "You do not have permission to read this zone" ..
-it is not related to the permission of "Advanced DNS Zone Edit feature/package"
( unless it's an unix permission, ? )
-There is only ONE username/account in cpanel that owns it.
Given that this is an exception instance [ all domains are owned by the same entity ], this is my question:
How can we bypass this problem ? Can we somehow chmod +x ( or alike ) a path ? or
which validation this is really doing ? root via whm user:2087 doesnt help ..
We have full control of the server (it's physically local, the server ! ) - ..
Before we write a from-scratch/apache fetching DNS Zone workaround, I really, really wonder:
can we not bypass this somehow ?
any help greatly appreciated !
txs,
s
Hello, this is what i want.
I have two domains in godadday hosting
firstdomain
seconddomain
I have this code running in firstdomain but i wanna create sub-domain for second domain using following code.
$cpanelusr = 'username';
$cpanelpass = 'password';
$xmlapi = new xmlapi('seconddomain.com');
$xmlapi->set_port( 2083 );
$xmlapi->password_auth($cpanelusr,$cpanelpass);
$xmlapi->set_debug(1); //output actions in the error log 1 for true and 0 false
$result
= $xmlapi->api2_query($cpanelusr, 'SubDomain', 'addsubdomain',
array("$subdomain_name",'seconddomain.com',0,0,
'/public_html/project3/user'));
I am getting this error "curl_exec threw error "couldn't connect to host".............."
Why do I give a file as you do?
It has an error
In the 233 line
Forgot to add
Is createacct_example.php
There will be errors
Hi there,
This is technically a cPanel bug, but something that can be addressed in the xmlapi-php code in the meantime.
Attempting the following code seems to work, doesn't return an error or invalid code, but does not work correctly:
$xmlapi->setresellerips($reseller, $ipaddress);
That is, if you verify the result in WHM by selecting the reseller and their IP allocation, it is incorrect. The API documentation mentions that the IP addresses must be separated by a comma. Even if you are only passing a single value, the API seems to want this to end in a comma. Our workaround is as follows:
$xmlapi->setresellerips($reseller, $ipaddress . ",");
Cheers.
this is the code i am using to find if there is a db called "testing" for the "x" account .. the pb is that everytime it lists all dbs for this account ... am i doing something wrong?
$xmlapi = new xmlapi($ip);
$xmlapi->hash_auth("root",$root_hash);
$xmlapi->set_output('array');
$xmlapi->set_debug(1);
echo '
';
$arrCheck = $xmlapi->api2_query("x", "MysqlFE", "listdbs", array("db"=>"testing"));
print_r($arrCheck);
die();thanks,
Rares
When I exec script below, And php will show save file windows, How close it?
$cpanelusr = ''; //username cpanel
$cpanelpass = ''; //password cpanel
$domainroot = 'XXX.com.tw'; //root domain
$subdomain = 'TEST'; //sudomain
$xmlapi = new xmlapi('localhost'); //link cpanel (can use ip)
//create_subdomain($domain,$xmlapi); //
$xmlapi->set_output('array');
$xmlapi->set_port( 2083 ); //port cpanel
$xmlapi->password_auth($cpanelusr,$cpanelpass);
$xmlapi->set_debug(1); //output actions in the error log 1 for true and 0 false
file_get_contents($xmlapi->api1_query($cpanelusr, 'SubDomain', 'addsubdomain', array($subdomain, $domainroot,0,0, "/public_html/")));
So this repository is missing a composer.json
file. It would be nice if it can be added. Nobody likes downloading individual files this days.
Acording to http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/SetResellerPkgLimit
its required and can't be null.
Anyway it don't even get passed as a parameter in the xmlapi_query() function.
Mfg
Implement PSR-4 Standard.
Line Number 1546 of xmlapi.php
if (!$isset($pkg['name'])) {
should be
if (!isset($pkg['name'])) {
I know this is a question an not an issue but im unsure where else to ask so apologies for that.
Trying to use this for the first time an a common problem for me is my randomly generated password does not reach the required strength of 100.
Is there a way to make use of WHM's generate password or to check the strength of the password before trying to create the new cpanel account?
Or a method to produce a strong password that is going to pass everytime?
Thanks all.
Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "Failed to connect to xxx.xxx.xxx.xxx port 2082: Connection refused" for https://xxx.xxx.xxx.xxx:2083/xml-api/cpanel?user=xxxxxxx&cpanel_xmlapi_module=mysql&cpanel_xmlapi_func=adddb&cpanel_xmlapi_apiversion=1&arg-0=ihhemrl7_sitedb' in /home/xxxxxxx/public_html/includes/hooks/xmlapi-copy-2009.php:692
I'm doing tests with the xmlapi.php and trying to use the getdiskusage function
The documentation http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/ApiEmail#Email::getdiskusage says that the input parameters are domain and login but didn't work when trying to acces
$opts = array(
'domain' => "domain.com",
'login' => "mail-user",
);
print $xmlapi->api2_query($server_login, "Email", "getdiskusage", $opts);
Returns:
{
cpanelresult: {
data: [
{
user: null,
domain: "domain.com",
login: null,
diskused: "0"
}
],
module: "Email",
apiversion: 2,
func: "getdiskusage",
event: {
result: 1
}
}
}
But when i use the paramters user instead of login it works OK
Hi, we're facing a problem that we can't seem to resolve....the account seems to be created in the WHM server, but the xmlapi fails with an error 500 and the following message:
curl_exec threw error "" for https://server-ip-placeholder:2087/xml-api/createacct?username=xxxxxx&password=xxxxxx&domain=xxxxxx&plan=xxxxxx
Could anyone help with this? Much appreciated!!!
Not able to create data base
Just spotted what I think is a typo. Should line 2446 not read...
return $this->api2_query($username, 'AddonDomain', 'listaddondomains');
... instead of:
return $this->api2_query($username, 'Park', 'listaddondomains');
Regards,
Will
Can you please give example what & where to change the code for JSON serialization?
When i run the below code, xmlapi-php is running twice.
require_once('../xmlapi.php');
$cpanelUser = 'user';
$cpanelPass = 'password';
$XmlApi = new xmlapi('127.0.0.1');
$XmlApi->set_port(2083);
$XmlApi->password_auth($cpanelUser, $cpanelPass);
$XmlApi->set_debug(1);
$result = $XmlApi->api2_query($cpanelUser, 'SubDomain', 'addsubdomain', [
'domain' => 'marcio',
'rootdomain' => 'evoimobdev.com.br',
'dir' => '/usersite/marcio/public_html'
]);
So i get this result:
[14-Nov-2016 16:53:02 America/Sao_Paulo] URL: https://127.0.0.1:2083/xml-api/cpanel
[14-Nov-2016 16:53:02 America/Sao_Paulo] DATA: domain=marcio&rootdomain=evoimobdev.com.br&dir=%2Fusersite%2Fmarcio%2Fpublic_html&cpanel_xmlapi_user=imobevodev&cpanel_xmlapi_module=SubDomain&cpanel_xmlapi_func=addsubdomain&cpanel_xmlapi_apiversion=2
[14-Nov-2016 16:53:02 America/Sao_Paulo] Authentication Header: Authorization: Basic **hidden**
[14-Nov-2016 16:53:02 America/Sao_Paulo] RESPONSE:
<?xml version="1.0" ?>
<cpanelresult>
<apiversion>2</apiversion>
<data>
<reason>The subdomain “marcio.evoimobdev.com.br” has been added.</reason>
<result>1</result>
</data>
<event>
<result>1</result>
</event>
<func>addsubdomain</func>
<module>SubDomain</module>
</cpanelresult>
[14-Nov-2016 16:53:02 America/Sao_Paulo] SimpleXML var_dump:
SimpleXMLElement Object
(
[apiversion] => 2
[data] => SimpleXMLElement Object
(
[reason] => The subdomain “marcio.evoimobdev.com.br” has been added.
[result] => 1
)
[event] => SimpleXMLElement Object
(
[result] => 1
)
[func] => addsubdomain
[module] => SubDomain
)
[14-Nov-2016 16:53:04 America/Sao_Paulo] URL: https://127.0.0.1:2083/xml-api/cpanel
[14-Nov-2016 16:53:04 America/Sao_Paulo] DATA: domain=marcio&rootdomain=evoimobdev.com.br&dir=%2Fusersite%2Fmarcio%2Fpublic_html&cpanel_xmlapi_user=imobevodev&cpanel_xmlapi_module=SubDomain&cpanel_xmlapi_func=addsubdomain&cpanel_xmlapi_apiversion=2
[14-Nov-2016 16:53:04 America/Sao_Paulo] Authentication Header: Authorization: Basic **hidden**
[14-Nov-2016 16:53:04 America/Sao_Paulo] RESPONSE:
<?xml version="1.0" ?>
<cpanelresult>
<apiversion>2</apiversion>
<data>
<reason>(XID y945bg) A DNS entry for the domain “marcio.evoimobdev.com.br” already exists.</reason>
<result>0</result>
</data>
<error>(XID y945bg) A DNS entry for the domain “marcio.evoimobdev.com.br” already exists.</error>
<event>
<result>1</result>
</event>
<func>addsubdomain</func>
<module>SubDomain</module>
</cpanelresult>
[14-Nov-2016 16:53:04 America/Sao_Paulo] SimpleXML var_dump:
SimpleXMLElement Object
(
[apiversion] => 2
[data] => SimpleXMLElement Object
(
[reason] => (XID y945bg) A DNS entry for the domain “marcio.evoimobdev.com.br” already exists.
[result] => 0
)
[error] => (XID y945bg) A DNS entry for the domain “marcio.evoimobdev.com.br” already exists.
[event] => SimpleXMLElement Object
(
[result] => 1
)
[func] => addsubdomain
[module] => SubDomain
)
Someone knows why xmlapi-php is running twice?
I have read the documentation for cPanel_XMLAP_Client_Class addzonerecord() . I am relatively new to the concept of editing dns settings. It gives the required parameters as :
* @param string $zone The DNS zone that you want to add the record to
* @param array $args Associative array representing the record to be added
What is the name of the zone record so as I can use it as a parameter?
and:
Where can I get a list of the required fields and their format for the array?
for example is this the right idea? or close to it?
I have searched the cPanel documentation but have been unable to come up with an answer.
Just downloaded the latest version, and found this little bug on line 238:
if ( defined('XMLAPI_USER_SSL' ) && (XMLAPI_USE_SSL == '0' ) ) {
XMLAPI_USER_SSL should be XMLAPI_USE_SSL.
Hello,
I've added a function to the xmlapi file which sets a default e-mail address to forward e-mail to. What is the best way for me to contribute to this file?
Thanks,
LS
This api is nicely working on Linux hosting but it is not working on windows hosting...
This is a important feature that in this module could be implement.
Hi,
I am able to create database but I am not able to create database user.
Thanks
$xmlapi->api2_query($data->products->product[0]->username, "AddonDomain", "addaddondomain", array('newdomain'=>$domainlist[$i])); <- executed
Result is:
object(SimpleXMLElement)#9 (6) {
["apiversion"]=>
string(1) "2"
["data"]=>
object(SimpleXMLElement)#10 (2) {
["reason"]=>
string(76) "You have exceeded the maximum allowed FTP (File Transfer Protocol) accounts."
["result"]=>
string(1) "0"
}
["error"]=>
string(76) "You have exceeded the maximum allowed FTP (File Transfer Protocol) accounts."
["event"]=>
object(SimpleXMLElement)#8 (1) {
["result"]=>
string(1) "1"
}
["func"]=>
string(14) "addaddondomain"
["module"]=>
string(11) "AddonDomain"
}
How to tell the API to not create ftp-accounts?
The current source code of this repository is based on API0 of Cpanel documentation.
I would like to request that we should start the creating the PHP class that is base on API1 of CPanel. There have been a lot of new features of API1 in comparison to API0. It would help a lot of developers if there's a source code for XML-API1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.