xref: /web-bugs/www/index.php (revision 11c6f02e)
1<?php
2
3/**
4 * The bug system home page.
5 */
6use App\Repository\BugRepository;
7
8// Application bootstrap
9require_once __DIR__.'/../include/prepend.php';
10
11// Authentication
12require_once __DIR__.'/../include/auth.php';
13
14// If 'id' is passed redirect to the bug page
15$id = (int) ($_GET['id'] ?? 0);
16
17if (0 !== $id) {
18    redirect('bug.php?id='.$id);
19}
20
21if ('/random' === $_SERVER['REQUEST_URI']) {
22    $id = $container->get(BugRepository::class)->findRandom();
23    redirect('bug.php?id='.$id[0]);
24}
25
26$searches = [
27    'Most recent open bugs (all)' => '&bug_type=All&project=PHP',
28    'Most recent open bugs (all) with patch or pull request' => '&bug_type=All&project=PHP&patch=Y&pull=Y',
29    'Most recent open bugs (PHP 7.2)' => '&bug_type=All&phpver=7.2&project=PHP',
30    'Most recent open bugs (PHP 7.3)' => '&bug_type=All&phpver=7.3&project=PHP',
31    'Most recent open bugs (PHP 7.4)' => '&bug_type=All&phpver=7.4&project=PHP',
32    'Most recent open bugs (PHP 8.0)' => '&bug_type=All&phpver=8.0&project=PHP',
33    'Open Documentation bugs' => '&bug_type=Documentation+Problem',
34    'Open Documentation bugs (with patches)' => '&bug_type=Documentation+Problem&patch=Y',
35];
36
37if (!empty($_SESSION['user'])) {
38    $searches['Your assigned open bugs'] = '&assign='.urlencode($_SESSION['user']);
39}
40
41// Prefix query strings with base URL
42$searches = preg_filter(
43    '/^/',
44    '/search.php?limit=30&order_by=id&direction=DESC&cmd=display&status=Open',
45    $searches
46);
47
48// Output template with given template variables.
49echo $template->render('pages/index.php', [
50    'searches' => $searches,
51]);
52