/** * returns user object from forced parameter AffiliateID * parameter name is dependent on track.js, where it is used. * * @return Pap_Common_Banner * @throws Gpf_Exception */ private function getBannerFromForcedParameter(Pap_Contexts_Click $context) { $id = $context->getForcedBannerId(); if($id == '') { $message = 'Banner id not found in forced parameter'; $context->debug($message); throw new Pap_Tracking_Exception($message); } $context->debug("Getting banner from forced request parameter. Banner Id: ".$id); return $this->getBannerById($context, $id); }
/** * returns user object from standard parameter from request * * @return string */ protected function getUserFromParameter(Pap_Contexts_Click $context) { $parameterName = Pap_Tracking_Request::getAffiliateClickParamName(); if($parameterName == '') { $context->debug(" Cannot get name of request parameter for affiliate ID"); return null; } $context->debug(" Trying to get affiliate from request parameter '$parameterName'"); $userId = $context->getAffiliateId(); if($userId != '') { $context->debug(" Setting affiliate from request parameter. Affiliate Id: ".$userId); return $this->getUserById($context, $userId); } $context->debug(" Affiliate not found in parameter"); return null; }
public function saveRotatorClick(Pap_Contexts_Click $context) { $context->debug('FEATURE BannerRotator: saveRotatorClick started'); if($context->getDoTrackerSave()) { $banner = $context->getBannerObject(); if($banner != null && is_object($banner) && $banner->getParentBanner()!=null){ $context->debug(' FEATURE BannerRotator: Saving rotator click'); $this->saveChildClick($banner, $context); } else { $context->debug(' FEATURE BannerRotator: Banner is not in rotator, skipping'); } } else { $context->debug('FEATURE BannerRotator: Saving in Tracker is disabled (getDoTrackerSave() returned false), continuing without saving'); } $context->debug('FEATURE BannerRotator: saveRotatorClick ended'); $context->debug(''); return Gpf_Plugins_Engine::PROCESS_CONTINUE; }
public function checkClickFraudProtection(Pap_Contexts_Click $context) { $checkIt = Gpf_Settings::get(Pap_Settings::GEOIP_CLICKS); if($checkIt != Gpf::YES) { $context->debug(' PapGeoip: Check country blacklist is not turned on for clicks'); return; } $context->debug(' PapGeoip: Check country blacklist started'); $blacklistedCountries = str_replace(' ', ',', trim(strtoupper(Gpf_Settings::get(Pap_Settings::GEOIP_CLICKS_BLACKLIST)))); $checkAction = Gpf_Settings::get(Pap_Settings::GEOIP_CLICKS_BLACKLIST_ACTION); if($blacklistedCountries == '') { $context->debug("PapGeoip: No country is blacklisted."); return; } if($checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DECLINE && $checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) { $context->debug("PapGeoip: Action after check is not correct: '$checkAction'"); return; } $countryCode = strtoupper($context->getCountryCode()); if (!strlen($countryCode)) { $context->debug(" PapGeoip: Origin country was not recognized for IP: " . $context->getVisit()->getIp()); return; } $arrBlacklist = explode(',', $blacklistedCountries); if(in_array($countryCode, $arrBlacklist)) { if($checkAction == Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) { $context->debug(" PapGeoip: STOPPING (setting setDoTrackerSave(false), country $countryCode is blacklisted"); $context->setDoTrackerSave(false); $context->debug(' PapGeoip: Check country blacklist endeded'); return; } else { $context->debug(" DECLINING, country $countryCode is blacklisted"); $this->declineClick($context); $context->debug(' PapGeoip: Check country blacklist endeded'); return; } } else { $context->debug(" Country $countryCode is not blacklisted"); } $context->debug(' PapGeoip: Check country blacklist endeded'); }
private function getCampaignFromBanner(Pap_Contexts_Click $context, $banner) { $campaignId = $banner->getCampaignId(); if($campaignId != '') { $context->debug(" Setting campaign. Campaign Id: ".$campaignId); return $this->getCampaignById($context, $campaignId); } $context->debug(" Campaign not found"); return null; }
/** * Sets status of transaction to declined and sets it's message * * @param Pap_Plugins_Tracking_Action_Context $context * @param string $checkMessage */ private function declineClick(Pap_Contexts_Click $context) { $context->setClickStatus(Pap_Db_ClickImpression::STATUS_DECLINED); }
private function isOverWriteEnabled(Pap_Contexts_Click $context) { $key = ''; if ($context->getCampaignObject() != null) { $key .= $context->getCampaignObject()->getId(); } $key .= '_'; if ($context->getUserObject() != null) { $key .= $context->getUserObject()->getId(); } if (!isset($this->overwriteSettings[$key])) { $this->overwriteSettings[$key] = $this->cookieObject->isOverwriteEnabled($context->getCampaignObject(), $context->getUserObject()); } return $this->overwriteSettings[$key]; }
private function createContext(Pap_Db_Visit $visit) { $context = new Pap_Contexts_Click(); $context->setDoTrackerSave(true); $context->setVisit($visit); $context->setVisitorId($visit->getVisitorId()); $context->setDateCreated($visit->getDateVisit()); $this->accountRecognizer->recognize($context); $this->visitorAffiliateCache->setAccountId($context->getAccountId()); return $context; }
public function setSaleCookie(Pap_Contexts_Click $context) { $userObject = $context->getUserObject(); $campaignObject = $context->getCampaignObject(); $channelValue = null; if($context->getChannelObject() != null) { $channelValue = $context->getChannelObject()->getId(); } $campaignId = 0; $lifetime = 0; if($campaignObject != null) { $campaignId = $campaignObject->getId(); } else { $this->debug("No campaign recognized"); } $lifetime = time() + self::getCookieLifetime($context); $cookie = new Pap_Tracking_Cookie_Sale(); $cookie->setAffiliateId($userObject->getId()); $cookie->setCampaignId($campaignId); $cookie->setChannelId($channelValue); $this->setCookie(self::SALE_COOKIE_NAME, $cookie, $lifetime, $this->isOverwriteEnabled($campaignObject, $userObject)); }
private function getClickParamsArray(Pap_Db_ClickImpression $click, Pap_Contexts_Click $context, Pap_Common_Banner $banner=null) { $columns = array(); $columns[Pap_Db_Table_ClicksImpressions::ACCOUNTID] = $context->getAccountId(); $columns[Pap_Db_Table_ClicksImpressions::USERID] = $context->getUserObject()->getId(); $columns[Pap_Db_Table_ClicksImpressions::BANNERID] = $banner == null ? '' : $banner->getId(); $columns[Pap_Db_Table_ClicksImpressions::PARENTBANNERID] = $banner == null ? '' : $banner->getParentBannerId(); $columns[Pap_Db_Table_ClicksImpressions::CAMPAIGNID] = $context->getCampaignObject() == null ? '' : $context->getCampaignObject()->getId(); $columns[Pap_Db_Table_ClicksImpressions::COUNTRYCODE] = $context->getCountryCode(); $columns[Pap_Db_Table_ClicksImpressions::CDATA1] = $context->getExtraDataFromRequest(1); $columns[Pap_Db_Table_ClicksImpressions::CDATA2] = $context->getExtraDataFromRequest(2); $columns[Pap_Db_Table_ClicksImpressions::CHANNEL] = $this->getChannel($context); $timeNow = new Gpf_DateTime($context->getVisitDateTime()); $columns[Pap_Db_Table_ClicksImpressions::DATEINSERTED] = $timeNow->format("Y-m-d H:00:00"); return $columns; }
public function setSaveClickCommission(Pap_Contexts_Click $context) { $context->debug('MaxCommission per referral checking.'); $commissionTypeId = $this->getCommissionTypeId($context); if ($commissionTypeId == null) { $context->debug('MaxCommission Commission type is null. Ended.'); return; } try { $maxReferralNumber = $this->getMaxReferralLimitNumber($commissionTypeId); } catch (Gpf_DbEngine_NoRowException $e) { $context->debug('MaxCommission limit per referral is not defined. Ended.'); return; } if ($maxReferralNumber == '' || $maxReferralNumber <= -1) { $context->debug('MaxCommission limit is not set.'); return; } try { $maxReferralTimePeriod = $this->getMaxReferralLimitTimePeriod($commissionTypeId); } catch (Gpf_DbEngine_NoRowException $e) { $maxReferralTimePeriod = -1; } $numberOfCommission = $this->getNumberOfAllTransactionPerClickCommission($context->getUserObject()->getId(), $commissionTypeId, $maxReferralTimePeriod); if ($numberOfCommission < $maxReferralNumber) { $context->debug('MaxCommission per referral limit is not full ('.$numberOfCommission.'/ '.$maxReferralNumber.'). Saved. Ended.'); return; } $context->setDoCommissionsSave(false); $context->debug('MaxCommission per referral is full (' . $numberOfCommission . '). Commission will be NOT SAVED. Ended.'); }
private function initTransactionObject(Pap_Contexts_Click $context) { $transaction = new Pap_Common_Transaction(); $transaction->setTotalCost(''); $transaction->generateNewTransactionId(); $transaction->setData1($context->getExtraDataFromRequest(1)); $transaction->setData2($context->getExtraDataFromRequest(2)); $transaction->set(Pap_Db_Table_Transactions::REFERER_URL, $context->getReferrerUrl()); $transaction->set(Pap_Db_Table_Transactions::IP, $context->getIp()); $transaction->set(Pap_Db_Table_Transactions::BROWSER, $context->getUserAgent()); $transaction->setType(Pap_Common_Constants::TYPE_CLICK); $transaction->setDateInserted($context->getVisitDateTime()); if ($context->getVisit()!= null && $context->getVisit()->getCountryCode() != '') { $transaction->setCountryCode($context->getVisit()->getCountryCode()); } $context->setTransactionObject($transaction); $context->debug("Transaction object set"); }
/** * @return Pap_Db_Channel * @throws Gpf_Exception */ private function getChannelFromParameter(Pap_Contexts_Click $context) { $context->debug('Trying to get channel from parameter'); return $this->getChannelById($context, $context->getChannelId()); }