public function generalSettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('generalSettings');
     if (Piwik::isUserIsSuperUser()) {
         $enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
         $todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
         $showWarningCron = false;
         if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
             $showWarningCron = true;
         }
         $view->showWarningCron = $showWarningCron;
         $view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
         $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
         if (!Piwik_Config::getInstance()->isFileWritable()) {
             $view->configFileNotWritable = true;
         }
         $view->mail = Piwik_Config::getInstance()->mail;
         $view->branding = Piwik_Config::getInstance()->branding;
         $directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/themes/');
         $logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo.png') && is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo-header.png');
         $view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;
     }
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->topMenu = Piwik_GetTopMenu();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
	function index()
	{
		Piwik::checkUserIsSuperUser();

		$plugins = array();

		$listPlugins = Piwik_PluginsManager::getInstance()->readPluginsDirectory();
		foreach($listPlugins as $pluginName)
		{
			$oPlugin = Piwik_PluginsManager::getInstance()->loadPlugin($pluginName);
			$plugins[$pluginName] = array(
			 	'activated' => Piwik_PluginsManager::getInstance()->isPluginActivated($pluginName),
				'alwaysActivated' => Piwik_PluginsManager::getInstance()->isPluginAlwaysActivated($pluginName),
			);
		}
		Piwik_PluginsManager::getInstance()->loadPluginTranslations();

		$loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
		foreach($loadedPlugins as $oPlugin)
		{
			$pluginName = $oPlugin->getPluginName();
			$plugins[$pluginName]['info'] = $oPlugin->getInformation();
		}

		$view = Piwik_View::factory('manage');
		$view->pluginsName = $plugins;
		$this->setBasicVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		if(!Zend_Registry::get('config')->isFileWritable())
		{
			$view->configFileNotWritable = true;
		}
		echo $view->render();
	}
 function index()
 {
     $view = new Piwik_View('DBStats/templates/DBStats.tpl');
     $view->tablesStatus = Piwik_DBStats_API::getAllTablesStatus();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #4
0
 function index()
 {
     Piwik::checkUserIsSuperUser();
     $plugins = array();
     $listPlugins = array_merge(Piwik_PluginsManager::getInstance()->readPluginsDirectory(), Piwik_Config::getInstance()->Plugins['Plugins']);
     $listPlugins = array_unique($listPlugins);
     foreach ($listPlugins as $pluginName) {
         $oPlugin = Piwik_PluginsManager::getInstance()->loadPlugin($pluginName);
         $plugins[$pluginName] = array('activated' => Piwik_PluginsManager::getInstance()->isPluginActivated($pluginName), 'alwaysActivated' => Piwik_PluginsManager::getInstance()->isPluginAlwaysActivated($pluginName));
     }
     Piwik_PluginsManager::getInstance()->loadPluginTranslations();
     $loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
     foreach ($loadedPlugins as $oPlugin) {
         $pluginName = $oPlugin->getPluginName();
         $plugins[$pluginName]['info'] = $oPlugin->getInformation();
     }
     foreach ($plugins as $pluginName => &$plugin) {
         if (!isset($plugin['info'])) {
             $plugin['info'] = array('description' => '<strong><em>' . Piwik_Translate('CorePluginsAdmin_PluginCannotBeFound') . '</strong></em>', 'version' => Piwik_Translate('General_Unknown'));
         }
     }
     $view = Piwik_View::factory('manage');
     $view->pluginsName = $plugins;
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     if (!Piwik_Config::getInstance()->isFileWritable()) {
         $view->configFileNotWritable = true;
     }
     echo $view->render();
 }
Beispiel #5
0
 function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = Piwik_View::factory('Settings');
     $view->isSuperUser = Piwik::isUserIsSuperUser();
     $mobileMessagingAPI = Piwik_MobileMessaging_API::getInstance();
     $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
     $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
     $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
     $view->strHelpAddPhone = Piwik_Translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array(Piwik_Translate('UserSettings_SubmenuSettings'), Piwik_Translate('MobileMessaging_SettingsMenu')));
     if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
         $view->provider = $mobileMessagingAPI->getSMSProvider();
         $view->creditLeft = $mobileMessagingAPI->getCreditLeft();
     }
     $view->smsProviders = Piwik_MobileMessaging_SMSProvider::$availableSMSProviders;
     // construct the list of countries from the lang files
     $countries = array();
     foreach (Piwik_Common::getCountriesList() as $countryCode => $continentCode) {
         if (isset(Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode])) {
             $countries[$countryCode] = array('countryName' => Piwik_CountryTranslate($countryCode), 'countryCallingCode' => Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode]);
         }
     }
     $view->countries = $countries;
     $view->defaultCountry = Piwik_Common::getCountry(Piwik_LanguagesManager::getLanguageCodeForCurrentUser(), true, Piwik_IP::getIpFromHeader());
     $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #6
0
 protected function getDefaultIndexView()
 {
     $view = new Piwik_View('CoreAdminHome/templates/index.tpl');
     $view->content = '';
     $view->menu = Piwik_GetAdminMenu();
     return $view;
 }
Beispiel #7
0
 public function generalSettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('generalSettings');
     if (Piwik::isUserIsSuperUser()) {
         $enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
         $todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
         $showWarningCron = false;
         if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
             $showWarningCron = true;
         }
         $view->showWarningCron = $showWarningCron;
         $view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
         $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
         $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
         if (!Zend_Registry::get('config')->isFileWritable()) {
             $view->configFileNotWritable = true;
         }
         $view->mail = Zend_Registry::get('config')->mail->toArray();
     }
     $this->setBasicVariablesView($view);
     $view->topMenu = Piwik_GetTopMenu();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #8
0
 protected function getDefaultIndexView()
 {
     $view = Piwik_View::factory('index');
     $view->content = '';
     $this->setGeneralVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     return $view;
 }
	function index()
	{
		$view = Piwik_View::factory('DBStats');
		$view->tablesStatus = Piwik_DBStats_API::getAllTablesStatus();
		$this->setGeneralVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		echo $view->render();		
	}
Beispiel #10
0
	function index()
	{
		Piwik::checkUserIsSuperUser();
		$view = Piwik_View::factory('DBStats');
		$view->tablesStatus = Piwik_DBStats_API::getInstance()->getAllTablesStatus();
		$this->setBasicVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		echo $view->render();		
	}
Beispiel #11
0
 function displayJavascriptCode()
 {
     $idSite = Piwik_Common::getRequestVar('idsite', 1);
     Piwik::checkUserHasViewAccess($idSite);
     $jsTag = Piwik::getJavascriptCode($idSite, Piwik_Url::getCurrentUrlWithoutFileName());
     $view = new Piwik_View('SitesManager/templates/DisplayJavascriptCode.tpl');
     $view->menu = Piwik_GetAdminMenu();
     $view->jsTag = $jsTag;
     echo $view->render();
 }
Beispiel #12
0
	function displayJavascriptCode()
	{
		$idSite = Piwik_Common::getRequestVar('idsite', 1);
		Piwik::checkUserHasViewAccess($idSite);
		$jsTag = Piwik::getJavascriptCode($idSite, Piwik_Url::getCurrentUrlWithoutFileName());
		$view = Piwik_View::factory('DisplayJavascriptCode');
		$this->setGeneralVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		$view->jsTag = $jsTag;
		echo $view->render();
	}
/**
 * Returns the current AdminMenu name
 * @return boolean
 */
function Piwik_GetCurrentAdminMenuName()
{
    $menu = Piwik_GetAdminMenu();
    $currentModule = Piwik::getModule();
    $currentAction = Piwik::getAction();
    foreach ($menu as $name => $parameters) {
        if ($parameters['_url']['module'] == $currentModule && $parameters['_url']['action'] == $currentAction) {
            return $name;
        }
    }
    return false;
}
Beispiel #14
0
	function index()
	{
		$view = Piwik_View::factory('UsersManager');
		
		$IdSitesAdmin = Piwik_SitesManager_API::getSitesIdWithAdminAccess();
		$idSiteSelected = 1;
		
		if(count($IdSitesAdmin) > 0)
		{
			$defaultWebsiteId = $IdSitesAdmin[0];
			$idSiteSelected = Piwik_Common::getRequestVar('idsite', $defaultWebsiteId);
		}
		
		if($idSiteSelected==='all')
		{
			$usersAccessByWebsite = array();
		}
		else
		{
			$usersAccessByWebsite = Piwik_UsersManager_API::getUsersAccessFromSite( $idSiteSelected );
		}
	
		// requires super user access
		$usersLogin = Piwik_UsersManager_API::getUsersLogin();
		
		// we dont want to display the user currently logged so that the user can't change his settings from admin to view...
		$currentlyLogged = Piwik::getCurrentUserLogin();
		foreach($usersLogin as $login)
		{
			if(!isset($usersAccessByWebsite[$login]))
			{
				$usersAccessByWebsite[$login] = 'noaccess';
			}
		}
		unset($usersAccessByWebsite[$currentlyLogged]);

		ksort($usersAccessByWebsite);
		
		$users = array();
		if(Zend_Registry::get('access')->isSuperUser())
		{
			$users = Piwik_UsersManager_API::getUsers();
		}
		
		$view->idSiteSelected = $idSiteSelected;
		$view->users = $users;
		$view->usersAccessByWebsite = $usersAccessByWebsite;
		$view->formUrl = Piwik_Url::getCurrentUrl();
		$view->websites = Piwik_SitesManager_API::getSitesWithAdminAccess();
		$this->setGeneralVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		echo $view->render();
	}
Beispiel #15
0
 protected function getDefaultIndexView()
 {
     $view = new Piwik_View('AdminHome/templates/index.tpl');
     $view->menu = Piwik_GetAdminMenu();
     $view->menuJson = json_encode($view->menu);
     $view->userLogin = Piwik::getCurrentUserLogin();
     $view->sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess();
     $view->url = Piwik_Url::getCurrentUrl();
     $view->basicHtmlView = false;
     $view->content = '';
     return $view;
 }
 public function adminMenu()
 {
     Piwik::checkUserIsSuperUser();
     $view = Piwik_View::factory('settings');
     if (!Piwik_MobileAnalytics::settingsExist()) {
         Piwik_MobileAnalytics::createSettings();
     }
     $view->config = Piwik_Config::getInstance()->MobileAnalytics;
     $this->setBasicVariablesView($view);
     $view->topMenu = Piwik_GetTopMenu();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #17
0
 /**
  * Displays the admin UI page showing all tracking tags
  * @return unknown_type
  */
 function displayJavascriptCode()
 {
     $idSite = Piwik_Common::getRequestVar('idSite');
     Piwik::checkUserHasViewAccess($idSite);
     $jsTag = Piwik::getJavascriptCode($idSite, Piwik_Url::getCurrentUrlWithoutFileName());
     $view = Piwik_View::factory('Tracking');
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     $view->idSite = $idSite;
     $site = new Piwik_Site($idSite);
     $view->displaySiteName = $site->getName();
     $view->jsTag = $jsTag;
     echo $view->render();
 }
Beispiel #18
0
 function index()
 {
     Piwik::checkUserIsSuperUser();
     $listPlugins = Piwik_PluginsManager::getInstance()->readPluginsDirectory();
     $loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
     $plugins = array();
     foreach ($listPlugins as $pluginName) {
         $oPlugin = Piwik_PluginsManager::getInstance()->loadPlugin($pluginName);
         $plugins[$pluginName] = array('activated' => Piwik_PluginsManager::getInstance()->isPluginActivated($pluginName), 'alwaysActivated' => Piwik_PluginsManager::getInstance()->isPluginAlwaysActivated($pluginName), 'info' => $oPlugin->getInformation());
     }
     $view = new Piwik_View('CorePluginsAdmin/templates/manage.tpl');
     $view->pluginsName = $plugins;
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #19
0
 function index()
 {
     Piwik::checkUserIsSuperUser();
     $listPlugins = Piwik_PluginsManager::getInstance()->readPluginsDirectory();
     $loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
     $plugins = array();
     foreach ($listPlugins as $pluginName) {
         $oPlugin = Piwik_PluginsManager::getInstance()->loadPlugin($pluginName);
         $plugins[$pluginName] = array('activated' => Piwik_PluginsManager::getInstance()->isPluginActivated($pluginName), 'alwaysActivated' => Piwik_PluginsManager::getInstance()->isPluginAlwaysActivated($pluginName), 'info' => $oPlugin->getInformation());
     }
     $view = Piwik_View::factory('manage');
     $view->pluginsName = $plugins;
     $this->setGeneralVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #20
0
 /**
  * Returns the index for this plugin. Shows every other report defined by this plugin,
  * except the '...ByYear' reports. These can be loaded as related reports.
  * 
  * Also, the 'getIndividual...Summary' reports are loaded by AJAX, as they can take
  * a significant amount of time to load on setups w/ lots of websites.
  */
 public function index()
 {
     Piwik::checkUserIsSuperUser();
     $view = Piwik_View::factory('index');
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     $view->databaseUsageSummary = $this->getDatabaseUsageSummary(true);
     $view->trackerDataSummary = $this->getTrackerDataSummary(true);
     $view->metricDataSummary = $this->getMetricDataSummary(true);
     $view->reportDataSummary = $this->getReportDataSummary(true);
     $view->adminDataSummary = $this->getAdminDataSummary(true);
     list($siteCount, $userCount, $totalSpaceUsed) = Piwik_DBStats_API::getInstance()->getGeneralInformation();
     $view->siteCount = Piwik::getPrettyNumber($siteCount);
     $view->userCount = Piwik::getPrettyNumber($userCount);
     $view->totalSpaceUsed = Piwik::getPrettySizeFromBytes($totalSpaceUsed);
     echo $view->render();
 }
Beispiel #21
0
 public function privacySettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('privacySettings');
     if (Piwik::isUserIsSuperUser()) {
         $deleteLogs = array();
         $view->deleteLogs = $this->getDeleteLogsInfo();
         $view->anonymizeIP = $this->getAnonymizeIPInfo();
     }
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     if (!Zend_Registry::get('config')->isFileWritable()) {
         $view->configFileNotWritable = true;
     }
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #22
0
 function index()
 {
     Piwik::checkUserIsSuperUser();
     require_once dirname(__FILE__) . '/PhpSecInfo/PhpSecInfo.php';
     // instantiate the class
     $psi = new PhpSecInfo();
     // load and run all tests
     $psi->loadAndRun();
     // grab the results as a multidimensional array
     $results = $psi->getResultsAsArray();
     // suppress results
     unset($results['test_results']['Core']['memory_limit']);
     unset($results['test_results']['Core']['post_max_size']);
     unset($results['test_results']['Core']['upload_max_filesize']);
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     $view->results = $results;
     echo $view->render();
 }
Beispiel #23
0
 public function generate()
 {
     Piwik::checkUserIsSuperUser();
     $nonce = Piwik_Common::getRequestVar('form_nonce', '', 'string', $_POST);
     if (Piwik_Common::getRequestVar('choice', 'no') != 'yes' || !Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)) {
         Piwik::redirectToModule('VisitorGenerator', 'index');
     }
     Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate');
     $daysToCompute = Piwik_Common::getRequestVar('daysToCompute', 1, 'int');
     // get idSite from POST with fallback to GET
     $idSite = Piwik_Common::getRequestVar('idSite', false, 'int', $_GET);
     $idSite = Piwik_Common::getRequestVar('idSite', $idSite, 'int', $_POST);
     Piwik::setMaxExecutionTime(0);
     $timer = new Piwik_Timer();
     $time = time() - ($daysToCompute - 1) * 86400;
     // Update site.ts_created if we generate visits on days before the website was created
     $site = new Piwik_Site($idSite);
     $minGeneratedDate = Piwik_Date::factory($time);
     if ($minGeneratedDate->isEarlier($site->getCreationDate())) {
         // direct access to the website table (bad practise but this is a debug / dev plugin)
         Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"), array('ts_created' => $minGeneratedDate->getDatetime()), "idsite = {$idSite}");
     }
     $nbActionsTotal = 0;
     while ($time <= time()) {
         $nbActionsTotalThisDay = $this->generateVisits($time, $idSite);
         $time += 86400;
         $nbActionsTotal += $nbActionsTotalThisDay;
     }
     // Init view
     $view = Piwik_View::factory('generate');
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     $view->assign('timer', $timer);
     $view->assign('days', $daysToCompute);
     $view->assign('nbActionsTotal', $nbActionsTotal);
     $view->assign('nbRequestsPerSec', round($nbActionsTotal / $timer->getTime(), 0));
     $view->assign('siteName', Piwik_Site::getNameFor($idSite));
     echo $view->render();
 }
Beispiel #24
0
 function adminIndex()
 {
     Piwik::checkUserIsSuperUser();
     $view = Piwik_View::factory('adminIndex');
     $allProviderInfo = Piwik_UserCountry_LocationProvider::getAllProviderInfo($newline = '<br/>', $includeExtra = true);
     $view->locationProviders = $allProviderInfo;
     $view->currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
     $view->thisIP = Piwik_IP::getIpFromHeader();
     // check if there is a working provider (that isn't the default one)
     $isThereWorkingProvider = false;
     foreach ($allProviderInfo as $id => $provider) {
         if ($id != Piwik_UserCountry_LocationProvider_Default::ID && $provider['status'] == Piwik_UserCountry_LocationProvider::INSTALLED) {
             $isThereWorkingProvider = true;
             break;
         }
     }
     $view->isThereWorkingProvider = $isThereWorkingProvider;
     $this->setBasicVariablesView($view);
     Piwik_Controller_Admin::setBasicVariablesAdminView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #25
0
 /** Administration index */
 public function admin()
 {
     Piwik::checkUserIsSuperUser();
     $data = Piwik_Common::getRequestVar('SiteSearch_Data', array());
     if (is_array($data) && count($data)) {
         $this->setParameters($data);
     }
     $view = new Piwik_View('SiteSearch/templates/admin.tpl');
     $view->menu = Piwik_GetAdminMenu();
     $this->setGeneralVariablesView($view);
     $sitesList = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
     $view->assign('sitesList', $sitesList);
     echo $view->render();
 }
Beispiel #26
0
	/**
	 * The "User Settings" admin UI screen view
	 */
	public function userSettings()
	{
		$view = Piwik_View::factory('userSettings');
		
		$userLogin = Piwik::getCurrentUserLogin();
		if(Piwik::isUserIsSuperUser())
		{
			$view->userAlias = $userLogin;
			$view->userEmail = Piwik::getSuperUserEmail();
			if(!Zend_Registry::get('config')->isFileWritable())
			{
				$view->configFileNotWritable = true;
			}
		}
		else
		{
			$user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
			$view->userAlias = $user['alias'];
	 		$view->userEmail = $user['email'];
		}
		
		$defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
		if($defaultReport === false)
		{
			$defaultReport = $this->getDefaultWebsiteId();
		}
		$view->defaultReport = $defaultReport;

		$view->defaultDate = $this->getDefaultDateForUser($userLogin);
		$view->availableDefaultDates = array(
			'today' => Piwik_Translate('General_Today'),
			'yesterday' => Piwik_Translate('General_Yesterday'),
			'previous7' => Piwik_Translate('General_PreviousDays', 7),
			'previous30' => Piwik_Translate('General_PreviousDays', 30),
			'last7' => Piwik_Translate('General_LastDays', 7),
			'last30' => Piwik_Translate('General_LastDays', 30),
			'week' => Piwik_Translate('General_CurrentWeek'),
			'month' => Piwik_Translate('General_CurrentMonth'),
			'year' => Piwik_Translate('General_CurrentYear'),
		);
		
		$view->ignoreCookieSet = Piwik_Tracker_IgnoreCookie::isIgnoreCookieFound();
		$this->initViewAnonymousUserSettings($view);
		$view->piwikHost = Piwik_Url::getCurrentHost();
		$this->setBasicVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		echo $view->render();
	}
Beispiel #27
0
 public function generate()
 {
     // Only admin is allowed to do this!
     Piwik::checkUserIsSuperUser();
     $GET = $_GET;
     $POST = $_POST;
     $COOKIE = $_COOKIE;
     $REQUEST = $_REQUEST;
     $nonce = Piwik_Common::getRequestVar('form_nonce', '', 'string', $_POST);
     if (Piwik_Common::getRequestVar('choice', 'no') != 'yes' || !Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)) {
         Piwik::redirectToModule('VisitorGenerator', 'index');
     }
     Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate');
     $minVisitors = Piwik_Common::getRequestVar('minVisitors', 20, 'int');
     $maxVisitors = Piwik_Common::getRequestVar('maxVisitors', 100, 'int');
     $nbActions = Piwik_Common::getRequestVar('nbActions', 10, 'int');
     $daysToCompute = Piwik_Common::getRequestVar('daysToCompute', 1, 'int');
     // get idSite from POST with fallback to GET
     $idSite = Piwik_Common::getRequestVar('idSite', false, 'int', $_GET);
     $idSite = Piwik_Common::getRequestVar('idSite', $idSite, 'int', $_POST);
     Piwik::setMaxExecutionTime(0);
     $loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
     $loadedPlugins = array_keys($loadedPlugins);
     // we have to unload the Provider plugin otherwise it tries to lookup the IP for a hostname, and there is no dns server here
     if (Piwik_PluginsManager::getInstance()->isPluginActivated('Provider')) {
         Piwik_PluginsManager::getInstance()->unloadPlugin('Provider');
     }
     // we set the DO NOT load plugins so that the Tracker generator doesn't load the plugins we've just disabled.
     // if for some reasons you want to load the plugins, comment this line, and disable the plugin Provider in the plugins interface
     Piwik_PluginsManager::getInstance()->doNotLoadPlugins();
     $generator = new Piwik_VisitorGenerator_Generator();
     $generator->setMaximumUrlDepth(3);
     //$generator->disableProfiler();
     $generator->setIdSite($idSite);
     $nbActionsTotal = 0;
     //$generator->emptyAllLogTables();
     $generator->init();
     $timer = new Piwik_Timer();
     $startTime = time() - ($daysToCompute - 1) * 86400;
     // Update site.ts_created if we generate visits on days before the website was created
     $site = new Piwik_Site($idSite);
     $minGeneratedDate = Piwik_Date::factory($startTime);
     if ($minGeneratedDate->isEarlier($site->getCreationDate())) {
         // direct access to the website table (bad practise but this is a debug / dev plugin)
         Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"), array('ts_created' => $minGeneratedDate->getDatetime()), "idsite = {$idSite}");
     }
     $dates = array();
     while ($startTime <= time()) {
         $visitors = rand($minVisitors, $maxVisitors);
         $actions = $nbActions;
         $generator->setTimestampToUse($startTime);
         $nbActionsTotalThisDay = $generator->generate($visitors, $actions);
         $actionsPerVisit = round($nbActionsTotalThisDay / $visitors);
         $date = array();
         $date['visitors'] = $visitors;
         $date['actionsPerVisit'] = $actionsPerVisit;
         $date['startTime'] = $startTime;
         $dates[] = $date;
         $startTime += 86400;
         $nbActionsTotal += $nbActionsTotalThisDay;
         //sleep(1);
     }
     $generator->end();
     // Recover all super globals
     $_GET = $GET;
     $_POST = $POST;
     $_COOKIE = $COOKIE;
     $_REQUEST = $REQUEST;
     // Reload plugins
     Piwik_PluginsManager::getInstance()->loadPlugins($loadedPlugins);
     // Init view
     $view = Piwik_View::factory('generate');
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     $view->assign('dates', $dates);
     $view->assign('timer', $timer);
     $view->assign('nbActionsTotal', $nbActionsTotal);
     $view->assign('nbRequestsPerSec', round($nbActionsTotal / $timer->getTime(), 0));
     echo $view->render();
 }