meta.php
1.44 KB
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
<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Meta class.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubMeta extends JGithubObject
{
/**
* Method to get the authorized IP addresses for services
*
* @return array Authorized IP addresses
*
* @since 3.2.0
* @throws DomainException
*/
public function getMeta()
{
// Build the request path.
$path = '/meta';
$githubIps = $this->processResponse($this->client->get($this->fetchUrl($path)), 200);
/*
* The response body returns the IP addresses in CIDR format
* Decode the response body and strip the subnet mask information prior to
* returning the data to the user. We're assuming quite a bit here that all
* masks will be /32 as they are as of the time of development.
*/
$authorizedIps = array();
foreach ($githubIps as $key => $serviceIps)
{
// The first level contains an array of IPs based on the service
$authorizedIps[$key] = array();
foreach ($serviceIps as $serviceIp)
{
// The second level is each individual IP address, strip the mask here
$authorizedIps[$key][] = substr($serviceIp, 0, -3);
}
}
return $authorizedIps;
}
}