get(BugRepository::class); if (!($buginfo = $bugRepository->findOneById($bug_id))) { response_header('Error :: invalid bug selected'); display_bug_error("Invalid bug #{$bug_id} selected"); response_footer(); exit; } $package_name = $buginfo['package_name']; // captcha is not necessary if the user is logged in if (!$logged_in) { $captcha = $container->get(Captcha::class); } $show_bug_info = bugs_has_access($bug_id, $buginfo, $pw, $user_flags); if (!$show_bug_info) { response_header('Private report'); display_bug_error("The bug #{$bug_id} is not available to public"); response_footer(); exit; } $pullinfo = $container->get(GitHub::class); $pullRequestRepository = $container->get(PullRequestRepository::class); if (isset($_POST['addpull'])) { $errors = []; if (empty($_POST['repository'])) { $errors[] = 'No repository selected'; } if (empty($_POST['pull_id'])) { $errors[] = 'No Pull request selected'; } if (!$logged_in) { try { $email = isset($_POST['email']) ? $_POST['email'] : ''; if (!is_valid_email($email, $logged_in)) { $errors[] = 'Email address must be valid!'; } /** * Check if session answer is set, then compare * it with the post captcha value. If it's not * the same, then it's an incorrect password. */ if (!isset($_SESSION['answer']) || $_POST['captcha'] != $_SESSION['answer']) { $errors[] = 'Incorrect Captcha'; } if (count($errors)) { throw new Exception(''); } } catch (Exception $e) { $pulls = $pullRequestRepository->findAllByBugId($bug_id); include "{$ROOT_DIR}/templates/addghpull.php"; exit; } } else { $email = $auth_user->email; } if (!count($errors)) { try { $newpr = $pullinfo->attach($bug_id, $_POST['repository'], $_POST['pull_id'], $email); } catch(\Exception $e) { $errors = ['Could not attach pull request to Bug #'.$bug_id]; if ($e->errorInfo[1] === 1062) { $errors[] = 'This pull request is already added.'; } if ('dev' === $container->get('env')) { $errors[] = $e->getMessage(); } } } if (count($errors)) { $pulls = $pullRequestRepository->findAllByBugId($bug_id); include "{$ROOT_DIR}/templates/addghpull.php"; exit; } // Add a comment to the bug report. $text = <<title} On GitHub: {$newpr->html_url} Patch: {$newpr->patch_url} TXT; $res = bugs_add_comment($bug_id, $email, $auth_user->name, $text, 'patch'); // Send emails mail_bug_updates($buginfo, $buginfo, $email, $text, 4, $bug_id); $pulls = $pullRequestRepository->findAllByBugId($bug_id); $errors = []; include "{$ROOT_DIR}/templates/addghpull.php"; exit; } $email = isset($_GET['email']) ? $_GET['email'] : ''; $pulls = $pullRequestRepository->findAllByBugId($bug_id); include "{$ROOT_DIR}/templates/addghpull.php";