diff options
Diffstat (limited to 'Postman')
-rw-r--r-- | Postman/Postman-Configuration/PostmanConfigurationController.php | 23 | ||||
-rw-r--r-- | Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php | 19 | ||||
-rw-r--r-- | Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php | 3 | ||||
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogService.php | 1 | ||||
-rw-r--r-- | Postman/Postman-Mail/PostmanMailgunMailEngine.php | 2 | ||||
-rw-r--r-- | Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php | 14 | ||||
-rw-r--r-- | Postman/PostmanInputSanitizer.php | 3 | ||||
-rw-r--r-- | Postman/PostmanOptions.php | 14 | ||||
-rw-r--r-- | Postman/PostmanUtils.php | 36 | ||||
-rw-r--r-- | Postman/PostmanViewController.php | 2 | ||||
-rw-r--r-- | Postman/notifications/PostmanMailNotify.php | 2 | ||||
-rw-r--r-- | Postman/notifications/PostmanNotify.php | 22 |
12 files changed, 111 insertions, 30 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php index 6abb5e2..208fa0b 100644 --- a/Postman/Postman-Configuration/PostmanConfigurationController.php +++ b/Postman/Postman-Configuration/PostmanConfigurationController.php @@ -428,6 +428,29 @@ class PostmanConfigurationController { </table> </div> + <div id="use-chrome-extension"> + <h2><?php _e( 'Push To Chrome Extension', Postman::TEXT_DOMAIN ); ?></h2> + <table class="form-table"> + <tbody> + <tr> + <th scope="row"><?php _e( 'This is an extra notification to the selection above', Postman::TEXT_DOMAIN ); ?></th> + <td> + <input type="checkbox" id="notification_use_chrome" name="postman_options[notification_use_chrome]"> + <a target="_blank" class="" href="https://chrome.google.com/webstore/detail/npklmbkpbknkmbohdbpikeidiaekjoch"> + <?php _e( 'You can download the chrome extensiom here.', Postman::TEXT_DOMAIN ); ?> + </a> + </td> + </tr> + <tr> + <th scope="row"><?php _e( 'Your UID as you see in the extension.', Postman::TEXT_DOMAIN ); ?></th> + <td> + <input type="password" id="notification_chrome_uid" name="postman_options[notification_chrome_uid]" value=""> + </td> + </tr> + </tbody> + </table> + </div> + <?php print '</fieldset>'; diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php index ecd7ec3..6102d10 100644 --- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php @@ -213,6 +213,16 @@ class PostmanSettingsRegistry { 'slack_token_callback', ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' ); + add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + $this, + 'notification_use_chrome_callback', + ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); + + add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + $this, + 'notification_chrome_uid_callback', + ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); + } } @@ -415,6 +425,15 @@ class PostmanSettingsRegistry { printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } + public function notification_use_chrome_callback() { + $value = $this->options->useChromeExtension(); + printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_USE_CHROME, $value ? 'checked="checked"' : '' ); + } + + public function notification_chrome_uid_callback() { + printf( '<input type="password" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_CHROME_UID, $this->options->getNotificationChromeUid() ); + } + public function pushover_user_callback() { printf( '<input type="password" id="pushover_user" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_USER, $this->options->getPushoverUser() ); } diff --git a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php index 9f1c591..ad5fa84 100644 --- a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php +++ b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php @@ -208,8 +208,11 @@ class PostmanGetDiagnosticsViaAjax { /** */ public function getDiagnostics() { + $curl = curl_version(); $transportRegistry = PostmanTransportRegistry::getInstance(); $this->addToDiagnostics( 'HostName', PostmanUtils::getServerName() ); + $this->addToDiagnostics( 'cURL Version', $curl['version'] ); + $this->addToDiagnostics( 'OpenSSL Version', $curl['ssl_version'] ); $this->addToDiagnostics( 'OS', php_uname() ); $this->addToDiagnostics( 'PHP', PHP_OS . ' ' . PHP_VERSION . ' ' . setlocale( LC_CTYPE, 0 ) ); $this->addToDiagnostics( 'PHP Dependencies', $this->getPhpDependencies() ); diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php index ebb2e54..103dcc1 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogService.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php @@ -182,6 +182,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { $notify = new PostmanNotify( $notifyer, $message ); $notify->send($message, $log); + $notify->push_to_chrome($log->statusMessage); } /** diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php index e874704..f098ec9 100644 --- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php +++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php @@ -224,7 +224,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { private function addHeader( $name, $value, $deprecated = '' ) { if ( $value && ! empty( $value ) ) { - $this->mailgunMessage['h:' . $name] = $value; + $this->mailgunMessage['h:' . $name] = preg_replace('/.*:\s?/', '', $value); } } diff --git a/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php b/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php index be6d908..6f3c978 100644 --- a/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php +++ b/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php @@ -210,7 +210,19 @@ class Postman_Zend_Mail_Protocol_Smtp extends Postman_Zend_Mail_Protocol_Abstrac $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; - if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { + $curl = curl_version(); + preg_match('/.*\/(\d*\.\d*\.\d*)[a-z]?/', $curl['ssl_version'], $ver_match ); + $tlsv1_2_installed = ! empty( $ver_match[1] ) ? $ver_match[1] >= '1.0.1' : true; + + if ( $this->_host == 'smtp.office365.com' && ! $tlsv1_2_installed ) { + + $error = sprintf( 'Office365 SMTP servie require TLS v1.2 and OpenSSL version 1.0.1 or greater, your current OpenSSL version is: %s. +You need to contact your web hosting support for help.', $ver_match[1] ); + + throw new Postman_Zend_Mail_Protocol_Exception( $error ); + } + + if ( defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT') ) { $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; } diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php index b17df30..9e1fa52 100644 --- a/Postman/PostmanInputSanitizer.php +++ b/Postman/PostmanInputSanitizer.php @@ -74,6 +74,9 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) { $this->sanitizePassword( 'Pushover Token', PostmanOptions::PUSHOVER_TOKEN, $input, $new_input, $this->options->getPushoverToken() ); $this->sanitizePassword( 'Slack Token', PostmanOptions::SLACK_TOKEN, $input, $new_input, $this->options->getSlackToken() ); + $this->sanitizeString( 'Push Chrome Extension', PostmanOptions::NOTIFICATION_USE_CHROME, $input, $new_input ); + $this->sanitizePassword( 'Push Chrome Extension UID', PostmanOptions::NOTIFICATION_CHROME_UID, $input, $new_input, $this->options->getNotificationChromeUid() ); + if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) { $this->logger->debug( 'Recognized new Client ID' ); // the user entered a new client id and we should destroy the stored auth token diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php index 9c244bd..29ddbc6 100644 --- a/Postman/PostmanOptions.php +++ b/Postman/PostmanOptions.php @@ -106,6 +106,8 @@ if ( ! class_exists( 'PostmanOptions' ) ) { const TEMPORARY_DIRECTORY = 'tmp_dir'; const DISABLE_EMAIL_VALIDAITON = 'disable_email_validation'; const NOTIFICATION_SERVICE = 'notification_service'; + const NOTIFICATION_USE_CHROME = 'notification_use_chrome'; + const NOTIFICATION_CHROME_UID = 'notification_chrome_uid'; const PUSHOVER_USER = 'pushover_user'; const PUSHOVER_TOKEN = 'pushover_token'; const SLACK_TOKEN = 'slack_token'; @@ -341,6 +343,18 @@ if ( ! class_exists( 'PostmanOptions' ) ) { return base64_decode( $this->options [ PostmanOptions::SLACK_TOKEN ] ); } } + + public function useChromeExtension() { + if ( isset( $this->options [ PostmanOptions::NOTIFICATION_USE_CHROME ] ) ) { + return $this->options [ PostmanOptions::NOTIFICATION_USE_CHROME ]; + } + } + + public function getNotificationChromeUid() { + if ( isset( $this->options [ PostmanOptions::NOTIFICATION_CHROME_UID ] ) ) { + return base64_decode( $this->options [ PostmanOptions::NOTIFICATION_CHROME_UID ] ); + } + } public function getReplyTo() { if ( isset( $this->options [ PostmanOptions::REPLY_TO ] ) ) { diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index 8d5cd46..5405b79 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -445,37 +445,21 @@ class PostmanUtils { $result = 'localhost.localdomain'; if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { - $result = $_SERVER['SERVER_NAME']; + $host = $_SERVER['SERVER_NAME']; } elseif (function_exists('gethostname') and gethostname() !== false) { - $result = gethostname(); + $host = gethostname(); } elseif (php_uname('n') !== false) { - $result = php_uname('n'); + $host = php_uname('n'); } - if ( $result !== 'localhost.localdomain' ) { - // get the current result ip - $ip = gethostbyname($result); - - // dns query failed - if ( $ip == $result ) { - return $result; - } - - // get the current ip hostname - reverse dns - $host = gethostbyaddr($ip); - - // dns query failed - if ( $host == $ip ) { - return $result; - } - - // if hostname is not equal to the result set the ptr - if ( $result !== $host ) { - $result = $host; - } - } + // 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 $result; + return str_replace('www.', '', $host ); } public static function getHost( $url ) { diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 46aa39f..c0025a9 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -307,7 +307,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { echo ' <div class="updated settings-error notice is-dismissible"> <p> - <strong>Version ' . $version . ' Mailgun Europe region support:</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-1-9-5-mailgun-europe-region-support/">Read Here</a> + <strong>Version ' . $version . ' We have a new Chrome Extension:</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-1-9-6-new-chrome-extension/">Read Here</a> </p> <button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message"> <span class="screen-reader-text">Dismiss this notice.</span> diff --git a/Postman/notifications/PostmanMailNotify.php b/Postman/notifications/PostmanMailNotify.php index 795afaa..0313f7f 100644 --- a/Postman/notifications/PostmanMailNotify.php +++ b/Postman/notifications/PostmanMailNotify.php @@ -4,7 +4,7 @@ class PostmanMailNotify implements Postman_Notify { public function send_message($message) { - $to_email = get_bloginfo( 'admin_email' ); + $to_email = apply_filters( 'post_smtp_notify_email',get_bloginfo( 'admin_email' ) ); $domain = get_bloginfo( 'url' ); mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', Postman::TEXT_DOMAIN ), $message , '', "-f{$to_email}" ); diff --git a/Postman/notifications/PostmanNotify.php b/Postman/notifications/PostmanNotify.php index 22ca56f..365d708 100644 --- a/Postman/notifications/PostmanNotify.php +++ b/Postman/notifications/PostmanNotify.php @@ -14,4 +14,26 @@ class PostmanNotify { public function send( $message, $log ) { $this->notify->send_message( $message ); } + + public function push_to_chrome($message) { + $push_chrome = PostmanOptions::getInstance()->useChromeExtension(); + + if ( $push_chrome ) { + $uid = PostmanOptions::getInstance()->getNotificationChromeUid(); + + if ( empty( $uid ) ) { + return; + } + + $url = 'https://postmansmtp.com/chrome/' . $uid; + + $args = array( + 'body' => array( + 'message' => $message + ) + ); + + $response = wp_remote_post( $url , $args ); + } + } }
\ No newline at end of file |