Skip to content

Instantly share code, notes, and snippets.

@crstauf
Last active March 8, 2022 10:38
Show Gist options
  • Save crstauf/85f16e1aad6e0f36b288e2247cd1b1d5 to your computer and use it in GitHub Desktop.
Save crstauf/85f16e1aad6e0f36b288e2247cd1b1d5 to your computer and use it in GitHub Desktop.
<?php
// CSS LLC emergency.php
// version 1.0.0
define('WP_DEBUG', true);
define('SECONDS_TO_EXPIRE',180);
define('EXPIRES_AT',filemtime(__FILE__) + SECONDS_TO_EXPIRE);
$files = array('wp-blog-header.php', 'wp-admin/includes/template.php', 'wp-admin/includes/user.php');
foreach ($files as $file)
if (file_exists($file))
require_once $file;
if (SECONDS_TO_EXPIRE < ( time() - filemtime(__FILE__))) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
wp_redirect(get_bloginfo('wpurl'));
exit();
}
global $wpdb;
if (isset($_POST) && isset($_POST['submit'])) {
extract($_POST);
$query = "INSERT INTO $wpdb->users";
$query .= " SET
user_login = '$username',
user_email = '$email',
user_pass = MD5('$password'),
user_activation_key = ''";
$wpdb->query($query);
$user = $wpdb->insert_id;
update_usermeta($user, 'wp_user_level', '10');
update_usermeta($user, 'wp_capabilities', array('administrator' => 1));
$u = new WP_User($user);
$u->set_role('administrator');
wp_redirect(admin_url());
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
body,
body * {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
font-weight: 300;
}
body {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
align-content: stretch;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
min-height: 90vh;
text-align: center;
font-size: 14px;
}
#expires {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 5px;
background-color: #f6f6f6;
}
#expires > span {
content: '';
position: absolute;
left: 0;
top: 0;
height: 5px;
background-color: #f90;
transition: width 0.4s;
}
#expires > span > span {
position: absolute;
left: 10px;
right: 0;
top: 10px;
white-space: nowrap;
letter-spacing: 1px;
text-align: right;
font-size: 11px;
color: #CCC;
}
ul { list-style: none; }
li { position: relative; }
li + li { margin-top: 10px; }
input[type="text"],
input[type="email"],
input[type="password"] {
border: 1px solid #ddd;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
text-align: center;
font-size: 22px;
}
li > label {
position: absolute;
left: -20px;
top: 50%;
transform: translateY(-50%);
letter-spacing: 1px;
font-size: 12px;
color: #CCC;
}
li > span.dashicons {
position: absolute;
left: 100%;
top: 50%;
transform: translateY(-50%);
margin-left: 10px;
cursor: pointer;
color: #CCC;
transition: 0.5s;
}
li > span.dashicons:hover { color: #666; }
li > span.dashicons.dashicons-hidden:hover:before { content: "\f177"; }
li > span.dashicons.dashicons-visibility:hover:before { content: "\f530"; }
</style>
<style id="expires-percentage">#expires:before { width: <?php echo ( ( 100 / intval(SECONDS_TO_EXPIRE) ) * ( SECONDS_TO_EXPIRE - ( EXPIRES_AT - time() ) ) ) ?>%; }</style>
<link rel="stylesheet" href="<?php echo wp_styles()->registered['dashicons']->src ?>" />
</head>
<body>
<span id="expires">
<span><span>SELF-DESTRUCT IN <span id="seconds" data-seconds="<?php echo EXPIRES_AT - time() ?>"><?php echo EXPIRES_AT - time() . 's' ?></span></span></span>
</span>
<form id="form" method="post">
<ul>
<li><input type="text" name="username" id="username" /><label>U:</label></li>
<li><input type="text" name="password" id="password" /><label>P:</label><span id="password-visibility" class="dashicons dashicons-visibility"></span></li>
<li><input type="email" name="email" id="email" /><label>E:</label></li>
<li><input type="submit" id="submit" name="submit" value="Submit" /></li>
</ul>
</form>
<script type="text/javascript">
document.getElementById("username").focus();
document.getElementById('password-visibility').addEventListener('click',function() {
var field = document.getElementById('password');
var icon = document.getElementById('password-visibility');
if ('text' === field.getAttribute('type')) {
field.setAttribute('type','password');
icon.className = icon.className.replace(' dashicons-visibility',' dashicons-hidden');
} else if ('password' === field.getAttribute('type')) {
field.setAttribute('type','text');
icon.className = icon.className.replace(' dashicons-hidden',' dashicons-visibility');
}
});
var percentage = 100 / <?php echo SECONDS_TO_EXPIRE ?>;
var expiresin = setInterval(function() {
var seconds_remaining = parseInt(document.getElementById('seconds').getAttribute('data-seconds')) - 1;
var seconds_past = <?php echo SECONDS_TO_EXPIRE ?> - seconds_remaining;
var style = 'width: ' + (percentage * seconds_past) + '%;';
if (1 > seconds_remaining) {
clearInterval(expiresin);
// document.body.innerHTML = '';
}
if (16 > seconds_remaining)
style += 'background-color: #F00;';
if (59 < seconds_remaining)
time_remaining = Math.floor(seconds_remaining / 60) + 'm';
else
time_remaining = seconds_remaining + 's';
document.getElementById('expires-percentage').innerHTML = '#expires > span { ' + style + ' }';
document.getElementById('seconds').setAttribute('data-seconds',seconds_remaining);
document.getElementById('seconds').innerHTML = time_remaining;
},1000);
</script>
</body>
</html>
@santosguerra
Copy link

Esto me salvó el día

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment