Project

General

Profile

« Previous | Next » 

Revision ab197c42

Added by Steve Beaver about 7 years ago

PHP7 - Rewrite uploader to use curlFile class

View differences:

src/usr/local/www/crash_reporter.php
36 36
function upload_crash_report($files) {
37 37
	global $g, $config;
38 38

  
39
	$post = array();
39
	$target_url = $g['crashreporterurl'];
40

  
41
	$post = array ();
42

  
40 43
	$counter = 0;
41 44
	foreach ($files as $file) {
42
		$post["file{$counter}"] = "@{$file}";
45
		$post["file{$counter}"] = curl_file_create ($file);
43 46
		$counter++;
44 47
	}
45
	$ch = curl_init();
46
	curl_setopt($ch, CURLOPT_HEADER, 0);
47
	curl_setopt($ch, CURLOPT_VERBOSE, 0);
48
	curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
49
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
48

  
49
	$ch = curl_init ($target_url);
50
	curl_setopt ($ch, CURLOPT_POST, true);
51
	curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
52
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
53

  
50 54
	if (!isset($config['system']['do_not_send_uniqueid'])) {
51 55
		curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version'] . ':' . system_get_uniqueid());
52 56
	} else {
53 57
		curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version']);
54 58
	}
55
	curl_setopt($ch, CURLOPT_URL, $g['crashreporterurl']);
56
	curl_setopt($ch, CURLOPT_POST, true);
57
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
58
	$response = curl_exec($ch);
59
	return $response;
59

  
60
	$result=curl_exec ($ch);
61
	curl_close ($ch);
62
	return $result;
60 63
}
61 64

  
62 65
$pgtitle = array(gettext("Diagnostics"), gettext("Crash Reporter"));

Also available in: Unified diff