本文整理汇总了PHP中Piwik_Common::initCorePiwikInTrackerMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::initCorePiwikInTrackerMode方法的具体用法?PHP Piwik_Common::initCorePiwikInTrackerMode怎么用?PHP Piwik_Common::initCorePiwikInTrackerMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::initCorePiwikInTrackerMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runScheduledTasks
/**
* Tracker requests will automatically trigger the Scheduled tasks.
* This is useful for users who don't setup the cron,
* but still want daily/weekly/monthly PDF reports emailed automatically.
*
* This is similar to calling the API CoreAdminHome.runScheduledTasks (see misc/cron/archive.sh)
*
* @param int $now Current timestamp
*/
public static function runScheduledTasks($now)
{
// Currently, there is no hourly tasks. When there are some,
// this could be too agressive minimum interval (some hours would be skipped in case of low traffic)
$minimumInterval = Piwik_Config::getInstance()->Tracker['scheduled_tasks_min_interval'];
// If the user disabled browser archiving, he has already setup a cron
// To avoid parallel requests triggering the Scheduled Tasks,
// Get last time tasks started executing
$cache = Piwik_Common::getCacheGeneral();
if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerArchivingEnabled'])) {
printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
return;
}
$nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
$cache['lastTrackerCronRun'] = $now;
Piwik_Common::setCacheGeneral($cache);
Piwik_Common::initCorePiwikInTrackerMode();
Piwik_SetOption('lastTrackerCronRun', $cache['lastTrackerCronRun']);
printDebug('-> Scheduled Tasks: Starting...');
// save current user privilege and temporarily assume super user privilege
$isSuperUser = Piwik::isUserIsSuperUser();
// Scheduled tasks assume Super User is running
Piwik::setUserIsSuperUser();
// While each plugins should ensure that necessary languages are loaded,
// we ensure English translations at least are loaded
Piwik_Translate::getInstance()->loadEnglishTranslation();
$resultTasks = Piwik_TaskScheduler::runTasks();
// restore original user privilege
Piwik::setUserIsSuperUser($isSuperUser);
printDebug($resultTasks);
printDebug('Finished Scheduled Tasks.');
} else {
printDebug("-> Scheduled tasks not triggered.");
}
printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
}