56 lines
1.6 KiB
PHP
Executable File
56 lines
1.6 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
/**
|
|
* This script clears cache data from a backend.
|
|
*
|
|
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
|
*
|
|
* See the enclosed file COPYING for license information (LGPL-2). If you
|
|
* did not receive this file, see http://www.horde.org/licenses/lgpl.
|
|
*
|
|
* @author Michael Slusarz <slusarz@horde.org>
|
|
* @category Horde
|
|
* @license http://www.horde.org/licenses/lgpl LGPL-2
|
|
* @package Horde
|
|
*/
|
|
|
|
$baseFile = __DIR__ . '/../lib/Application.php';
|
|
if (file_exists($baseFile)) {
|
|
require_once $baseFile;
|
|
} else {
|
|
require_once 'PEAR/Config.php';
|
|
require_once PEAR_Config::singleton()
|
|
->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php';
|
|
}
|
|
Horde_Registry::appInit('horde', array(
|
|
'authentication' => 'none',
|
|
'cli' => true
|
|
));
|
|
|
|
try {
|
|
$cache = $injector->getInstance('Horde_Cache');
|
|
} catch (Exception $e) {
|
|
$cli->fatal($e);
|
|
}
|
|
|
|
$parser = new Horde_Argv_Parser();
|
|
$parser->addOption('-f', array(
|
|
'action' => 'store_true',
|
|
'help' => 'Force cleaning without prompt',
|
|
'dest' => 'force'
|
|
));
|
|
list($values,) = $parser->parseArgs();
|
|
|
|
$clear = $values->force
|
|
? true
|
|
: ($cli->prompt($cli->red('Are you sure you want to expire all cached data?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y');
|
|
|
|
if ($clear) {
|
|
try {
|
|
$cache->clear();
|
|
$cli->message('Cache data cleared. NOTE: This does not indicate that cache data was successfully cleared on the backend, only that no error messages were returned.', 'cli.success');
|
|
} catch (Horde_Exception $e) {
|
|
$cli->fatal($e);
|
|
}
|
|
}
|