diff options
author | yehuda <yehuda@myinbox.in> | 2019-05-16 12:15:39 +0300 |
---|---|---|
committer | yehuda <yehuda@myinbox.in> | 2019-05-16 12:15:39 +0300 |
commit | 6b0c4d5d97cac613ad8218fc9f0779eec63c28e3 (patch) | |
tree | 3ac2513ad5cb08650b03f55d837cf6b1d578dd21 /Postman/PostmanUtils.php | |
parent | c88e7ad0b42cefd8fb7b509c8c2e355f567d9434 (diff) | |
parent | 09ad01149ef5981407149bc3c9502058482fb419 (diff) | |
download | Post-SMTP-6b0c4d5d97cac613ad8218fc9f0779eec63c28e3.zip |
Merge remote-tracking branch 'origin/dev'
Diffstat (limited to 'Postman/PostmanUtils.php')
-rw-r--r-- | Postman/PostmanUtils.php | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index 8c7081f..6858fe3 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -32,7 +32,7 @@ class PostmanUtils { /** * - * @param unknown $slug + * @param mixed $slug * @return string */ public static function getPageUrl( $slug ) { @@ -71,8 +71,8 @@ class PostmanUtils { /** * from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php * - * @param unknown $haystack - * @param unknown $needle + * @param mixed $haystack + * @param mixed $needle * @return boolean */ public static function startsWith( $haystack, $needle ) { @@ -82,8 +82,8 @@ class PostmanUtils { /** * from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php * - * @param unknown $haystack - * @param unknown $needle + * @param mixed $haystack + * @param mixed $needle * @return boolean */ public static function endsWith( $haystack, $needle ) { @@ -99,8 +99,8 @@ class PostmanUtils { /** * Detect if the host is NOT a domain name * - * @param unknown $ipAddress - * @return number + * @param mixed $ipAddress + * @return bool */ public static function isHostAddressNotADomainName( $host ) { // IPv4 / IPv6 test from http://stackoverflow.com/a/17871737/4368109 @@ -115,9 +115,9 @@ class PostmanUtils { * Inside WordPress we can use wp_remote_post(). * Outside WordPress, not so much. * - * @param unknown $url - * @param unknown $args - * @return the HTML body + * @param mixed $url + * @param mixed $args + * @return string the HTML body */ static function remotePostGetBodyOnly( $url, $parameters, array $headers = array() ) { $response = PostmanUtils::remotePost( $url, $parameters, $headers ); @@ -130,9 +130,9 @@ class PostmanUtils { * Inside WordPress we can use wp_remote_post(). * Outside WordPress, not so much. * - * @param unknown $url - * @param unknown $args - * @return the HTTP response + * @param mixed $url + * @param mixed $args + * @return array|WP_Error the HTTP response */ static function remotePost( $url, $parameters = array(), array $headers = array() ) { $args = array( @@ -161,7 +161,7 @@ class PostmanUtils { * A facade function that handles redirects. * Inside WordPress we can use wp_redirect(). Outside WordPress, not so much. **Load it before postman-core.php** * - * @param unknown $url + * @param mixed $url */ static function redirect( $url ) { // redirections back to THIS SITE should always be relative because of IIS bug @@ -182,7 +182,7 @@ class PostmanUtils { * Rounds the bytes returned from memory_get_usage to smaller amounts used IEC binary prefixes * See http://en.wikipedia.org/wiki/Binary_prefix * - * @param unknown $size + * @param mixed $size * @return string */ static function roundBytes( $size ) { @@ -261,7 +261,7 @@ class PostmanUtils { /** * Creates the pathname of the lockfile * - * @param unknown $tempDirectory + * @param mixed $tempDirectory * @return string */ private static function calculateTemporaryLockPath( $tempDirectory ) { @@ -290,7 +290,7 @@ class PostmanUtils { /** * From http://stackoverflow.com/a/381275/4368109 * - * @param unknown $text + * @param mixed $text * @return boolean */ public static function isEmpty( $text ) { @@ -324,8 +324,8 @@ class PostmanUtils { /** * Validate an e-mail address * - * @param unknown $email - * @return number + * @param mixed $email + * @return string|bool */ static function validateEmail( $email ) { if ( PostmanOptions::getInstance()->isEmailValidationDisabled() ) { @@ -348,7 +348,7 @@ class PostmanUtils { /** * From http://stackoverflow.com/questions/13430120/str-getcsv-alternative-for-older-php-version-gives-me-an-empty-array-at-the-e * - * @param unknown $string + * @param mixed $string * @return multitype: */ static function postman_strgetcsv_impl( $string ) { @@ -364,7 +364,7 @@ class PostmanUtils { /** * - * @return Ambigous <string, unknown> + * @return string|mixed */ static function postmanGetServerName() { if ( ! empty( $_SERVER ['SERVER_NAME'] ) ) { @@ -380,7 +380,7 @@ class PostmanUtils { /** * Does this hostname belong to Google? * - * @param unknown $hostname + * @param mixed $hostname * @return boolean */ static function isGoogle( $hostname ) { @@ -389,8 +389,8 @@ class PostmanUtils { /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ public static function registerAdminMenu( $viewController, $callbackName ) { $logger = PostmanUtils::$logger; @@ -406,8 +406,8 @@ class PostmanUtils { /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ public static function registerAjaxHandler( $actionName, $class, $callbackName ) { if ( is_admin() ) { @@ -422,7 +422,7 @@ class PostmanUtils { /** * - * @param unknown $parameterName + * @param mixed $parameterName * @return mixed */ public static function getBooleanRequestParameter( $parameterName ) { @@ -431,8 +431,8 @@ class PostmanUtils { /** * - * @param unknown $parameterName - * @return unknown + * @param mixed $parameterName + * @return mixed */ public static function getRequestParameter( $parameterName ) { $logger = PostmanUtils::$logger; @@ -447,7 +447,7 @@ class PostmanUtils { } public static function getServerName() { - $result = 'localhost.localdomain'; + $host = 'localhost'; if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { $host = $_SERVER['SERVER_NAME']; @@ -457,13 +457,6 @@ class PostmanUtils { $host = php_uname('n'); } - // as final option - if ip returned or hostname without extension (not valid dns name) - $extension = pathinfo( $host, PATHINFO_EXTENSION ); - if ( filter_var( $result, FILTER_VALIDATE_IP ) || empty( $extension ) ) { - $siteurl = get_bloginfo('url'); - $host = parse_url($siteurl, PHP_URL_HOST); - } - return str_replace('www.', '', $host ); } |