This file is indexed.

/usr/share/php/Horde/Icalendar/Vtimezone.php is in php-horde-icalendar 2.0.7-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
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
 * Class representing vTimezones.
 *
 * Copyright 2003-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @author   Mike Cochrane <mike@graftonhall.co.nz>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  Icalendar
 */
class Horde_Icalendar_Vtimezone extends Horde_Icalendar
{
    /**
     * The component type of this class.
     *
     * @var string
     */
    public $type = 'vTimeZone';

    /**
     * TODO
     *
     * @return TODO
     */
    public function exportvCalendar()
    {
        return $this->_exportvData('VTIMEZONE');
    }

    /**
     * Parse child components of the vTimezone component. Returns an
     * array with the exact time of the time change as well as the
     * 'from' and 'to' offsets around the change. Time is arbitrarily
     * based on UTC for comparison.
     *
     * @param &$child TODO
     * @param $year TODO
     *
     * @return TODO
     */
    public function parseChild(&$child, $year)
    {
        // Make sure 'time' key is first for sort().
        $result['time'] = 0;

        try {
            $t = $child->getAttribute('TZOFFSETFROM');
        } catch (Horde_Icalendar_Exception $e) {
            return array();
        }
        $result['from'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1);

        try {
            $t = $child->getAttribute('TZOFFSETTO');
        } catch (Horde_Icalendar_Exception $e) {
            return array();
        }
        $result['to'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1);

        try {
            $start = $child->getAttribute('DTSTART');
        } catch (Horde_Icalendar_Exception $e) {
            return array();
        }
        if (!is_int($start)) {
            return array();
        }
        $start = getdate($start);
        if ($start['year'] > $year) {
            return array();
        }

        $results = array();
        try {
            $rdates = $child->getAttributeValues('RDATE');
            foreach ($rdates as $rdate) {
                if ($rdate['year'] == $year || $rdate['year'] == $year - 1) {
                    $result['time'] = gmmktime(
                    $start['hours'], $start['minutes'], $start['seconds'],
                    $rdate['month'], $rdate['mday'], $rdate['year']);
                    $results[] = $result;
                }
            }
        } catch (Horde_Icalendar_Exception $e) {
        }

        try {
            $rrules = $child->getAttribute('RRULE');
        } catch (Horde_Icalendar_Exception $e) {
            if (!$results) {
                $result['time'] = $start[0];
                $results[] = $result;
            }
            return $results;
        }

        $rrules = explode(';', $rrules);
        foreach ($rrules as $rrule) {
            $t = explode('=', $rrule);
            switch ($t[0]) {
            case 'FREQ':
                if ($t[1] != 'YEARLY') {
                    return array();
                }
                break;

            case 'INTERVAL':
                if ($t[1] != '1') {
                    return array();
                }
                break;

            case 'BYMONTH':
                $month = intval($t[1]);
                break;

            case 'BYDAY':
                $len = strspn($t[1], '1234567890-+');
                if ($len == 0) {
                    return array();
                }
                $weekday = substr($t[1], $len);
                $weekdays = array(
                    'SU' => 0,
                    'MO' => 1,
                    'TU' => 2,
                    'WE' => 3,
                    'TH' => 4,
                    'FR' => 5,
                    'SA' => 6
                );
                $weekday = $weekdays[$weekday];
                $which = intval(substr($t[1], 0, $len));
                break;

            case 'UNTIL':
                if (intval($year) > intval(substr($t[1], 0, 4))) {
                    return array();
                }
                break;
            }
        }

        if (empty($month) || !isset($weekday)) {
            return array();
        }

        // Get the timestamp for the first day of $month.
        $when = gmmktime($start['hours'], $start['minutes'], $start['seconds'],
                         $month, 1, $year);
        // Get the day of the week for the first day of $month.
        $first_of_month_weekday = intval(gmstrftime('%w', $when));

        // Go to the first $weekday before first day of $month.
        if ($weekday >= $first_of_month_weekday) {
            $weekday -= 7;
        }
        $when -= ($first_of_month_weekday - $weekday) * 60 * 60 * 24;

        // If going backwards go to the first $weekday after last day
        // of $month.
        if ($which < 0) {
            do {
                $when += 60*60*24*7;
            } while (intval(gmstrftime('%m', $when)) == $month);
        }

        // Calculate $weekday number $which.
        $when += $which * 60 * 60 * 24 * 7;

        $result['time'] = $when;
        $results[] = $result;

        return $results;
    }

}