xref: /web-bugs/www/rss/bug.php (revision 9d47b05f)
1<?php
2
3use App\Repository\BugRepository;
4use App\Repository\CommentRepository;
5
6/* Generates an RSS/RDF feed for a particular bug specified as the "id"
7 * parameter.  optionally, if "format" is "xml", generates data in a
8 * non-standard xml format.
9 *
10 * Contributed by Sara Golemon <pollita@php.net>
11 * ported from php-bugs-web by Gregory Beaver <cellog@php.net>
12 */
13
14require_once '../../include/prepend.php';
15
16$bug_id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
17$format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'rss2';
18
19$bugRepository = $container->get(BugRepository::class);
20$bug = $bugRepository->findOneById($bug_id);
21
22if (!$bug) {
23    header('HTTP/1.0 404 Not Found');
24    die('Nothing found');
25}
26
27if ($bug['private'] == 'Y') {
28    header('HTTP/1.0 403 Forbidden');
29    die('Access restricted');
30}
31
32$commentRepository = $container->get(CommentRepository::class);
33$comments = $commentRepository->findByBugId($bug_id);
34
35if ($format == 'xml') {
36    header('Content-type: text/xml; charset=utf-8');
37    include './xml.php';
38    exit;
39} elseif ($format == "rss2") {
40    header('Content-type: application/rss+xml; charset=utf-8');
41    $uri = "{$site_method}://{$site_url}{$basedir}/bug.php?id={$bug['id']}";
42    include './rss.php';
43    exit;
44} else {
45    header('Content-type: application/rdf+xml; charset=utf-8');
46    $uri = "{$site_method}://{$site_url}{$basedir}/bug.php?id={$bug['id']}";
47    include './rdf.php';
48    exit;
49}
50