ActiveDonationFormsData.php
4 years ago
DonationData.php
4 years ago
DonationFormsData.php
4 years ago
DonationMetricsData.php
4 years ago
EditedDonationFormsData.php
4 years ago
GivePluginSettingsData.php
4 years ago
PluginsData.php
4 years ago
ServerData.php
4 years ago
ThemeData.php
4 years ago
WebsiteData.php
4 years ago
WebsiteInfoData.php
4 years ago
ServerData.php
82 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Tracking\TrackingData; |
| 4 | |
| 5 | use Give\Tracking\Contracts\TrackData; |
| 6 | |
| 7 | /** |
| 8 | * Class ServerData |
| 9 | * |
| 10 | * Represents the server data. |
| 11 | * |
| 12 | * @package Give\Tracking\TrackingData |
| 13 | * @since 2.10.0 |
| 14 | */ |
| 15 | class ServerData implements TrackData |
| 16 | { |
| 17 | |
| 18 | /** |
| 19 | * Returns the collection data. |
| 20 | * |
| 21 | * @since 2.10.0 |
| 22 | * |
| 23 | * @return array The collection data. |
| 24 | */ |
| 25 | public function get() |
| 26 | { |
| 27 | return $this->getServerData(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Returns the values with server details. |
| 32 | * |
| 33 | * @since 2.10.0 |
| 34 | * |
| 35 | * @return array Array with the value. |
| 36 | */ |
| 37 | private function getServerData() |
| 38 | { |
| 39 | $server_data = []; |
| 40 | |
| 41 | // Validate if the server address is a valid IP-address. |
| 42 | $ipaddress = filter_input(INPUT_SERVER, 'SERVER_ADDR', FILTER_VALIDATE_IP); |
| 43 | if ($ipaddress) { |
| 44 | $server_data['server_ip'] = $ipaddress; |
| 45 | $server_data['server_hostname'] = gethostbyaddr($ipaddress); |
| 46 | } |
| 47 | |
| 48 | $server_data['server_os'] = php_uname(); |
| 49 | $server_data['php_version'] = PHP_VERSION; |
| 50 | $server_data = array_merge($server_data, $this->getCurlInfo()); |
| 51 | |
| 52 | return $server_data; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns details about the curl version. |
| 57 | * |
| 58 | * @since 2.10.0 |
| 59 | * |
| 60 | * @return array|null The curl info. Or null when curl isn't available.. |
| 61 | */ |
| 62 | private function getCurlInfo() |
| 63 | { |
| 64 | if ( ! function_exists('curl_version')) { |
| 65 | return null; |
| 66 | } |
| 67 | |
| 68 | $curl = curl_version(); |
| 69 | |
| 70 | $ssl_support = 1; |
| 71 | if ( ! $curl['features'] && CURL_VERSION_SSL) { |
| 72 | $ssl_support = 0; |
| 73 | } |
| 74 | |
| 75 | return [ |
| 76 | 'curl_version' => $curl['version'], |
| 77 | 'is_ssl' => $ssl_support, |
| 78 | ]; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 |