diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 08:22:35 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 08:22:35 +0000 |
commit | c61784411988d36d9bbd93cd3a97e773990af342 (patch) | |
tree | 924e6e9dea2ba7b1eedb14d0c4b03a38aefdf179 /Postman/PostmanPreRequisitesCheck.php | |
parent | 907ce8c044159ca8da6ccce3ec5362ac61e7c142 (diff) | |
download | Post-SMTP-c61784411988d36d9bbd93cd3a97e773990af342.zip |
Adding a folder
Diffstat (limited to 'Postman/PostmanPreRequisitesCheck.php')
-rw-r--r-- | Postman/PostmanPreRequisitesCheck.php | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Postman/PostmanPreRequisitesCheck.php b/Postman/PostmanPreRequisitesCheck.php new file mode 100644 index 0000000..c187a9b --- /dev/null +++ b/Postman/PostmanPreRequisitesCheck.php @@ -0,0 +1,87 @@ +<?php +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} +if (! class_exists ( 'PostmanPreRequisitesCheck' )) { + class PostmanPreRequisitesCheck { + public static function checkIconv() { + return function_exists ( 'iconv' ); + } + public static function checkSpl() { + return function_exists ( 'spl_autoload_register' ); + } + public static function checkZlibEncode() { + return extension_loaded ( "zlib" ) && function_exists ( 'gzcompress' ) && function_exists ( 'gzuncompress' ); + } + public static function checkOpenSsl() { + // apparently curl can use ssl libraries in the OS, and doesn't need ssl in PHP + return extension_loaded ( 'openssl' ) || extension_loaded ( 'php_openssl' ); + } + public static function checkSockets() { + return extension_loaded ( 'sockets' ) || extension_loaded ( 'php_sockets' ); + } + public static function checkAllowUrlFopen() { + return filter_var ( ini_get ( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ); + } + public static function checkMcrypt() { + return function_exists ( 'mcrypt_get_iv_size' ) && function_exists ( 'mcrypt_create_iv' ) && function_exists ( 'mcrypt_encrypt' ) && function_exists ( 'mcrypt_decrypt' ); + } + /** + * Return an array of state: + * [n][name=>x,ready=>true|false,required=true|false] + */ + public static function getState() { + $state = array (); + array_push ( $state, array ( + 'name' => 'iconv', + 'ready' => self::checkIconv (), + 'required' => true + ) ); + array_push ( $state, array ( + 'name' => 'spl_autoload', + 'ready' => self::checkSpl (), + 'required' => true + ) ); + array_push ( $state, array ( + 'name' => 'openssl', + 'ready' => self::checkOpenSsl (), + 'required' => false + ) ); + array_push ( $state, array ( + 'name' => 'sockets', + 'ready' => self::checkSockets (), + 'required' => false + ) ); + array_push ( $state, array ( + 'name' => 'allow_url_fopen', + 'ready' => self::checkAllowUrlFopen (), + 'required' => false + ) ); + array_push ( $state, array ( + 'name' => 'mcrypt', + 'ready' => self::checkMcrypt (), + 'required' => false + ) ); + array_push ( $state, array ( + 'name' => 'zlib_encode', + 'ready' => self::checkZlibEncode (), + 'required' => false + ) ); + return $state; + } + /** + * + * @return boolean + */ + public static function isReady() { + $states = self::getState (); + foreach ( $states as $state ) { + if ($state ['ready'] == false && $state ['required'] == true) { + return false; + } + } + + return true; + } + } +}
\ No newline at end of file |