Add PHP script 'Files/opcache_clear.php'.
This commit is contained in:
94
Files/opcache_clear.php
Normal file
94
Files/opcache_clear.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// -------------------- KONFIGURATION --------------------
|
||||
$valid_user = 'admin';
|
||||
$valid_pass = 'supergeheim';
|
||||
|
||||
$allowed_ips = []; // z. B. ['127.0.0.1', '192.168.1.100']; leer = keine Prüfung
|
||||
|
||||
session_start();
|
||||
|
||||
// -------------------- IP-WHITELIST --------------------
|
||||
$remote_ip = $_SERVER['REMOTE_ADDR'];
|
||||
if (!empty($allowed_ips) && !in_array($remote_ip, $allowed_ips)) {
|
||||
http_response_code(403);
|
||||
exit("Zugriff verweigert für IP: $remote_ip");
|
||||
}
|
||||
|
||||
// -------------------- LOGIN VERARBEITUNG --------------------
|
||||
if (isset($_POST['username'], $_POST['password'])) {
|
||||
if ($_POST['username'] === $valid_user && $_POST['password'] === $valid_pass) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
} else {
|
||||
$error = "Falscher Benutzername oder Passwort.";
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- LOGOUT --------------------
|
||||
if (isset($_GET['logout'])) {
|
||||
session_destroy();
|
||||
header("Location: " . strtok($_SERVER["REQUEST_URI"], '?'));
|
||||
exit;
|
||||
}
|
||||
|
||||
// -------------------- HTML-AUSGABE --------------------
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>OPCache-Verwaltung</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; background: #f4f4f4; padding: 2em; }
|
||||
.box { background: white; padding: 1.5em; max-width: 500px; margin: auto; border-radius: 10px; box-shadow: 0 0 10px #ccc; }
|
||||
h1 { font-size: 1.4em; }
|
||||
input[type="text"], input[type="password"] { width: 100%; padding: 0.5em; margin-top: 0.3em; }
|
||||
input[type="submit"] { padding: 0.6em 1.2em; margin-top: 1em; }
|
||||
.status { margin-top: 1em; padding: 1em; background: #eef; border-left: 4px solid #99f; }
|
||||
.error { color: red; }
|
||||
.logout { float: right; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<?php if (!isset($_SESSION['authenticated'])): ?>
|
||||
<h1>Login zur OPCache-Verwaltung</h1>
|
||||
<?php if (!empty($error)): ?><p class="error"><?= htmlspecialchars($error) ?></p><?php endif; ?>
|
||||
<form method="post">
|
||||
<label>Benutzername:<br><input type="text" name="username" required></label><br><br>
|
||||
<label>Passwort:<br><input type="password" name="password" required></label><br>
|
||||
<input type="submit" value="Anmelden">
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="logout">
|
||||
<a href="?logout=1">Abmelden</a>
|
||||
</div>
|
||||
<h1>OPCache-Verwaltung</h1>
|
||||
<form method="post">
|
||||
<input type="submit" name="clear" value="OPCache jetzt leeren">
|
||||
</form>
|
||||
|
||||
<div class="status">
|
||||
<?php
|
||||
if (function_exists('opcache_get_status') && function_exists('opcache_reset')) {
|
||||
$status = @opcache_get_status(false);
|
||||
if (!$status || empty($status['opcache_enabled'])) {
|
||||
echo "ℹ️ OPCache ist installiert, aber aktuell nicht aktiviert.";
|
||||
} else {
|
||||
echo "✅ OPCache ist aktiviert.<br>";
|
||||
if (isset($_POST['clear'])) {
|
||||
if (opcache_reset()) {
|
||||
echo "✅ OPCache wurde erfolgreich geleert.";
|
||||
} else {
|
||||
echo "⚠️ Fehler beim Leeren des OPCache.";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "❌ OPCache ist auf diesem Server nicht verfügbar.";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user