1<?php
2/**
3 * @package    Joomla.Cli
4 *
5 * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
6 * @license    GNU General Public License version 2 or later; see LICENSE.txt
7 */
8
9/**
10 * A command line cron job to attempt to remove files that should have been deleted at update.
11 */
12
13// We are a valid entry point.
14const _JEXEC = 1;
15
16// Load system defines
17if (file_exists(dirname(__DIR__) . '/defines.php'))
18{
19	require_once dirname(__DIR__) . '/defines.php';
20}
21
22if (!defined('_JDEFINES'))
23{
24	define('JPATH_BASE', dirname(__DIR__));
25	require_once JPATH_BASE . '/includes/defines.php';
26}
27
28// Get the framework.
29require_once JPATH_LIBRARIES . '/import.legacy.php';
30
31// Bootstrap the CMS libraries.
32require_once JPATH_LIBRARIES . '/cms.php';
33
34// Configure error reporting to maximum for CLI output.
35error_reporting(E_ALL);
36ini_set('display_errors', 1);
37
38// Load Library language
39$lang = JFactory::getLanguage();
40
41// Try the files_joomla file in the current language (without allowing the loading of the file in the default language)
42$lang->load('files_joomla.sys', JPATH_SITE, null, false, false)
43// Fallback to the files_joomla file in the default language
44|| $lang->load('files_joomla.sys', JPATH_SITE, null, true);
45
46/**
47 * A command line cron job to attempt to remove files that should have been deleted at update.
48 *
49 * @since  3.0
50 */
51class DeletefilesCli extends JApplicationCli
52{
53	/**
54	 * Entry point for CLI script
55	 *
56	 * @return  void
57	 *
58	 * @since   3.0
59	 */
60	public function doExecute()
61	{
62		// Import the dependencies
63		jimport('joomla.filesystem.file');
64		jimport('joomla.filesystem.folder');
65
66		// We need the update script
67		JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
68
69		// Instantiate the class
70		$class = new JoomlaInstallerScript;
71
72		// Run the delete method
73		$class->deleteUnexistingFiles();
74	}
75}
76
77// Instantiate the application object, passing the class name to JCli::getInstance
78// and use chaining to execute the application.
79JApplicationCli::getInstance('DeletefilesCli')->execute();
80