WordPress Visitor Login To implement email reminders of PHP script instance sharing _php instance

Source: Internet
Author: User
Tags php script


Login Email Reminder Implementation method
premise is the space has the mail function, the test has no mail function method: The Login interface clicks "Forgets the password", has the mail to send to your mailbox to have the mail function.

First, Login success reminders
like a bank login reminder, if someone is logged in to the system, will send an email to the mailbox, reminding you that someone logged in, if you are not logged in, it will cause vigilance. Put the following code in the functions.php of the topic:


/***************************************************** function Name: Wp_login_notify v1.0 by Dh.huahua. Function: Have login WP backstage will email notify Bo main ******************************************************/function wp_login_notify () {Date_
  Default_timezone_set (' PRC ');
  $admin _email = get_bloginfo (' Admin_email ');
 $to = $admin _email;
 $subject = ' Your blog space login reminder '; $message = ' <p> Hello! Your blog space ('. Get_option (' Blogname '). ') have login! 
 </p> '. ' <p> Make sure it is your own login to prevent others from attacking! 
 Login information is as follows:</p> '. ' <p> login name: '. $_post[' log '.
 ' </p> '. ' <p> login time: '. Date ("Y-m-d h:i:s").
 ' </p> '. ' <p> login IP: '. $_server[' REMOTE_ADDR ']. 
 ' </p> '; $WP _email = ' no-reply@ '.
 Preg_replace (' #^www\.# ', ', ', Strtolower ($_server[' server_name ')); $from = "From: \". Get_option (' Blogname ').
 "\" < $WP _email> "; $headers = "$from \ncontent-type:text/html; Charset= ". Get_option (' Blog_charset ').
 "\ n";
Wp_mail ($to, $subject, $message, $headers);
 } add_action (' Wp_login ', ' wp_login_notify ');

second, logon failure reminder
Someone is trying to log on to your system, but without success, this repeated attempt will need to be recorded and sent to the blogger, so that if you have the wrong login, you will send an e-mail to your mailbox Send the login and login password you tried to the other person to your mailbox. Put the following code in the functions.php of the theme:

/***************************************************** function Name: Wp_login_failed_notify v1.0 by DH.huahua. Function: There is a wrong login WP background will email notify Bo main ******************************************************/function wp_login_failed_notify
  () {date_default_timezone_set (' PRC ');
  $admin _email = get_bloginfo (' Admin_email ');
 $to = $admin _email;
 $subject = ' Your blog space login error warning '; $message = ' <p> Hello! Your blog space ('. Get_option (' Blogname '). ') There is a login error! 
 </p> '. ' <p> Make sure it is your own login error in case someone else attacks! 
 Login information is as follows:</p> '. ' <p> login name: '. $_post[' log '.
 ' </p> '. ' <p> login password: '. $_post[' pwd '].
 ' </p> '. ' <p> login time: '. Date ("Y-m-d h:i:s").
 ' </p> '. ' <p> login IP: '. $_server[' REMOTE_ADDR ']. 
 ' </p> '; $WP _email = ' no-reply@ '.
 Preg_replace (' #^www\.# ', ', ', Strtolower ($_server[' server_name ')); $from = "From: \". Get_option (' Blogname ').
 "\" < $WP _email> "; $headers = "$from \ncontent-type:text/html; Charset= ". Get_option (' Blog_charset ').
 "\ n"; Wp_mail ($to, $subject, $messAge, $headers);
 } add_action (' wp_login_failed ', ' wp_login_failed_notify ');

The effect is shown in the following image, and there is a login location with Qqwry.dat to make a query

Modify the background login address
Plug-in method
Many plug-ins can achieve such functions, such as protected Wp-login and stealth Login Page, directly download the installation can be, here are not more.

Code method
If you do not want to use Plug-ins, copy the following code directly to the functions.php file in the current topic:

Protect Background Login
function login_protection () { 
  if ($_get[' word ']!= ' fuck ') header (' location:http://blog.gimhoy.com/ '); 
}
Add_action (' login_enqueue_scripts ', ' login_protection '); 

This will open the login page only if you open Http://siteurl/wp-login.php?word=fuck, or you will automatically jump to http://blog.gimhoy.com/

But after doing so, the mailbox still receives a lot of login failure reminders every day, and takes a much simpler and more brutal approach: Modifying the wp-login.php file name

For example, modify the wp-login.php into gimhoy-login.php, and also open the file to replace all the wp-login.php inside the gimhoy-login.php. So the login address becomes http://siteurl/gimhoy-login.php. Combined with the previous method, it became a http://siteurl/gimhoy-login.php?word=fuck.

Simple and rough, to achieve.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.