本文整理汇总了PHP中Piwik_GetOption函数的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_GetOption函数的具体用法?PHP Piwik_GetOption怎么用?PHP Piwik_GetOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Piwik_GetOption函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isNewestVersionAvailable
/**
* @return string|false false if current version is the latest available,
* or the latest version number if a newest release is available
*/
public static function isNewestVersionAvailable()
{
$latestVersion = Piwik_GetOption(self::LATEST_VERSION);
if (!empty($latestVersion) && version_compare(Piwik_Version::VERSION, $latestVersion) == -1) {
return $latestVersion;
}
return false;
}
示例2: deleteLogTables
function deleteLogTables()
{
$deleteSettings = Zend_Registry::get('config')->Deletelogs;
//Make sure, log deletion is enabled
if ($deleteSettings->delete_logs_enable == 0) {
return;
}
//Log deletion may not run until it is once rescheduled (initial run). This is the only way to guarantee the calculated next scheduled deletion time.
$initialDelete = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL);
if (empty($initialDelete)) {
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
return;
}
//Make sure, log purging is allowed to run now
$lastDelete = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
$deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteSettings->delete_logs_schedule_lowest_interval);
if ($lastDelete === false ||
($lastDelete !== false && ((int)$lastDelete + $deleteIntervalSeconds) <= time())
) {
$maxIdVisit = $this->getDeleteIdVisitOffset($deleteSettings->delete_logs_older_than);
$logTables = $this->getDeleteTableLogTables();
//set lastDelete time to today
$date = Piwik_Date::factory("today");
$lastDeleteDate = $date->getTimestamp();
/*
* Tell the DB that log deletion has run BEFORE deletion is executed;
* If deletion / table optimization exceeds execution time, other tasks maybe prevented of being executed every time,
* when the schedule is triggered.
*/
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate);
//Break if no ID was found (nothing to delete for given period)
if (empty($maxIdVisit)) {
return;
}
foreach ($logTables as $logTable) {
$this->deleteRowsFromTable($logTable, $maxIdVisit, $deleteSettings->delete_max_rows_per_run * self::DELETE_MAX_ROWS_MULTIPLICATOR);
}
//optimize table overhead after deletion
$query = "OPTIMIZE TABLE " . implode(",", $logTables);
Piwik_Query($query);
}
}
示例3: getScheduledTimeForTask
public static function getScheduledTimeForTask($className, $methodName)
{
// Gets the array where rescheduled timetables are stored
$option = Piwik_GetOption(self::TIMETABLE_OPTION_STRING);
$timetable = self::getTimetableFromOption($option);
if ($timetable === false) {
return;
}
$taskName = $className . '.' . $methodName;
if (isset($timetable[$taskName])) {
return $timetable[$taskName];
} else {
return false;
}
}
示例4: runTasks
public static function runTasks()
{
// Gets the array where rescheduled timetables are stored
$option = Piwik_GetOption(self::TIMETABLE_OPTION_STRING);
if ($option === false) {
$timetable = array();
} elseif (!is_string($option)) {
return;
} else {
$timetable = unserialize($option);
}
if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) {
$timetable = array();
}
// Collects tasks
Piwik_PostEvent(self::GET_TASKS_EVENT, $tasks);
$return = array();
// Loop through each task
foreach ($tasks as $task) {
$scheduledTime = $task->getScheduledTime();
$className = $task->getClassName();
$methodName = $task->getMethodName();
$fullyQualifiedMethodName = get_class($className) . '.' . $methodName;
/*
* Task has to be executed if :
* - it is the first time, ie. rescheduledTime is not set
* - that task has already been executed and the current system time is greater than the
* rescheduled time.
*/
if (!isset($timetable[$fullyQualifiedMethodName]) || isset($timetable[$fullyQualifiedMethodName]) && time() >= $timetable[$fullyQualifiedMethodName]) {
// Updates the rescheduled time
$timetable[$fullyQualifiedMethodName] = $scheduledTime->getRescheduledTime();
Piwik_SetOption(self::TIMETABLE_OPTION_STRING, serialize($timetable));
// Run the task
try {
$timer = new Piwik_Timer();
call_user_func(array($className, $methodName));
$message = $timer->__toString();
} catch (Exception $e) {
$message = 'ERROR: ' . $e->getMessage();
}
$return[] = array('task' => $fullyQualifiedMethodName, 'output' => $message);
}
}
return $return;
}
示例5: getDeleteLogsInfo
protected function getDeleteLogsInfo()
{
Piwik::checkUserIsSuperUser();
$deleteLogsInfos = array();
$taskScheduler = new Piwik_TaskScheduler();
$deleteLogsInfos["config"] = Zend_Registry::get('config')->Deletelogs->toArray();
$privacyManager = new Piwik_PrivacyManager();
$deleteLogsInfos["deleteTables"] = implode(", ", $privacyManager->getDeleteTableLogTables());
$scheduleTimetable = $taskScheduler->getScheduledTimeForTask("Piwik_PrivacyManager", "deleteLogTables");
$optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
//If task was already rescheduled, read time from taskTimetable. Else, calculate next possible runtime.
if (!empty($scheduleTimetable) && $scheduleTimetable - time() > 0) {
$nextPossibleSchedule = (int) $scheduleTimetable;
} else {
$date = Piwik_Date::factory("today");
$nextPossibleSchedule = $date->addDay(1)->getTimestamp();
}
//deletion schedule did not run before
if (empty($optionTable)) {
$deleteLogsInfos["lastRun"] = false;
//next run ASAP (with next schedule run)
$date = Piwik_Date::factory("today");
$deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
} else {
$deleteLogsInfos["lastRun"] = $optionTable;
$deleteLogsInfos["lastRunPretty"] = Piwik_Date::factory((int) $optionTable)->getLocalized('%day% %shortMonth% %longYear%');
//Calculate next run based on last run + interval
$nextScheduleRun = (int) ($deleteLogsInfos["lastRun"] + $deleteLogsInfos["config"]["delete_logs_schedule_lowest_interval"] * 24 * 60 * 60);
//is the calculated next run in the past? (e.g. plugin was disabled in the meantime or something) -> run ASAP
if ($nextScheduleRun - time() <= 0) {
$deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
} else {
$deleteLogsInfos["nextScheduleTime"] = $nextScheduleRun;
}
}
$deleteLogsInfos["nextRunPretty"] = Piwik::getPrettyTimeFromSeconds($deleteLogsInfos["nextScheduleTime"] - time());
return $deleteLogsInfos;
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
$dbName = false;
if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) {
$dbName = $GLOBALS['PIWIK_BENCHMARK_DATABASE'];
}
// connect to database
self::createTestConfig();
self::connectWithoutDatabase();
// create specified fixture (global var not set, use default no-data fixture (see end of this file))
if (empty($GLOBALS['PIWIK_BENCHMARK_FIXTURE'])) {
$fixtureName = 'Piwik_Test_Fixture_EmptyOneSite';
} else {
$fixtureName = 'Piwik_Test_Fixture_' . $GLOBALS['PIWIK_BENCHMARK_FIXTURE'];
}
self::$fixture = new $fixtureName();
// figure out if the desired fixture has already been setup, and if not empty the database
$installedFixture = false;
try {
if (isset(self::$fixture->tablesPrefix)) {
Piwik_Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix;
Piwik_Common::$cachedTablePrefix = null;
}
Piwik_Query("USE " . $dbName);
$installedFixture = Piwik_GetOption('benchmark_fixture_name');
} catch (Exception $ex) {
// ignore
}
$createEmptyDatabase = $fixtureName != $installedFixture;
parent::setUpBeforeClass($dbName, $createEmptyDatabase, $createConfig = false);
// if we created an empty database, setup the fixture
if ($createEmptyDatabase) {
self::$fixture->setUp();
Piwik_SetOption('benchmark_fixture_name', $fixtureName);
}
}
示例7: getPiwikUrl
/**
* Returns the cached the Piwik URL, eg. http://demo.piwik.org/ or http://example.org/piwik/
* If not found, then tries to cache it and returns the value.
*
* If the Piwik URL changes (eg. Piwik moved to new server), the value will automatically be refreshed in the cache.
* @return string
*/
public static function getPiwikUrl()
{
$key = 'piwikUrl';
$url = Piwik_GetOption($key);
if (Piwik_Common::isPhpCliMode() || Piwik_Common::isArchivePhpTriggered() || defined('PIWIK_MODE_ARCHIVE')) {
return $url;
}
$currentUrl = Piwik_Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName());
if (empty($url) || $currentUrl != $url) {
if (strlen($currentUrl) >= strlen('http://a/')) {
Piwik_SetOption($key, $currentUrl, $autoload = true);
}
$url = $currentUrl;
}
return $url;
}
示例8: buildView
protected function buildView()
{
// access control
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik_API_Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
// collect data
$this->parametersToModify['action'] = $this->currentControllerAction;
$this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
$this->graphData = $this->getGraphData();
// build view
$view = new Piwik_View($this->dataTableTemplate);
$view->width = $this->width;
$view->height = $this->height;
$view->chartDivId = $this->getUniqueIdViewDataTable() . "Chart";
$view->graphType = $this->graphType;
$view->data = $this->graphData;
$view->isDataAvailable = strpos($this->graphData, '"series":[]') === false;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
$view->properties = $this->getViewProperties();
$view->reportDocumentation = $this->getReportDocumentation();
// if it's likely that the report data for this data table has been purged,
// set whether we should display a message to that effect.
$view->showReportDataWasPurgedMessage = $this->hasReportBeenPurged();
$view->deleteReportsOlderThan = Piwik_GetOption('delete_reports_older_than');
return $view;
}
示例9: doWelcomeUpdates
private function doWelcomeUpdates($view, $componentsWithUpdateFile)
{
$view->new_piwik_version = Piwik_Version::VERSION;
$view->commandUpgradePiwik = "<br /><code>php " . Piwik_Common::getPathToPiwikRoot() . "/index.php -- \"module=CoreUpdater\" </code>";
$pluginNamesToUpdate = array();
$coreToUpdate = false;
// handle case of existing database with no tables
if (!Piwik::isInstalled()) {
$this->errorMessages[] = Piwik_Translate('CoreUpdater_EmptyDatabaseError', Zend_Registry::get('config')->database->dbname);
$this->coreError = true;
$currentVersion = 'N/A';
} else {
$this->errorMessages = array();
try {
$currentVersion = Piwik_GetOption('version_core');
} catch (Exception $e) {
$currentVersion = '<= 0.2.9';
}
foreach ($componentsWithUpdateFile as $name => $filenames) {
if ($name == 'core') {
$coreToUpdate = true;
} else {
$pluginNamesToUpdate[] = $name;
}
}
}
// check file integrity
$integrityInfo = Piwik::getFileIntegrityInformation();
if (isset($integrityInfo[1])) {
if ($integrityInfo[0] == false) {
$this->warningMessages[] = '<b>' . Piwik_Translate('General_FileIntegrityWarningExplanation') . '</b>';
}
$this->warningMessages = array_merge($this->warningMessages, array_slice($integrityInfo, 1));
}
Piwik::deleteAllCacheOnUpdate();
$view->coreError = $this->coreError;
$view->warningMessages = $this->warningMessages;
$view->errorMessages = $this->errorMessages;
$view->current_piwik_version = $currentVersion;
$view->pluginNamesToUpdate = $pluginNamesToUpdate;
$view->coreToUpdate = $coreToUpdate;
echo $view->render();
}
示例10: start
public static function start($options = false)
{
if(Piwik_Common::isPhpCliMode() || version_compare(Piwik_GetOption('version_core'), '1.5-b5') < 0)
{
return;
}
// use cookies to store session id on the client side
@ini_set('session.use_cookies', '1');
// prevent attacks involving session ids passed in URLs
@ini_set('session.use_only_cookies', '1');
// advise browser that session cookie should only be sent over secure connection
if(Piwik_Url::getCurrentScheme() === 'https')
{
@ini_set('session.cookie_secure', '1');
}
// advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
@ini_set('session.cookie_httponly', '1');
// don't use the default: PHPSESSID
$sessionName = defined('PIWIK_SESSION_NAME') ? PIWIK_SESSION_NAME : 'PIWIK_SESSID';
@ini_set('session.name', $sessionName);
// proxies may cause the referer check to fail and
// incorrectly invalidate the session
@ini_set('session.referer_check', '');
// we consider these to be misconfigurations, in that
// - user - we can't verify that user-defined session handler functions have been set via session_set_save_handler()
// - mm - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
// - files - this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
$currentSaveHandler = ini_get('session.save_handler');
if(in_array($currentSaveHandler, array('user', 'mm', 'files')))
{
$db = Zend_Registry::get('db');
$config = array(
'name' => Piwik_Common::prefixTable('session'),
'primary' => 'id',
'modifiedColumn' => 'modified',
'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime',
'db' => $db,
);
$saveHandler = new Piwik_Session_SaveHandler_DbTable($config);
if($saveHandler)
{
self::setSaveHandler($saveHandler);
}
}
// garbage collection may disabled by default (e.g., Debian)
if(ini_get('session.gc_probability') == 0)
{
@ini_set('session.gc_probability', 1);
}
try {
Zend_Session::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch(Exception $e) {
Piwik::log('Unable to start session: ' . $e->getMessage());
Piwik_ExitWithMessage(Piwik_Translate('General_ExceptionUnableToStartSession'));
}
}
示例11: getDateOfLastCachingRun
/** Returns the date when the cacheDataByArchiveNameReports was last run. */
public static function getDateOfLastCachingRun()
{
return Piwik_GetOption(self::TIME_OF_LAST_TASK_RUN_OPTION);
}
示例12: getCacheGeneral
/**
* Returns contents of general (global) cache
*
* @return array
*/
protected static function getCacheGeneral()
{
$cache = self::getTrackerCache();
$cacheId = 'general';
$expectedRows = 3;
if (($cacheContent = $cache->get($cacheId)) !== false && count($cacheContent) == $expectedRows) {
return $cacheContent;
}
self::initCorePiwikInTrackerMode();
$cacheContent = array('isBrowserTriggerArchivingEnabled' => Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled(), 'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'), 'currentLocationProviderId' => Piwik_UserCountry_LocationProvider::getCurrentProviderId());
return $cacheContent;
}
示例13: doWelcomeUpdates
private function doWelcomeUpdates($view, $componentsWithUpdateFile)
{
$view->new_piwik_version = Piwik_Version::VERSION;
$pluginNamesToUpdate = array();
$coreToUpdate = false;
// handle case of existing database with no tables
$tablesInstalled = Piwik::getTablesInstalled();
if (count($tablesInstalled) == 0) {
$this->errorMessages[] = Piwik_Translate('CoreUpdater_EmptyDatabaseError', Zend_Registry::get('config')->database->dbname);
$this->coreError = true;
$currentVersion = 'N/A';
} else {
$this->errorMessages = array();
try {
$currentVersion = Piwik_GetOption('version_core');
} catch (Exception $e) {
$currentVersion = '<= 0.2.9';
}
foreach ($componentsWithUpdateFile as $name => $filenames) {
if ($name == 'core') {
$coreToUpdate = true;
} else {
$pluginNamesToUpdate[] = $name;
}
}
}
$view->coreError = $this->coreError;
$view->errorMessages = $this->errorMessages;
$view->current_piwik_version = $currentVersion;
$view->pluginNamesToUpdate = $pluginNamesToUpdate;
$view->coreToUpdate = $coreToUpdate;
$view->clearCompiledTemplates();
echo $view->render();
}
示例14: isBrowserTriggerArchivingEnabled
static public function isBrowserTriggerArchivingEnabled()
{
$browserArchivingEnabled = Piwik_GetOption(self::OPTION_BROWSER_TRIGGER_ARCHIVING);
if($browserArchivingEnabled !== false)
{
return (bool)$browserArchivingEnabled;
}
return (bool)Zend_Registry::get('config')->General->enable_browser_archiving_triggering;
}
示例15: initStateFromParameters
protected function initStateFromParameters()
{
// Detect parameters
$reset = $this->isParameterSet("force-all-periods", $valuePossible = true);
$forceAll = $this->isParameterSet("force-all-websites");
$forceTimeoutPeriod = $this->isParameterSet("force-timeout-for-periods", $valuePossible = true);
if (!empty($forceTimeoutPeriod) && $forceTimeoutPeriod !== true) {
// Ensure the cache for periods is at least as high as cache for today
$todayTTL = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
if ($forceTimeoutPeriod < $todayTTL) {
$this->log("WARNING: Automatically increasing --force-timeout-for-periods from {$forceTimeoutPeriod} to " . $todayTTL . " to match the cache timeout for Today's report specified in Piwik UI > Settings > General Settings");
$forceTimeoutPeriod = $todayTTL;
}
$this->processPeriodsMaximumEverySeconds = $forceTimeoutPeriod;
}
// Recommend to disable browser archiving when using this script
if (Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled()) {
$this->log("NOTE: if you execute this script at least once per hour (or more often) in a crontab, you may disable 'Browser trigger archiving' in Piwik UI > Settings > General Settings. ");
$this->log(" see doc at: http://piwik.org/docs/setup-auto-archiving/");
}
if ($reset) {
$this->log("--force-all-periods was detected: the script will run as if it was its first run, and will trigger archiving for all periods.");
$this->shouldResetState = true;
if (!$forceAll && is_numeric($reset) && $reset > 0) {
$this->firstRunActiveWebsitesWithTraffic = (int) $reset;
}
}
if ($forceAll) {
$this->log("--force-all-websites was detected: the script will archive all websites and all periods sequentially");
$this->shouldArchiveAllWebsites = true;
}
$this->timeLastCompleted = Piwik_GetOption(self::OPTION_ARCHIVING_FINISHED_TS);
if ($this->shouldResetState) {
$this->timeLastCompleted = false;
}
}