本文整理汇总了PHP中Piwik\Tracker\Request::getIdSite方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getIdSite方法的具体用法?PHP Request::getIdSite怎么用?PHP Request::getIdSite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Tracker\Request
的用法示例。
在下文中一共展示了Request::getIdSite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: record
/**
* Records in the DB the association between the visit and this action.
*
* @param int $idReferrerActionUrl is the ID of the last action done by the current visit.
* @param $idReferrerActionName
* @param Visitor $visitor
*/
public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
{
$this->loadIdsFromLogActionTable();
$visitAction = array('idvisit' => $visitor->getVisitorColumn('idvisit'), 'idsite' => $this->request->getIdSite(), 'idvisitor' => $visitor->getVisitorColumn('idvisitor'), 'idaction_url' => $this->getIdActionUrl(), 'idaction_url_ref' => $idReferrerActionUrl, 'idaction_name_ref' => $idReferrerActionName);
/** @var ActionDimension[] $dimensions */
$dimensions = ActionDimension::getAllDimensions();
foreach ($dimensions as $dimension) {
$value = $dimension->onNewAction($this->request, $visitor, $this);
if ($value !== false) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$visitAction[$dimension->getColumnName()] = $value;
}
}
// idaction_name is NULLable. we only set it when applicable
if ($this->isActionHasActionName()) {
$visitAction['idaction_name'] = (int) $this->getIdActionName();
}
foreach ($this->actionIdsCached as $field => $idAction) {
$visitAction[$field] = $idAction === false ? 0 : $idAction;
}
$customValue = $this->getCustomFloatValue();
if (!empty($customValue)) {
$visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$visitAction = array_merge($visitAction, $this->customFields);
$this->idLinkVisitAction = $this->getModel()->createAction($visitAction);
$visitAction['idlink_va'] = $this->idLinkVisitAction;
Common::printDebug("Inserted new action:");
$visitActionDebug = $visitAction;
$visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
Common::printDebug($visitActionDebug);
}
示例2: onNewVisit
/**
* @param Request $request
* @param Visitor $visitor
* @param Action|null $action
* @return mixed
*/
public function onNewVisit(Request $request, Visitor $visitor, $action)
{
$referrerUrl = $request->getParam('urlref');
$currentUrl = $request->getParam('url');
$information = $this->getReferrerInformation($referrerUrl, $currentUrl, $request->getIdSite());
return $information['referer_url'];
}
示例3: afterRequestProcessed
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
{
$goalsConverted = $request->getMetadata('Goals', 'goalsConverted');
/** @var Action $action */
$action = $request->getMetadata('Actions', 'action');
// if the visit hasn't already been converted another way (ie, manual goal conversion or ecommerce conversion,
// try to convert based on the action)
if (empty($goalsConverted) && $action) {
$goalsConverted = $this->goalManager->detectGoalsMatchingUrl($request->getIdSite(), $action);
$existingGoalsConverted = $request->getMetadata('Goals', 'goalsConverted') ?: array();
$request->setMetadata('Goals', 'goalsConverted', array_merge($existingGoalsConverted, $goalsConverted));
if (!empty($goalsConverted)) {
$request->setMetadata('Goals', 'visitIsConverted', true);
}
}
// There is an edge case when:
// - two manual goal conversions happen in the same second
// - which result in handleExistingVisit throwing the exception
// because the UPDATE didn't affect any rows (one row was found, but not updated since no field changed)
// - the exception is caught here and will result in a new visit incorrectly
// In this case, we cancel the current conversion to be recorded:
$isManualGoalConversion = $this->isManualGoalConversion($request);
$requestIsEcommerce = $request->getMetadata('Goals', 'isRequestEcommerce');
$visitorNotFoundInDb = $request->getMetadata('CoreHome', 'visitorNotFoundInDb');
if ($visitorNotFoundInDb && ($isManualGoalConversion || $requestIsEcommerce)) {
$request->setMetadata('Goals', 'goalsConverted', array());
$request->setMetadata('Goals', 'visitIsConverted', false);
}
}
示例4: updateExistingVisit
/**
* @param $valuesToUpdate
* @throws VisitorNotFoundInDb
*/
protected function updateExistingVisit($valuesToUpdate)
{
$sqlQuery = "UPDATE " . Common::prefixTable('log_visit') . "\n SET %s\n WHERE idsite = ?\n AND idvisit = ?";
// build sql query
$updateParts = $sqlBind = array();
foreach ($valuesToUpdate as $name => $value) {
// Case where bind parameters don't work
if (strpos($value, $name) !== false) {
//$name = 'visit_total_events'
//$value = 'visit_total_events + 1';
$updateParts[] = " {$name} = {$value} ";
} else {
$updateParts[] = $name . " = ?";
$sqlBind[] = $value;
}
}
$sqlQuery = sprintf($sqlQuery, implode($updateParts, ', '));
array_push($sqlBind, $this->request->getIdSite(), (int) $this->visitorInfo['idvisit']);
$result = Tracker::getDatabase()->query($sqlQuery, $sqlBind);
// Debug output
if (isset($valuesToUpdate['idvisitor'])) {
$valuesToUpdate['idvisitor'] = bin2hex($valuesToUpdate['idvisitor']);
}
Common::printDebug('Updating existing visit: ' . var_export($valuesToUpdate, true));
if (Tracker::getDatabase()->rowCount($result) == 0) {
Common::printDebug("Visitor with this idvisit wasn't found in the DB.");
Common::printDebug("{$sqlQuery} --- ");
Common::printDebug($sqlBind);
throw new VisitorNotFoundInDb("The visitor with idvisitor=" . bin2hex($this->visitorInfo['idvisitor']) . " and idvisit=" . $this->visitorInfo['idvisit'] . " wasn't found in the DB, we fallback to a new visitor");
}
}
示例5: getNewVisitorInformation
protected function getNewVisitorInformation($action)
{
$actionType = $idActionName = $idActionUrl = false;
if ($action) {
$idActionUrl = $action->getIdActionUrlForEntryAndExitIds();
$idActionName = $action->getIdActionNameForEntryAndExitIds();
$actionType = $action->getActionType();
}
$daysSinceFirstVisit = $this->request->getDaysSinceFirstVisit();
$visitCount = $this->request->getVisitCount();
$daysSinceLastVisit = $this->request->getDaysSinceLastVisit();
$daysSinceLastOrder = $this->request->getDaysSinceLastOrder();
$isReturningCustomer = $daysSinceLastOrder !== false;
if ($daysSinceLastOrder === false) {
$daysSinceLastOrder = 0;
}
// User settings
$userInfo = $this->getSettingsObject();
$userInfo = $userInfo->getInfo();
// Referrer data
$referrer = new Referrer();
$referrerUrl = $this->request->getParam('urlref');
$currentUrl = $this->request->getParam('url');
$referrerInfo = $referrer->getReferrerInformation($referrerUrl, $currentUrl, $this->request->getIdSite());
$visitorReturning = $isReturningCustomer ? 2 : ($visitCount > 1 || $this->isVisitorKnown() || $daysSinceLastVisit > 0 ? 1 : 0);
$defaultTimeOnePageVisit = Config::getInstance()->Tracker['default_time_one_page_visit'];
return array('idsite' => $this->request->getIdSite(), 'visitor_localtime' => $this->request->getLocalTime(), 'idvisitor' => $this->getVisitorIdcookie(), 'visitor_returning' => $visitorReturning, 'visitor_count_visits' => $visitCount, 'visitor_days_since_last' => $daysSinceLastVisit, 'visitor_days_since_order' => $daysSinceLastOrder, 'visitor_days_since_first' => $daysSinceFirstVisit, 'visit_first_action_time' => Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()), 'visit_last_action_time' => Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()), 'visit_entry_idaction_url' => (int) $idActionUrl, 'visit_entry_idaction_name' => (int) $idActionName, 'visit_exit_idaction_url' => (int) $idActionUrl, 'visit_exit_idaction_name' => (int) $idActionName, 'visit_total_actions' => in_array($actionType, array(Action::TYPE_PAGE_URL, Action::TYPE_DOWNLOAD, Action::TYPE_OUTLINK, Action::TYPE_SITE_SEARCH, Action::TYPE_EVENT)) ? 1 : 0, 'visit_total_searches' => $actionType == Action::TYPE_SITE_SEARCH ? 1 : 0, 'visit_total_events' => $actionType == Action::TYPE_EVENT ? 1 : 0, 'visit_total_time' => self::cleanupVisitTotalTime($defaultTimeOnePageVisit), 'visit_goal_buyer' => $this->goalManager->getBuyerType(), 'referer_type' => $referrerInfo['referer_type'], 'referer_name' => $referrerInfo['referer_name'], 'referer_url' => $referrerInfo['referer_url'], 'referer_keyword' => $referrerInfo['referer_keyword'], 'config_id' => $userInfo['config_id'], 'config_os' => $userInfo['config_os'], 'config_browser_name' => $userInfo['config_browser_name'], 'config_browser_version' => $userInfo['config_browser_version'], 'config_resolution' => $userInfo['config_resolution'], 'config_pdf' => $userInfo['config_pdf'], 'config_flash' => $userInfo['config_flash'], 'config_java' => $userInfo['config_java'], 'config_director' => $userInfo['config_director'], 'config_quicktime' => $userInfo['config_quicktime'], 'config_realplayer' => $userInfo['config_realplayer'], 'config_windowsmedia' => $userInfo['config_windowsmedia'], 'config_gears' => $userInfo['config_gears'], 'config_silverlight' => $userInfo['config_silverlight'], 'config_cookie' => $userInfo['config_cookie'], 'location_ip' => $this->getVisitorIp(), 'location_browser_lang' => $userInfo['location_browser_lang']);
}
示例6: __construct
/**
* @param Request $request
*/
public function __construct(Request $request)
{
$this->spamFilter = new ReferrerSpamFilter();
$this->request = $request;
$this->idSite = $request->getIdSite();
$userAgent = $request->getUserAgent();
$this->userAgent = Common::unsanitizeInputValue($userAgent);
$this->ip = $request->getIp();
}
示例7: onNewVisit
/**
* @param Request $request
* @param Visitor $visitor
* @param Action|null $action
* @return mixed
*/
public function onNewVisit(Request $request, Visitor $visitor, $action)
{
$referrerUrl = $request->getParam('urlref');
$currentUrl = $request->getParam('url');
$information = $this->getReferrerInformation($referrerUrl, $currentUrl, $request->getIdSite());
if (!empty($information['referer_keyword'])) {
return substr($information['referer_keyword'], 0, 255);
}
return $information['referer_keyword'];
}
示例8: getConfigHash
/**
* Returns a 64-bit hash that attemps to identify a user.
* Maintaining some privacy by default, eg. prevents the merging of several Piwik serve together for matching across instances..
*
* @param $os
* @param $browserName
* @param $browserVersion
* @param $plugin_Flash
* @param $plugin_Java
* @param $plugin_Director
* @param $plugin_Quicktime
* @param $plugin_RealPlayer
* @param $plugin_PDF
* @param $plugin_WindowsMedia
* @param $plugin_Gears
* @param $plugin_Silverlight
* @param $plugin_Cookie
* @param $ip
* @param $browserLang
* @return string
*/
protected function getConfigHash(Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
// prevent the config hash from being the same, across different Piwik instances
// (limits ability of different Piwik instances to cross-match users)
$salt = SettingsPiwik::getSalt();
$configString = $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang . $salt;
if (!$this->isSameFingerprintsAcrossWebsites) {
$configString .= $request->getIdSite();
}
$hash = md5($configString, $raw_output = true);
return substr($hash, 0, Tracker::LENGTH_BINARY_ID);
}
示例9: __construct
/**
* @param Request $request
* @param bool|string $ip
* @param bool|string $userAgent
*/
public function __construct(Request $request, $ip = false, $userAgent = false)
{
if ($ip === false) {
$ip = $request->getIp();
}
if ($userAgent === false) {
$userAgent = $request->getUserAgent();
}
$this->request = $request;
$this->idSite = $request->getIdSite();
$this->userAgent = $userAgent;
$this->ip = $ip;
}
示例10: __construct
/**
* @param Request $request
* @param bool|string $ip
* @param bool|string $userAgent
*/
public function __construct(Request $request, $ip = false, $userAgent = false)
{
$this->spamFilter = new ReferrerSpamFilter();
if (false === $ip) {
$ip = $request->getIp();
}
if (false === $userAgent) {
$userAgent = $request->getUserAgent();
}
$this->request = $request;
$this->idSite = $request->getIdSite();
$this->userAgent = $userAgent;
$this->ip = $ip;
}
示例11: record
/**
* Records in the DB the association between the visit and this action.
*
* @param int $idReferrerActionUrl is the ID of the last action done by the current visit.
* @param $idReferrerActionName
* @param Visitor $visitor
*/
public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
{
$this->loadIdsFromLogActionTable();
$visitAction = array('idvisit' => $visitor->getVisitorColumn('idvisit'), 'idsite' => $this->request->getIdSite(), 'idvisitor' => $visitor->getVisitorColumn('idvisitor'), 'idaction_url' => $this->getIdActionUrl(), 'idaction_url_ref' => $idReferrerActionUrl, 'idaction_name_ref' => $idReferrerActionName);
/** @var ActionDimension[] $dimensions */
$dimensions = ActionDimension::getAllDimensions();
foreach ($dimensions as $dimension) {
$value = $dimension->onNewAction($this->request, $visitor, $this);
if ($value !== false) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$visitAction[$dimension->getColumnName()] = $value;
}
}
// idaction_name is NULLable. we only set it when applicable
if ($this->isActionHasActionName()) {
$visitAction['idaction_name'] = (int) $this->getIdActionName();
}
foreach ($this->actionIdsCached as $field => $idAction) {
$visitAction[$field] = $idAction === false ? 0 : $idAction;
}
$customValue = $this->getCustomFloatValue();
if (!empty($customValue)) {
$visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$customVariables = $this->getCustomVariables();
if (!empty($customVariables)) {
Common::printDebug("Page level Custom Variables: ");
Common::printDebug($customVariables);
}
$visitAction = array_merge($visitAction, $customVariables);
$this->idLinkVisitAction = $this->getModel()->createAction($visitAction);
$visitAction['idlink_va'] = $this->idLinkVisitAction;
Common::printDebug("Inserted new action:");
$visitActionDebug = $visitAction;
$visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
Common::printDebug($visitActionDebug);
/**
* Triggered after successfully persisting a [visit action entity](/guides/persistence-and-the-mysql-backend#visit-actions).
*
* This event is deprecated, use [Dimensions](http://developer.piwik.org/guides/dimensions) instead.
*
* @param Action $tracker Action The Action tracker instance.
* @param array $visitAction The visit action entity that was persisted. Read
* [this](/guides/persistence-and-the-mysql-backend#visit-actions) to see what it contains.
* @deprecated
*/
Piwik::postEvent('Tracker.recordAction', array($trackerAction = $this, $visitAction));
}
示例12: markArchivedReportsAsInvalidIfArchiveAlreadyFinished
private function markArchivedReportsAsInvalidIfArchiveAlreadyFinished()
{
$idSite = (int) $this->request->getIdSite();
$time = $this->request->getCurrentTimestamp();
$timezone = $this->getTimezoneForSite($idSite);
if (!isset($timezone)) {
return;
}
$date = Date::factory((int) $time, $timezone);
if (!$date->isToday()) {
// we don't have to handle in case date is in future as it is not allowed by tracker
$this->invalidator->rememberToInvalidateArchivedReportsLater($idSite, $date);
}
}
示例13: updateExistingVisit
/**
* @param $valuesToUpdate
* @throws VisitorNotFoundInDb
*/
protected function updateExistingVisit($valuesToUpdate)
{
$idSite = $this->request->getIdSite();
$idVisit = (int) $this->visitorInfo['idvisit'];
$wasInserted = $this->getModel()->updateVisit($idSite, $idVisit, $valuesToUpdate);
// Debug output
if (isset($valuesToUpdate['idvisitor'])) {
$valuesToUpdate['idvisitor'] = bin2hex($valuesToUpdate['idvisitor']);
}
if ($wasInserted) {
Common::printDebug('Updated existing visit: ' . var_export($valuesToUpdate, true));
} else {
throw new VisitorNotFoundInDb("The visitor with idvisitor=" . bin2hex($this->visitorInfo['idvisitor']) . " and idvisit=" . $this->visitorInfo['idvisit'] . " wasn't found in the DB, we fallback to a new visitor");
}
}
示例14: findKnownVisitor
public function findKnownVisitor($configId, VisitProperties $visitProperties, Request $request)
{
$idSite = $request->getIdSite();
$idVisitor = $request->getVisitorId();
$isVisitorIdToLookup = !empty($idVisitor);
if ($isVisitorIdToLookup) {
$visitProperties->setProperty('idvisitor', $idVisitor);
Common::printDebug("Matching visitors with: visitorId=" . bin2hex($idVisitor) . " OR configId=" . bin2hex($configId));
} else {
Common::printDebug("Visitor doesn't have the piwik cookie...");
}
$persistedVisitAttributes = $this->getVisitFieldsPersist();
$shouldMatchOneFieldOnly = $this->shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup, $request);
list($timeLookBack, $timeLookAhead) = $this->getWindowLookupThisVisit($request);
$visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
$isNewVisitForced = $request->getParam('new_visit');
$isNewVisitForced = !empty($isNewVisitForced);
$enforceNewVisit = $isNewVisitForced || $this->trackerAlwaysNewVisitor;
if (!$enforceNewVisit && $visitRow && count($visitRow) > 0) {
// These values will be used throughout the request
foreach ($persistedVisitAttributes as $field) {
$visitProperties->setProperty($field, $visitRow[$field]);
}
$visitProperties->setProperty('visit_last_action_time', strtotime($visitRow['visit_last_action_time']));
$visitProperties->setProperty('visit_first_action_time', strtotime($visitRow['visit_first_action_time']));
// Custom Variables copied from Visit in potential later conversion
if (!empty($numCustomVarsToRead)) {
for ($i = 1; $i <= $numCustomVarsToRead; $i++) {
if (isset($visitRow['custom_var_k' . $i]) && strlen($visitRow['custom_var_k' . $i])) {
$visitProperties->setProperty('custom_var_k' . $i, $visitRow['custom_var_k' . $i]);
}
if (isset($visitRow['custom_var_v' . $i]) && strlen($visitRow['custom_var_v' . $i])) {
$visitProperties->setProperty('custom_var_v' . $i, $visitRow['custom_var_v' . $i]);
}
}
}
Common::printDebug("The visitor is known (idvisitor = " . bin2hex($visitProperties->getProperty('idvisitor')) . ",\n config_id = " . bin2hex($configId) . ",\n idvisit = {$visitProperties->getProperty('idvisit')},\n last action = " . date("r", $visitProperties->getProperty('visit_last_action_time')) . ",\n first action = " . date("r", $visitProperties->getProperty('visit_first_action_time')) . ",\n visit_goal_buyer' = " . $visitProperties->getProperty('visit_goal_buyer') . ")");
return true;
} else {
Common::printDebug("The visitor was not matched with an existing visitor...");
return false;
}
}
示例15: recordLogs
public function recordLogs(VisitProperties $visitProperties, Request $request)
{
// if we successfully record some data and the date is older than the site's created time,
// update the created time so the data will be viewable in the UI
$idSite = $request->getIdSite();
$createdTimeTimestamp = $this->getSiteCreatedTime($idSite);
if (empty($createdTimeTimestamp)) {
return;
}
$requestTimestamp = Date::factory((int) $request->getCurrentTimestamp());
// replicating old Piwik logic, see:
// https://github.com/piwik/piwik/blob/baa6da86266c7c44bc2d65821c7ffe042c2f4716/core/Archive/ArchiveInvalidator.php#L150
// before when this was done during archive invalidation, the date would not have an attached time and
// one extra day was subtracted from the minimum.
// I am not sure why this is required or if it is still required, but some tests that check the contents
// of archive tables will fail w/o this.
$requestTimestamp = $requestTimestamp->subDay(1)->setTime('00:00:00');
if ($requestTimestamp->isEarlier($createdTimeTimestamp)) {
$this->updateSiteCreatedTime($idSite, $requestTimestamp);
}
}