1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

Show clear cache output in tools.php

This commit is contained in:
FreeScout 2019-07-03 06:12:46 -07:00
parent f24bd71576
commit 77ab67edcd
2 changed files with 10 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
/node_modules
/public/hot
/public/storage
/public/js/vars.js
/storage/*.key
# We are committing /vendor directory to make installation process super easy, even on a shared hosting:
# - https://www.codeenigma.com/build/blog/do-you-really-need-composer-production

View File

@ -48,11 +48,12 @@ function getAppKey($root_dir, $check_cache = true)
}
}
function clearCache($root_dir)
function clearCache($root_dir, $php_path)
{
if (file_exists($root_dir.'bootstrap/cache/config.php')) {
unlink($root_dir.'bootstrap/cache/config.php');
}
return shell_exec($php_path.' '.$root_dir.'artisan freescout:clear-cache');
}
$alerts = [];
@ -60,14 +61,20 @@ $errors = [];
$app_key = $_POST['app_key'] ?? '';
if (!empty($_POST)) {
$php_path = 'php';
if (!empty($_POST['php_path'])) {
$php_path = $_POST['php_path'];
}
if (trim($app_key) != trim(getAppKey($root_dir))) {
$errors['app_key'] = 'Invalid App Key';
} else {
clearCache($root_dir);
$cc_output = clearCache($root_dir, $php_path);
if ($_POST['action'] == 'cc') {
$alerts[] = [
'type' => 'success',
'text' => 'Cache cleared successfully.',
'text' => 'Cache cleared: <br/><pre>'.htmlspecialchars($cc_output).'</pre>',
];
} else {
if (!function_exists('shell_exec')) {
@ -77,10 +84,6 @@ if (!empty($_POST)) {
];
} else {
try {
$php_path = 'php';
if (!empty($_POST['php_path'])) {
$php_path = $_POST['php_path'];
}
// First check PHP version
$version_output = shell_exec($php_path.' -v');