40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?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()
|
||
]);
|
||
}
|
||
?>
|