|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of PHP-Typography. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright 2017 Peter Putzer. |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software; you can redistribute it and/or |
|
8
|
|
|
* modify it under the terms of the GNU General Public License |
|
9
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
10
|
|
|
* of the License, or (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
* along with this program; if not, write to the Free Software |
|
19
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20
|
|
|
* |
|
21
|
|
|
* *** |
|
22
|
|
|
* |
|
23
|
|
|
* @package mundschenk-at/php-typography |
|
24
|
|
|
* @author Peter Putzer <[email protected]> |
|
25
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
namespace PHP_Typography\Bin; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Encapsulate some common file operations (including on remote files). |
|
32
|
|
|
*/ |
|
33
|
|
|
abstract class File_Operations { |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Retrieve a HTTP response code via cURL. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $url Required. |
|
39
|
|
|
* |
|
40
|
|
|
* @return int |
|
41
|
|
|
*/ |
|
42
|
|
|
public static function get_http_response_code( $url ) { |
|
43
|
|
|
|
|
44
|
|
|
$curl = curl_init(); |
|
|
|
|
|
|
45
|
|
|
curl_setopt_array( $curl, [ |
|
|
|
|
|
|
46
|
|
|
CURLOPT_RETURNTRANSFER => true, |
|
47
|
|
|
CURLOPT_URL => $url, |
|
48
|
|
|
] ); |
|
49
|
|
|
curl_exec( $curl ); |
|
|
|
|
|
|
50
|
|
|
$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); |
|
|
|
|
|
|
51
|
|
|
curl_close( $curl ); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
return $response_code; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|