12 Commits
v2.0.0 ... main

Author SHA1 Message Date
Gitea Actions
7c3f522dd7 Sync README from template [▶️] 2026-01-22 04:00:50 +00:00
Gitea Actions
bbea7c94a4 Update manifest version to 2.0.5 [▶️] 2026-01-21 23:59:43 +00:00
5016158a96 Update README.md
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 28s
2026-01-21 23:59:27 +00:00
Gitea Actions
5213bd4e6e Update manifest version to 2.0.4 [▶️] 2026-01-21 23:55:09 +00:00
8ab3f57894 update debug
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 27s
2026-01-21 20:54:54 -03:00
Gitea Actions
1431c72909 Update manifest version to 2.0.3 [▶️] 2026-01-21 23:52:06 +00:00
9f3e1b7017 update debug
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 27s
2026-01-21 20:51:50 -03:00
de13c42a13 fix dbug 2026-01-21 20:51:42 -03:00
Gitea Actions
3457c14bbf Update manifest version to 2.0.2 [▶️] 2026-01-21 23:49:50 +00:00
4acb64e852 debug delete temp
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 28s
2026-01-21 20:45:52 -03:00
Gitea Actions
ecb3c8866d Update manifest version to 2.0.1 [▶️] 2026-01-21 23:38:36 +00:00
da573d0a9d update
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 28s
2026-01-21 20:38:04 -03:00
3 changed files with 119 additions and 92 deletions

70
README.md Executable file → Normal file
View File

@@ -23,65 +23,17 @@ What you need:
* This Plugin ;-)
* A bit of understanding what it does and what you can do with it ;-)
Installation
------------
<!-- footer -->
---
* Navigate to the folder `./user/plugins/` inside your YOURLS-install directory
## 🧑‍💻 Consulting and technical support
* For personal support and queries, please submit a new issue to have it addressed.
* For commercial related questions, please [**contact me**][ivancarlos] for consulting costs.
* Use any of these two ways to install:
- **Either** clone this repo using `git`
- **or** create a new folder named ´Upload-and-Shorten´, then download all files from here *into that directory*.
* Prepare your configuration:
* If necessary create a directory where your files can be accessed from the webserver (i.e '/full/path/to/httpd/directory/')
* Depending on your webserver´s setup you may have to modify the permissions of that directory:
- Make sure your webserver has read+write permissions for it. Explaining that is beyond the scope of this readme, please refer to the manual of your server, operating system or hosting provider. On a Linux box something like
`chown :www-data /full/path/to/httpd/directory && chmod g+rwx /full/path/to/httpd/directory`
should do the trick, but please don't rely on it.
**A correct server configuration is important for its functionality, but essential for its safety!**
* Now open `./user/config.php` in your YOURLS-directory with any text editor and ...
- add these definition lines and save the file:
`# Paths for plugin: "Upload-and-Shorten":`
`# The web URL path where YOURLS short-links will redirect to:`
`define( 'SHARE_URL', 'http://my.domain.tld/directory/' );`
`# The physical path where the plugin drops your files into:`
`define( 'SHARE_DIR', '/full/path/to/httpd/directory/' );`
(Adjust paths to your needs...)
* Go to the Plugins Administration Page (eg. `http://sho.rt/admin/plugins.php`) and activate the plugin.
* Have fun!
* Consider helping with translations.
Bugs & Issues
-------------
No critical misbehaviour known, most issues are caused by configuration errors.
Beware of scripts and plugins which validate URLs or intercept the data flow. ~~Namely the plugin "Check URL" can interfere with this plugin,~~ (This issue has been fixed for basic setups, see [issue #11](https://github.com/fredl99/YOURLS-Upload-and-Shorten/issues/11).) However, there might still occur interferences with plugins which check target URLs or manipulate the database by themselves. So, when you notice a strange behaviour always think about this and if you report an issue please include a list of installed and activated plugins.
Localization (l10n)
--------------------
This plugin supports **localization** (translations into your language).
**For this to work you need at least YOURLS v1.7 from March 1, 2015**. It will basically work fine with earlier versions, except that translations won't work because of a minor bug in the YOURLS-code. Just upgrade to the latest YOURLS version and it will do.
The default language is English. Translation files for French, German, Spanish and Simplified Chinese are included in the folder `l10n/`. To use this feature you just have to define your locale in `user/config.php` like this:
`define( 'YOURLS_LANG', 'de_DE' );`
(can be found within the standard YOURLS options there)
Looking for translators
-----------------------
If you're willing to provide translations, please [read this](http://blog.yourls.org/2013/02/workshop-how-to-create-your-own-translation-file-for-yourls/). If necessary you can contact me for further instructions. Any help is appreciated, at most by your fellow countrymen!
Donations
---------
There are many ways to integrate this plugin into your daily routines. The more you use it the more you will discover. The more you discover the more you will like it.
If you do, remember someone spends his time for improving it. If you want say thanks for that, just [buy him a coffee](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H5B9UKVYP88X4). That will certainly motivate him to make further enhancements. Just for You! ...
![](https://s.fredls.net/wjotnlsc1igvzq) and him :)
License
-------
**Free for personal use only.**
If you want to make money with it you have to contact me first.
Thanks for your attention.
| 🩷 Project support |
| :---: |
If you found this project helpful, consider [**buying me a coffee**][buymeacoffee]
|Thanks for your support, it is much appreciated!|
[ivancarlos]: https://ivancarlos.me
[buymeacoffee]: https://www.buymeacoffee.com/ivancarlos

View File

@@ -1 +1,5 @@
{ "version": "2.0.0", "author": "Ivan Carlos", "upstream_sha": "" }
{
"version": "2.0.5",
"author": "Ivan Carlos",
"upstream_sha": ""
}

View File

@@ -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 = '';
if (isset($_POST['submit']) && $_POST['submit'] == '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" />
</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>
</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
@@ -603,45 +673,46 @@ function icc_upload_and_shorten_local_file_manager($dir, $url)
}
}
// Recursive directory removal
function icc_rrmdir($dir)
{
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir . "/" . $object) && !is_link($dir . "/" . $object))
icc_rrmdir($dir . "/" . $object);
else
unlink($dir . "/" . $object);
}
}
// Recursive directory removal
function icc_rrmdir($dir)
{
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir . "/" . $object) && !is_link($dir . "/" . $object))
icc_rrmdir($dir . "/" . $object);
else
unlink($dir . "/" . $object);
}
rmdir($dir);
}
rmdir($dir);
}
}
// Cleanup Temp Folders
function icc_upload_and_shorten_cleanup_temp()
{
$temp_dir = yourls_get_option('icc_upload_share_dir');
if (!$temp_dir)
$temp_dir = sys_get_temp_dir();
// Cleanup Temp Folders
function icc_upload_and_shorten_cleanup_temp()
{
$temp_dir = yourls_get_option('icc_upload_share_dir');
if (!$temp_dir)
$temp_dir = sys_get_temp_dir();
if (!is_dir($temp_dir))
return;
if (!is_dir($temp_dir))
return;
// Scan for icc_temp_* directories
$files = scandir($temp_dir);
foreach ($files as $file) {
if ($file == '.' || $file == '..')
continue;
// Scan for icc_temp_* directories
$files = scandir($temp_dir);
foreach ($files as $file) {
if ($file == '.' || $file == '..')
continue;
$path = rtrim($temp_dir, '/') . '/' . $file;
if (is_dir($path) && strpos($file, 'icc_temp_') === 0) {
// Check age (1 hour = 3600 seconds)
if (filemtime($path) < (time() - 3600)) {
icc_rrmdir($path);
}
$path = rtrim($temp_dir, '/') . '/' . $file;
if (is_dir($path) && strpos($file, 'icc_temp_') === 0) {
// Check age (1 hour = 3600 seconds)
if (filemtime($path) < (time() - 86400)) {
icc_rrmdir($path);
}
}
}