示例#1
0
    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');
    }
示例#2
0
	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;
	}