From 4acb64e852d56577de505d664575c9f41ad3f06a Mon Sep 17 00:00:00 2001 From: Ivan Carlos Date: Wed, 21 Jan 2026 20:43:49 -0300 Subject: [PATCH] debug delete temp --- plugin.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/plugin.php b/plugin.php index 8c86a2a..ab7ede9 100755 --- a/plugin.php +++ b/plugin.php @@ -179,6 +179,65 @@ function icc_upload_and_shorten_do_page() echo "
Security check failed (Invalid Nonce).
"; } } + + // Manual Cleanup Handler + if (isset($_POST['action']) && $_POST['action'] == 'icc_manual_cleanup') { + $nonce = $_POST['nonce'] ?? ''; + if (yourls_verify_nonce('icc_manual_cleanup', $nonce)) { + echo '
'; + echo 'Starting Manual Cleanup Diagnostics...
'; + + $temp_dir = yourls_get_option('icc_upload_share_dir'); + if (!$temp_dir) $temp_dir = sys_get_temp_dir(); + + echo "Target Directory: " . htmlspecialchars($temp_dir) . "
"; + + if (!is_dir($temp_dir)) { + echo "Directory does not exist!
"; + } elseif (!is_writable($temp_dir)) { + echo "Directory is not writable! Permissions issues likely.
"; + } else { + $files = scandir($temp_dir); + $found = 0; + foreach ($files as $file) { + if ($file == '.' || $file == '..') continue; + + // Only look for icc_temp_ folders + if (strpos($file, 'icc_temp_') !== 0) continue; + + $path = rtrim($temp_dir, '/') . '/' . $file; + if (!is_dir($path)) continue; + + $found++; + $age = time() - filemtime($path); + echo "
Found: " . htmlspecialchars($file) . "
"; + echo "Path: " . htmlspecialchars($path) . "
"; + echo "Age: " . $age . " seconds (" . round($age/3600, 2) . " hours)
"; + + // Force delete if requested via manual action, or just standard check + // For manual diagnostics, we'll try to delete anything > 24 hours just like the automated one + if ($age > 86400) { + echo "Status: Older than 24 hours. Attempting deletion...
"; + icc_rrmdir($path); + if (!file_exists($path)) { + echo "Result: DELETED SUCCESS.
"; + } else { + echo "Result: DELETED FAILED. Check server log/permissions.
"; + } + } else { + echo "Status: Kept (Not old enough).
"; + } + } + + if ($found == 0) { + echo "No temporary 'icc_temp_' folders found.
"; + } + } + echo 'Diagnostics Complete.
'; + } else { + echo "
Security check failed.
"; + } + } $message = ''; if (isset($_POST['submit']) && $_POST['submit'] == 'Upload') @@ -465,9 +524,20 @@ function icc_upload_and_shorten_do_page()

+ +

+
+ Run Cleanup & Diagnostics Now + (Checks for 'icc_temp_' folders older than 24 hours and attempts to delete them) +

+ + '; // footer