This file is indexed.

/usr/share/php/Horde/Support/Numerizer/Locale/Base.php is in php-horde-support 2.1.5-3.

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
<?php
/**
 * Copyright 2010-2016 Horde LLC (http://www.horde.org/)
 *
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @license  http://www.horde.org/licenses/bsd BSD
 * @category Horde
 * @package  Support
 */

/**
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @license  http://www.horde.org/licenses/bsd BSD
 * @category Horde
 * @package  Support
 */
class Horde_Support_Numerizer_Locale_Base
{
    public $DIRECT_NUMS = array(
        'eleven' => '11',
        'twelve' => '12',
        'thirteen' => '13',
        'fourteen' => '14',
        'fifteen' => '15',
        'sixteen' => '16',
        'seventeen' => '17',
        'eighteen' => '18',
        'nineteen' => '19',
        'ninteen' => '19',      // Common mis-spelling
        'zero' => '0',
        'one' => '1',
        'two' => '2',
        'three' => '3',
        'four(\W|$)' => '4$1',  // The weird regex is so that it matches four but not fourty
        'five' => '5',
        'six(\W|$)' => '6$1',
        'seven(\W|$)' => '7$1',
        'eight(\W|$)' => '8$1',
        'nine(\W|$)' => '9$1',
        'ten' => '10',
        '\ba[\b^$]' => '1',     // doesn't make sense for an 'a' at the end to be a 1
    );

    public $TEN_PREFIXES = array(
        'twenty' => 20,
        'thirty' => 30,
        'forty' => 40,
        'fourty' => 40, // Common mis-spelling
        'fifty' => 50,
        'sixty' => 60,
        'seventy' => 70,
        'eighty' => 80,
        'ninety' => 90,
        'ninty' => 90, // Common mis-spelling
    );

    public $BIG_PREFIXES = array(
        'hundred' => 100,
        'thousand' => 1000,
        'million' => 1000000,
        'billion' => 1000000000,
        'trillion' => 1000000000000,
    );

    public function numerize($string)
    {
        // preprocess
        $string = $this->_splitHyphenatedWords($string);
        $string = $this->_hideAHalf($string);

        $string = $this->_directReplacements($string);
        $string = $this->_replaceTenPrefixes($string);
        $string = $this->_replaceBigPrefixes($string);
        $string = $this->_fractionalAddition($string);

        return $string;
    }

    /**
     * will mutilate hyphenated-words but shouldn't matter for date extraction
     */
    protected function _splitHyphenatedWords($string)
    {
        return preg_replace('/ +|([^\d])-([^d])/', '$1 $2', $string);
    }

    /**
     * take the 'a' out so it doesn't turn into a 1, save the half for the end
     */
    protected function _hideAHalf($string)
    {
        return str_replace('a half', 'haAlf', $string);
    }

    /**
     * easy/direct replacements
     */
    protected function _directReplacements($string)
    {
        foreach ($this->DIRECT_NUMS as $dn => $dn_replacement) {
            $string = preg_replace("/$dn/i", $dn_replacement, $string);
        }
        return $string;
    }

    /**
     * ten, twenty, etc.
     */
    protected function _replaceTenPrefixes($string)
    {
        foreach ($this->TEN_PREFIXES as $tp => $tp_replacement) {
            $string = preg_replace_callback(
                "/(?:$tp)( *\d(?=[^\d]|\$))*/i",
                create_function(
                    '$m',
                    'return ' . $tp_replacement . ' + (isset($m[1]) ? (int)$m[1] : 0);'
                ),
                $string);
        }
        return $string;
    }

    /**
     * hundreds, thousands, millions, etc.
     */
    protected function _replaceBigPrefixes($string)
    {
        foreach ($this->BIG_PREFIXES as $bp => $bp_replacement) {
            $string = preg_replace_callback(
                '/(\d*) *' . $bp . '/i',
                create_function(
                    '$m',
                    'return ' . $bp_replacement . ' * (int)$m[1];'
                ),
                $string);
            $string = $this->_andition($string);
        }
        return $string;
    }

    protected function _andition($string)
    {
        while (true) {
            if (preg_match('/(\d+)( | and )(\d+)(?=[^\w]|$)/i', $string, $sc, PREG_OFFSET_CAPTURE)) {
                if (preg_match('/and/', $sc[2][0]) || (strlen($sc[1][0]) > strlen($sc[3][0]))) {
                    $string = substr($string, 0, $sc[1][1]) . ((int)$sc[1][0] + (int)$sc[3][0]) . substr($string, $sc[3][1] + strlen($sc[3][0]));
                    continue;
                }
            }
            break;
        }
        return $string;
    }

    protected function _fractionalAddition($string)
    {
        return preg_replace_callback(
            '/(\d+)(?: | and |-)*haAlf/i',
            create_function(
                '$m',
                'return (string)((float)$m[1] + 0.5);'
            ),
            $string);
    }

}