This file is indexed.

/usr/share/php/Horde/Service/Facebook/Request/Rest.php is in php-horde-service-facebook 2.0.10-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
<?php
/**
 * Horde_Service_Facebook_Request:: encapsulate a request to the Facebook API.
 *
 * Copyright 2009-2017 Horde LLC (http://www.horde.org/)
 *
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 * @category Horde
 * @package Service_Facebook
 */
class Horde_Service_Facebook_Request_Rest extends Horde_Service_Facebook_Request_Base
{
    /**
     * Run this request and return the data.
     *
     * @return array  The results of the request.
     *
     * @throws Horde_Service_Facebook_Exception
     */
    public function run()
    {
        $data = $this->_postRequest($this->_method, $this->_params);

        if (defined('JSON_BIGINT_AS_STRING')) {
            $result = json_decode($data, true, 512, constant('JSON_BIGINT_AS_STRING'));
        } else {
            if (is_numeric($data)) {
                $result = $data;
            } else {
                $result = json_decode($data, true);
            }
        }

        if (is_array($result) && isset($result['error_code'])) {
            throw new Horde_Service_Facebook_Exception($result['error_msg'], $result['error_code']);
        }

        return $result;
    }

    /**
     * Perform a multipart/form-data upload.
     *
     * @param array $options  An options array:
     *   - params: (array) Form parameters to pass
     *   - file: (string) Local path to the file
     */
    public function upload(array $options = array())
    {
        throw new Horde_Service_Facebook_Exception('Deprecated');
    }

    /**
     * Send a POST request
     *
     * @param string $method  The method to call.
     * @param array  $params  The method parameters.
     *
     * @return string The request results
     * @throws Horde_Service_Facebook_Exception
     */
    protected function _postRequest($method, &$params)
    {
        $this->_finalizeParams($params);
        try {
            $url = new Horde_Url(Horde_Service_Facebook::REST_SERVER_ADDR . $method);
            $result = $this->_http->request('POST', $url->toString(), $this->_createPostString($params));
        } catch (Exception $e) {
            $this->_facebook->logger->err($e->getMessage());
            throw new Horde_Service_Facebook_Exception(Horde_Service_Facebook_Translation::t("Facebook service is unavailable. Please try again later."));
        }

        return $result->getBody();
    }

    /**
     * Finalize, sanity check, standardze and sign the method parameters, $params
     *
     * @param string $method  The method name
     * @param array  $params  Method parameters
     *
     * @return void
     */
    protected function _finalizeParams(&$params)
    {
        // Run through the params and see if any of them are arrays. If so,
        // json encode them, as per the new Facebook API guidlines.
        // http://www.facebook.com/developers/message.php#msg_351
        foreach ($params as &$param) {
            if (is_array($param)) {
                $param = json_encode($param);
            }
        }

        $this->_addStandardParams($params);
    }

    /**
     * Adds standard facebook api parameters to $params
     *
     * @param array  $params  Method parameters
     *
     * @return void
     */
    protected function _addStandardParams(&$params)
    {
        $params['access_token'] = $this->_facebook->auth->getSessionKey();
        $params['format'] = 'json';
        if (!isset($params['v'])) {
            $params['v'] = '1.0';
        }
        if (!empty($this->_facebook->useSslResources)) {
            $params['return_ssl_resources'] = true;
        }
    }

    /**
     * Helper function to convert array to CSV string
     *
     * @param array $params
     * @return string
     */
    protected function _convertToCsv(&$params)
    {
        foreach ($params as $key => &$val) {
            if (is_array($val)) {
                $val = implode(',', $val);
            }
        }
    }

    /**
     * Create a string suitable for sending as POST data.
     *
     * TODO: Figure out why using http_build_query doesn't work here.
     *
     * @param array $params  The parameters array
     *
     * @return string  The POST string
     */
    protected function _createPostString($params)
    {
        $post_params = array();
        foreach ($params as $key => &$val) {
            $post_params[] = $key.'='.urlencode($val);
        }

        return implode('&', $post_params);
    }

}