Last active
December 19, 2015 17:19
-
-
Save yireo/5990197 to your computer and use it in GitHub Desktop.
PHP-script to discover Joomla! extensions that were uploaded to the Joomla! filesystem, and install them automatically. It also installs any database-fixes that might be pending after upgrading through patch-files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define variables | |
define('DOCUMENT_ROOT', dirname(__FILE__).'/'); | |
define('_JEXEC', 1); | |
define('JPATH_BASE', DOCUMENT_ROOT); | |
define('DS', DIRECTORY_SEPARATOR ); | |
if(!isset($_SERVER['REQUEST_METHOD'])) $_SERVER['REQUEST_METHOD'] = null; | |
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null; | |
if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = null; | |
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); | |
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); | |
jimport('joomla.environment.request'); | |
jimport('joomla.database.database'); | |
// Start the application | |
$app = JFactory::getApplication('administrator'); | |
$app->initialise(); | |
$db = JFactory::getDbo(); | |
// Require the database-model | |
require_once JPATH_SITE.'/administrator/components/com_installer/models/database.php'; | |
$databaseModel = new InstallerModelDatabase(); | |
$databaseModel->fix(); | |
// Require the discovery-model | |
require_once JPATH_SITE.'/administrator/components/com_installer/models/discover.php'; | |
$installerModel = new InstallerModelDiscover(); | |
$installerModel->discover(); | |
// Require the Joomla! installer | |
$installer = JInstaller::getInstance(); | |
// optionally define a search-string | |
//$search = 'jce'; | |
// Discover the extensions | |
$extensions = $installerModel->getItems(); | |
foreach($extensions as $extension) { | |
$match = true; | |
if(!empty($search)) { | |
$match = false; | |
if(stristr($extension->name, $search)) { | |
$match = true; | |
} | |
} | |
if($match == true) { | |
echo "Installing: ".$extension->name." ".$extension->type." [".$extension->extension_id."]"."\n"; | |
$installer->discover_install($extension->extension_id); | |
} else { | |
echo "Skipping: ".$extension->name." ".$extension->type." [".$extension->extension_id."]"."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment