This file is indexed.

/usr/share/php/Horde/Service/Gravatar.php is in php-horde-service-gravatar 1.0.1-1ubuntu1.

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
182
183
<?php
/**
 * Copyright 2011-2016 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.
 *
 * @category Horde
 * @package  Service_Gravatar
 * @author   Gunnar Wrobel <wrobel@pardus.de>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 */

/**
 * Horde_Service_Gravatar abstracts communication with Services supporting the
 * Gravatar API.
 *
 * @category Horde
 * @package  Service_Gravatar
 * @author   Gunnar Wrobel <wrobel@pardus.de>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @link     http://www.gravatar.com/site/implement/
 */
class Horde_Service_Gravatar
{
    /** The default Gravatar base URL */
    const STANDARD = 'http://www.gravatar.com';

    /** The Gravatar base URL in SSL context */
    const SECURE  = 'https://secure.gravatar.com';

    /**
     * The base Gravatar URL.
     *
     * @var string
     */
    private $_base;

    /**
     * The HTTP client to access the server.
     *
     * @var Horde_Http_Client
     */
    private $_client;

    /**
     * Constructor.
     *
     * The default Gravatar base URL is Horde_Service_Gravatar::STANDARD. If
     * you need URLs in an HTTPS context you should provide the base URL
     * parameter as Horde_Service_Gravatar::SECURE. In case you wish to access
     * another URL offering the Gravatar API you can specify the base URL of
     * this service as $base.
     *
     * @param string            $base    The base Gravatar URL.
     * @param Horde_Http_Client $client  The HTTP client to access the server.
     */
    public function __construct(
        $base = self::STANDARD,
        Horde_Http_Client $client = null
    )
    {
        $this->_base   = $base;
        if ($client === null) {
            $client = new Horde_Http_Client();
        }
        $this->_client = $client;
    }

    /**
     * Return the Gravatar ID for the specified mail address.
     *
     * @param string $mail  The mail address.
     *
     * @return string  The Gravatar ID.
     */
    public function getId($mail)
    {
        if (!is_string($mail)) {
            throw new InvalidArgumentException('The mail address must be a string!');
        }
        return md5(Horde_String::lower(trim($mail)));
    }

    /**
     * Return the Gravatar image URL for the specified mail address. The
     * returned URL can be directly used with an IMG tag e.g.:
     * &lt;img src="http://www.gravatar.com/avatar/hash" /&gt;
     *
     * @param string $mail  The mail address.
     * @param mixed $opts   Additional options. If an integer, treated as the
     *                      'size' option.  If an array, the following options
     *                      are available:
     * <pre>
     *   - default: (string) Default behavior. Valid values are '404', 'mm',
     *              'identicon', 'monsterid', 'wavatar', 'retro', 'blank', or
     *              a URL-encoded URL to use as the default image.
     *   - rating: (string) Rating. Valid values are 'g', 'pg', 'r', and 'x'.
     *   - size: (integer) Image size. Valid values are between 1 and 512.
     * </pre>
     *
     * @return Horde_Url  The image URL.
     */
    public function getAvatarUrl($mail, $opts = array())
    {
        if (is_integer($opts)) {
            $opts = array('size' => $opts);
        }

        if (!empty($opts['size']) &&
            (($opts['size'] < 1) || ($opts['size'] > 512))) {
            throw InvalidArgumentException('The size parameter is out of bounds');
        }

        $url = new Horde_Url($this->_base . '/avatar/' . $this->getId($mail));
        if (!empty($opts['default'])) {
            $url->add('d', $opts['default']);
        }
        if (!empty($opts['rating'])) {
            $url->add('r', $opts['rating']);
        }
        if (!empty($opts['size'])) {
            $url->add('s', $opts['size']);
        }

        return $url;
    }

    /**
     * Return the Gravatar profile URL.
     *
     * @param string $mail  The mail address.
     *
     * @return string  The profile URL.
     */
    public function getProfileUrl($mail)
    {
        return $this->_base . '/' . $this->getId($mail);
    }

    /**
     * Fetch the Gravatar profile information.
     *
     * @param string $mail  The mail address.
     *
     * @return string  The profile information.
     */
    public function fetchProfile($mail)
    {
        return $this->_client->get($this->getProfileUrl($mail) . '.json')
            ->getBody();
    }

    /**
     * Return the Gravatar profile information as an array.
     *
     * @param string $mail  The mail address.
     *
     * @return array  The profile information.
     */
    public function getProfile($mail)
    {
        return json_decode($this->fetchProfile($mail), true);
    }

    /**
     * Fetch the avatar image.
     *
     * @param string $mail  The mail address.
     * @param mixed $opts   Additional options. See getAvatarUrl().
     *
     * @return resource  The image as stream resource, or null if the server
     *                   returned an error.
     */
    public function fetchAvatar($mail, $opts = array())
    {
        $get = $this->_client->get($this->getAvatarUrl($mail, $opts));
        return ($get->code == 404)
            ? null
            : $get->getStream();
    }

}