this is my code: when i try to connect to whm/Cpanel to add new account this issue occure but when i try to delete a user from whm/cpanel it works perfect. my problem is curl_exec line die and show me blank white screen there isn't any error on the page and curl_error didn't return anything codes after curl_exec didn't run at all.
Thanks for your answers
$curl = curl_init();
# Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
# Allow certs that do not match the domain
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
# Allow self-signed certs
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
# Return contents of transfer on curl_exec
$header[0] = "Authorization: WHM $cpanel_user:" . preg_replace("'(|
)'", "", $whmhash);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1800);
# Remove newlines from the hash
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
# Set curl header
curl_setopt($curl, CURLOPT_URL, $command);
# Set your URL
curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
if( ! $result = curl_exec($curl))
{
trigger_error(curl_error($curl));
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
# Execute Query, assign to $result
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
}
curl_close($curl);
The problem was nginx that didn't allow the response came back to my code. by disabling nginx on server that working on proxy mode for apache it solved.
You should use curl_errno to check if there was any error with curl
Replace this
if( ! $result = curl_exec($curl))
{
trigger_error(curl_error($curl));
}
By
$result = curl_exec($curl);
// Check for errors and display the error message
if($errno = curl_errno($curl)) {
$error_message = curl_strerror($errno);
trigger_error("cURL error ({$errno}):
{$error_message}");
}