• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • The ImunifyAV extension is now deprecated and no longer available for installation.
    Existing ImunifyAV installations will continue operating for three months, and after that will automatically be replaced with the new Imunify extension. We recommend that you manually replace any existing ImunifyAV installations with Imunify at your earliest convenience.

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