Commit 1f5552cf authored by Ad Schellevis's avatar Ad Schellevis

crash_reporter move to curl_file_create

parent 7566fa09
...@@ -41,20 +41,23 @@ function upload_crash_report($files) ...@@ -41,20 +41,23 @@ function upload_crash_report($files)
$post = array(); $post = array();
$counter = 0; $counter = 0;
foreach($files as $file) { foreach($files as $filename) {
$post["file{$counter}"] = "@{$file}"; $post["file{$counter}"] = curl_file_create($filename, "plain/text", basename($filename));
$counter++; $counter++;
} }
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, 'https://crash.opnsense.org/');
curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible;)'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible;)');
curl_setopt($ch, CURLOPT_URL, 'https://crash.opnsense.org/');
curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data;' ) );
$response = curl_exec($ch); $response = curl_exec($ch);
curl_close($ch);
return !$response; return !$response;
} }
...@@ -87,7 +90,7 @@ $crash_report_header = sprintf( ...@@ -87,7 +90,7 @@ $crash_report_header = sprintf(
<?php <?php
if ($_POST['Submit'] == 'yes') { if (isset($_POST['Submit']) && $_POST['Submit'] == 'yes') {
echo '<p>' . gettext('Processing...'); echo '<p>' . gettext('Processing...');
ob_flush(); ob_flush();
flush(); flush();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment