public function __construct($subject, $config = array()) { // Turn off E_STRICT errors for now error_reporting(error_reporting() & ~E_STRICT); // Check if database type is MySQLi if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') { if (JFactory::getApplication()->getName() === 'administrator') { $string = version_compare(JVERSION, '1.6', '<') ? 'mysqli' : 'MySQLi'; $link = JRoute::_('index.php?option=com_config'); $error = 'In order to use Joomlatools framework, your database type in Global Configuration should be set to <strong>%1$s</strong>. Please go to <a href="%2$s">Global Configuration</a> and in the \'Server\' tab change your Database Type to <strong>%1$s</strong>.'; JError::raiseWarning(0, sprintf(JText::_($error), $string, $link)); } return; } // Set pcre.backtrack_limit to a larger value // See: https://bugs.php.net/bug.php?id=40846 if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) { @ini_set('pcre.backtrack_limit', 1000000); } //Set constants define('KDEBUG', JDEBUG); //Set path definitions define('JPATH_FILES', JPATH_ROOT); define('JPATH_IMAGES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'images'); //Set exception handler set_exception_handler(array($this, 'exceptionHandler')); // Koowa : setup require_once JPATH_LIBRARIES . '/koowa/koowa.php'; Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false)); KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE))); KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT))); KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module')); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin')); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component')); KServiceIdentifier::setApplication('site', JPATH_SITE); KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR); KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli'); KService::setAlias('translator', 'com:default.translator'); //Setup the request if (JFactory::getApplication()->getName() !== 'site') { KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base())); } //Load the koowa plugins JPluginHelper::importPlugin('koowa', null, true); //Bugfix : Set offset accoording to user's timezone if (!JFactory::getUser()->guest) { if ($offset = JFactory::getUser()->getParam('timezone')) { if (version_compare(JVERSION, '3.0', '>=')) { JFactory::getConfig()->set('offset', $offset); } else { JFactory::getConfig()->setValue('config.offset', $offset); } } } // Load language files for the framework KService::get('com:default.translator')->loadLanguageFiles(); parent::__construct($subject, $config); }
/** * Constructor. * * Prevent creating instances of this class by making the contructor private * * @param array An optional array with configuration options. */ private final function __construct($config = array()) { //store the path $this->_path = dirname(__FILE__); //instantiate koowa Koowa::getInstance(array('cache_prefix' => $config['cache_prefix'], 'cache_enabled' => $config['cache_enabled'])); //if caching is not enabled then reset the apc cache to //to prevent corrupt identifier if (!$config['cache_enabled']) { clean_apc_with_prefix($config['cache_prefix']); } require_once dirname(__FILE__) . '/loader/adapter/anahita.php'; KLoader::addAdapter(new AnLoaderAdapterAnahita(array('basepath' => dirname(__FILE__)))); KLoader::addAdapter(new AnLoaderAdapterDefault(array('basepath' => JPATH_LIBRARIES . '/default'))); AnServiceClass::getInstance(); KServiceIdentifier::addLocator(new AnServiceLocatorAnahita()); KServiceIdentifier::addLocator(new AnServiceLocatorRepository()); //register an empty path for the application //a workaround to remove the applicaiton path from an identifier KServiceIdentifier::setApplication('', ''); //create a central event dispatcher KService::set('anahita:event.dispatcher', KService::get('koowa:event.dispatcher')); }
jimport('joomla.user.user'); jimport('joomla.environment.uri'); jimport('joomla.html.html'); jimport('joomla.html.parameter'); jimport('joomla.utilities.utility'); jimport('joomla.event.event'); jimport('joomla.event.dispatcher'); jimport('joomla.language.language'); jimport('joomla.utilities.string'); jimport('joomla.plugin.helper'); require_once JPATH_CONFIGURATION . '/configuration.php'; require_once JPATH_LIBRARIES . '/anahita/anahita.php'; $config = new JConfig(); //instantiate anahita and nooku Anahita::getInstance(array('cache_prefix' => md5($config->secret) . '-cache-koowa', 'cache_enabled' => $config->caching)); KServiceIdentifier::setApplication('site', JPATH_SITE); KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR); KLoader::addAdapter(new AnLoaderAdapterComponent(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('anahita:service.locator.component')); KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT))); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin')); KLoader::addAdapter(new AnLoaderAdapterTemplate(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('anahita:service.locator.template')); KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli'); KService::setAlias('anahita:domain.store.database', 'com:base.domain.store.database'); KService::setAlias('anahita:domain.space', 'com:base.domain.space'); //make sure for the autoloader to be reigstered after nooku $autoloader = (require_once JPATH_VENDOR . '/autoload.php'); $autoloader->unregister(); $autoloader->register(); KLoader::getInstance()->loadIdentifier('com://site/application.aliases');
public function __construct($subject, $config = array()) { // Turn off E_STRICT errors for now error_reporting(error_reporting() & ~E_STRICT); // Command line fixes for Joomla if (PHP_SAPI === 'cli') { if (!isset($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = ''; } if (!isset($_SERVER['REQUEST_METHOD'])) { $_SERVER['REQUEST_METHOD'] = ''; } } // Check if Koowa is active if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') { JError::raiseWarning(0, JText::_("Koowa plugin requires MySQLi Database Driver. Please change your database configuration settings to 'mysqli'")); return; } // Check for suhosin if (in_array('suhosin', get_loaded_extensions())) { //Attempt setting the whitelist value @ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://'); //Checking if the whitelist is ok if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) { JError::raiseWarning(0, sprintf(JText::_('Your server has Suhosin loaded. Please follow <a href="%s" target="_blank">this</a> tutorial.'), 'http://www.joomlatools.com/framework-known-issues')); return; } } //Safety Extender compatibility if (extension_loaded('safeex') && strpos('tmpl', @ini_get('safeex.url_include_proto_whitelist')) === false) { $whitelist = @ini_get('safeex.url_include_proto_whitelist'); $whitelist = (strlen($whitelist) ? $whitelist . ',' : '') . 'tmpl'; @ini_set('safeex.url_include_proto_whitelist', $whitelist); } // Set pcre.backtrack_limit to a larger value // See: https://bugs.php.net/bug.php?id=40846 if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) { @ini_set('pcre.backtrack_limit', 1000000); } //Set constants define('KDEBUG', JDEBUG); //Set path definitions define('JPATH_FILES', JPATH_ROOT); define('JPATH_IMAGES', JPATH_ROOT . DS . 'images'); //Set exception handler set_exception_handler(array($this, 'exceptionHandler')); // Koowa : setup require_once JPATH_LIBRARIES . '/koowa/koowa.php'; Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false)); KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE))); KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT))); KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module')); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin')); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component')); KServiceIdentifier::setApplication('site', JPATH_SITE); KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR); KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli'); KService::setAlias('translator', 'com:default.translator'); //Setup the request KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base())); //Load the koowa plugins JPluginHelper::importPlugin('koowa', null, true, KService::get('com://admin/default.event.dispatcher')); //Bugfix : Set offset accoording to user's timezone if (!JFactory::getUser()->guest) { if ($offset = JFactory::getUser()->getParam('timezone')) { JFactory::getConfig()->setValue('config.offset', $offset); } } // Load language files for the framework KService::get('com:default.translator')->loadLanguageFiles(); parent::__construct($subject, $config); }
/** * Creates the admin user */ public static function createAdminUser(&$vars) { $DBtype = JArrayHelper::getValue($vars, 'DBtype', 'mysqli'); $DBhostname = JArrayHelper::getValue($vars, 'DBhostname', ''); $DBuserName = JArrayHelper::getValue($vars, 'DBuserName', ''); $DBpassword = JArrayHelper::getValue($vars, 'DBpassword', ''); $DBname = JArrayHelper::getValue($vars, 'DBname', ''); $DBPrefix = JArrayHelper::getValue($vars, 'DBPrefix', ''); $adminPassword = JArrayHelper::getValue($vars, 'adminPassword', ''); $adminEmail = JArrayHelper::getValue($vars, 'adminEmail', ''); jimport('joomla.user.helper'); // Create random salt/password for the admin user $salt = JUserHelper::genRandomPassword(32); $crypt = JUserHelper::getCryptedPassword($adminPassword, $salt); $cryptpass = $crypt . ':' . $salt; $db =& JInstallationHelper::getDBO($DBtype, $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix); $vars = array_merge(array('adminLogin' => 'admin', 'adminName' => 'Administrator'), $vars); $adminLogin = $vars['adminLogin']; $adminName = $vars['adminName']; // create the admin user $installdate = date('Y-m-d H:i:s'); $nullDate = $db->getNullDate(); $query = "INSERT INTO #__users VALUES (62, '{$adminName}', '{$adminLogin}', " . $db->Quote($adminEmail) . ", " . $db->Quote($cryptpass) . ", 'Super Administrator', 0, 1, 25, '{$installdate}', '{$nullDate}', '', '')"; $db->setQuery($query); if (!$db->query()) { // is there already and existing admin in migrated data if ($db->getErrorNum() == 1062) { $vars['adminLogin'] = JText::_('Admin login in migrated content was kept'); $vars['adminPassword'] = JText::_('Admin password in migrated content was kept'); return; } else { echo $db->getErrorMsg(); return; } } // add the ARO (Access Request Object) $query = "INSERT INTO #__core_acl_aro VALUES (10,'users','62',0,'Administrator',0)"; $db->setQuery($query); if (!$db->query()) { echo $db->getErrorMsg(); return; } // add the map between the ARO and the Group $query = "INSERT INTO #__core_acl_groups_aro_map VALUES (25,'',10)"; $db->setQuery($query); if (!$db->query()) { echo $db->getErrorMsg(); return; } //Anahita Installation require_once JPATH_LIBRARIES . '/anahita/anahita.php'; //instantiate anahita and nooku Anahita::getInstance(array('cache_prefix' => uniqid(), 'cache_enabled' => false)); KServiceIdentifier::setApplication('site', JPATH_SITE); KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR); KLoader::addAdapter(new AnLoaderAdapterComponent(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('anahita:service.locator.component')); KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT))); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin')); KService::setAlias('anahita:domain.space', 'com:base.domain.space'); KService::set('koowa:database.adapter.mysqli', KService::get('koowa:database.adapter.mysqli', array('connection' => $db->_resource, 'table_prefix' => $DBPrefix))); KService::set('anahita:domain.store.database', KService::get('anahita:domain.store.database', array('adapter' => KService::get('koowa:database.adapter.mysqli')))); KService::set('plg:storage.default', new KObject()); $person = KService::get('repos://site/people')->getEntity()->setData(array('name' => $adminName, 'userId' => 62, 'username' => $adminLogin, 'userType' => 'Super Administrator', 'email' => $adminEmail)); $note = KService::get('repos://site/notes')->getEntity()->setData(array('author' => $person, 'owner' => $person, 'body' => 'Welcome to Anahita!')); $comment = $note->addComment(array('author' => $person, 'body' => 'The best Social Platform there is', 'component' => 'com_notes')); $story = KService::get('repos://site/stories')->getEntity()->setData(array('component' => 'com_notes', 'name' => 'note_comment', 'object' => $note, 'comment' => $comment, 'target' => $person, 'owner' => $person, 'subject' => $person)); $entities = array(); $comment->save($entities); return true; }