Compare commits
4 Commits
v2.0.0
...
3457c14bbf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3457c14bbf | ||
| 4acb64e852 | |||
|
|
ecb3c8866d | ||
| da573d0a9d |
@@ -1 +1,5 @@
|
|||||||
{ "version": "2.0.0", "author": "Ivan Carlos", "upstream_sha": "" }
|
{
|
||||||
|
"version": "2.0.2",
|
||||||
|
"author": "Ivan Carlos",
|
||||||
|
"upstream_sha": ""
|
||||||
|
}
|
||||||
|
|||||||
72
plugin.php
72
plugin.php
@@ -180,6 +180,65 @@ function icc_upload_and_shorten_do_page()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manual Cleanup Handler
|
||||||
|
if (isset($_POST['action']) && $_POST['action'] == 'icc_manual_cleanup') {
|
||||||
|
$nonce = $_POST['nonce'] ?? '';
|
||||||
|
if (yourls_verify_nonce('icc_manual_cleanup', $nonce)) {
|
||||||
|
echo '<div style="background:#fff; border:1px solid #ccc; padding:10px; margin: 10px 0; max-height: 300px; overflow:auto;">';
|
||||||
|
echo '<strong>Starting Manual Cleanup Diagnostics...</strong><br/>';
|
||||||
|
|
||||||
|
$temp_dir = yourls_get_option('icc_upload_share_dir');
|
||||||
|
if (!$temp_dir) $temp_dir = sys_get_temp_dir();
|
||||||
|
|
||||||
|
echo "Target Directory: " . htmlspecialchars($temp_dir) . "<br/>";
|
||||||
|
|
||||||
|
if (!is_dir($temp_dir)) {
|
||||||
|
echo "<span style='color:red'>Directory does not exist!</span><br/>";
|
||||||
|
} elseif (!is_writable($temp_dir)) {
|
||||||
|
echo "<span style='color:red'>Directory is not writable! Permissions issues likely.</span><br/>";
|
||||||
|
} 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 "<hr/><strong>Found:</strong> " . htmlspecialchars($file) . "<br/>";
|
||||||
|
echo "Path: " . htmlspecialchars($path) . "<br/>";
|
||||||
|
echo "Age: " . $age . " seconds (" . round($age/3600, 2) . " hours)<br/>";
|
||||||
|
|
||||||
|
// 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: <span style='color:blue'>Older than 24 hours. Attempting deletion...</span><br/>";
|
||||||
|
icc_rrmdir($path);
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
echo "Result: <span style='color:green'>DELETED SUCCESS.</span><br/>";
|
||||||
|
} else {
|
||||||
|
echo "Result: <span style='color:red'>DELETED FAILED. Check server log/permissions.</span><br/>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Status: <span style='color:orange'>Kept (Not old enough).</span><br/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($found == 0) {
|
||||||
|
echo "No temporary 'icc_temp_' folders found.<br/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<strong>Diagnostics Complete.</strong></div>';
|
||||||
|
} else {
|
||||||
|
echo "<div class='error'>Security check failed.</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
if (isset($_POST['submit']) && $_POST['submit'] == 'Upload')
|
if (isset($_POST['submit']) && $_POST['submit'] == 'Upload')
|
||||||
$message = icc_upload_and_shorten_process_upload();
|
$message = icc_upload_and_shorten_process_upload();
|
||||||
@@ -466,8 +525,19 @@ function icc_upload_and_shorten_do_page()
|
|||||||
<input type="number" id="icc_upload_suffix_length" name="icc_upload_suffix_length" value="' . $suffix_length . '" min="1" max="32" />
|
<input type="number" id="icc_upload_suffix_length" name="icc_upload_suffix_length" value="' . $suffix_length . '" min="1" max="32" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label><strong>Diagnostics:</strong></label><br />
|
||||||
|
<a href="javascript:void(0);" onclick="document.getElementById('icc_cleanup_form').submit();" class="button">Run Cleanup & Diagnostics Now</a>
|
||||||
|
<small> (Checks for 'icc_temp_' folders older than 24 hours and attempts to delete them)</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><input type="submit" value="Save Configuration" class="button-primary" /></p>
|
<p><input type="submit" value="Save Configuration" class="button-primary" /></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form id="icc_cleanup_form" method="post" style="display:none;">
|
||||||
|
<input type="hidden" name="action" value="icc_manual_cleanup" />
|
||||||
|
<input type="hidden" name="nonce" value="' . yourls_create_nonce('icc_manual_cleanup') . '" />
|
||||||
|
</form>
|
||||||
';
|
';
|
||||||
|
|
||||||
// footer
|
// footer
|
||||||
@@ -639,7 +709,7 @@ function icc_upload_and_shorten_local_file_manager($dir, $url)
|
|||||||
$path = rtrim($temp_dir, '/') . '/' . $file;
|
$path = rtrim($temp_dir, '/') . '/' . $file;
|
||||||
if (is_dir($path) && strpos($file, 'icc_temp_') === 0) {
|
if (is_dir($path) && strpos($file, 'icc_temp_') === 0) {
|
||||||
// Check age (1 hour = 3600 seconds)
|
// Check age (1 hour = 3600 seconds)
|
||||||
if (filemtime($path) < (time() - 3600)) {
|
if (filemtime($path) < (time() - 86400)) {
|
||||||
icc_rrmdir($path);
|
icc_rrmdir($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user