Files
random_scripts/php/clean-cache.php
T
2025-01-08 13:32:06 +01:00

84 lines
2.4 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex, nofollow">
<title>Cache Cleaner</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
padding: 50px;
}
h1 {
color: #333;
}
.btn-clean {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 20px 0;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.btn-clean:hover {
background-color: #45a049;
}
.result {
color: #555;
margin-top: 20px;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Cache Cleaner</h1>
<form method="post">
<button type="submit" class="btn-clean" name="clear_cache">Clear Cache</button>
</form>
<div class="result">
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['clear_cache'])) {
// Clear OPcache
if (function_exists('opcache_reset')) {
if (opcache_reset()) {
echo "✅ OPcache cleared successfully.<br>";
} else {
echo "❌ Failed to clear OPcache.<br>";
}
} else {
echo "❌ OPcache is not enabled or available.<br>";
}
// Clear APCu Cache
if (function_exists('apcu_clear_cache')) {
apcu_clear_cache();
echo "✅ APCu cache cleared successfully.<br>";
} else {
echo "❌ APCu is not enabled or available.<br>";
}
// Clear Realpath Cache
if (function_exists('clearstatcache')) {
clearstatcache();
echo "✅ Realpath cache cleared successfully.<br>";
} else {
echo "❌ Failed to clear Realpath cache.<br>";
}
echo "<strong>🎉 Cache cleaning process completed.</strong>";
}
?>
</div>
</body>
</html>