当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik::log方法代码示例

本文整理汇总了PHP中Piwik::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::log方法的具体用法?PHP Piwik::log怎么用?PHP Piwik::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik的用法示例。


在下文中一共展示了Piwik::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: purgeData

 /**
  * Purges old data from the following tables:
  * - log_visit
  * - log_link_visit_action
  * - log_conversion
  * - log_conversion_item
  * - log_action
  */
 public function purgeData()
 {
     $maxIdVisit = $this->getDeleteIdVisitOffset();
     // break if no ID was found (nothing to delete for given period)
     if (empty($maxIdVisit)) {
         return;
     }
     $logTables = self::getDeleteTableLogTables();
     // delete data from log tables
     $where = "WHERE idvisit <= ?";
     foreach ($logTables as $logTable) {
         // deleting from log_action must be handled differently, so we do it later
         if ($logTable != Piwik_Common::prefixTable('log_action')) {
             Piwik_DeleteAllRows($logTable, $where, $this->maxRowsToDeletePerQuery, array($maxIdVisit));
         }
     }
     // delete unused actions from the log_action table (but only if we can lock tables)
     if (Piwik::isLockPrivilegeGranted()) {
         $this->purgeUnusedLogActions();
     } else {
         $logMessage = get_class($this) . ": LOCK TABLES privilege not granted; skipping unused actions purge";
         Piwik::log($logMessage);
     }
     // optimize table overhead after deletion
     Piwik_OptimizeTables($logTables);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:34,代码来源:LogDataPurger.php

示例2: main

 /**
  * @see Piwik_ViewDataTable::main()
  * @throws Exception|Piwik_Access_NoAccessException
  * @return null
  */
 public function main()
 {
     if ($this->mainAlreadyExecuted) {
         return;
     }
     $this->mainAlreadyExecuted = true;
     $this->isDataAvailable = true;
     try {
         $this->loadDataTableFromAPI();
     } catch (Piwik_Access_NoAccessException $e) {
         throw $e;
     } catch (Exception $e) {
         Piwik::log("Failed to get data from API: " . $e->getMessage());
         $this->isDataAvailable = false;
     }
     $this->postDataTableLoadedFromAPI();
     $this->view = $this->buildView();
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:23,代码来源:HtmlTable.php

示例3: printMemoryUsage

 public static function printMemoryUsage($prefixString = null)
 {
     $memory = false;
     if (function_exists('xdebug_memory_usage')) {
         $memory = xdebug_memory_usage();
     } elseif (function_exists('memory_get_usage')) {
         $memory = memory_get_usage();
     }
     if ($memory !== false) {
         $usage = round($memory / 1024 / 1024, 2);
         if (!is_null($prefixString)) {
             Piwik::log($prefixString);
         }
         Piwik::log("Memory usage = {$usage} Mb");
     } else {
         Piwik::log("Memory usage function not found.");
     }
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:18,代码来源:Piwik.php

示例4: init


//.........这里部分代码省略.........
	 * - 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));
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:101,代码来源:FrontController.php

示例5: activatePlugin

 /**
  * Activate the specified plugin and install (if needed)
  *
  * @param string  $pluginName  Name of plugin
  * @throws Exception
  */
 public function activatePlugin($pluginName)
 {
     $plugins = Piwik_Config::getInstance()->Plugins['Plugins'];
     if (in_array($pluginName, $plugins)) {
         throw new Exception("Plugin '{$pluginName}' already activated.");
     }
     $existingPlugins = $this->readPluginsDirectory();
     if (array_search($pluginName, $existingPlugins) === false) {
         Piwik::log("Unable to find the plugin '{$pluginName}' in activatePlugin.");
         return;
     }
     $plugin = $this->loadPlugin($pluginName);
     if ($plugin === null) {
         return;
     }
     $this->installPluginIfNecessary($plugin);
     $plugin->activate();
     // we add the plugin to the list of activated plugins
     if (!in_array($pluginName, $plugins)) {
         $plugins[] = $pluginName;
     } else {
         // clean up if we find a dupe
         $plugins = array_unique($plugins);
     }
     // the config file will automatically be saved with the new plugin
     $this->updatePluginsConfig($plugins);
     Piwik_Config::getInstance()->forceSave();
     // Delete merged js/css files to force regenerations to include the activated plugin
     Piwik::deleteAllCacheOnUpdate();
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:36,代码来源:PluginsManager.php

示例6: tableInsertBatch

 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Piwik_Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @return bool True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values)
 {
     $filePath = PIWIK_USER_PATH . '/' . Piwik_AssetManager::MERGED_FILE_DIR . $tableName . '-' . Piwik_Common::generateUniqId() . '.csv';
     if (Zend_Registry::get('db')->hasBulkLoader()) {
         try {
             //				throw new Exception('');
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => create_function('$str', 'return str_replace(array(chr(92), chr(34)), array(chr(92).chr(92), chr(92).chr(34)), $str);'), 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!self::isDatabaseConnectionUTF8() && !isset(Zend_Registry::get('config')->database->charset)) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
             throw new Exception('unknown cause');
         } catch (Exception $e) {
             Piwik::log("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was:" . $e->getMessage());
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:36,代码来源:Piwik.php

示例7: 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'));
		}
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:69,代码来源:Session.php

示例8: strtolower

        $location = $provider->getLocation(array('ip' => $ip));
        if (!empty($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY])) {
            $location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY] = strtolower($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY]);
        }
        $row['location_country'] = strtolower($row['location_country']);
        $columnsToSet = array();
        $bind = array();
        foreach ($logVisitFieldsToUpdate as $column => $locationKey) {
            if (!empty($location[$locationKey]) && $location[$locationKey] != $row[$column]) {
                $columnsToSet[] = $column . ' = ?';
                $bind[] = $location[$locationKey];
            }
        }
        if (empty($columnsToSet)) {
            continue;
        }
        $bind[] = $row['idvisit'];
        // update log_visit
        $sql = "UPDATE " . Piwik_Common::prefixTable('log_visit') . "\n\t\t\t\t   SET " . implode(', ', $columnsToSet) . "\n\t\t\t\t WHERE idvisit = ?";
        Piwik_Query($sql, $bind);
        // update log_conversion
        $sql = "UPDATE " . Piwik_Common::prefixTable('log_conversion') . "\n\t\t\t\t   SET " . implode(', ', $columnsToSet) . "\n\t\t\t\t WHERE idvisit = ?";
        Piwik_Query($sql, $bind);
    }
    Piwik::log(round($start * 100 / $count) . "% done...");
    flush();
}
Piwik::log("100% done!");
Piwik::log("");
Piwik::log("[note] Now that you've geolocated your old visits, you need to force your reports to be re-processed. See this FAQ entry: http://piwik.org/faq/how-to/#faq_59");
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:30,代码来源:geoipUpdateRows.php

示例9: postCompute

 /**
  * Called at the end of the archiving process.
  * Does some cleaning job in the database.
  */
 protected function postCompute()
 {
     parent::postCompute();
     $blobTable = $this->tableArchiveBlob->getTableName();
     $numericTable = $this->tableArchiveNumeric->getTableName();
     $key = 'lastPurge_' . $blobTable;
     $timestamp = Piwik_GetOption($key);
     if (!$timestamp || $timestamp < time() - 86400) {
         Piwik_SetOption($key, time());
         // we delete out of date daily archives from table, maximum once per day
         // we only delete archives processed that are older than 1 day, to not delete archives we just processed
         $yesterday = Piwik_Date::factory('yesterday')->getDateTime();
         $result = Piwik_FetchAll("\n\t\t\t\t\t\t\tSELECT idarchive\n\t\t\t\t\t\t\tFROM {$numericTable}\n\t\t\t\t\t\t\tWHERE name LIKE 'done%'\n\t\t\t\t\t\t\t\tAND value = " . Piwik_ArchiveProcessing::DONE_OK_TEMPORARY . "\n\t\t\t\t\t\t\t\tAND ts_archived < ?", array($yesterday));
         $idArchivesToDelete = array();
         if (!empty($result)) {
             foreach ($result as $row) {
                 $idArchivesToDelete[] = $row['idarchive'];
             }
             $query = "DELETE \n    \t\t\t\t\t\tFROM %s\n    \t\t\t\t\t\tWHERE idarchive IN (" . implode(',', $idArchivesToDelete) . ")\n    \t\t\t\t\t\t";
             Piwik_Query(sprintf($query, $blobTable));
             Piwik_Query(sprintf($query, $numericTable));
         }
         Piwik::log("Purging temporary archives: done [ purged archives older than {$yesterday} from {$blobTable} and {$numericTable} ] [Deleted IDs: " . implode(',', $idArchivesToDelete) . "]");
         // Deleting "Custom Date Range" reports after 1 day, since they can be re-processed
         // and would take up unecessary space
         $query = "DELETE \n    \t\t\t\t\tFROM %s\n    \t\t\t\t\tWHERE period = ?\n    \t\t\t\t\t\tAND ts_archived < ?";
         $bind = array(Piwik::$idPeriods['range'], $yesterday);
         Piwik_Query(sprintf($query, $blobTable), $bind);
         Piwik_Query(sprintf($query, $numericTable), $bind);
     } else {
         Piwik::log("Purging temporary archives: skipped.");
     }
     if (!isset($this->archives)) {
         return;
     }
     foreach ($this->archives as $archive) {
         destroy($archive);
     }
     $this->archives = array();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:44,代码来源:Period.php

示例10: log

 private function log($m)
 {
     $this->output .= $m . "\n";
     Piwik::log($m);
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:5,代码来源:archive.php

示例11: initCompute

	/**
	 * Init the object before launching the real archive processing
	 */
	protected function initCompute()
	{
		$this->loadNextIdarchive();
		$done = $this->getDoneStringFlag();
		$this->insertNumericRecord($done, Piwik_ArchiveProcessing::DONE_ERROR);
		
		// Can be removed when GeoIp is in core
		$this->logTable = Piwik_Common::prefixTable('log_visit');
		
		$temporary = 'definitive archive';
		if($this->isArchiveTemporary())
		{
			$temporary = 'temporary archive';
		}
		Piwik::log("'" . $this->period->getLabel() . "'" 
								.", idSite = ". $this->idsite." ($temporary)" 
								.", segment = '". $this->getSegment()->getString()."'"
								.", report = '". $this->getRequestedReport()."'" 
								.", UTC datetime [".$this->startDatetimeUTC." -> ".$this->endDatetimeUTC." ]...");
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:23,代码来源:ArchiveProcessing.php

示例12: getLocation

 /**
  * Uses a GeoIP database to get a visitor's location based on their IP address.
  * 
  * This function will return different results based on the data used. If a city
  * database is used, it may return the country code, region code, city name, area
  * code, latitude, longitude and postal code of the visitor.
  * 
  * Alternatively, if used with a country database, only the country code will be
  * returned.
  * 
  * @param array $info Must have an 'ip' field.
  * @return array
  */
 public function getLocation($info)
 {
     $ip = $this->getIpFromInfo($info);
     $result = array();
     $locationGeoIp = $this->getGeoIpInstance($key = 'loc');
     if ($locationGeoIp) {
         switch ($locationGeoIp->databaseType) {
             case GEOIP_CITY_EDITION_REV0:
                 // city database type
             // city database type
             case GEOIP_CITY_EDITION_REV1:
             case GEOIP_CITYCOMBINED_EDITION:
                 $location = geoip_record_by_addr($locationGeoIp, $ip);
                 if (!empty($location)) {
                     $result[self::COUNTRY_CODE_KEY] = $location->country_code;
                     $result[self::REGION_CODE_KEY] = $location->region;
                     $result[self::CITY_NAME_KEY] = utf8_encode($location->city);
                     $result[self::AREA_CODE_KEY] = $location->area_code;
                     $result[self::LATITUDE_KEY] = $location->latitude;
                     $result[self::LONGITUDE_KEY] = $location->longitude;
                     $result[self::POSTAL_CODE_KEY] = $location->postal_code;
                 }
                 break;
             case GEOIP_REGION_EDITION_REV0:
                 // region database type
             // region database type
             case GEOIP_REGION_EDITION_REV1:
                 $location = geoip_region_by_addr($locationGeoIp, $ip);
                 if (!empty($location)) {
                     $result[self::COUNTRY_CODE_KEY] = $location[0];
                     $result[self::REGION_CODE_KEY] = $location[1];
                 }
                 break;
             case GEOIP_COUNTRY_EDITION:
                 // country database type
                 $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
                 break;
             default:
                 // unknown database type, log warning and fallback to country edition
                 Piwik::log("Found unrecognized database type: " . $locationGeoIp->databaseType);
                 $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
                 break;
         }
     }
     // NOTE: ISP & ORG require commercial dbs to test. this code has been tested manually,
     // but not by integration tests.
     $ispGeoIp = $this->getGeoIpInstance($key = 'isp');
     if ($ispGeoIp) {
         $isp = geoip_org_by_addr($ispGeoIp, $ip);
         if (!empty($isp)) {
             $result[self::ISP_KEY] = utf8_encode($isp);
         }
     }
     $orgGeoIp = $this->getGeoIpInstance($key = 'org');
     if ($orgGeoIp) {
         $org = geoip_org_by_addr($orgGeoIp, $ip);
         if (!empty($org)) {
             $result[self::ORG_KEY] = utf8_encode($org);
         }
     }
     if (empty($result)) {
         return false;
     }
     $this->completeLocationResult($result);
     return $result;
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:79,代码来源:Php.php

示例13: log

 function log($m)
 {
     Piwik::log($m);
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:4,代码来源:test_generateLotsVisitsWebsites.php

示例14: postCompute

 /**
  * Called at the end of the archiving process.
  * Does some cleaning job in the database.
  */
 protected function postCompute()
 {
     parent::postCompute();
     $blobTable = $this->tableArchiveBlob->getTableName();
     $numericTable = $this->tableArchiveNumeric->getTableName();
     $key = 'lastPurge_' . $blobTable;
     $timestamp = Piwik_GetOption($key);
     // we shall purge temporary archives after their timeout is finished, plus an extra 2 hours
     // in case archiving is disabled and is late to run, we give it this extra time to run and re-process more recent records
     $temporaryArchivingTimeout = self::getTodayArchiveTimeToLive();
     $purgeEveryNSeconds = $temporaryArchivingTimeout + 2 * 3600;
     // we only delete archives if we are able to process them, otherwise, the browser might process reports
     // when &segment= is specified (or custom date range) and would below, delete temporary archives that the
     // browser is not able to process until next cron run (which could be more than 1 hour away)
     if ($this->isRequestAuthorizedToArchive() && (!$timestamp || $timestamp < time() - $purgeEveryNSeconds)) {
         Piwik_SetOption($key, time());
         $purgeArchivesOlderThan = Piwik_Date::factory(time() - $purgeEveryNSeconds)->getDateTime();
         $result = Piwik_FetchAll("\n\t\t\t\t\t\t\tSELECT idarchive\n\t\t\t\t\t\t\tFROM {$numericTable}\n\t\t\t\t\t\t\tWHERE name LIKE 'done%'\n\t\t\t\t\t\t\t\tAND value = " . Piwik_ArchiveProcessing::DONE_OK_TEMPORARY . "\n\t\t\t\t\t\t\t\tAND ts_archived < ?", array($purgeArchivesOlderThan));
         $idArchivesToDelete = array();
         if (!empty($result)) {
             foreach ($result as $row) {
                 $idArchivesToDelete[] = $row['idarchive'];
             }
             $query = "DELETE \n    \t\t\t\t\t\tFROM %s\n    \t\t\t\t\t\tWHERE idarchive IN (" . implode(',', $idArchivesToDelete) . ")\n    \t\t\t\t\t\t";
             Piwik_Query(sprintf($query, $blobTable));
             Piwik_Query(sprintf($query, $numericTable));
         }
         Piwik::log("Purging temporary archives: done [ purged archives older than {$purgeArchivesOlderThan} from {$blobTable} and {$numericTable} ] [Deleted IDs: " . implode(',', $idArchivesToDelete) . "]");
         // Deleting "Custom Date Range" reports after 1 day, since they can be re-processed
         // and would take up unecessary space
         $yesterday = Piwik_Date::factory('yesterday')->getDateTime();
         $query = "DELETE \n    \t\t\t\t\tFROM %s\n    \t\t\t\t\tWHERE period = ?\n    \t\t\t\t\t\tAND ts_archived < ?";
         $bind = array(Piwik::$idPeriods['range'], $yesterday);
         Piwik::log("Purging Custom Range archives: done [ purged archives older than {$yesterday} from {$blobTable} and {$numericTable} ]");
         Piwik_Query(sprintf($query, $blobTable), $bind);
         Piwik_Query(sprintf($query, $numericTable), $bind);
         // these tables will be OPTIMIZEd daily in a scheduled task, to claim lost space
     } else {
         Piwik::log("Purging temporary archives: skipped.");
     }
     if (!isset($this->archives)) {
         return;
     }
     foreach ($this->archives as $archive) {
         destroy($archive);
     }
     $this->archives = array();
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:52,代码来源:Period.php

示例15: start

 /**
  * Start the session
  *
  * @param array|bool  $options  An array of configuration options; the auto-start (bool) setting is ignored
  * @return void
  */
 public static function start($options = false)
 {
     if (Piwik_Common::isPhpCliMode() || self::$sessionStarted || defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START) {
         return;
     }
     self::$sessionStarted = true;
     // 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::isHttps()) {
         @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', '');
     $currentSaveHandler = ini_get('session.save_handler');
     $config = Piwik_Config::getInstance();
     if (self::isFileBasedSessions()) {
         // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
         // for "files", use our own folder to prevent local session file hijacking
         $sessionPath = PIWIK_USER_PATH . '/tmp/sessions';
         // We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
         Piwik_Common::mkdir($sessionPath);
         @ini_set('session.save_handler', 'files');
         @ini_set('session.save_path', $sessionPath);
     } else {
         if ($config->General['session_save_handler'] === 'dbtable' || in_array($currentSaveHandler, array('user', 'mm'))) {
             // We consider these to be misconfigurations, in that:
             // - user  - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
             // - mm    - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
             $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());
         $enableDbSessions = '';
         if (Piwik::isInstalled()) {
             $enableDbSessions = "<br/>If you still experience issues after trying these changes, \n\t\t\t            \t\t\twe recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' target='_blank'>enable database session storage</a>.";
         }
         $message = 'Error: ' . Piwik_Translate('General_ExceptionUnableToStartSession') . ' ' . Piwik::getErrorMessageMissingPermissions(Piwik_Common::getPathToPiwikRoot() . '/tmp/sessions/') . $enableDbSessions . "\n<pre>Debug: the original error was \n" . $e->getMessage() . "</pre>";
         Piwik_ExitWithMessage($message);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:68,代码来源:Session.php


注:本文中的Piwik::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。