From d4dd77e5fb1275fb1332b583477c8744ed30ca81 Mon Sep 17 00:00:00 2001 From: Julio Vinachi Date: Thu, 28 May 2015 11:23:01 -0430 Subject: [PATCH 1/2] add config.php --- config.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 config.php diff --git a/config.php b/config.php new file mode 100644 index 0000000..1c49a6b --- /dev/null +++ b/config.php @@ -0,0 +1,10 @@ + \ No newline at end of file From 7edf6b2ec082174c7b1f019b618e9c2e650c9fe6 Mon Sep 17 00:00:00 2001 From: Julio Vinachi Date: Thu, 28 May 2015 11:39:08 -0430 Subject: [PATCH 2/2] adding new access settings in single file (config.php) --- Examples/adddns_example.php | 7 ++----- Examples/addip_example.php | 7 ++----- Examples/api1_example.php | 7 ++----- Examples/api2_example.php | 7 ++----- Examples/api2_example_withargs.php | 7 ++----- Examples/createacct_example.php | 9 +++------ Examples/hashauth_example.php | 5 +---- Examples/killdns_example.php | 7 ++----- Examples/listips_example.php | 7 ++----- Examples/listzones_example.php | 7 ++----- xmlapi.php | 2 +- 11 files changed, 21 insertions(+), 51 deletions(-) diff --git a/Examples/adddns_example.php b/Examples/adddns_example.php index db45e65..2860223 100644 --- a/Examples/adddns_example.php +++ b/Examples/adddns_example.php @@ -23,13 +23,10 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - $domain = "somedns.com"; -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_http_client('curl'); $xmlapi->set_port(2086); $xmlapi->set_debug(1); diff --git a/Examples/addip_example.php b/Examples/addip_example.php index a16dee6..bbe8f71 100644 --- a/Examples/addip_example.php +++ b/Examples/addip_example.php @@ -23,11 +23,8 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); diff --git a/Examples/api1_example.php b/Examples/api1_example.php index 107a4b0..5956ff3 100644 --- a/Examples/api1_example.php +++ b/Examples/api1_example.php @@ -23,17 +23,14 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - $account = "cptest"; $email_user = "somerandomuser"; $email_password = "adfm90f1m3f0m0adf"; $email_domain = "somedomain.com"; $email_query = '10'; -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_output('json'); $xmlapi->set_debug(1); diff --git a/Examples/api2_example.php b/Examples/api2_example.php index 4623915..c7ac099 100644 --- a/Examples/api2_example.php +++ b/Examples/api2_example.php @@ -23,13 +23,10 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - $account = "cptest"; -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_output("json"); $xmlapi->set_debug(1); diff --git a/Examples/api2_example_withargs.php b/Examples/api2_example_withargs.php index b0fd55d..0b0006d 100644 --- a/Examples/api2_example_withargs.php +++ b/Examples/api2_example_withargs.php @@ -23,15 +23,12 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - $account = "someuser"; $email_account = "randomemail"; $email_domain = "somedomain.com"; -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); print $xmlapi->api2_query($account, "Email", "getdiskusage", array(domain=>$email_domain, login=>$email_account) ); diff --git a/Examples/createacct_example.php b/Examples/createacct_example.php index 06c5f70..5f5e601 100644 --- a/Examples/createacct_example.php +++ b/Examples/createacct_example.php @@ -22,13 +22,10 @@ # POSSIBILITY OF SUCH DAMAGE. include_once '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); -$acct = array( username => "someuser", password => "pass123", domain => "thisdomain.com"); +$acct = array( username => "someuser", password => "pass123", domain => "thisdomain.com", plan =>"user_plan_diamond", contactemail=>"user@gmail.com",language=>"es"); print $xmlapi->createacct($acct); diff --git a/Examples/hashauth_example.php b/Examples/hashauth_example.php index 41e7397..62e9d33 100644 --- a/Examples/hashauth_example.php +++ b/Examples/hashauth_example.php @@ -22,13 +22,10 @@ # POSSIBILITY OF SUCH DAMAGE. include '../xmlapi.php'; - -$ip = getenv('REMOTE_HOST'); - # The access has can be found on your server under WHM's "Setup remote access hash" section or at /root/.accesshash $root_hash = '__ROOT_HASH_GOES_HERE__'; -$xmlapi = new xmlapi($ip); +$xmlapi = new xmlapi(SERVER_IP); $xmlapi->hash_auth("root",$root_hash); $xmlapi->return_xml(1); $xmlapi->set_debug(1); diff --git a/Examples/killdns_example.php b/Examples/killdns_example.php index 09e3ec6..84bfcee 100644 --- a/Examples/killdns_example.php +++ b/Examples/killdns_example.php @@ -23,13 +23,10 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - $domain = "somedns.com"; -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); diff --git a/Examples/listips_example.php b/Examples/listips_example.php index 598d40a..a9ceb08 100644 --- a/Examples/listips_example.php +++ b/Examples/listips_example.php @@ -23,11 +23,8 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); diff --git a/Examples/listzones_example.php b/Examples/listzones_example.php index 86adf4c..469c850 100644 --- a/Examples/listzones_example.php +++ b/Examples/listzones_example.php @@ -23,11 +23,8 @@ include '../xmlapi.php'; -$ip = getenv('REMOTE_HOST'); -$root_pass = getenv('REMOTE_PASSWORD'); - -$xmlapi = new xmlapi($ip); -$xmlapi->password_auth("root",$root_pass); +$xmlapi = new xmlapi(SERVER_IP); +$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD); $xmlapi->set_debug(1); diff --git a/xmlapi.php b/xmlapi.php index 51b65dc..f25c991 100644 --- a/xmlapi.php +++ b/xmlapi.php @@ -128,7 +128,7 @@ * @link http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi * @since Class available since release 0.1 **/ - +require_once('config.php'); class xmlapi { // should debugging statements be printed?