/** * Sets the sender to use * * @param string $email * @param null|string $name */ public function setFrom($email, $name = null) { $hostname = Piwik_Config::getInstance()->mail['defaultHostnameIfEmpty']; $piwikHost = Piwik_Url::getCurrentHost($hostname); // If known Piwik URL, use it instead of "localhost" $piwikUrl = Piwik::getPiwikUrl(); $url = parse_url($piwikUrl); if (isset($url['host']) && $url['host'] != 'localhost' && $url['host'] != '127.0.0.1') { $piwikHost = $url['host']; } $email = str_replace('{DOMAIN}', $piwikHost, $email); parent::setFrom($email, $name); }
private function assignCommonParameters($smarty) { $smarty->assign("reportTitleTextColor", Piwik_ReportRenderer::REPORT_TITLE_TEXT_COLOR); $smarty->assign("reportTitleTextSize", self::REPORT_TITLE_TEXT_SIZE); $smarty->assign("reportTextColor", Piwik_ReportRenderer::REPORT_TEXT_COLOR); $smarty->assign("tableHeaderBgColor", Piwik_ReportRenderer::TABLE_HEADER_BG_COLOR); $smarty->assign("tableHeaderTextColor", Piwik_ReportRenderer::TABLE_HEADER_TEXT_COLOR); $smarty->assign("tableCellBorderColor", Piwik_ReportRenderer::TABLE_CELL_BORDER_COLOR); $smarty->assign("tableBgColor", Piwik_ReportRenderer::TABLE_BG_COLOR); $smarty->assign("reportTableHeaderTextSize", self::REPORT_TABLE_HEADER_TEXT_SIZE); $smarty->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE); $smarty->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE); $smarty->assign("currentPath", Piwik::getPiwikUrl()); $smarty->assign("logoHeader", Piwik_API_API::getInstance()->getHeaderLogoUrl()); }
public function index() { Piwik::checkUserHasSomeAdminAccess(); $idSite = Piwik_Common::getRequestVar('idSite', 1, 'int'); $period = Piwik_Common::getRequestVar('period', 'day', 'string'); $date = Piwik_Common::getRequestVar('date', 'today', 'string'); $_GET['token_auth'] = Piwik::getCurrentUserTokenAuth(); $reports = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date); $plot = array(); foreach ($reports as $report) { if (!empty($report['imageGraphUrl'])) { $plot[] = array($report['category'] . ' › ' . $report['name'], Piwik::getPiwikUrl() . $report['imageGraphUrl']); } } $view = Piwik_View::factory('index'); $view->titleAndUrls = $plot; echo $view->render(); }
/** * Returns the url to header logo (~127x50px) * * @param bool $pathOnly If true, returns path relative to doc root. Otherwise, returns a URL. * @return string */ public function getHeaderLogoUrl($pathOnly = false) { $logo = 'themes/default/images/logo-header.png'; if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/themes/logo-header.png')) { $logo = 'themes/logo-header.png'; } if (!$pathOnly) { return Piwik::getPiwikUrl() . $logo; } return Piwik_Common::getPathToPiwikRoot() . '/' . $logo; }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { static $initialized = false; if($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer); $directoriesToCheck = array( '/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/' ); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch(Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e, $info = array(), $pending = true); $exceptionToThrow = $e; } if(Zend_Registry::get('config')->General->maintenance_mode == 1 && !Piwik_Common::isPhpCliMode()) { throw new Exception("Piwik is in scheduled maintenance. Please come back later."); } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsManager->loadPlugins( Zend_Registry::get('config')->Plugins->Plugins->toArray() ); if($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch(Exception $e) { Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } 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(); // ensure the current Piwik URL is known for later use if(method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } 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? <br />You can activate the plugin by adding:<br /> <code>Plugins[] = Login</code><br /> under the <code>[Plugins]</code> section in your config/config.inc.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik_Translate::getInstance()->reloadLanguage(); Piwik::raiseMemoryLimitIfNecessary(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch(Exception $e) { Piwik_ExitWithMessage($e->getMessage(), false, true); } Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }
/** * Returns the url to header logo (~127x50px) * * @param bool $pathOnly If true, returns path relative to doc root. Otherwise, returns a URL. * @return string */ public function getHeaderLogoUrl($pathOnly = false) { $logo = 'themes/default/images/logo-header.png'; if (Zend_Registry::get('config')->branding->use_custom_logo == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/themes/logo-header.png')) { $logo = 'themes/logo-header.png'; } if (!$pathOnly) { return Piwik::getPiwikUrl() . $logo; } return Piwik_Common::getPathToPiwikRoot() . '/' . $logo; }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { static $initialized = false; if ($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer()); $directoriesToCheck = array('/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/', '/tmp/tcpdf/'); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch (Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e, $info = array(), $pending = true); $exceptionToThrow = $e; } if (Piwik_Session::isFileBasedSessions()) { Piwik_Session::start(); } if (Piwik_Config::getInstance()->General['maintenance_mode'] == 1 && !Piwik_Common::isPhpCliMode()) { $format = Piwik_Common::getRequestVar('format', ''); $exception = new Exception("Piwik is in scheduled maintenance. Please come back later."); if (empty($format)) { throw $exception; } $response = new Piwik_API_ResponseBuilder($format); echo $response->getResponseException($exception); exit; } if (!Piwik_Common::isPhpCliMode() && Piwik_Config::getInstance()->General['force_ssl'] == 1 && !Piwik::isHttps()) { $url = Piwik_Url::getCurrentUrl(); $url = str_replace("http://", "https://", $url); Piwik_Url::redirectToUrl($url); } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); if ($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } 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(); // ensure the current Piwik URL is known for later use if (method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } 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?\n\t\t\t\t\t\t\t\t\t<br />You can activate the plugin by adding:<br />\n\t\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br />\n\t\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.ini.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik::raiseMemoryLimitIfNecessary(); Piwik_Translate::getInstance()->reloadLanguage(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_ExitWithMessage($e->getMessage(), false, true); } // Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. * @throws Exception * @throws Exception * @throws bool|Exception * @return */ function init() { static $initialized = false; if ($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer()); $directoriesToCheck = array('/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/', '/tmp/tcpdf/'); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = $this->createConfigObject(); if (Piwik_Session::isFileBasedSessions()) { Piwik_Session::start(); } $this->handleMaintenanceMode(); $this->handleSSLRedirection(); $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); if ($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs $this->createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); // ensure the current Piwik URL is known for later use if (method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } 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?\n\t\t\t\t\t\t\t\t\t<br />You can activate the plugin by adding:<br />\n\t\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br />\n\t\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.ini.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); // Force the auth to use the token_auth if specified, so that embed dashboard // and all other non widgetized controller methods works fine if (($token_auth = Piwik_Common::getRequestVar('token_auth', false, 'string')) !== false) { Piwik_API_Request::reloadAuthUsingTokenAuth(); } Piwik::raiseMemoryLimitIfNecessary(); Piwik_Translate::getInstance()->reloadLanguage(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_ExitWithMessage($e->getMessage(), false, true); } // Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }