Lid |
|
Hallo Forumleden,
Ik probeer in Plesk een custom database aan te maken. Dus zonder in de plesk control panel in te loggen. Je moet gebruik maken van de API van PLESK, maar het staat hier niet echt duidelijk uitgelegd. Heeft iemand anders op het forum ervaring met het toevoegen van een database onder een domain in plesk?
PS. het is gelukt. Als men een database wilt aanmaken via de PLESK API zie volgende code:
<?php define ('HOST', 'xxxx.nl');
define ('PORT', 8443);
define ('PATH', 'enterprise/control/agent.php');
$url = 'https://' . HOST . ':' . PORT . '/' . PATH;
$headers = array(
'HTTP_AUTH_LOGIN: xxxx',
'HTTP_AUTH_PASSWD: xxxx',
'Content-Type: text/xml'
);
// initialize the curl engine
$ch = curl_init();
// set the curl options:
// do not check the name of SSL certificate of the remote server
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// do not check up the remote server certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// pass in the header elements
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// pass in the url of the target server
curl_setopt($ch, CURLOPT_URL, $url);
$packet = '<packet version="1.6.0.2">
<database>
<add-db>
<domain-id>1</domain-id>
<name>goodbase</name>
<type>mysql</type>
<db-server-id>1</db-server-id>
</add-db>
</database>
</packet>';
// tell CURL to return the result rather than to load it to the browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// pass in the packet to deliver
curl_setopt($ch, CURLOPT_POSTFIELDS, $packet);
// perform the CURL request and return the result
$retval = curl_exec($ch);
// close the CURL session
curl_close($ch);
echo $retval;
<?php define ('HOST', 'xxxx.nl'); define ('PATH', 'enterprise/control/agent.php'); $url = 'https://' . HOST . ':' . PORT . '/' . PATH; 'HTTP_AUTH_LOGIN: xxxx', 'HTTP_AUTH_PASSWD: xxxx', 'Content-Type: text/xml' ); // initialize the curl engine $ch = curl_init(); // set the curl options: // do not check the name of SSL certificate of the remote server curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // do not check up the remote server certificate curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // pass in the header elements curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // pass in the url of the target server curl_setopt($ch, CURLOPT_URL, $url); $packet = '<packet version="1.6.0.2"> <database> <add-db> <domain-id>1</domain-id> <name>goodbase</name> <type>mysql</type> <db-server-id>1</db-server-id> </add-db> </database> </packet>'; // tell CURL to return the result rather than to load it to the browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // pass in the packet to deliver curl_setopt($ch, CURLOPT_POSTFIELDS, $packet); // perform the CURL request and return the result $retval = curl_exec($ch); // close the CURL session curl_close($ch);
|