本文整理汇总了PHP中Piwik_Site::getCreationDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Site::getCreationDate方法的具体用法?PHP Piwik_Site::getCreationDate怎么用?PHP Piwik_Site::getCreationDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Site
的用法示例。
在下文中一共展示了Piwik_Site::getCreationDate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultIndexView
protected function getDefaultIndexView()
{
$view = new Piwik_View('Home/templates/index.tpl');
$this->setGeneralVariablesView($view);
$site = new Piwik_Site($view->idSite);
$minDate = $site->getCreationDate();
$view->minDateYear = $minDate->toString('Y');
$view->minDateMonth = $minDate->toString('m');
$view->minDateDay = $minDate->toString('d');
$view->basicHtmlView = false;
$view->content = '';
return $view;
}
示例2: generate
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));
echo $view->render();
}
示例3: setGeneralVariablesView
/**
* Sets general variables to the view that are used by various templates and Javascript.
* If any error happens, displays the login screen
* @param Piwik_View $view
* @return void
*/
protected function setGeneralVariablesView($view)
{
$view->date = $this->strDate;
try {
$view->idSite = $this->idSite;
if(empty($this->site) || empty($this->idSite))
{
throw new Exception("The requested website idSite is not found in the request, or is invalid.
Please check that you are logged in Piwik and have permission to access the specified website.");
}
$this->setPeriodVariablesView($view);
$rawDate = Piwik_Common::getRequestVar('date');
$periodStr = Piwik_Common::getRequestVar('period');
if($periodStr != 'range')
{
$date = Piwik_Date::factory($this->strDate);
$period = Piwik_Period::factory($periodStr, $date);
}
else
{
$period = new Piwik_Period_Range($periodStr, $rawDate, $this->site->getTimezone());
}
$view->rawDate = $rawDate;
$view->prettyDate = $period->getPrettyString();
$view->siteName = $this->site->getName();
$view->siteMainUrl = $this->site->getMainUrl();
$datetimeMinDate = $this->site->getCreationDate()->getDatetime();
$minDate = Piwik_Date::factory($datetimeMinDate, $this->site->getTimezone());
$this->setMinDateView($minDate, $view);
$maxDate = Piwik_Date::factory('now', $this->site->getTimezone());
$this->setMaxDateView($maxDate, $view);
// Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
$dateStart = $period->getDateStart();
if($dateStart->isEarlier($minDate)) { $dateStart = $minDate; }
$dateEnd = $period->getDateEnd();
if($dateEnd->isLater($maxDate)) { $dateEnd = $maxDate; }
$view->startDate = $dateStart;
$view->endDate = $dateEnd;
$this->setBasicVariablesView($view);
} catch(Exception $e) {
Piwik_ExitWithMessage($e->getMessage());
}
}
示例4: setDateTodayIfWebsiteCreatedToday
protected function setDateTodayIfWebsiteCreatedToday()
{
$date = Piwik_Common::getRequestVar('date', false);
$date = Piwik_Date::factory($date);
if ($date->isToday()) {
return;
}
$websiteId = Piwik_Common::getRequestVar('idSite', false);
if ($websiteId) {
$website = new Piwik_Site($websiteId);
if ($website->getCreationDate()->isToday()) {
Piwik::redirectToModule('CoreHome', 'index', array('date' => 'today', 'idSite' => $websiteId, 'period' => Piwik_Common::getRequestVar('period')));
}
}
}
示例5: setGeneralVariablesView
/**
* Sets general variables to the view that are used by
* various templates and Javascript.
* If any error happens, displays the login screen
*
* @param Piwik_View $view
* @throws Exception
* @return void
*/
protected function setGeneralVariablesView($view)
{
$view->date = $this->strDate;
try {
$view->idSite = $this->idSite;
if (empty($this->site) || empty($this->idSite)) {
throw new Exception("The requested website idSite is not found in the request, or is invalid.\n\t\t\t\tPlease check that you are logged in Piwik and have permission to access the specified website.");
}
$this->setPeriodVariablesView($view);
$rawDate = Piwik_Common::getRequestVar('date');
$periodStr = Piwik_Common::getRequestVar('period');
if ($periodStr != 'range') {
$date = Piwik_Date::factory($this->strDate);
$period = Piwik_Period::factory($periodStr, $date);
} else {
$period = new Piwik_Period_Range($periodStr, $rawDate, $this->site->getTimezone());
}
$view->rawDate = $rawDate;
$view->prettyDate = self::getCalendarPrettyDate($period);
$view->siteName = $this->site->getName();
$view->siteMainUrl = $this->site->getMainUrl();
$datetimeMinDate = $this->site->getCreationDate()->getDatetime();
$minDate = Piwik_Date::factory($datetimeMinDate, $this->site->getTimezone());
$this->setMinDateView($minDate, $view);
$maxDate = Piwik_Date::factory('now', $this->site->getTimezone());
$this->setMaxDateView($maxDate, $view);
// Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
$dateStart = $period->getDateStart();
if ($dateStart->isEarlier($minDate)) {
$dateStart = $minDate;
}
$dateEnd = $period->getDateEnd();
if ($dateEnd->isLater($maxDate)) {
$dateEnd = $maxDate;
}
$view->startDate = $dateStart;
$view->endDate = $dateEnd;
$language = Piwik_LanguagesManager::getLanguageForSession();
$view->language = !empty($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
$view->config_action_url_category_delimiter = Piwik_Config::getInstance()->General['action_url_category_delimiter'];
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
} catch (Exception $e) {
Piwik_ExitWithMessage($e->getMessage(), '');
}
}
示例6: redirectToIndex
function redirectToIndex($moduleToRedirect, $actionToRedirect)
{
$sitesId = Piwik_SitesManager_API::getSitesIdWithAtLeastViewAccess();
if (!empty($sitesId)) {
$firstSiteId = $sitesId[0];
$firstSite = new Piwik_Site($firstSiteId);
if ($firstSite->getCreationDate()->isToday()) {
$defaultDate = 'today';
} else {
$defaultDate = Zend_Registry::get('config')->General->default_day;
}
$defaultPeriod = Zend_Registry::get('config')->General->default_period;
header("Location:index.php?module=" . $moduleToRedirect . "&action=" . $actionToRedirect . "&idSite={$firstSiteId}&period={$defaultPeriod}&date={$defaultDate}");
} else {
if (Piwik::isUserIsSuperUser()) {
Piwik_ExitWithMessage("Error: no website were found in this Piwik installation. \n\t\t\t\t<br>Check the table '" . Piwik::prefixTable('site') . "' that should contain your Piwik websites.", false, true);
}
$currentLogin = Piwik::getCurrentUserLogin();
if (!empty($currentLogin) && $currentLogin != 'anonymous') {
$errorMessage = sprintf(Piwik_Translate('CoreHome_NoPrivileges'), $currentLogin);
$errorMessage .= "<br /><br /> <b><a href='?module=" . Zend_Registry::get('auth')->getName() . "&action=logout'>› " . Piwik_Translate('General_Logout') . "</a></b><br />";
Piwik_ExitWithMessage($errorMessage, false, true);
} else {
Piwik_FrontController::dispatch('Login', false);
}
}
exit;
}
示例7: generate
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();
}
示例8: array
function test_setDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
{
// test that they return default values
$defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$this->assertEqual($defaultTimezone, 'UTC');
$defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
$this->assertEqual($defaultCurrency, 'USD');
$excludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
$this->assertEqual($excludedIps, '');
$excludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEqual($excludedQueryParameters, '');
// test that when not specified, defaults are set as expected
$idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
$site = new Piwik_Site($idsite);
$this->assertEqual($site->getTimezone(), 'UTC');
$this->assertEqual($site->getCurrency(), 'USD');
$this->assertEqual($site->getExcludedQueryParameters(), '');
$this->assertEqual($site->getExcludedIps(), '');
$this->assertEqual($site->isEcommerceEnabled(), false);
// set the global timezone and get it
$newDefaultTimezone = 'UTC+5.5';
Piwik_SitesManager_API::getInstance()->setDefaultTimezone($newDefaultTimezone);
$defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$this->assertEqual($defaultTimezone, $newDefaultTimezone);
// set the default currency and get it
$newDefaultCurrency = 'EUR';
Piwik_SitesManager_API::getInstance()->setDefaultCurrency($newDefaultCurrency);
$defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
$this->assertEqual($defaultCurrency, $newDefaultCurrency);
// set the global IPs to exclude and get it
$newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
$globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
$this->assertEqual($globalExcludedIps, $newGlobalExcludedIps);
// set the global URL query params to exclude and get it
$newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
// removed the space
$expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
$globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEqual($globalExcludedQueryParameters, $expectedGlobalExcludedQueryParameters);
// create a website and check that default currency and default timezone are set
// however, excluded IPs and excluded query Params are not returned
$idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 1, '', '', $newDefaultTimezone);
$site = new Piwik_Site($idsite);
$this->assertEqual($site->getTimezone(), $newDefaultTimezone);
$this->assertEqual($site->getCreationDate()->toString(), date('Y-m-d'));
$this->assertEqual($site->getCurrency(), $newDefaultCurrency);
$this->assertEqual($site->getExcludedIps(), '');
$this->assertEqual($site->getExcludedQueryParameters(), '');
$this->assertEqual($site->isEcommerceEnabled(), true);
}
示例9: setGeneralVariablesView
protected function setGeneralVariablesView($view)
{
$view->date = $this->strDate;
try {
$this->setPeriodVariablesView($view);
$period = Piwik_Period::factory(Piwik_Common::getRequestVar('period'), Piwik_Date::factory($this->strDate));
$view->prettyDate = $period->getLocalizedLongString();
$idSite = Piwik_Common::getRequestVar('idSite');
$view->idSite = $idSite;
$site = new Piwik_Site($idSite);
$view->siteName = $site->getName();
$view->siteMainUrl = $site->getMainUrl();
$minDate = $site->getCreationDate();
$this->setMinDateView($minDate, $view);
$maxDate = Piwik_Date::factory('today');
$view->maxDateYear = $maxDate->toString('Y');
$view->maxDateMonth = $maxDate->toString('m');
$view->maxDateDay = $maxDate->toString('d');
$view->debugTrackVisitsInsidePiwikUI = Zend_Registry::get('config')->Debug->track_visits_inside_piwik_ui;
$view->isSuperUser = Zend_Registry::get('access')->isSuperUser();
} catch (Exception $e) {
self::redirectToIndex(Piwik::getModule(), Piwik::getAction());
}
}