diff --git a/activitypurges.blueprint b/activitypurges.blueprint new file mode 100644 index 0000000..cbacd0b Binary files /dev/null and b/activitypurges.blueprint differ diff --git a/admin/controller.php b/admin/controller.php new file mode 100644 index 0000000..79a170b --- /dev/null +++ b/admin/controller.php @@ -0,0 +1,62 @@ +isMethod('post')) { + // Validate the input timestamp. + $validated = $request->validate([ + 'timestamp' => 'required|date' + ]); + + // Convert the HTML datetime-local value to MySQL datetime format. + $rawTimestamp = $validated['timestamp']; + $mysqlTimestamp = date('Y-m-d H:i:s', strtotime($rawTimestamp)); + + try { + // Purge records older than the provided timestamp. + $deleted = DB::table('activity_logs') + ->where('timestamp', '<', $mysqlTimestamp) + ->delete(); + + $message = "{$deleted} log(s) have been purged successfully."; + } catch (\Exception $e) { + \Log::error('Purge error: ' . $e->getMessage()); + $message = "An error occurred while purging logs."; + } + } + + return $this->view->make('admin.extensions.activitypurges.index', [ + 'root' => "/admin/extensions/activitypurges", + 'blueprint' => $this->blueprint, + 'message' => $message, + ]); + } + + /** + * Handle POST requests by delegating to index(). + */ + public function post(Request $request): View + { + return $this->index($request); + } +} diff --git a/admin/view.blade.php b/admin/view.blade.php new file mode 100644 index 0000000..70cec41 --- /dev/null +++ b/admin/view.blade.php @@ -0,0 +1,30 @@ + +
+
+

Information

+
+
+ + @if(isset($message) && $message) +
+ {{ $message }} +
+ @endif + +

+ An Extension Used To Clear/Purge old Activity Logs, in order to clear database storage used. +

+ + +
+ @csrf +
+ + +
+ +
+
+
diff --git a/conf.yml b/conf.yml new file mode 100644 index 0000000..cbc0123 --- /dev/null +++ b/conf.yml @@ -0,0 +1,37 @@ +info: + name: "ActivityPurges" + identifier: "activitypurges" + description: "Purgin Old Activity Logs From Database" + flags: "" + version: "1.10" + target: "beta-2024-12" + author: "nekomonci12" + icon: "public/icon.jpg" + website: "" + +admin: + view: "admin/view.blade.php" + controller: "admin/controller.php" + css: "" + wrapper: "" + +dashboard: + css: "" + wrapper: "" + components: "" + +data: + directory: "" + public: "" + console: "" + +requests: + views: "" + app: "" + routers: + application: "" + client: "" + web: "" + +database: + migrations: "" diff --git a/public/icon.jpg b/public/icon.jpg new file mode 100644 index 0000000..f748b7c Binary files /dev/null and b/public/icon.jpg differ