From b2cf09a6cd5ac7959a770548c4bdb4ccf746f14f Mon Sep 17 00:00:00 2001 From: Bofh Date: Tue, 13 Dec 2022 12:06:30 +0100 Subject: [PATCH] Added cli.php command for purging caches --- cli.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cli.php b/cli.php index 3624c98..7540939 100644 --- a/cli.php +++ b/cli.php @@ -68,19 +68,52 @@ function cli__users($args) { echo $msg."\n"; } +function cli__cache($args) { + $help = function() { + cli__help(false); + echo ' cache prune|purge|delete Delete all application caches'."\n"; + die; + }; + $msg = null; + switch ($args[0]) { + case 'prune': + case 'purge': + case 'delete': + foreach (scandir(filedb_getdir('cache')) as $fil) { + if (in_array($fil, ['.','..'])) + continue; + filedb_del('cache', $fil); + } + $msg = 'Application cache has been succesfully purged'; + break; + case 'help': + default: + $help(); + } + if ($msg != nulL) + echo $msg."\n"; +} + function cli__help($full=true) { echo 'APub Control cli.php 1.0 author: bofh@nogafam.es'."\n"; echo "\n"; echo ' Parameters:'."\n"; if ($full === false) return; echo ' users Add/delete/modify web application users'."\n"; + echo ' cache Handle all the web application caches'."\n"; die; } +if (count($argv) <= 1) + cli__help(); + switch ($argv[1]) { case 'users': cli__users(array_slice($argv, 2)); break; + case 'cache': + cli__cache(array_slice($argv, 2)); + break; case 'help': cli__help(); break;