| 1 |
<?php |
| 2 |
/* |
| 3 |
* Tiny Compress Images - WordPress plugin. |
| 4 |
* Copyright (C) 2015-2018 Tinify B.V. |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU General Public License as published by the Free |
| 8 |
* Software Foundation; either version 2 of the License, or (at your option) |
| 9 |
* any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 |
* more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License along |
| 17 |
* with this program; if not, write to the Free Software Foundation, Inc., 51 |
| 18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
class Tiny_PHP { |
| 22 |
public static function has_fully_supported_php() { |
| 23 |
return version_compare( PHP_VERSION, '5.3', '>' ); |
| 24 |
} |
| 25 |
|
| 26 |
public static function curl_available() { |
| 27 |
return extension_loaded( 'curl' ); |
| 28 |
} |
| 29 |
|
| 30 |
public static function fopen_available() { |
| 31 |
return ini_get( 'allow_url_fopen' ); |
| 32 |
} |
| 33 |
|
| 34 |
public static function curl_exec_disabled() { |
| 35 |
$disabled_functions = explode( ',', ini_get( 'disable_functions' ) ); |
| 36 |
return in_array( 'curl_exec', $disabled_functions ); |
| 37 |
} |
| 38 |
|
| 39 |
public static function client_supported() { |
| 40 |
return Tiny_PHP::has_fully_supported_php() && |
| 41 |
Tiny_PHP::curl_available() && |
| 42 |
! Tiny_PHP::curl_exec_disabled(); |
| 43 |
} |
| 44 |
} |
| 45 |
|