From c0d7e154b73219a921425a5ea2a1e507164b0790 Mon Sep 17 00:00:00 2001 From: smusman98 Date: Mon, 18 Jul 2022 15:56:12 +0500 Subject: [PATCH] 2.1.3 --- Postman/Extensions/Admin/PostmanAdmin.php | 31 - Postman/Extensions/Admin/PostmanAdminView.php | 92 --- .../License/EDD_SL_Plugin_Updater.php | 585 ------------------ .../License/PostmanLicenseHandler.php | 482 --------------- .../License/PostmanLicenseManager.php | 90 --- postman-smtp.php | 2 +- readme.txt | 61 +- 7 files changed, 43 insertions(+), 1300 deletions(-) delete mode 100644 Postman/Extensions/Admin/PostmanAdmin.php delete mode 100644 Postman/Extensions/Admin/PostmanAdminView.php delete mode 100644 Postman/Extensions/License/EDD_SL_Plugin_Updater.php delete mode 100644 Postman/Extensions/License/PostmanLicenseHandler.php delete mode 100644 Postman/Extensions/License/PostmanLicenseManager.php diff --git a/Postman/Extensions/Admin/PostmanAdmin.php b/Postman/Extensions/Admin/PostmanAdmin.php deleted file mode 100644 index 3b61a0a6..00000000 --- a/Postman/Extensions/Admin/PostmanAdmin.php +++ /dev/null @@ -1,31 +0,0 @@ -get_extensions(); - - if ( count( $extensions ) > 0 ) { - add_action('admin_menu', [ $this, 'add_menu' ], 20 ); - } - - } - - public function add_menu() { - add_submenu_page( - PostmanViewController::POSTMAN_MENU_SLUG, - __('Extensions', 'post-smtp'), - __('Extensions', 'post-smtp'), - 'manage_options', - 'post-smtp-extensions', - [ $this, 'render_menu' ] - ); - } - - public function render_menu() { - include_once 'PostmanAdminView.php'; - } -} diff --git a/Postman/Extensions/Admin/PostmanAdminView.php b/Postman/Extensions/Admin/PostmanAdminView.php deleted file mode 100644 index 428ee174..00000000 --- a/Postman/Extensions/Admin/PostmanAdminView.php +++ /dev/null @@ -1,92 +0,0 @@ - - - - -
-

Post SMTP Installed Extensions

-
-
- get_extensions(); - - foreach ( $extensions as $slug => $extension) : - $short_name = $extension['license_manager']->get_slug( $extension['plugin_data']['Name'] ); - $nonce = $short_name . '_license_key-nonce'; - - $license_data = get_option( $short_name . '_license_active' ); - $license_key = get_option( $short_name . '_license_key' ); - - $license_valid = is_object( $license_data ) && $license_data->license === 'valid'; - $license_field_class = $license_valid ? 'readonly' : ''; - $license_field_value = $license_valid ? base64_encode($license_key) : ''; - - wp_nonce_field( $nonce, $nonce ); - ?> - -
-
- -
- -
-
- - type="password" - name="post_smtp_extension[]" - class="regular-text" - value="" - placeholder="Serial Key"> -
- -
- - - - - license === 'expired' ) : ?> - Renew License - - - -
-
- -
- - - -
-
-
diff --git a/Postman/Extensions/License/EDD_SL_Plugin_Updater.php b/Postman/Extensions/License/EDD_SL_Plugin_Updater.php deleted file mode 100644 index 06738347..00000000 --- a/Postman/Extensions/License/EDD_SL_Plugin_Updater.php +++ /dev/null @@ -1,585 +0,0 @@ -api_url = trailingslashit( $_api_url ); - $this->api_data = $_api_data; - $this->name = plugin_basename( $_plugin_file ); - $this->slug = basename( $_plugin_file, '.php' ); - $this->version = $_api_data['version']; - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; - $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); - - $edd_plugin_data[ $this->slug ] = $this->api_data; - - /** - * Fires after the $edd_plugin_data is setup. - * - * @since x.x.x - * - * @param array $edd_plugin_data Array of EDD SL plugin data. - */ - do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data ); - - // Set up hooks. - $this->init(); - - } - - /** - * Set up WordPress filters to hook into WP's update process. - * - * @uses add_filter() - * - * @return void - */ - public function init() { - - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); - add_action( 'admin_init', array( $this, 'show_changelog' ) ); - - } - - /** - * Check for Updates at the defined API endpoint and modify the update array. - * - * This function dives into the update API just when WordPress creates its update array, - * then adds a custom API call and injects the custom plugin data retrieved from the API. - * It is reassembled from parts of the native WordPress plugin update code. - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. - * - * @uses api_request() - * - * @param array $_transient_data Update array build by WordPress. - * @return array Modified update array with custom plugin data. - */ - public function check_update( $_transient_data ) { - - global $pagenow; - - if ( ! is_object( $_transient_data ) ) { - $_transient_data = new stdClass; - } - - if ( 'plugins.php' == $pagenow && is_multisite() ) { - return $_transient_data; - } - - if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { - return $_transient_data; - } - - $version_info = $this->get_cached_version_info(); - - if ( false === $version_info ) { - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); - - $this->set_version_info_cache( $version_info ); - - } - - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { - - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { - - $_transient_data->response[ $this->name ] = $version_info; - - // Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo. - $_transient_data->response[ $this->name ]->plugin = $this->name; - - } - - $_transient_data->last_checked = time(); - $_transient_data->checked[ $this->name ] = $this->version; - - } - - return $_transient_data; - } - - /** - * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! - * - * @param string $file - * @param array $plugin - */ - public function show_update_notification( $file, $plugin ) { - - if ( is_network_admin() ) { - return; - } - - if( ! current_user_can( 'update_plugins' ) ) { - return; - } - - if( ! is_multisite() ) { - return; - } - - if ( $this->name != $file ) { - return; - } - - // Remove our filter on the site transient - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); - - $update_cache = get_site_transient( 'update_plugins' ); - - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); - - if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { - - $version_info = $this->get_cached_version_info(); - - if ( false === $version_info ) { - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); - - // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now: - if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) { - $version_info->banners = $this->convert_object_to_array( $version_info->banners ); - } - - if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) { - $version_info->sections = $this->convert_object_to_array( $version_info->sections ); - } - - if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) { - $version_info->icons = $this->convert_object_to_array( $version_info->icons ); - } - - if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) { - $version_info->icons = $this->convert_object_to_array( $version_info->icons ); - } - - if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) { - $version_info->contributors = $this->convert_object_to_array( $version_info->contributors ); - } - - $this->set_version_info_cache( $version_info ); - } - - if ( ! is_object( $version_info ) ) { - return; - } - - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { - - $update_cache->response[ $this->name ] = $version_info; - - } - - $update_cache->last_checked = time(); - $update_cache->checked[ $this->name ] = $this->version; - - set_site_transient( 'update_plugins', $update_cache ); - - } else { - - $version_info = $update_cache->response[ $this->name ]; - - } - - // Restore our filter - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); - - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { - - // build a plugin list row, with update notification - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); - # - echo ''; - echo ''; - echo '
'; - - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); - - if ( empty( $version_info->download_link ) ) { - printf( - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ), - esc_html( $version_info->name ), - '', - esc_html( $version_info->new_version ), - '' - ); - } else { - printf( - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ), - esc_html( $version_info->name ), - '', - esc_html( $version_info->new_version ), - '', - '', - '' - ); - } - - do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); - - echo '
'; - } - } - - /** - * Updates information on the "View version x.x details" page with custom data. - * - * @uses api_request() - * - * @param mixed $_data - * @param string $_action - * @param object $_args - * @return object $_data - */ - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { - - if ( $_action != 'plugin_information' ) { - - return $_data; - - } - - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { - - return $_data; - - } - - $to_send = array( - 'slug' => $this->slug, - 'is_ssl' => is_ssl(), - 'fields' => array( - 'banners' => array(), - 'reviews' => false, - 'icons' => array(), - ) - ); - - $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); - - // Get the transient where we store the api request for this plugin for 24 hours - $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); - - //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now. - if ( empty( $edd_api_request_transient ) ) { - - $api_response = $this->api_request( 'plugin_information', $to_send ); - - // Expires in 3 hours - $this->set_version_info_cache( $api_response, $cache_key ); - - if ( false !== $api_response ) { - $_data = $api_response; - } - - } else { - $_data = $edd_api_request_transient; - } - - // Convert sections into an associative array, since we're getting an object, but Core expects an array. - if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) { - $_data->sections = $this->convert_object_to_array( $_data->sections ); - } - - // Convert banners into an associative array, since we're getting an object, but Core expects an array. - if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) { - $_data->banners = $this->convert_object_to_array( $_data->banners ); - } - - // Convert icons into an associative array, since we're getting an object, but Core expects an array. - if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) { - $_data->icons = $this->convert_object_to_array( $_data->icons ); - } - - // Convert contributors into an associative array, since we're getting an object, but Core expects an array. - if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) { - $_data->contributors = $this->convert_object_to_array( $_data->contributors ); - } - - if( ! isset( $_data->plugin ) ) { - $_data->plugin = $this->name; - } - - return $_data; - } - - /** - * Convert some objects to arrays when injecting data into the update API - * - * Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON - * decoding, they are objects. This method allows us to pass in the object and return an associative array. - * - * @since 3.6.5 - * - * @param stdClass $data - * - * @return array - */ - private function convert_object_to_array( $data ) { - $new_data = array(); - foreach ( $data as $key => $value ) { - $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value; - } - - return $new_data; - } - - /** - * Disable SSL verification in order to prevent download update failures - * - * @param array $args - * @param string $url - * @return object $array - */ - public function http_request_args( $args, $url ) { - - $verify_ssl = $this->verify_ssl(); - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { - $args['sslverify'] = $verify_ssl; - } - return $args; - - } - - /** - * Calls the API and, if successfull, returns the object delivered by the API. - * - * @uses get_bloginfo() - * @uses wp_remote_post() - * @uses is_wp_error() - * - * @param string $_action The requested action. - * @param array $_data Parameters for the API action. - * @return false|object - */ - private function api_request( $_action, $_data ) { - - global $wp_version, $edd_plugin_url_available; - - $verify_ssl = $this->verify_ssl(); - - // Do a quick status check on this domain if we haven't already checked it. - $store_hash = md5( $this->api_url ); - if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { - $test_url_parts = parse_url( $this->api_url ); - - $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; - $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; - $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; - - if ( empty( $host ) ) { - $edd_plugin_url_available[ $store_hash ] = false; - } else { - $test_url = $scheme . '://' . $host . $port; - $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) ); - $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; - } - } - - if ( false === $edd_plugin_url_available[ $store_hash ] ) { - return; - } - - $data = array_merge( $this->api_data, $_data ); - - if ( $data['slug'] != $this->slug ) { - return; - } - - if( $this->api_url == trailingslashit ( home_url() ) ) { - return false; // Don't allow a plugin to ping itself - } - - $api_params = array( - 'edd_action' => 'get_version', - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, - 'version' => isset( $data['version'] ) ? $data['version'] : false, - 'slug' => $data['slug'], - 'author' => $data['author'], - 'url' => home_url(), - 'beta' => ! empty( $data['beta'] ), - ); - - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); - - if ( ! is_wp_error( $request ) ) { - $request = json_decode( wp_remote_retrieve_body( $request ) ); - } - - if ( $request && isset( $request->sections ) ) { - $request->sections = maybe_unserialize( $request->sections ); - } else { - $request = false; - } - - if ( $request && isset( $request->banners ) ) { - $request->banners = maybe_unserialize( $request->banners ); - } - - if ( $request && isset( $request->icons ) ) { - $request->icons = maybe_unserialize( $request->icons ); - } - - if( ! empty( $request->sections ) ) { - foreach( $request->sections as $key => $section ) { - $request->$key = (array) $section; - } - } - - return $request; - } - - public function show_changelog() { - - global $edd_plugin_data; - - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { - return; - } - - if( empty( $_REQUEST['plugin'] ) ) { - return; - } - - if( empty( $_REQUEST['slug'] ) ) { - return; - } - - if( ! current_user_can( 'update_plugins' ) ) { - wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); - } - - $data = $edd_plugin_data[ $_REQUEST['slug'] ]; - $beta = ! empty( $data['beta'] ) ? true : false; - $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); - $version_info = $this->get_cached_version_info( $cache_key ); - - if( false === $version_info ) { - - $api_params = array( - 'edd_action' => 'get_version', - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, - 'slug' => $_REQUEST['slug'], - 'author' => $data['author'], - 'url' => home_url(), - 'beta' => ! empty( $data['beta'] ) - ); - - $verify_ssl = $this->verify_ssl(); - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); - - if ( ! is_wp_error( $request ) ) { - $version_info = json_decode( wp_remote_retrieve_body( $request ) ); - } - - - if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { - $version_info->sections = maybe_unserialize( $version_info->sections ); - } else { - $version_info = false; - } - - if( ! empty( $version_info ) ) { - foreach( $version_info->sections as $key => $section ) { - $version_info->$key = (array) $section; - } - } - - $this->set_version_info_cache( $version_info, $cache_key ); - - } - - if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { - echo '
' . $version_info->sections['changelog'] . '
'; - } - - exit; - } - - public function get_cached_version_info( $cache_key = '' ) { - - if( empty( $cache_key ) ) { - $cache_key = $this->cache_key; - } - - $cache = get_option( $cache_key ); - - if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { - return false; // Cache is expired - } - - // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. - $cache['value'] = json_decode( $cache['value'] ); - if ( ! empty( $cache['value']->icons ) ) { - $cache['value']->icons = (array) $cache['value']->icons; - } - - return $cache['value']; - - } - - public function set_version_info_cache( $value = '', $cache_key = '' ) { - - if( empty( $cache_key ) ) { - $cache_key = $this->cache_key; - } - - $data = array( - 'timeout' => strtotime( '+3 hours', time() ), - 'value' => json_encode( $value ) - ); - - update_option( $cache_key, $data, 'no' ); - - } - - /** - * Returns if the SSL of the store should be verified. - * - * @since 1.6.13 - * @return bool - */ - private function verify_ssl() { - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); - } - -} diff --git a/Postman/Extensions/License/PostmanLicenseHandler.php b/Postman/Extensions/License/PostmanLicenseHandler.php deleted file mode 100644 index f8f32a21..00000000 --- a/Postman/Extensions/License/PostmanLicenseHandler.php +++ /dev/null @@ -1,482 +0,0 @@ -file = $_file; - $this->item_name = $_item_name; - - if ( is_numeric( $_item_id ) ) { - $this->item_id = absint( $_item_id ); - } - - $this->item_shortname = $this->get_slug(); - $this->version = $_version; - $this->license = trim( get_option( $this->item_shortname . '_license_key', '' ) ); - $this->license_data = get_option( $this->item_shortname . '_license_active', '' ); - $this->author = $_author; - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; - - /** - * Allows for backwards compatibility with old license options, - * i.e. if the plugins had license key fields previously, the license - * handler will automatically pick these up and use those in lieu of the - * user having to reactive their license. - */ - if ( ! empty( $_optname ) ) { - $opt = get_option( $_optname, false ); - - if( isset( $opt ) && empty( $this->license ) ) { - $this->license = trim( $opt ); - } - } - - // Setup hooks - $this->includes(); - $this->hooks(); - - } - - /** - * Include the updater class - * - * @access private - * @return void - */ - private function includes() { - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { - require_once 'EDD_SL_Plugin_Updater.php'; - } - } - - /** - * Setup hooks - * - * @access private - * @return void - */ - public function hooks() { - - // Activate license key on settings save - add_action( 'admin_init', array( $this, 'activate_license' ) ); - - // Deactivate license key - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); - - add_action( 'init', array( $this, 'cron' ), 20 ); - - add_action( 'admin_init', array( $this, 'validate_license' ) ); - - // Updater - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); - - // Display notices to admins - add_action( 'admin_notices', array( $this, 'notices' ) ); - - //add_action( 'in_plugin_update_message-' . plugin_basename( $this->file ), array( $this, 'plugin_row_license_missing' ), 10, 2 ); - } - - /** - * Auto updater - * - * @access private - * @return void - */ - public function auto_updater() { - - $args = array( - 'version' => $this->version, - 'license' => $this->license, - 'author' => $this->author, - 'beta' => function_exists( 'edd_extension_has_beta_support' ) && edd_extension_has_beta_support( $this->item_shortname ), - ); - - if( ! empty( $this->item_id ) ) { - $args['item_id'] = $this->item_id; - } else { - $args['item_name'] = $this->item_name; - } - - // Setup the updater - $edd_updater = new EDD_SL_Plugin_Updater( - $this->api_url, - $this->file, - $args - ); - } - - public function cron() { - if ( ! wp_next_scheduled( $this->item_shortname . '_scheduled_events' ) ) { - wp_schedule_event( current_time( 'timestamp', true ), 'daily', $this->item_shortname . '_scheduled_events' ); - } - } - - public function get_slug() { - return preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); - } - - /** - * Display help text at the top of the Licenses tag - * - * @since 2.5 - * @param string $active_tab - * @return void - */ - public function license_help_text( $active_tab = '' ) { - - static $has_ran; - - if( 'licenses' !== $active_tab ) { - return; - } - - if( ! empty( $has_ran ) ) { - return; - } - - echo '

' . sprintf( - __( 'Enter your extension license keys here to receive updates for purchased extensions. If your license key has expired, please renew your license.', 'easy-digital-downloads' ), - 'http://docs.easydigitaldownloads.com/article/1000-license-renewal' - ) . '

'; - - $has_ran = true; - - } - - - /** - * Activate the license key - * - * @return void - */ - public function activate_license() { - - if ( ! isset( $_POST['post_smtp_extension'][ $this->item_shortname . '_activate'] ) ) { - return; - } - - if ( ! isset( $_REQUEST[ $this->item_shortname . '_license_key-nonce'] ) || ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) { - - return; - - } - - if ( ! current_user_can( 'manage_options' ) ) { - return; - } - - if ( empty( $_POST['post_smtp_extension'][ $this->item_shortname . '_license_key'] ) ) { - - delete_option( $this->item_shortname . '_license_active' ); - delete_option( $this->item_shortname . '_license_key' ); - - return; - - } - - foreach ( $_POST as $key => $value ) { - if( false !== strpos( $key, 'license_key_deactivate' ) ) { - // Don't activate a key when deactivating a different key - return; - } - } - - $details = get_option( $this->item_shortname . '_license_active' ); - - if ( is_object( $details ) && 'valid' === $details->license ) { - return; - } - - $license = sanitize_text_field( $_POST['post_smtp_extension'][ $this->item_shortname . '_license_key'] ); - - if( empty( $license ) ) { - return; - } - - // Data to send to the API - $api_params = array( - 'edd_action' => 'activate_license', - 'license' => $license, - 'item_name' => urlencode( $this->item_name ), - 'url' => home_url() - ); - - if ( ! empty( $this->item_id ) ) { - $api_params['item_id'] = $this->item_id; - } - - // Call the API - $response = wp_remote_post( - $this->api_url, - array( - 'timeout' => 15, - 'sslverify' => false, - 'body' => $api_params - ) - ); - - // Make sure there are no errors - if ( is_wp_error( $response ) ) { - return; - } - - // Tell WordPress to look for updates - set_site_transient( 'update_plugins', null ); - - // Decode license data - $this->license_data = json_decode( wp_remote_retrieve_body( $response ) ); - - update_option( $this->item_shortname . '_license_active', $this->license_data ); - update_option( $this->item_shortname . '_license_key', $license ); - - if ( $this->license_data->success && $this->license_data->license == 'valid' ) { - $slug = plugin_basename($this->file); - PostmanLicenseManager::get_instance()->add_extension($slug); - } - } - - - /** - * Deactivate the license key - * - * @return void - */ - public function deactivate_license() { - - if ( ! isset( $_POST['post_smtp_extension'][ $this->item_shortname . '_deactivate'] ) ) { - return; - } - - if ( ! isset( $_POST['post_smtp_extension'][ $this->item_shortname . '_license_key'] ) ) - return; - - if( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) { - - wp_die( __( 'Nonce verification failed', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); - - } - - if( ! current_user_can( 'manage_options' ) ) { - return; - } - - $license_key = sanitize_text_field( base64_decode( $_POST['post_smtp_extension'][ $this->item_shortname . '_license_key'] ) ); - - // Run on deactivate button press - // Data to send to the API - $api_params = array( - 'edd_action' => 'deactivate_license', - 'license' => $license_key, - 'item_name' => urlencode( $this->item_name ), - 'url' => home_url() - ); - - if ( ! empty( $this->item_id ) ) { - $api_params['item_id'] = $this->item_id; - } - - // Call the API - $response = wp_remote_post( - $this->api_url, - array( - 'timeout' => 15, - 'sslverify' => false, - 'body' => $api_params - ) - ); - - // Make sure there are no errors - if ( is_wp_error( $response ) ) { - return; - } - - // Decode the license data - $this->license_data = json_decode( wp_remote_retrieve_body( $response ) ); - - delete_option( $this->item_shortname . '_license_active' ); - delete_option( $this->item_shortname . '_license_key' ); - - $slug = plugin_basename($this->file); - PostmanLicenseManager::get_instance()->remove_extension($slug); - - } - - public function validate_license() { - if ( false === ( $cron_data = get_transient( $this->item_shortname . '_cron' ) ) ) { - $this->license_check(); - - set_transient( $this->item_shortname . '_cron', true, rand( 12, 48 ) * HOUR_IN_SECONDS ); - } - - $license_data = $this->license_data; - - if ( $license_data && isset( $license_data->expires ) ) { - if ( $license_data->expires == 'lifetime' ) { - $expires = '2500/12/12'; - } else { - $expires = $license_data->expires; - } - } else { - return; - } - - $datetime1 = new DateTime(); - - if ( is_numeric( $expires ) ) { - $datetime2 = new DateTime(); - $datetime2->setTimestamp( $expires ); - } else { - $datetime2 = new DateTime( $expires ); - } - - foreach ( self::DAYS_TO_ALERT as $day_to_alert ) { - - $interval = $datetime1->diff($datetime2); - if( $interval->days == $day_to_alert ){ - add_action( 'admin_notices', function () use ( $day_to_alert, $license_data ) { - //echo $this->item_name . ' is about to expire in ' . $day_to_alert . ' days: ' . $license_data->expires; - }); - - return; - } - - if ( $interval->days == 0 ) { - add_action( 'admin_notices', function () use ( $license_data ) { - //echo $this->item_name . ' license expire today at: ' . $license_data->expires; - }); - - return; - } - } - - if ( $license_data->activations_left == 0 ) { - add_action( 'admin_notices', function () use ( $license_data ) { - //echo $this->item_name . ' has no activations'; - }); - - return; - } - } - - - /** - * Check if license key is valid once per week - * - * @since 2.5 - * @return void - */ - public function license_check() { - - // data to send in our API request - $api_params = array( - 'edd_action'=> 'check_license', - 'license' => $this->license, - 'item_name' => urlencode( $this->item_name ), - 'url' => home_url() - ); - - // Call the API - $response = wp_remote_post( - $this->api_url, - array( - 'timeout' => 15, - 'sslverify' => false, - 'body' => $api_params - ) - ); - - // make sure the response came back okay - if ( is_wp_error( $response ) ) { - return false; - } - - if ( wp_remote_retrieve_response_code( $response ) !== 200 ) { - return false; - } - - $this->license_data = json_decode( wp_remote_retrieve_body( $response ) ); - - update_option( $this->item_shortname . '_license_active', $this->license_data ); - - } - - private function get_license_data() { - return get_option( $this->item_shortname . '_license_active' ); - } - - - /** - * Admin notices for errors - * - * @return void - */ - public function notices() { - - $showed_invalid_message = null; - - if( empty( $this->license ) ) { - return; - } - - if( ! current_user_can( 'manage_options' ) ) { - return; - } - - $messages = array(); - - $license = get_option( $this->item_shortname . '_license_active' ); - - if( is_object( $license ) && 'valid' !== $license->license && empty( $showed_invalid_message ) ) { - - if( isset( $_GET['page'] ) && 'post-smtp-extensions' === $_GET['page'] ) { - - $messages[] = sprintf( - __( '%s has invalid or expired license key for Post SMTP.'), - '' . $this->item_name . '' - ); - - $showed_invalid_message = true; - - } - - } - - if( ! empty( $messages ) ) { - - foreach( $messages as $message ) { - - echo '
'; - echo '

' . $message . '

'; - echo '
'; - - } - - } - - } - - public function is_licensed() { - return is_object($this->license_data) && 'valid' === $this->license_data->license; - } -} - -endif; // end class_exists check diff --git a/Postman/Extensions/License/PostmanLicenseManager.php b/Postman/Extensions/License/PostmanLicenseManager.php deleted file mode 100644 index 17cfecf7..00000000 --- a/Postman/Extensions/License/PostmanLicenseManager.php +++ /dev/null @@ -1,90 +0,0 @@ -includes(); - $this->rand_cache_interval = rand( 1, 24 ); - } - - public function includes() { - include_once 'PostmanLicenseHandler.php'; - - include_once ABSPATH . '/wp-admin/includes/plugin.php'; - - } - - /** - * Init - */ - public function init() { - - $plugins = get_plugins(); - foreach ( $plugins as $plugin_dir_and_filename => $plugin_data ) { - - if ( ! is_plugin_active( $plugin_dir_and_filename ) ) { - continue; - } - - if ( false !== strpos( $plugin_dir_and_filename, 'post-smtp-extension' ) ) { - $slug = $plugin_dir_and_filename; - $class = $plugin_data['Class']; - $plugin_path = WP_CONTENT_DIR . '/plugins/' . $plugin_dir_and_filename; - - $this->extensions[$slug]['plugin_data'] = $plugin_data; - $this->extensions[$slug]['plugin_dir_and_filename'] = $plugin_dir_and_filename; - $this->extensions[$slug]['license_manager'] = new PostmanLicenseHandler( - $plugin_path, $plugin_data['Name'], - $plugin_data['Version'], $plugin_data['Author'], null, self::ENDPOINT - ); - if ( $this->extensions[$slug]['license_manager']->is_licensed() ) { - $this->extensions[$slug]['instance'] = new $class; - } - } - } - - if ( ! empty( $this->extensions ) ) { - new PostmanAdmin(); - } - } - - public function add_extension($slug) { - $plugin_path = WP_CONTENT_DIR . '/plugins/' . $this->extensions[$slug]['plugin_dir_and_filename']; - $class = $this->extensions[$slug]['plugin_data']['Class']; - - include_once $plugin_path; - $this->extensions[$slug]['instance'] = new $class; - } - - public function remove_extension($slug) { - $this->extensions[$slug]['instance'] = null; - unset($this->extensions[$slug]['instance']); - } - - public function get_extensions() { - return $this->extensions; - } -} diff --git a/postman-smtp.php b/postman-smtp.php index fcf0b3f8..0b219e5f 100644 --- a/postman-smtp.php +++ b/postman-smtp.php @@ -173,4 +173,4 @@ function post_setupPostman() { require_once 'Postman/Postman.php'; $kevinCostner = new Postman( __FILE__, POST_SMTP_VER ); do_action( 'post_smtp_init'); -} +} \ No newline at end of file diff --git a/readme.txt b/readme.txt index 6a2db2f5..bc4ac005 100644 --- a/readme.txt +++ b/readme.txt @@ -14,18 +14,18 @@ Send, log, and get notified when your emails are failing. Plus a unique option f = WordPress Mail SMTP Plugin = -Post SMTP is a next-generation WP Mail SMTP plugin that assists in the delivery of email generated by your WordPress site. Post SMTP is the first and only plugin to support the [latest security standards](http://googleonlinesecurity.blogspot.ca/2014/04/new-security-measures-will-affect-older.html). With OAuth 2.0, there is **no need** to [store your email passsword](http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/) in the WordPress database where it might be found. +Post SMTP is a next-generation WP Mail SMTP plugin, that assists in the delivery of email generated by your WordPress site. Post SMTP is the first and only plugin to support the [latest security standards](http://googleonlinesecurity.blogspot.ca/2014/04/new-security-measures-will-affect-older.html). With OAuth 2.0, there is **no need** to [store your email passsword](http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/) in the WordPress database where it might be found. The **Connectivity Test** and intelligent **Setup Wizard** scan your SMTP server to detect firewall blocks and eliminate configuration mistakes. The built-in **Email Log** is an invaluable resource for [diagnosing problems](https://wordpress.org/support/topic/ugly-e-mails-no-html-and-no-special-characters?replies=15) with emails. Even hosts that block the standard SMTP ports, like GoDaddy or Bluehost, can't stop your email as **Post SMTP can deliver via HTTPS** if it can't use SMTP. -Post SMTP is *not* another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces the default WordPress SMTP library, PHPMailer, with the heavy-duty Zend_Mail. Never lose an email to PHP mail() again. +Post SMTP is *not* another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces the default WordPress SMTP library, PHPMailer, with the heavy-duty Zend_Mail. Never [lose an email to PHP mail()](http://www.jvfconsulting.com/blog/php-mail-function-vs-smtp-guaranteed-delivery/) again. = The Only SMTP plugin with chrome Notifications = Get notified if your emails are failing inside your Chrome browser. [Download here](https://chrome.google.com/webstore/detail/post-smtp-notifications/npklmbkpbknkmbohdbpikeidiaekjoch?hl=en-US) https://www.youtube.com/watch?v=mXDEEE9jnfw -= Post SMTP Features = += Standard Features = * Easy-to-use, powerful Setup Wizard for perfect configuration * Commercial-grade Connectivity Tester to diagnose server issues * Log and resend all emails; see the exact cause of failed emails @@ -34,23 +34,28 @@ https://www.youtube.com/watch?v=mXDEEE9jnfw * [SASL](https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer) Support: Plain/Login/CRAM-MD5/[XOAUTH2](https://en.wikipedia.org/wiki/OAuth#OAuth_2.0) authentication * Security Support: [SMTPS](https://en.wikipedia.org/wiki/SMTPS) and [STARTTLS](https://en.wikipedia.org/wiki/STARTTLS) ([SSL/TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security)) * Copy configuration to other instances of Post -* Supports the proprietary OAuth 2.0 implementations of Gmail, Hotmail and Yahoo -* Fire-and-forget delivery continues even if you change your password. -* [Set up an app password](https://youtu.be/OX2g6QB6LWI) in your Google account. = Looking for Post SMTP Pro Extensions? = Post SMTP's pro extensions are everything you need to enhance your WordPress email deliverability experience. Check our extensions for Amazon SES, Better Email Logger and Office365. [Post SMTP Pro Extensions](https://postmansmtp.com/extensions/) -= Office365 API delivery = += Looking for Office365 API delivery? = [Office365 Pro extension](https://postmansmtp.com/extensions/office-365-extension-for-post-smtp/) allows you to connect PostSMTP with your Outlook and Microsoft 365 accounts to improve email deliverability. -= Amazon SES API delivery? = -[Amazon SES Pro Extension](https://postmansmtp.com/extensions/post-smtp-extension-for-amazon-ses/) combines Amazon's mail service provider with PostSMTP's powerful and easy-to-use SMTP mailing features. - -= Better Email Logger Extension? = += Looking for Better Email Logger Pro Extension? = [Better Email Logger Pro extension](https://postmansmtp.com/extensions/the-better-email/) allows you to design email marketing campaigns and improve email deliverability for your WordPress site. += Looking for Amazon SES API delivery? = +[Amazon SES Pro Extension](https://postmansmtp.com/extensions/post-smtp-extension-for-amazon-ses/) combines Amazon’s mail service provider with PostSMTP’s powerful and easy-to-use SMTP mailing features. + += OAuth 2.0 Features = +* Supports the proprietary OAuth 2.0 implementations of Gmail, Hotmail and Yahoo +* Fire-and-forget delivery continues even if your password changes +* Gmail: By combining OAuth2 and the Gmail API, Post can deliver where other plugins can not + += The Most Fast And Easy = +See how fast and easy to setup Post SMTP with Google/Gsuite or any SMTP service including: + = API (HTTPS) Email Support = * **Gmail API for sending Gmail and Google Apps email** (requires a [Google](https://accounts.google.com/signup) account) Often bloggers and small business owners don't want to use third-party SMTP services. Well you can use your Gmail or G Suite account for SMTP emails. @@ -68,16 +73,20 @@ SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. * **Sendinblue API for sending any email** (requires a [Sendinblue](https://www.sendinblue.com/) account and PHP 5.3) SendinBlue is an effective and great email software for Small to Medium businesses. You can build customer relationships with an all-in-one digital marketing toolbox. Their free plan allows you to send up to 300 emails per day. -= Compatibility & Support = -* [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) +> Post SMTP needs [translators](https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable)! If you are a non-English speaker, please get involved! + += Compatibile With.. = * [Woocommerce](https://wordpress.org/plugins/woocommerce/) -* [New User Approve](https://wordpress.org/plugins/new-user-approve/) -* [Password Protected](https://wordpress.org/plugins/password-protected/) +* [WPForms](https://wordpress.org/plugins/wpforms-lite/) * [Elementor Forms](https://elementor.com/features/form-widget/) +* [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) * [Gravity Forms](http://www.gravityforms.com) -* [Login Designer](https://wordpress.org/plugins/login-designer/) +* [Fast Secure Contact Form](https://wordpress.org/plugins/si-contact-form/) * [Visual Forms Builder](https://wordpress.org/plugins/visual-form-builder/) -* [MyMail Newsletter](http://revaxarts-themes.com/?t=mymail) +* [Contact Form Builder](https://wordpress.org/plugins/contact-form-builder/) +* [PlanSo Forms](https://wordpress.org/plugins/planso-forms/) +* [Quform](https://www.quform.com/) +* [MyMail Newsletter](http://revaxarts-themes.com/?t=mymail) by revaxarts * [SendPress Newsletters](https://wordpress.org/plugins/sendpress/) * [WP HTML Mail](https://wordpress.org/plugins/wp-html-mail/) * [Email Templates](https://wordpress.org/plugins/email-templates/) @@ -85,17 +94,27 @@ SendinBlue is an effective and great email software for Small to Medium business * .. and every other plugin that uses the WordPress API [wp_mail](https://codex.wordpress.org/Function_Reference/wp_mail) to send mail! = Requirements = -* WordPress 5.6 and PHP 5.6 with SPL and iconv +* WordPress 3.9 and PHP 5.6 with SPL and iconv * Memory: 750KiB per process at idle * Reliable mail delivery with custom email domains requires an SPF record * Reliable SMTP delivery requires credentials with an email service provider +* OAuth 2.0 features require a Gmail, Hotmail or Yahoo mail OAuth 2.0 credentials + += Looking for Google Analytics plugin? = +If you used Google Analytics Dashboard For WP and you really hate the latest updates, I have forked the original plugin here: +[https://wordpress.org/plugins/metrics-query/](https://wordpress.org/plugins/metrics-query/) + += CREDITS = + +Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks. == Installation == > To send email reliably, you must use the SMTP server assigned to that email. If Post is unable to connect to the right SMTP server, you may have to ask your host to open the ports, or create a new email account managed by your host, or switch hosts! +> > The Connectivity Test utility will tell you which ports are open and the actions available to you. -= Easy to install and setup! (Recommended for all users) = += Easy install and setup! (Recommended for all users) = 1. Install and activate the plugin through the 'Plugins' menu in WordPress. 1. In the WordPress 'Settings' menu select 'Post SMTP'. 1. Choose 'Start the Wizard' and follow the instructions. @@ -135,6 +154,10 @@ SendinBlue is an effective and great email software for Small to Medium business == Frequently Asked Questions == += Where is Postman SMTP? = +From 2015-11-08 more or less I can say that Jason the original author stoped maintain the plugin. +He may still answered some support tickets, but nothing more. + = What is OAuth 2.0? = A modern replacement for traditional password-based authentication. Post supports the OAuth 2.0 implementations of all three major e-mail providers: Gmail, Hotmail and Yahoo Mail.