Files
citrus-cms/resources/views/admin-ajax/delete-all-logs.blade.php
T
2026-04-28 21:15:09 +03:00

40 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Support\Facades\Storage;
// CSRF token kontrolü
if (!isset($_POST['_token']) || !csrf_token()) {
echo json_encode(['status' => 'error', 'message' => 'CSRF token error']);
exit();
}
try {
$logsPath = storage_path('logs');
$deletedCount = 0;
// Tüm log dosyalarını tara
$logFiles = glob($logsPath . '/*.log');
foreach ($logFiles as $logFile) {
$fileName = basename($logFile);
// Sadece .log uzantılı dosyaları sil
if (pathinfo($fileName, PATHINFO_EXTENSION) === 'log') {
if (unlink($logFile)) {
$deletedCount++;
}
}
}
echo json_encode([
'status' => 'success',
'message' => $deletedCount . ' log files have been successfully deleted',
'deleted_count' => $deletedCount
]);
} catch (Exception $e) {
echo json_encode([
'status' => 'error',
'message' => 'An error occurred while deleting log files: ' . $e->getMessage()
]);
}
?>