diff --git a/bin/keychain.php b/bin/keychain.php index 1320b2e1b34e8..956d562320dc3 100644 --- a/bin/keychain.php +++ b/bin/keychain.php @@ -7,11 +7,51 @@ * @license GNU General Public License version 2 or later; see LICENSE */ +// Make sure we're being called from the command line, not a web interface +if (PHP_SAPI !== 'cli') +{ + die('This is a command line only application.'); +} + +// We are a valid entry point. define('_JEXEC', 1); -define('JPATH_BASE', dirname(__FILE__)); -// Load the Joomla! Platform -require_once realpath('../libraries/import.php'); +// Load system defines +if (file_exists(dirname(__DIR__) . '/defines.php')) +{ + require_once dirname(__DIR__) . '/defines.php'; +} + +if (!defined('_JDEFINES')) +{ + define('JPATH_BASE', dirname(__DIR__)); + require_once JPATH_BASE . '/includes/defines.php'; +} + +// Get the framework. +require_once JPATH_LIBRARIES . '/import.legacy.php'; + +// Bootstrap the CMS libraries. +require_once JPATH_LIBRARIES . '/cms.php'; + +// Import the configuration. +require_once JPATH_CONFIGURATION . '/configuration.php'; + +// System configuration. +$config = new JConfig; + +// Configure error reporting to maximum for CLI output. +error_reporting(E_ALL); +ini_set('display_errors', 1); + +// Load Library language +$lang = JFactory::getLanguage(); + +// Try the finder_cli file in the current language (without allowing the loading of the file in the default language) +$lang->load('finder_cli', JPATH_SITE, null, false, false) + +// Fallback to the finder_cli file in the default language +|| $lang->load('finder_cli', JPATH_SITE, null, true); /** * Keychain Manager.