Update KeyHelp.php

New:
- Adding getCURL()
- Replaced tabs with spaces

Still not working:
- synchronizeAccount() waiting for FOSSBilling
This commit is contained in:
Syltmedia 2023-01-12 18:12:21 +01:00 committed by GitHub
parent 6eec3339cb
commit 359a1211e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,30 +15,26 @@
* @see https://app.swaggerhub.com/apis-docs/keyhelp/api/2.4 * @see https://app.swaggerhub.com/apis-docs/keyhelp/api/2.4
*/ */
class Server_Manager_KeyHelp extends Server_Manager { class Server_Manager_KeyHelp extends Server_Manager {
/** public function init()
* Method is called just after obejct contruct is complete.
* Add required parameters checks here.
*/
public function init()
{ {
if (!extension_loaded('curl')) { if (!extension_loaded('curl')) {
throw new Server_Exception('cURL extension is not enabled'); throw new Server_Exception('cURL extension is not enabled');
} }
if(empty($this->_config['ip'])) { if(empty($this->_config['ip'])) {
throw new Server_Exception('Server manager "KeyHelp" is not configured properly. IP address is not set!'); throw new Server_Exception('Server manager "KeyHelp" is not configured properly. IP address is not set!');
} }
if(empty($this->_config['host'])) { if(empty($this->_config['host'])) {
throw new Server_Exception('Server manager "KeyHelp" is not configured properly. Hostname is not set!'); throw new Server_Exception('Server manager "KeyHelp" is not configured properly. Hostname is not set!');
} }
if(empty($this->_config['accesshash'])) { if(empty($this->_config['accesshash'])) {
throw new Server_Exception('Server manager "KeyHelp" is not configured properly. API Key / Access Hash is not set!'); throw new Server_Exception('Server manager "KeyHelp" is not configured properly. API Key / Access Hash is not set!');
} else { } else {
$this->_config['accesshash'] = preg_replace("'(\r|\n)'","",$this->_config['accesshash']); $this->_config['accesshash'] = preg_replace("'(\r|\n)'","",$this->_config['accesshash']);
} }
} }
public static function getForm() public static function getForm()
{ {
@ -60,434 +56,346 @@ class Server_Manager_KeyHelp extends Server_Manager {
]; ];
} }
public function getLoginUrl() /**
{ * curl GET
/* */
############################### public function getCURL($action, $actionEx)
### VORBEREITUNG FÜR SPÄTER ### {
############################### $host = $this->_config['host'];
$username = "rokkcloud"; $apiUrl = "https://".$host."/api/v2/";
$host = $this->_config['host']; $action = $action . $actionEx;
$apiUrl = "https://".$host."/api/v2/";
$action = "clients/name/".$username;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $apiKey = $this->_config['accesshash'];
$curl_session = curl_init(); $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl); curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session)); $result = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
$userID = $result->id;
$host = $this->_config['host']; return $result;
$apiUrl = "https://".$host."/api/v2/"; }
$action = "login/".$userID;
$actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash'];
/**
$curl_session = curl_init(); * Later: Custom login url for User ;) Waiting for FOSSBilling
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl); */
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); public function getLoginUrl()
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( {
'X-API-Key: '.$apiKey, $host = $this->_config['host'];
'accept: application/json', return 'https://'.$host.'';
'Content-Type: application/json', }
));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userLogin = $result->url;
return $userLogin; */
$host = $this->_config['host'];
return 'https://'.$host.'';
}
public function getResellerLoginUrl() public function getResellerLoginUrl()
{ {
$host = $this->_config['host']; $host = $this->_config['host'];
return 'https://'.$host.''; return 'https://'.$host.'';
} }
/**
public function testConnection() * Here we check if the API is working ;)
{ */
$host = $this->_config['host']; public function testConnection()
{
$apiUrl = "https://".$host."/api/v2/";
$action = "ping"; $action = "ping";
$actionapiUrl = $apiUrl . $action; $actionEx = "";
$apiKey = $this->_config['accesshash']; $result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
if(isset($result)) { if(isset($result)) {
return true; return true;
var_dump($a); var_dump($a);
} else { } else {
throw new Server_Exception('Failed to connect to server'); throw new Server_Exception('Failed to connect to server');
} }
} }
/**
public function synchronizeAccount(Server_Account $a) * Not working, because of FOSSBilling
{ */
$host = $this->_config['host']; public function synchronizeAccount(Server_Account $a)
$apiUrl = "https://".$host."/api/v2/"; {
$action = "clients/name/".$a->getUsername(); $action = "clients/name/";
$actionapiUrl = $apiUrl . $action; $actionEx = $a->getUsername();
$apiKey = $this->_config['accesshash']; $result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$new = clone $a;
$curl_session = curl_init(); if(empty($result->is_suspended)) {
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl); $new->setSuspended(false);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); } else {
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( $new->setSuspended(true);
'X-API-Key: '.$apiKey, }
'accept: application/json',
'Content-Type: application/json',
));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userID = $result->id;
$new = clone $a;
$new->setSuspended($result->is_suspended);
$new->setUsername($result->username);
return $new; return $new;
} }
/** /**
* Package name must match on both KeyHelp and FOSSBilling! * Package name must match on both KeyHelp and FOSSBilling!
*/ */
public function createAccount(Server_Account $a) public function createAccount(Server_Account $a)
{ {
$apiUrl = "https://".$this->_config['host']."/api/v2/"; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$action = "clients/";
$actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $apiKey = $this->_config['accesshash'];
$this->getLog()->info('Creating account '.$a->getUsername()); $this->getLog()->info('Creating account '.$a->getUsername());
$client = $a->getClient(); $client = $a->getClient();
$package = $a->getPackage()->getName(); $package = $a->getPackage()->getName();
$data = array( $action = "hosting-plans/name/";
$actionEx = preg_replace("/\s+/", "%20", $package);
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$packageID = $result->id;
$data = array(
"username"=> $a->getUsername(), "username"=> $a->getUsername(),
"language"=> "de", "language"=> "de",
"email"=> $client->getEmail(), "email"=> $client->getEmail(),
"password"=> $a->getPassword(), "password"=> $a->getPassword(),
"id_hosting_plan"=> $package, "id_hosting_plan"=> $packageID,
"is_suspended"=> false, "is_suspended"=> false,
"suspend_on"=> null, "suspend_on"=> null,
"delete_on"=> null, "delete_on"=> null,
"send_login_credentials"=> true, "send_login_credentials"=> true,
"create_system_domain"=> false, "create_system_domain"=> false,
); );
$action = "clients/";
$curl_session_b = curl_init();
curl_setopt($curl_session_b ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session_b, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session_b, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl_session_b, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl_session_b, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session_b, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session_b, CURLOPT_POST, 1);
curl_setopt($curl_session_b, CURLOPT_POSTFIELDS, json_encode($data));
$result_a = json_decode(curl_exec($curl_session_b));
curl_close($curl_session_b );
$keyhelp_user_id = $result_a->id;
$data = array(
"id_user"=> $keyhelp_user_id,
"domain"=> $a->getDomain()
);
$action = "domains";
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$curl_session = curl_init(); $curl_session_b = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl); curl_setopt($curl_session_b ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session_b, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($curl_session_b, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl_session, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl_session_b, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_session_b, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session_b, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
curl_setopt($curl_session, CURLOPT_POST, 1); curl_setopt($curl_session_b, CURLOPT_POST, 1);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl_session_b, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session)); $result_a = json_decode(curl_exec($curl_session_b));
curl_close($curl_session ); curl_close($curl_session_b );
$keyhelp_user_id = $result_a->id;
if(isset($result_a)&&isset($result_c)) { $data = array(
"id_user"=> $keyhelp_user_id,
"domain"=> $a->getDomain()
);
$action = "domains";
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl_session, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session, CURLOPT_POST, 1);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session );
if(isset($result_a)&&isset($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to create the hosting'); throw new Server_Exception('Failed to create the hosting');
} }
} }
public function suspendAccount(Server_Account $a) public function suspendAccount(Server_Account $a)
{ {
$host = $this->_config['host']; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$apiUrl = "https://".$host."/api/v2/"; $apiKey = $this->_config['accesshash'];
$action = "clients/name/".$a->getUsername();
$action = "clients/name/";
$actionEx = $a->getUsername();
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$userID = $result->id;
$data = array(
"is_suspended"=> true,
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userID = $result->id;
$data = array(
"is_suspended"=> true,
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session)); $result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
if(isset($result_c)) { if(isset($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to suspend account!'); throw new Server_Exception('Failed to suspend account!');
} }
} }
public function unsuspendAccount(Server_Account $a) public function unsuspendAccount(Server_Account $a)
{ {
$host = $this->_config['host']; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$apiUrl = "https://".$host."/api/v2/"; $apiKey = $this->_config['accesshash'];
$action = "clients/name/".$a->getUsername();
$action = "clients/name/";
$actionEx = $a->getUsername();
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$userID = $result->id;
$data = array(
"is_suspended"=> false,
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userID = $result->id;
$data = array(
"is_suspended"=> false,
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session)); $result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
if(isset($result_c)) { if(isset($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to suspend account!'); throw new Server_Exception('Failed to suspend account!');
} }
} }
public function cancelAccount(Server_Account $a) public function cancelAccount(Server_Account $a)
{ {
$host = $this->_config['host']; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$apiUrl = "https://".$host."/api/v2/"; $apiKey = $this->_config['accesshash'];
$action = "clients/name/".$a->getUsername();
$action = "clients/name/";
$actionEx = $a->getUsername();
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$userID = $result->id;
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session)); $result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
$userID = $result->id;
$action = "clients/".$userID; if(empty($result_c)) {
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
$result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session );
if(empty($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to cancel / delete account!'); throw new Server_Exception('Failed to cancel / delete account!');
} }
} }
public function changeAccountPackage(Server_Account $a, Server_Package $p) public function changeAccountPackage(Server_Account $a, Server_Package $p)
{ {
$this->getLog()->info('Changing password on account '.$a->getUsername()); $this->getLog()->info('Changing password on account '.$a->getUsername());
$host = $this->_config['host']; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$apiUrl = "https://".$host."/api/v2/"; $apiKey = $this->_config['accesshash'];
$action = "clients/name/".$a->getUsername();
$action = "clients/name/";
$actionEx = $a->getUsername();
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$userID = $result->id;
$package = preg_replace("/\s+/", "%20", $p->getName());
$data = array(
"id_hosting_plan"=> $package,
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userID = $result->id;
$data = array(
"id_hosting_plan"=> $p->getName(),
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session)); $result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
if(isset($result_c)) { if(isset($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to change the account password!'); throw new Server_Exception('Failed to change the account password!');
} }
} }
public function changeAccountPassword(Server_Account $a, $new) public function changeAccountPassword(Server_Account $a, $new)
{ {
$this->getLog()->info('Changing password on account '.$a->getUsername()); $this->getLog()->info('Changing password on account '.$a->getUsername());
$host = $this->_config['host']; $apiUrl = "https://".$this->_config['host']."/api/v2/";
$apiUrl = "https://".$host."/api/v2/"; $apiKey = $this->_config['accesshash'];
$action = "clients/name/".$a->getUsername();
$action = "clients/name/";
$actionEx = $a->getUsername();
$result = Server_Manager_KeyHelp::getCURL($action, $actionEx);
$userID = $result->id;
$data = array(
"password"=> $a->getPassword(),
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action; $actionapiUrl = $apiUrl . $action;
$apiKey = $this->_config['accesshash']; $curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array( curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey, 'X-API-Key: '.$apiKey,
'accept: application/json', 'accept: application/json',
'Content-Type: application/json', 'Content-Type: application/json',
)); ));
$result = json_decode(curl_exec($curl_session));
curl_close($curl_session );
$userID = $result->id;
$data = array(
"password"=> $a->getPassword(),
);
$action = "clients/".$userID;
$actionapiUrl = $apiUrl . $action;
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL,$actionapiUrl);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array(
'X-API-Key: '.$apiKey,
'accept: application/json',
'Content-Type: application/json',
));
curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl_session, CURLOPT_POSTFIELDS, json_encode($data));
$result_c = json_decode(curl_exec($curl_session)); $result_c = json_decode(curl_exec($curl_session));
curl_close($curl_session ); curl_close($curl_session );
if(isset($result_c)) { if(isset($result_c)) {
return true; return true;
} else { } else {
throw new Server_Exception('Failed to change the account password!'); throw new Server_Exception('Failed to change the account password!');
} }
} }
/*#######################################
### KEIN SUPPORT FÜR DIESE FUNKTIONEN ###
#######################################*/
public function changeAccountUsername(Server_Account $a, $new) /*
{ Maybe upcoming - maybe not....
throw new Server_Exception('KeyHelp does not support username changes'); */
} public function changeAccountUsername(Server_Account $a, $new)
public function changeAccountDomain(Server_Account $a, $new) {
{ throw new Server_Exception('KeyHelp does not support username changes');
throw new Server_Exception('KeyHelp does not support changing the primary domain name'); }
} public function changeAccountDomain(Server_Account $a, $new)
public function changeAccountIp(Server_Account $a, $new) {
{ throw new Server_Exception('KeyHelp does not support changing the primary domain name');
throw new Server_Exception('KeyHelp does not support changing the IP'); }
} public function changeAccountIp(Server_Account $a, $new)
{
throw new Server_Exception('KeyHelp does not support changing the IP');
}
} }