overload(); } catch (\Exception $e) { // Do nothing } if (!empty($_ENV['APP_KEY'])) { return $_ENV['APP_KEY']; } else { return ''; } } 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 = []; $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 { $cc_output = clearCache($root_dir, $php_path); if ($_POST['action'] == 'cc') { $alerts[] = [ 'type' => 'success', 'text' => 'Cache cleared:
'.htmlspecialchars($cc_output).'
', ]; } else { if (!function_exists('shell_exec')) { $alerts[] = [ 'type' => 'danger', 'text' => 'shell_exec function is unavailable. Can not run updating.', ]; } else { try { // First check PHP version $version_output = shell_exec($php_path.' -r "echo phpversion();"'); if (!version_compare($version_output, '7.1', '>=')) { $alerts[] = [ 'type' => 'danger', 'text' => 'Incorrect PHP version (7.1+ is required):

'.htmlspecialchars($version_output).'
', ]; } else { if ($_POST['action'] == 'update') { // Update Now $output = shell_exec($php_path.' '.$root_dir.'artisan freescout:update --force'); if (strstr($output, 'Broadcasting queue restart signal')) { $alerts[] = [ 'type' => 'success', 'text' => 'Updating finished:
'.htmlspecialchars($output).'
', ]; } else { $alerts[] = [ 'type' => 'danger', 'text' => 'Something went wrong... Please download the latest version and extract it into your application folder replacing existing files. After that click "Migrate DB" button.

'.htmlspecialchars($output).'
', ]; } } else { // Migreate DB $output = shell_exec($php_path.' '.$root_dir.'artisan migrate --force'); $alerts[] = [ 'type' => 'success', 'text' => 'Migrating finished:

'.htmlspecialchars($output).'
', ]; } } } catch (\Exception $e) { $alerts[] = [ 'type' => 'danger', 'text' => 'Error occurred: '.htmlspecialchars($e->getMessage()), ]; } } } } } ?> FreeScout Tools

FreeScout Tools