isPluginActivated( $module )) { throw new Piwik_FrontController_PluginDeactivatedException($module); } $controllerClassName = 'Piwik_'.$module.'_Controller'; // FrontController's autoloader if(!class_exists($controllerClassName, false)) { $moduleController = PIWIK_INCLUDE_PATH . '/plugins/' . $module . '/Controller.php'; if( !Zend_Loader::isReadable($moduleController)) { throw new Exception("Module controller $moduleController not found!"); } require_once $moduleController; // prefixed by PIWIK_INCLUDE_PATH } $controller = new $controllerClassName(); if($action === false) { $action = $controller->getDefaultAction(); } if( !is_callable(array($controller, $action))) { throw new Exception("Action $action not found in the controller $controllerClassName."); } try { return call_user_func_array( array($controller, $action ), $parameters); } catch(Piwik_Access_NoAccessException $e) { Piwik_PostEvent('FrontController.NoAccessException', $e); } } /** * Often plugins controller display stuff using echo/print. * Using this function instead of dispatch() returns the output string form the actions calls. * * @param string $controllerName * @param string $actionName * @param array $parameters * @return string */ function fetchDispatch( $controllerName = null, $actionName = null, $parameters = null) { ob_start(); $output = $this->dispatch( $controllerName, $actionName, $parameters); // if nothing returned we try to load something that was printed on the screen if(empty($output)) { $output = ob_get_contents(); } ob_end_clean(); return $output; } /** * Called at the end of the page generation * */ function __destruct() { try { Piwik::printSqlProfilingReportZend(); Piwik::printQueryCount(); } catch(Exception $e) {} if(Piwik::getModule() !== 'API') { // Piwik::printMemoryUsage(); // Piwik::printTimer(); } } /** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { try { Zend_Registry::set('timer', new Piwik_Timer); $directoriesToCheck = array( '/tmp', '/tmp/templates_c', '/tmp/cache', ); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); self::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch(Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e); $exceptionToThrow = $e; } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsManager->setPluginsToLoad( Zend_Registry::get('config')->Plugins->Plugins->toArray() ); if($exceptionToThrow) { throw $exceptionToThrow; } Piwik_Translate::getInstance()->loadUserTranslation(); Piwik::createDatabaseObject(); Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs Piwik::createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); Piwik_PostEvent('FrontController.initAuthenticationObject'); try { $authAdapter = Zend_Registry::get('auth'); } catch(Exception $e){ throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated?
You can activate the plugin by adding:
Plugins[] = Login
under the [Plugins] section in your config/config.inc.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik::raiseMemoryLimitIfNecessary(); $pluginsManager->setLanguageToLoad( Piwik_Translate::getInstance()->getLanguageToLoad() ); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch(Exception $e) { Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString(), true); } } /** * Assign CLI parameters as if they were REQUEST or GET parameters. * You can trigger Piwik from the command line by * # /usr/bin/php5 /path/to/piwik/index.php -- "module=API&method=Actions.getActions&idSite=1&period=day&date=previous8&format=php" */ static protected function assignCliParametersToRequest() { if(isset($_SERVER['argc']) && $_SERVER['argc'] > 0) { for ($i=1; $i < $_SERVER['argc']; $i++) { parse_str($_SERVER['argv'][$i],$tmp); $_GET = array_merge($_GET, $tmp); } } } } /** * Exception thrown when the requested plugin is not activated in the config file * * @package Piwik * @subpackage Piwik_FrontController */ class Piwik_FrontController_PluginDeactivatedException extends Exception { function __construct($module) { parent::__construct("The plugin '$module' is not activated. You can activate the plugin on the 'Plugins admin' page."); } } /** * For more information: @link http://dev.piwik.org/trac/ticket/374 */ function destroy(&$var) { if (is_object($var)) $var->__destruct(); unset($var); $var = null; }