This file is indexed.

/usr/share/horde/whups/search.php is in php-horde-whups 3.0.0~beta1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
 * Copyright 2001-2002 Robert E. Coyle <robertecoyle@hotmail.com>
 * Copyright 2001-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 *
 * @author Chuck Hagenbuch <chuck@horde.org>
 */

/**
 * Construct the URL back to a supplied search
 */
function _getSearchUrl($vars)
{
    $qUrl = new Horde_Url();

    $queue = (int)$vars->get('queue');
    $qUrl->add(array('queue' => $queue));

    $summary = $vars->get('summary');
    if ($summary) {
        $qUrl->add('summary', $summary);
    }

    $states = $vars->get('states');
    if (is_array($states)) {
        foreach ($states as $type => $state) {
            if (is_array($state)) {
                foreach ($state as $s) {
                    $qUrl->add("states[$type][]", $s);
                }
            } else {
                $qUrl->add("states[$type]", $state);
            }
        }
    }

    return substr($qUrl, 1);
}

require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('whups');

$renderer = new Horde_Form_Renderer();
$beendone = false;
$vars = Horde_Variables::getDefaultVariables();

Whups::addTopbarSearch();

$form = new Whups_Form_Search($vars);
$results = null;
if (($vars->get('formname') || $vars->get('summary') || $vars->get('states') ||
     Horde_Util::getFormData('haveSearch', false)) && $form->validate($vars, true)) {

    $form->getInfo($vars, $info);
    if ($vars->get('submitbutton') == _("Save as Query")) {
        $qManager = new Whups_Query_Manager();
        $whups_query = $qManager->newQuery();
        if (strlen($info['summary'])) {
            $whups_query->insertCriterion('', Whups_Query::CRITERION_SUMMARY, null,
                                          Whups_Query::OPERATOR_CI_SUBSTRING, $info['summary']);
        }
        if ($vars->get('queue')) {
            $whups_query->insertCriterion('', Whups_Query::CRITERION_QUEUE, null,
                                          Whups_Query::OPERATOR_EQUAL, $info['queue'][0]);
        }
        foreach (array('ticket_timestamp', 'date_updated', 'date_resolved', 'date_assigned', 'date_due') as $date_field) {
            if (!empty($info[$date_field]['from']) || !empty($info[$date_field]['to'])) {
                $path = $whups_query->insertBranch('', Whups_Query::TYPE_AND);
                break;
            }
        }
        if (!empty($info['ticket_timestamp']['from'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_TIMESTAMP, null,
                                          Whups_Query::OPERATOR_GREATER, $info['ticket_timestamp']['from']);
        }
        if (!empty($info['ticket_timestamp']['to'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_TIMESTAMP, null,
                                          Whups_Query::OPERATOR_LESS, $info['ticket_timestamp']['to']);
        }
        if (!empty($info['date_updated']['from'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_UPDATED, null,
                                          Whups_Query::OPERATOR_GREATER, $info['date_updated']['from']);
        }
        if (!empty($info['date_updated']['to'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_UPDATED, null,
                                          Whups_Query::OPERATOR_LESS, $info['date_updated']['to']);
        }
        if (!empty($info['date_resolved']['from'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_RESOLVED, null,
                                          Whups_Query::OPERATOR_GREATER, $info['date_resolved']['from']);
        }
        if (!empty($info['date_resolved']['to'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_RESOLVED, null,
                                          Whups_Query::OPERATOR_LESS, $info['date_resolved']['to']);
        }
        if (!empty($info['date_assigned']['from'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_ASSIGNED, null,
                                          Whups_Query::OPERATOR_GREATER, $info['date_assigned']['from']);
        }
        if (!empty($info['date_assigned']['to'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_ASSIGNED, null,
                                          Whups_Query::OPERATOR_LESS, $info['date_assigned']['to']);
        }
        if (!empty($info['date_due']['from'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_DUE, null,
                                          Whups_Query::OPERATOR_GREATER, $info['date_due']['from']);
        }
        if (!empty($info['date_due']['to'])) {
            $whups_query->insertCriterion($path, Whups_Query::CRITERION_DUE, null,
                                          Whups_Query::OPERATOR_LESS, $info['date_due']['to']);
        }
        if ($info['state_id']) {
            $path = $whups_query->insertBranch('', Whups_Query::TYPE_OR);
            foreach ($info['state_id'] as $state) {
                $whups_query->insertCriterion($path, Whups_Query::CRITERION_STATE, null,
                                              Whups_Query::OPERATOR_EQUAL, $state);
            }
        }
        $session->set('whups', 'query', $whups_query);
        Horde::url('query/index.php', true)
            ->add('action', 'save')
            ->redirect();
    }
    try {
        $tickets = $whups_driver->getTicketsByProperties($info);
        Whups::sortTickets($tickets);
        $session->set('whups', 'last_search', Horde::url('search.php?' . _getSearchUrl($vars)));
        $results = new Whups_View_Results(
            array('title' => _("Search Results"),
                  'results' => $tickets,
                  'values' => Whups::getSearchResultColumns(),
                  'url' => $session->get('whups', 'last_search')));
        $beendone = true;
    } catch (Whups_Exception $e) {
        $notification->push(sprintf(_("There was an error performing your search: %s"), $tickets->getMessage()), 'horde.error');
    }
}

Whups::addFeedLink();
$page_output->header(array(
    'title' => _("Search")
));
$notification->notify(array('listeners' => 'status'));

if ($results) {
    $results->html();
    if (is_object($form)) {
        $form->setTitle(_("Refine Search"));
        $form->renderActive($renderer, $vars, Horde::url('search.php'), 'get');
    }
}

if (!$beendone) {
    // Front search page.
    $form->setTitle(_("Ticket Search"));
    $form->renderActive($renderer, $vars, Horde::url('search.php'), 'get');
}

$qManager = new Whups_Query_Manager();
$myqueries = new Whups_View_SavedQueries(
    array('title' => $GLOBALS['registry']->getAuth() ? _("My Queries") : _("Public Queries"),
          'results' => $qManager->listQueries($GLOBALS['registry']->getAuth(), true)));
$myqueries->html();

$page_output->footer();