|
|
|
@ -40,7 +40,7 @@
|
|
|
|
|
class rcube_plesk_password
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* this method is called from roundcube to change the password
|
|
|
|
|
* This method is called from roundcube to change the password
|
|
|
|
|
*
|
|
|
|
|
* roundcube allready validated the old password so we just need to change it at this point
|
|
|
|
|
*
|
|
|
|
@ -88,6 +88,8 @@ class rcube_plesk_password
|
|
|
|
|
*/
|
|
|
|
|
class plesk_rpc
|
|
|
|
|
{
|
|
|
|
|
protected $old_version = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* init plesk-rpc via curl
|
|
|
|
|
*
|
|
|
|
@ -120,35 +122,24 @@ class plesk_rpc
|
|
|
|
|
* send a request to the plesk
|
|
|
|
|
*
|
|
|
|
|
* @param string $packet XML-Packet to send to Plesk
|
|
|
|
|
* @returns bool request was successful or not
|
|
|
|
|
*
|
|
|
|
|
* @returns string Response body
|
|
|
|
|
*/
|
|
|
|
|
function send_request($packet)
|
|
|
|
|
{
|
|
|
|
|
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $packet);
|
|
|
|
|
$retval = curl_exec($this->curl);
|
|
|
|
|
$result = curl_exec($this->curl);
|
|
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
|
return $result && strpos($result, '<?xml') === 0 ? $result : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* close curl
|
|
|
|
|
*/
|
|
|
|
|
function destroy(){
|
|
|
|
|
curl_close($this->curl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an Initial SimpleXML-Object for Plesk-RPC
|
|
|
|
|
*
|
|
|
|
|
* @returns object SimpleXML object
|
|
|
|
|
*/
|
|
|
|
|
function get_request_obj()
|
|
|
|
|
function destroy()
|
|
|
|
|
{
|
|
|
|
|
$request = new SimpleXMLElement("<packet></packet>");
|
|
|
|
|
$request->addAttribute("version", "1.6.3.0");
|
|
|
|
|
|
|
|
|
|
return $request;
|
|
|
|
|
curl_close($this->curl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -160,7 +151,7 @@ class plesk_rpc
|
|
|
|
|
function domain_info($domain)
|
|
|
|
|
{
|
|
|
|
|
// build xml
|
|
|
|
|
$request = $this->get_request_obj();
|
|
|
|
|
$request = new SimpleXMLElement("<packet></packet>");
|
|
|
|
|
$site = $request->addChild("site");
|
|
|
|
|
$get = $site->addChild("get");
|
|
|
|
|
$filter = $get->addChild("filter");
|
|
|
|
@ -171,11 +162,23 @@ class plesk_rpc
|
|
|
|
|
$dataset->addChild("hosting");
|
|
|
|
|
$packet = $request->asXML();
|
|
|
|
|
|
|
|
|
|
// send the request
|
|
|
|
|
$res = $this->send_request($packet);
|
|
|
|
|
// send the request and make it to simple-xml-object
|
|
|
|
|
if ($res = $this->send_request($packet)) {
|
|
|
|
|
$xml = new SimpleXMLElement($res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Old Plesk versions require version attribute, add it and try again
|
|
|
|
|
if ($xml && $xml->site->get->result->status == 'error' && $xml->site->get->result->errcode == 1017) {
|
|
|
|
|
$request->addAttribute("version", "1.6.3.0");
|
|
|
|
|
$packet = $request->asXML();
|
|
|
|
|
|
|
|
|
|
// make it to simple-xml-object
|
|
|
|
|
$xml = new SimpleXMLElement($res);
|
|
|
|
|
$this->old_version = true;
|
|
|
|
|
|
|
|
|
|
// send the request and make it to simple-xml-object
|
|
|
|
|
if ($res = $this->send_request($packet)) {
|
|
|
|
|
$xml = new SimpleXMLElement($res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $xml;
|
|
|
|
|
}
|
|
|
|
@ -185,15 +188,13 @@ class plesk_rpc
|
|
|
|
|
*
|
|
|
|
|
* @param string $domain domain-name
|
|
|
|
|
*
|
|
|
|
|
* @returns bool|int false if failed and integer if successed
|
|
|
|
|
* @returns int Domain ID
|
|
|
|
|
*/
|
|
|
|
|
function get_domain_id($domain)
|
|
|
|
|
{
|
|
|
|
|
$xml = $this->domain_info($domain);
|
|
|
|
|
$id = intval($xml->site->get->result->id);
|
|
|
|
|
$id = (is_int($id)) ? $id : false;
|
|
|
|
|
|
|
|
|
|
return $id;
|
|
|
|
|
if ($xml = $this->domain_info($domain)) {
|
|
|
|
|
return intval($xml->site->get->result->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -215,11 +216,11 @@ class plesk_rpc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// build xml-packet
|
|
|
|
|
$request = $this -> get_request_obj();
|
|
|
|
|
$mail = $request -> addChild("mail");
|
|
|
|
|
$update = $mail -> addChild("update");
|
|
|
|
|
$add = $update -> addChild("set");
|
|
|
|
|
$filter = $add -> addChild("filter");
|
|
|
|
|
$request = new SimpleXMLElement("<packet></packet>");
|
|
|
|
|
$mail = $request->addChild("mail");
|
|
|
|
|
$update = $mail->addChild("update");
|
|
|
|
|
$add = $update->addChild("set");
|
|
|
|
|
$filter = $add->addChild("filter");
|
|
|
|
|
$filter->addChild("site-id", $domain_id);
|
|
|
|
|
|
|
|
|
|
$mailname = $filter->addChild("mailname");
|
|
|
|
@ -229,13 +230,20 @@ class plesk_rpc
|
|
|
|
|
$password->addChild("value", $newpass);
|
|
|
|
|
$password->addChild("type", "plain");
|
|
|
|
|
|
|
|
|
|
if ($this->old_version) {
|
|
|
|
|
$request->addAttribute("version", "1.6.3.0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$packet = $request->asXML();
|
|
|
|
|
|
|
|
|
|
// send the request to plesk
|
|
|
|
|
$res = $this->send_request($packet);
|
|
|
|
|
$xml = new SimpleXMLElement($res);
|
|
|
|
|
$res = strval($xml->mail->update->set->result->status);
|
|
|
|
|
if ($res = $this->send_request($packet)) {
|
|
|
|
|
$xml = new SimpleXMLElement($res);
|
|
|
|
|
$res = strval($xml->mail->update->set->result->status);
|
|
|
|
|
|
|
|
|
|
return $res == "ok";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $res == "ok";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|