Skip to content

Instantly share code, notes, and snippets.

@ercanozkaya
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ercanozkaya/89dc310f7ce26dbaa5d5 to your computer and use it in GitHub Desktop.
Save ercanozkaya/89dc310f7ce26dbaa5d5 to your computer and use it in GitHub Desktop.
<?php
/**
* Put this file in the cli/ folder in your Joomla site and call it from the command line:
* $ php filename.php
*/
@ini_set('memory_limit', -1);
@ini_set('xdebug.max_nesting_level', 2000);
const _JEXEC = 1;
const FOF_INCLUDED = 1; // Trick the system into believing FOF is already included
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$_SERVER['HTTP_HOST'] = 'nooku.dev';
// Set up application
$app = JFactory::getApplication('site', array('root_user' => 'root'));
// Set up user
$user = JFactory::getUser();
$user->guest = 0;
$user->name = 'root';
$user->username = 'root';
$user->email = 'root@localhost.home';
$user->groups = array(8);
// Push the JUser object into the session otherwise getUser() always returns a new instance of JUser.
JFactory::getSession()->set('user', $user);
JFactory::getLanguage()->load('lib_joomla');
// Set up menu as it is checked in a lot of places in the code
$app->getMenu()->setActive($app->getMenu()->getDefault()->id);
$_GET['Itemid'] = $app->getMenu()->getDefault()->id;
// Boot Koowa plugin
require_once JPATH_PLUGINS.'/system/koowa/koowa.php';
$plugin = JFactory::getDbo()->setQuery("SELECT folder AS type, element AS name, params FROM #__extensions
WHERE folder = 'system' AND element = 'koowa'")->loadObject();
new plgSystemKoowa(JDispatcher::getInstance(), (array) $plugin);
// Custom code can be added from here forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment