public function __construct(Pap_Tracking_Action_RequestActionObject $requestActionObject = null, Pap_Db_Visit $visit = null) { if ($requestActionObject == null) { $requestActionObject = new Pap_Tracking_Action_RequestActionObject(); } $this->requestActionObject = $requestActionObject; $this->visit = $visit; if ($visit != null) { $this->setVisitorId($visit->getVisitorId()); } $this->setTransactionObject(new Pap_Common_Transaction()); parent::__construct(); }
public function getReferrerUrl() { if ($this->visit == null) { return null; } return $this->visit->getReferrerUrl(); }
public function processVisit(Pap_Db_Visit $visit) { $compoundContext = new Gpf_Data_Record(array(self::IP, self::COUNTRYCODE), array($visit->getIp(), '')); $this->getCountryCode($compoundContext); $countryCode = $compoundContext->get(self::COUNTRYCODE); if (!strlen($countryCode)) { Gpf_Log::debug("Preprocessing visit error: country code not recognized from IP " . $visit->getIp()); return; } Gpf_Log::debug('Preprocessing visit: found country code ' . $countryCode . ', resolved from IP ' . $visit->getIp() . ', and setting it to visit'); $visit->setCountryCode($countryCode); }
private function processVisitsFrom($tableIndex) { $this->updateRowsToBeProcessed($tableIndex); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_Visits::getInstance($tableIndex)); $selectBuilder->from->add(Pap_Db_Table_Visits::getName($tableIndex)); $selectBuilder->where->add(Pap_Db_Table_Visits::RSTATUS, '=', Pap_Db_Visit::INPROCESSING); $this->initVisitsWhere($selectBuilder->where); foreach ($selectBuilder->getAllRowsIterator() as $visitRecord) { $visit = new Pap_Db_Visit($tableIndex); $visit->fillFromRecord($visitRecord); $this->processAndUpdateVisit($visit); } }
/** * @return Pap_Db_Visit */ protected function getNextVisit($processedTableIndex) { $this->debug('Loading next unprocessed visit from database.'); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->from->add(Pap_Db_Table_Visits::getName($processedTableIndex)); $selectBuilder->select->addAll(Pap_Db_Table_Visits::getInstance($processedTableIndex)); $selectBuilder->where->add(Pap_Db_Table_Visits::RSTATUS, '=', Pap_Db_Visit::UNPROCESSED); $selectBuilder->where->add(Pap_Db_Table_Visits::VISITORID_HASH, '=', $this->task->getWorkingAreaFrom()); $selectBuilder->limit->set(0, 1); $visit = new Pap_Db_Visit($processedTableIndex); try { $visit->fillFromSelect($selectBuilder); return $visit; } catch (Gpf_Exception $e) { return false; } }
protected function loadCookies(Pap_Db_Visit $visit) { $cookiesArray = array(); $args = explode('||', ltrim($visit->getCookies(), '|'));; foreach ($args as $arg) { $parsedParams = explode('=', $arg); if (count($parsedParams)>=2) { list($argName, $argValue) = $parsedParams; if ($argValue != '') { $cookiesArray[$argName] = urldecode($argValue); } } } $cookies = new Pap_Tracking_Cookie($cookiesArray); try { $this->firstClickCookie = $this->getClickCookie($cookies->getFirstClickCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } try { $this->lastClickCookie = $this->getClickCookie($cookies->getLastClickCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } try { $this->saleCookie = $this->getSaleCookie($cookies->getSaleCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } }
/** * * @return Pap_Db_Visit */ protected function createVisit() { $visit = new Pap_Db_Visit(Gpf_Settings::get(Pap_Settings::VISITS_TABLE_INPUT)); $visit->setSaleParams($this->getJSONsale()); $visit->setCookies($this->getCookieParams()); $visit->setVisitorId($this->getVisitorId()); $visit->setAccountId($this->getAccountId()); $visit->setTrackMethod($this->getTrackMethod()); $visit->setIp(@Gpf_Http::getRemoteIp()); $visit->setUserAgent(@$_SERVER['HTTP_USER_AGENT']); $visit->setDateVisit(Gpf_Common_DateUtils::now()); $visit->setReferrerUrl($this->referrer); $visit->setVisitorIdHash(sprintf('%u', crc32($this->getVisitorId())) % 255); return $visit; }
Lib_VisitorCookie::readVisitorIdAndAccountId($params, $settings); if ($settings->isOfflineVisitProcessing()) { $settings->saveVisit($params, $settings->get('visitsTableInput')); if ($settings->isOnlineSaleProcessingEnabled() && $params->isSale()) { require_once 'bootstrap.php'; @include_once('../include/Compiled/Tracking.php'); Gpf_Session::create(new Pap_Tracking_ModuleBase(), null, false); $singleVisitorProcessor = new Pap_Tracking_Visit_SingleVisitorProcessor($params->getVisitorId(), $params->getAccountId(), $params->getIp()); $singleVisitorProcessor->processAllVisitorVisits(); } return; } require_once 'bootstrap.php'; @include_once('../include/Compiled/Tracking.php'); Gpf_Session::create(new Pap_Tracking_ModuleBase(), null, false); $visit = new Pap_Db_Visit(); foreach ($params->toArray() as $key => $value) { $visit->set($key, $value); } $processor = new Pap_Tracking_Visit_Processor(); $processor->runOnline($visit); } catch(Exception $e) { echo '//' . $e->getMessage() . "\n"; } ?>