Esempio n. 1
0
$dump_filename = $entry_name . '.dmp';
$dump_path = $dump_dir . '/' . $dump_filename;
if (!move_uploaded_file($_FILES['upload_file_minidump']['tmp_name'], $dump_path)) {
    header('HTTP/1.1 400 Bad Request');
    exit('400 Bad Request -- illegal or bad dump file');
}
# store metadata as json
$meta_filename = $entry_name . '.json';
$meta_path = $dump_dir . '/' . $meta_filename;
file_put_contents($meta_path, json_encode($_POST));
# send response
header('HTTP/1.1 201 Created');
header('Connection: close');
header('Content-type: text/plain; charset=utf8');
header('Content-length: ' . strlen($entry_name));
echo $entry_name;
# send mail if there are comments
if (isset($_POST['comments']) && ($_POST['comments'] = trim($_POST['comments']))) {
    ignore_user_abort(true);
    require 'stackwalk.php';
    $stacktrace = breakpad_stackwalk($dump_path, $symbol_dir);
    $email_body = '';
    foreach ($_POST as $k => $v) {
        if ($k != 'comments') {
            $email_body .= $k . ': ' . $v . "\n";
        }
    }
    $email_body .= "entry: {$entry_name} <{$entry_url_base}" . urlencode($entry_name) . ">\n" . "comments:\n" . $_POST['comments'] . "\n----\n" . $stacktrace . "\n";
    $mail = hgmail::newtext($email_recipient, $email_replyto_addr, $email_replyto_name, $_POST['prod'] . ' ' . $_POST['ver'] . ' crash report ' . $entry_id, $email_body);
    $mail->Send();
}
Esempio n. 2
0
if (!$dstf) {
    header('HTTP/1.1 500 Internal Server Error');
    exit('unable to write to ' . $dirpath);
}
$srcf = fopen('php://input', 'r');
$size = stream_copy_to_stream($srcf, $dstf, $MAXLENGTH);
fclose($dstf);
if ($size === 0) {
    @unlink($abspath);
} elseif ($size >= $MAXLENGTH) {
    @unlink($abspath);
    # because it's probably broken
    header('HTTP/1.1 413 Request Entity Too Large');
    exit('Request entity larger than or equal to ' . $MAXLENGTH . ' B');
}
# send response
header('HTTP/1.1 201 Created');
header('Connection: close');
header('Content-type: text/plain; charset=utf8');
header('Content-length: ' . strlen($entry_id));
echo $entry_id;
# send mail
ignore_user_abort(true);
$crash_report = file_get_contents($abspath);
$version = '?';
if (preg_match('/Version:[\\t ]+([0-9\\.]+)/', $crash_report, $m)) {
    $version = $m[1];
}
$email_body = $crash_report;
$mail = hgmail::newtext($email_recipient, $email_replyto_addr, $email_replyto_name, 'Kod ' . $version . ' crash report ' . $entry_id, $email_body);
$mail->Send();