コード例 #1
0
/**
 * Sends report data to the error reporting server
 *
 * @param array $report the report info to be sent
 *
 * @return String the reply of the server
 */
function PMA_sendErrorReport($report)
{
    $data_string = json_encode($report);
    if (ini_get('allow_url_fopen')) {
        $context = array("http" => array('method' => 'POST', 'content' => $data_string, 'header' => "Content-Type: application/json\r\n"));
        $context = PMA\libraries\Util::handleContext($context);
        $response = @file_get_contents(SUBMISSION_URL, false, stream_context_create($context));
        return $response;
    }
    if (!function_exists('curl_init')) {
        return null;
    }
    $curl_handle = curl_init(SUBMISSION_URL);
    if ($curl_handle === false) {
        return null;
    }
    $curl_handle = PMA\libraries\Util::configureCurl($curl_handle);
    curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Type: application/json'));
    curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl_handle);
    curl_close($curl_handle);
    return $response;
}