Initial commit

This commit is contained in:
Sophia Atkinson 2024-03-03 14:48:13 -08:00
commit 94b70b2104
Signed by: Sophia
GPG Key ID: 73928E5CCCD28BE1
3 changed files with 101 additions and 0 deletions

24
LICENSE Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

19
README.md Normal file
View File

@ -0,0 +1,19 @@
YOURLS XML Sitemap Generator
====================
Plugin for [YOURLS](https://yourls.org) `v1.19.2`.
*I haven't tested it with older versions so tread with caution :)*
Description
-----------
Purges all logs for YOURLS
Installation
------------
1. In `/user/plugins`, create a new folder named `yourls-purge-all-logs`.
2. Drop these files in that directory.
3. Go to the Plugins administration page ( *eg* `http://sho.rt/admin/plugins.php` ) and activate the plugin.
Thats all folks
------------

58
plugin.php Normal file
View File

@ -0,0 +1,58 @@
<?php
/*
Plugin Name: Purge All Logs
Plugin URI: https://github.com/SophiaAtkinson/yourls-purge-all-logs
Description: Purges all logs for YOURLS
Version: 1.0
Author: Sophia Atkinson
Author URI: https://sophia.wtf
*/
// Register the plugin admin page
yourls_add_action('plugins_loaded', 'purge_all_logs_add_page');
function purge_all_logs_add_page()
{
yourls_register_plugin_page('purge_logs', 'Purge Logs', 'purge_all_logs_page_display');
}
// Display the plugin page content
function purge_all_logs_page_display()
{
// Check if the form is submitted
if (isset($_POST['purge_logs'])) {
// Call the function to purge logs
purge_all_logs();
}
echo '<h2>Purge <strong>All</strong> Logs</h2>';
echo '<p><strong>Warning:</strong> This action is irreversible and will permanently delete all logs in Yourls. It is highly recommended to take a database snapshot before proceeding.</p>';
echo '<form id="purge-logs-form" method="post">';
echo '<input type="submit" name="purge_logs" value="Purge Logs" onclick="return confirmPurgeLogs();">';
echo '</form>';
echo '<script>
function confirmPurgeLogs() {
return confirm("This action is irreversible and will permanently delete ALL YOURLS logs. Are you sure you want to proceed?");
}
</script>';
}
// Function to purge all logs
function purge_all_logs()
{
global $ydb;
// Check if the user is authorized to perform this action (optional)
// For example, you might check for admin privileges here
// Purge all logs from the database
$delete_logs = $ydb->query("DELETE FROM `" . YOURLS_DB_TABLE_LOG . "`");
// Check if the logs were successfully purged
if ($delete_logs) {
yourls_add_notice('success', 'Logs purged successfully!');
} else {
yourls_add_notice('error', 'Failed to purge logs.');
}
}
?>