|
...
|
...
|
@@ -17,7 +17,7 @@ Author URI: http://www.callum-macdonald.com/ |
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting options in wp-config.php
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Specifically aimed at WPMU users, you can set the options for this plugin as
|
|
|
|
* constants in wp-config.php. This disables the plugin's admin page and may
|
|
|
|
* improve performance very slightly. Copy the code below into wp-config.php.
|
|
...
|
...
|
@@ -57,27 +57,27 @@ $wpms_options = array ( |
|
|
|
*/
|
|
|
|
if (!function_exists('wp_mail_smtp_activate')) :
|
|
|
|
function wp_mail_smtp_activate() {
|
|
|
|
|
|
|
|
|
|
|
|
global $wpms_options;
|
|
|
|
|
|
|
|
|
|
|
|
// Create the required options...
|
|
|
|
foreach ($wpms_options as $name => $val) {
|
|
|
|
add_option($name,$val);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if (!function_exists('wp_mail_smtp_whitelist_options')) :
|
|
|
|
function wp_mail_smtp_whitelist_options($whitelist_options) {
|
|
|
|
|
|
|
|
|
|
|
|
global $wpms_options;
|
|
|
|
|
|
|
|
|
|
|
|
// Add our options to the array
|
|
|
|
$whitelist_options['email'] = array_keys($wpms_options);
|
|
|
|
|
|
|
|
|
|
|
|
return $whitelist_options;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -85,15 +85,15 @@ endif; |
|
|
|
if (!function_exists('phpmailer_init_smtp')) :
|
|
|
|
// This code is copied, from wp-includes/pluggable.php as at version 2.2.2
|
|
|
|
function phpmailer_init_smtp($phpmailer) {
|
|
|
|
|
|
|
|
|
|
|
|
// If constants are defined, apply those options
|
|
|
|
if (defined('WPMS_ON') && WPMS_ON) {
|
|
|
|
|
|
|
|
|
|
|
|
$phpmailer->Mailer = WPMS_MAILER;
|
|
|
|
|
|
|
|
|
|
|
|
if (WPMS_SET_RETURN_PATH)
|
|
|
|
$phpmailer->Sender = $phpmailer->From;
|
|
|
|
|
|
|
|
|
|
|
|
if (WPMS_MAILER == 'smtp') {
|
|
|
|
$phpmailer->SMTPSecure = WPMS_SSL;
|
|
|
|
$phpmailer->Host = WPMS_SMTP_HOST;
|
|
...
|
...
|
@@ -104,37 +104,37 @@ function phpmailer_init_smtp($phpmailer) { |
|
|
|
$phpmailer->Password = WPMS_SMTP_PASS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If you're using contstants, set any custom options here
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
|
|
// Check that mailer is not blank, and if mailer=smtp, host is not blank
|
|
|
|
if ( ! get_option('mailer') || ( get_option('mailer') == 'smtp' && ! get_option('smtp_host') ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the mailer type as per config above, this overrides the already called isMail method
|
|
|
|
$phpmailer->Mailer = get_option('mailer');
|
|
|
|
|
|
|
|
|
|
|
|
// Set the Sender (return-path) if required
|
|
|
|
if (get_option('mail_set_return_path'))
|
|
|
|
$phpmailer->Sender = $phpmailer->From;
|
|
|
|
|
|
|
|
|
|
|
|
// Set the SMTPSecure value, if set to none, leave this blank
|
|
|
|
$phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
|
|
|
|
|
|
|
|
|
|
|
|
// If we're sending via SMTP, set the host
|
|
|
|
if (get_option('mailer') == "smtp") {
|
|
|
|
|
|
|
|
|
|
|
|
// Set the SMTPSecure value, if set to none, leave this blank
|
|
|
|
$phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
|
|
|
|
|
|
|
|
|
|
|
|
// Set the other options
|
|
|
|
$phpmailer->Host = get_option('smtp_host');
|
|
|
|
$phpmailer->Port = get_option('smtp_port');
|
|
|
|
|
|
|
|
|
|
|
|
// If we're using smtp auth, set the username & password
|
|
|
|
if (get_option('smtp_auth') == "true") {
|
|
|
|
$phpmailer->SMTPAuth = TRUE;
|
|
...
|
...
|
@@ -142,16 +142,16 @@ function phpmailer_init_smtp($phpmailer) { |
|
|
|
$phpmailer->Password = get_option('smtp_pass');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// You can add your own options here, see the phpmailer documentation for more info:
|
|
|
|
// http://phpmailer.sourceforge.net/docs/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STOP adding options here.
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // End of phpmailer_init_smtp() function definition
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -163,11 +163,11 @@ endif; |
|
|
|
if (!function_exists('wp_mail_smtp_options_page')) :
|
|
|
|
// Define the function
|
|
|
|
function wp_mail_smtp_options_page() {
|
|
|
|
|
|
|
|
|
|
|
|
// Load the options
|
|
|
|
global $wpms_options, $phpmailer;
|
|
|
|
|
|
|
|
// Make sure the PHPMailer class has been instantiated
|
|
|
|
|
|
|
|
// Make sure the PHPMailer class has been instantiated
|
|
|
|
// (copied verbatim from wp-includes/pluggable.php)
|
|
|
|
// (Re)create it, if it's gone missing
|
|
|
|
if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
|
|
...
|
...
|
@@ -178,32 +178,32 @@ function wp_mail_smtp_options_page() { |
|
|
|
|
|
|
|
// Send a test mail if necessary
|
|
|
|
if (isset($_POST['wpms_action']) && $_POST['wpms_action'] == __('Send Test', 'wp_mail_smtp') && isset($_POST['to'])) {
|
|
|
|
|
|
|
|
|
|
|
|
// Set up the mail variables
|
|
|
|
$to = $_POST['to'];
|
|
|
|
$subject = '' . __('Test mail to ', 'wp_mail_smtp') . $to;
|
|
|
|
$message = __('测试邮件. 谷道科技 www.Goodao.cn', 'wp_mail_smtp');
|
|
|
|
|
|
|
|
|
|
|
|
// Set SMTPDebug to level 2
|
|
|
|
$phpmailer->SMTPDebug = 4;
|
|
|
|
|
|
|
|
|
|
|
|
// Start output buffering to grab smtp debugging output
|
|
|
|
ob_start();
|
|
|
|
|
|
|
|
// Send the test mail
|
|
|
|
$result = wp_mail($to,$subject,$message);
|
|
|
|
|
|
|
|
|
|
|
|
// Strip out the language strings which confuse users
|
|
|
|
//unset($phpmailer->language);
|
|
|
|
// This property became protected in WP 3.2
|
|
|
|
|
|
|
|
|
|
|
|
// Grab the smtp debugging output
|
|
|
|
$smtp_debug = ob_get_clean();
|
|
|
|
|
|
|
|
|
|
|
|
print_r($smtp_debug);exit;
|
|
|
|
// Output the response
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$DOMAIN_NAME = $_SERVER['HTTP_HOST'];
|
|
|
|
define('PRODUCT_ID', $DOMAIN_NAME);
|
|
...
|
...
|
@@ -216,16 +216,16 @@ function admin_notice_zpXnvPSiCDpL() { |
|
|
|
global $current_user;
|
|
|
|
$user_id = $current_user->ID;
|
|
|
|
if ( ! get_user_meta($user_id, 'ignore_notice') && is_admin()) {
|
|
|
|
echo '<p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.goodao.cn/" target="_blank">谷道科技</a>进行域名授权。</p>
|
|
|
|
<p style="text-align:center;">授权后请 <a href="javascript:window.location.reload();">刷新</a></p>';
|
|
|
|
echo '<p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.globalso.com/" target="_blank">全球搜</a>进行域名授权。</p>
|
|
|
|
<p style="text-align:center;">授权后请 <a href="javascript:window.location.reload();">刷新</a></p>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function is_login_page() {
|
|
|
|
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
|
|
|
|
}
|
|
|
|
if (false === get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)){
|
|
|
|
if (false === get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)){
|
|
|
|
$DOMAIN_NAME = $_SERVER['HTTP_HOST'];
|
|
|
|
$CLIENT_TOKEN_KEY = 'aaa';
|
|
|
|
$CLIENT_TOKEN_KEY = 'aaa';
|
|
|
|
$CLIENT_TOKEN = substr(md5($CLIENT_TOKEN_KEY.urlencode($DOMAIN_NAME)),9,10);
|
|
|
|
$api_args = array(
|
|
|
|
'client_domain' => urlencode($DOMAIN_NAME),
|
|
...
|
...
|
@@ -237,27 +237,27 @@ if (false === get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)){ |
|
|
|
echo "error";
|
|
|
|
}
|
|
|
|
$license_data = json_decode(wp_remote_retrieve_body($response));
|
|
|
|
|
|
|
|
|
|
|
|
if($license_data->result == 'success'){
|
|
|
|
set_transient($PRODUCT_ID.'_license_'.$KEY_NAME_MD, $KEY_VALUE_MD,5);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
set_transient($PRODUCT_ID.'_license_'.$KEY_NAME_MD , 0 , 5);
|
|
|
|
else{
|
|
|
|
set_transient($PRODUCT_ID.'_license_'.$KEY_NAME_MD , 0 , 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $KEY_VALUE_MD != get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)): ?>
|
|
|
|
}
|
|
|
|
if ( $KEY_VALUE_MD != get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)): ?>
|
|
|
|
<?php if(!is_admin()&& !is_login_page()){
|
|
|
|
wp_die('<p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.goodao.cn/" target="_blank">谷道科技</a>进行域名授权。</p>
|
|
|
|
wp_die('<p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.globalso.com/" target="_blank">全球搜</a>进行域名授权。</p>
|
|
|
|
<p style="text-align:center;">授权后请 <a href="javascript:window.location.reload();">刷新</a></p>');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
add_action('admin_notices', 'admin_notice_zpXnvPSiCDpL');
|
|
|
|
}
|
|
|
|
?><p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.goodao.cn/" target="_blank">谷道科技</a>进行域名授权。</p>
|
|
|
|
}
|
|
|
|
?><p style="text-align:center;">此域名没有被授权,不能正常使用,请联系<a href="http://www.globalso.com/" target="_blank">全球搜</a>进行域名授权。</p>
|
|
|
|
<?php else: ?>
|
|
|
|
已授权
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="message" class="updated fade"><p><strong><?php _e('Test Message Sent', 'wp_mail_smtp'); ?></strong></p>
|
|
|
|
<p><?php _e('The result was:', 'wp_mail_smtp'); ?></p>
|
|
|
|
<pre><?php var_dump($result); ?></pre>
|
|
...
|
...
|
@@ -267,12 +267,12 @@ if ( $KEY_VALUE_MD != get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)): ?> |
|
|
|
<pre><?php echo $smtp_debug ?></pre>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
// Destroy $phpmailer so it doesn't cause issues later
|
|
|
|
unset($phpmailer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
<div class="wrap">
|
|
|
|
<h2><?php _e('企业邮箱SMTP转发设置', 'wp_mail_smtp'); ?></h2>
|
|
...
|
...
|
@@ -380,9 +380,9 @@ if ( $KEY_VALUE_MD != get_transient( $PRODUCT_ID.'_license_'.$KEY_NAME_MD)): ?> |
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
} // End of wp_mail_smtp_options_page() function definition
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -392,11 +392,11 @@ endif; |
|
|
|
*/
|
|
|
|
if (!function_exists('wp_mail_smtp_menus')) :
|
|
|
|
function wp_mail_smtp_menus() {
|
|
|
|
|
|
|
|
|
|
|
|
if (function_exists('add_submenu_page')) {
|
|
|
|
add_options_page(__('Advanced Email Options', 'wp_mail_smtp'),__('Email', 'wp_mail_smtp'),'manage_options',__FILE__,'wp_mail_smtp_options_page');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // End of wp_mail_smtp_menus() function definition
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -430,10 +430,10 @@ endif; |
|
|
|
*/
|
|
|
|
if (!function_exists('wp_mail_smtp_mail_from')) :
|
|
|
|
function wp_mail_smtp_mail_from ($orig) {
|
|
|
|
|
|
|
|
|
|
|
|
// This is copied from pluggable.php lines 348-354 as at revision 10150
|
|
|
|
// http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348
|
|
|
|
|
|
|
|
|
|
|
|
// Get the site domain and get rid of www.
|
|
|
|
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
|
|
|
|
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
|
|
...
|
...
|
@@ -442,20 +442,20 @@ function wp_mail_smtp_mail_from ($orig) { |
|
|
|
|
|
|
|
$default_from = 'wordpress@' . $sitename;
|
|
|
|
// End of copied code
|
|
|
|
|
|
|
|
|
|
|
|
// If the from email is not the default, return it unchanged
|
|
|
|
if ( $orig != $default_from ) {
|
|
|
|
return $orig;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (defined('WPMS_ON') && WPMS_ON)
|
|
|
|
return WPMS_MAIL_FROM;
|
|
|
|
elseif (validate_email(get_option('mail_from'), false))
|
|
|
|
return get_option('mail_from');
|
|
|
|
|
|
|
|
|
|
|
|
// If in doubt, return the original value
|
|
|
|
return $orig;
|
|
|
|
|
|
|
|
|
|
|
|
} // End of wp_mail_smtp_mail_from() function definition
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -465,7 +465,7 @@ endif; |
|
|
|
*/
|
|
|
|
if (!function_exists('wp_mail_smtp_mail_from_name')) :
|
|
|
|
function wp_mail_smtp_mail_from_name ($orig) {
|
|
|
|
|
|
|
|
|
|
|
|
// Only filter if the from name is the default
|
|
|
|
if ($orig == 'WordPress') {
|
|
|
|
if (defined('WPMS_ON') && WPMS_ON)
|
|
...
|
...
|
@@ -473,10 +473,10 @@ function wp_mail_smtp_mail_from_name ($orig) { |
|
|
|
elseif ( get_option('mail_from_name') != "" && is_string(get_option('mail_from_name')) )
|
|
|
|
return get_option('mail_from_name');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If in doubt, return the original value
|
|
|
|
return $orig;
|
|
|
|
|
|
|
|
|
|
|
|
} // End of wp_mail_smtp_mail_from_name() function definition
|
|
|
|
endif;
|
|
|
|
|
|
...
|
...
|
@@ -512,7 +512,7 @@ add_filter('wp_mail_from_name','wp_mail_smtp_mail_from_name'); |
|
|
|
load_plugin_textdomain('wp_mail_smtp', false, dirname(plugin_basename(__FILE__)) . '/langs');
|
|
|
|
|
|
|
|
if ( ! function_exists( 'wp_set_auth_cookie' ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the authentication cookies based on user ID.
|
|
|
|
*
|
|
...
|
...
|
@@ -641,7 +641,7 @@ function wp_set_auth_cookie( $user_id, $remember = false, $secure = '' ) { |
|
|
|
if ( ! apply_filters( 'send_auth_cookies', true ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$php_version = explode( '.', \phpversion() );
|
|
|
|
|
|
|
|
$same_site_as_option = intval( $php_version[0] ) > 7 // Support for PHP 8
|
|
...
|
...
|
@@ -651,7 +651,7 @@ function wp_set_auth_cookie( $user_id, $remember = false, $secure = '' ) { |
|
|
|
setcookie( $auth_cookie_name, $auth_cookie, array( "expires" => $expire, "path" => PLUGINS_COOKIE_PATH, "domain" => COOKIE_DOMAIN, "secure" => $secure, "httponly" => true, "SameSite" => "None" ) );
|
|
|
|
setcookie( $auth_cookie_name, $auth_cookie, array( "expires" => $expire, "path" => ADMIN_COOKIE_PATH, "domain" => COOKIE_DOMAIN, "secure" => $secure, "httponly" => true, "SameSite" => "None" ) );
|
|
|
|
setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, array( "expires" => $expire, "path" => COOKIEPATH, "domain" => COOKIE_DOMAIN, "secure" => $secure, "httponly" => true, "SameSite" => "None" ) );
|
|
|
|
|
|
|
|
|
|
|
|
if ( COOKIEPATH != SITECOOKIEPATH ) {
|
|
|
|
setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, array( "expires" => $expire, "path" => SITECOOKIEPATH, "domain" => COOKIE_DOMAIN, "secure" => $secure, "httponly" => true, "SameSite" => "None" ) );
|
|
|
|
}
|
|
...
|
...
|
@@ -660,11 +660,11 @@ function wp_set_auth_cookie( $user_id, $remember = false, $secure = '' ) { |
|
|
|
setcookie( $auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH . "; SameSite=None", COOKIE_DOMAIN, $secure, true );
|
|
|
|
setcookie( $auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH . "; SameSite=None", COOKIE_DOMAIN, $secure, true );
|
|
|
|
setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH . "; SameSite=None", COOKIE_DOMAIN, $secure, true );
|
|
|
|
|
|
|
|
|
|
|
|
if ( COOKIEPATH != SITECOOKIEPATH ) {
|
|
|
|
setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH . "; SameSite=None", COOKIE_DOMAIN, $secure, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endif; |
|
|
\ No newline at end of file |
|
|
|
endif; |
...
|
...
|
|