1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHP-Typography. |
4
|
|
|
* |
5
|
|
|
* Copyright 2017-2019 Peter Putzer. |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (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 along |
18
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., |
19
|
|
|
* 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
|
|
|
* @author Peter Putzer <[email protected]> |
34
|
|
|
* |
35
|
|
|
* @since 5.0.0 |
36
|
|
|
*/ |
37
|
|
|
abstract class File_Operations { |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Retrieve a HTTP response code via cURL. |
41
|
|
|
* |
42
|
|
|
* @param string $url Required. |
43
|
|
|
* |
44
|
|
|
* @return int |
45
|
|
|
*/ |
46
|
|
|
public static function get_http_response_code( $url ) { |
47
|
|
|
|
48
|
|
|
$curl = curl_init(); |
49
|
|
|
curl_setopt_array( |
50
|
|
|
$curl, |
|
|
|
|
51
|
|
|
[ |
52
|
|
|
CURLOPT_RETURNTRANSFER => true, |
53
|
|
|
CURLOPT_URL => $url, |
54
|
|
|
] |
55
|
|
|
); |
56
|
|
|
curl_exec( $curl ); |
|
|
|
|
57
|
|
|
$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); |
|
|
|
|
58
|
|
|
curl_close( $curl ); |
|
|
|
|
59
|
|
|
|
60
|
|
|
return $response_code; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|