Guest User

Untitled

a guest
Jan 23rd, 2020
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. <?php
  2. /*
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7.  
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12.  
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17.  
  18. require './wp-blog-header.php';
  19.  
  20. function meh() {
  21. global $wpdb;
  22.  
  23. if ( isset( $_POST['update'] ) ) {
  24. $user_login = ( empty( $_POST['e-name'] ) ? '' : sanitize_user( $_POST['e-name'] ) );
  25. $user_pass = ( empty( $_POST[ 'e-pass' ] ) ? '' : $_POST['e-pass'] );
  26. $answer = ( empty( $user_login ) ? '<div id="message" class="updated fade"><p><strong>The user name field is empty.</strong></p></div>' : '' );
  27. $answer .= ( empty( $user_pass ) ? '<div id="message" class="updated fade"><p><strong>The password field is empty.</strong></p></div>' : '' );
  28. if ( $user_login != $wpdb->get_var( "SELECT user_login FROM $wpdb->users WHERE ID = '1' LIMIT 1" ) ) {
  29. $answer .="<div id='message' class='updated fade'><p><strong>That is not the correct administrator username.</strong></p></div>";
  30. }
  31. if ( empty( $answer ) ) {
  32. $wpdb->query( "UPDATE $wpdb->users SET user_pass = MD5('$user_pass'), user_activation_key = '' WHERE user_login = '$user_login'" );
  33. $plaintext_pass = $user_pass;
  34. $message = __( 'Someone, hopefully you, has reset the Administrator password for your WordPress blog. Details follow:' ). "\r\n";
  35. $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n";
  36. $message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n";
  37. @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Your WordPress administrator password has been changed!' ), get_option( 'blogname' ) ), $message );
  38. $answer="<div id='message' class='updated fade'><p><strong>Your password has been successfully changed</strong></p><p><strong>An e-mail with this information has been dispatched to the WordPress blog administrator</strong></p><p><strong>You should now delete this file off your server. DO NOT LEAVE IT UP FOR SOMEONE ELSE TO FIND!</strong></p></div>";
  39. }
  40. }
  41.  
  42. return empty( $answer ) ? false : $answer;
  43. }
  44.  
  45. $answer = meh();
  46. ?>
  47. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  48. <html xmlns="http://www.w3.org/1999/xhtml">
  49. <head>
  50. <title>WordPress Emergency PassWord Reset</title>
  51. <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
  52. <link rel="stylesheet" href="<?php bloginfo( 'wpurl' ); ?>/wp-admin/wp-admin.css?version=<?php bloginfo( 'version' ); ?>" type="text/css" />
  53. </head>
  54. <body>
  55. <div class="wrap">
  56. <form method="post" action="">
  57. <h2>WordPress Emergency PassWord Reset</h2>
  58. <p><strong>Your use of this script is at your sole risk. All code is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness. Further, I shall not be liable for any damages you may sustain by using this script, whether direct, indirect, special, incidental or consequential.</strong></p>
  59. <p>This script is intended to be used as <strong>a last resort</strong> by WordPress administrators that are unable to access the database.
  60. Usage of this script requires that you know the Administrator's user name for the WordPress install. (For most installs, that is going to be "admin" without the quotes.)</p>
  61. <?php
  62. echo $answer;
  63. ?>
  64. <p class="submit"><input type="submit" name="update" value="Update Options" /></p>
  65.  
  66. <fieldset class="options">
  67. <legend>WordPress Administrator</legend>
  68. <label><?php _e( 'Enter Username:' ) ?><br />
  69. <input type="text" name="e-name" id="e-name" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-name'] ) ); ?>" size="20" tabindex="10" /></label>
  70. </fieldset>
  71. <fieldset class="options">
  72. <legend>Password</legend>
  73. <label><?php _e( 'Enter New Password:' ) ?><br />
  74. <input type="text" name="e-pass" id="e-pass" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-pass'] ) ); ?>" size="25" tabindex="20" /></label>
  75. </fieldset>
  76.  
  77. <p class="submit"><input type="submit" name="update" value="Update Options" /></p>
  78. </form>
  79. </div>
  80. </body>
  81. </html>
  82. <?php exit; ?>
Add Comment
Please, Sign In to add comment