• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.

Issue CurlInitialize for PHP XML API

cipcip

Basic Pleskian
Hi guys,

I did not had any issues with this on my localhost, but apparently as soon as i uploaded to the server, I get errors about the curlinitialize file that i have for API. I can't remember where I took it from now, it was not written by me, but can you help me with this ?

Errors received:

[Sat Jan 26 01:55:12.200814 2019] [proxy_fcgi:error] [pid 9549:tid 140402248107776] [client 188.250.203.236:56547] AH01071: Got error 'PHP message: PHP Warning: curl_setopt(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 22\nPHP message: PHP Warning: curl_exec(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 24\nPHP message: PHP Warning: curl_errno(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 26\nPHP message: PHP Warning: curl_close(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 32\nPHP message: PHP Warning: curl_setopt(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 22\nPHP message: PHP Warning: curl_exec(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 24\nPHP message: PHP Warning: curl_errno(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 26\nPHP message: PHP Warning: curl_close(): supplied resource is not a valid cURL handle resource in /var/www/vhosts/domain/httpdocs/inc/curlInitialize.php on line 32\n', referer: https://domain/signup

The PHP code for the file is:

Code:
<?php
function curlInit($host, $login, $password)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://{$host}:8443/enterprise/control/agent.php");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("HTTP_AUTH_LOGIN: {$login}",
"HTTP_AUTH_PASSWD: {$password}",
"HTTP_PRETTY_PRINT: TRUE",
"Content-Type: text/xml")
);

return $curl;
}

function sendRequest($curl, $packet)
{
curl_setopt($curl, CURLOPT_POSTFIELDS, $packet);

$result = curl_exec($curl);

if (curl_errno($curl)) {
$errmsg = curl_error($curl);
$errcode = curl_errno($curl);
curl_close($curl);
throw new ApiRequestException($errmsg, $errcode);
}
curl_close($curl);
return $result;
}

?>

Thank you
 
I fixed the curl errors, that was a bug from my part.

Now I get:

[Sat Jan 26 10:54:39.742055 2019] [proxy_fcgi:error] [pid 26396:tid 140165766960896] [client 188.250.203.236:52575] AH01067: Failed to read FastCGI header, referer: https://domain/signup
[Sat Jan 26 10:54:39.742098 2019] [proxy_fcgi:error] [pid 26396:tid 140165766960896] (104)Connection reset by peer: [client 188.250.203.236:52575] AH01075: Error dispatching request to : , referer: https://domain/signup

I tried to run a query by itself, to create a subdomain, and it fails, it gives 503 error.
Code used to create a subdomain is:

<?php

include('inc/config.php');
include('inc/curlInitialize.php');

function createSubdomain($nom, $domeniu)
{
$xmldoc = new DomDocument('1.0', 'UTF-8');
$xmldoc->formatOutput = true;
$packet = $xmldoc->createElement('packet');
$packet->setAttribute('version', '1.6.8.0');
$xmldoc->appendChild($packet);
$subdomain = $xmldoc->createElement('subdomain');
$packet->appendChild($subdomain);
$add = $xmldoc->createElement('add');
$subdomain->appendChild($add);
$parent = $xmldoc->createElement('parent', $domeniu);
$add->appendChild($parent);
$name = $xmldoc->createElement('name', $nom);
$add->appendChild($name);
$add->appendChild($xmldoc->createElement('home', $domeniu.'/'.$nom.''));
$property = $xmldoc->createElement('property');
$property->appendChild($xmldoc->createElement('name', 'ssi'));
$property->appendChild($xmldoc->createElement('value', 'true'));
$add->appendChild($property);
return $xmldoc;
}

$subdomeniu = 'test';

$curl = curlInit($host, $login, $pass);
$cerere = createSubDomain($subdomeniu, $domeniu)->saveXML();
printf(htmlspecialchars($cerere));
echo '<br /><br /><br />';
$raspuns = sendRequest($curl, $cerere);
$extractid = array($raspuns);
print_r($extractid);

?>

Same errors in log file as above.
Can this happen because of server resources?

I have a VPS with the following:

Web Space 100 GB SSD
CPU Power 2 vCores
Guaranteed RAM 4 GB
Burst RAM 8 GB
Traffic 100-Mbit/s-Flatrate

Thank you
 
Last edited:
Back
Top