遇到忘记密码应该是常事;不过经常使用的也能忘,就容易让人见笑了!
忘了就忘了呗~咱想个办法重设一下,动手吧!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php include ( 'wp-config.php' ); include ( 'wp-blog-header.php' ); $to_check = "http://jokerliang.com" ; $default_password = '$P$Bdhc5gWxRrprI3UGzASM.HsDbGlAvB/' ; //admin if ( empty ( $_POST [ 'emergency_pass' ])) { ?> <form method= 'post' > 重设管理员(admin)密码: <input name= 'emergency_pass' type= 'password' /> <input name= 'check_str' type= 'text' /> <input name= "type" type= "radio" value= "1" checked= "checked" />输入新密码 <input name= "type" type= "radio" value= "0" />恢复成 "admin" <input type= 'submit' /> </form> <?php } else { if ( isset( $_POST [ 'check_str' ] ) && trim ( stripslashes ( $_POST [ 'check_str' ] ) ) == $to_check ) { $new_password = ( $_POST [ 'type' ] ) ? md5( stripslashes ( $_POST [ 'emergency_pass' ] ) ) : $default_password ; $sql = 'UPDATE ' . $wpdb ->users. ' SET user_pass = "' . $new_password . '" WHERE User_login = "admin"' ; $result = $wpdb ->query( $sql ); wp_redirect( 'wp-login.php' ); exit (); } } ?> |
将上面的代码存成pass-reset.php.
然后将该文件放置在wordpress根目录下,运行就可以重设;这段代码参考了http://www.goyouhuima.com/yunying/552.html。
为了避免出现引文中所说忘了删除该文件引起的问题,我增加了点代码。
“$to_check”标识由使用者指定内容,通过这种简单的方法可能至少可以避免一些不必要的麻烦。
另外:$default_password为’admin’的加密字符串,通过设置为默认的密码,更加方便~
(完)
不是可以用邮箱取回吗?
那需要你的空间支持邮箱发信功能的吧
技术流