Ejemplo n.º 1
0
 public function process(Pap_Contexts_Action $context) {
     $context->debug('Started checking md5 checksums');
     $checksum = $context->getExtraDataFromRequest(Gpf_Settings::get(SaleFraudProtection_Config::PARAM_NAME));
 
     $myChecksum = $this->createCheckSum($context->getTotalCostFromRequest(), $context->getOrderIdFromRequest());
     if ($checksum == $myChecksum) {
         $context->debug('Checkings md5 checksums finished. Checksums equals.');
         return;
     }
     $context->debug('Checking md5 checksums failed. Transaction not saved. Checksums: '.$checksum.' - '.$myChecksum);
     $context->setDoCommissionsSave(false);
 }
Ejemplo n.º 2
0
    public function checkActionFraudProtection(Pap_Contexts_Action $context) {
        $checkIt = Gpf_Settings::get(Pap_Settings::GEOIP_SALES);
        if($checkIt != Gpf::YES) {
            $context->debug('    PapGeoip: Check for blacklisted countries is not turned on');
            return true;
        }

        $context->debug('    PapGeoip: Check if origin country of visitor related to action is not blacklisted started ');

        $blacklistedCountries = str_replace(' ', ',', trim(strtoupper(Gpf_Settings::get(Pap_Settings::GEOIP_SALES_BLACKLIST))));
        $checkAction = Gpf_Settings::get(Pap_Settings::GEOIP_SALES_BLACKLIST_ACTION);

        if($blacklistedCountries == '') {
            $context->debug("PapGeoip: No country is blacklisted.");
            return true;
        }
        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 true;
        }

        $countryCode = strtoupper($context->getCountryCode());
        if (!strlen($countryCode)) {
            $context->debug("    PapGeoip: Origin country was not recognized.");
            return true;
        }

        $arrBlacklist = explode(',', $blacklistedCountries);

        if(in_array($countryCode, $arrBlacklist)) {
            if($checkAction == Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) {
                $context->debug("    PapGeoip: STOPPING (setting setDoCommissionsSave(false), country $countryCode is blacklisted");
                $context->setDoCommissionsSave(false);
                $context->debug('      PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded');
                return false;
            } else {
                $context->debug("  PapGeoip: DECLINING, country $countryCode is blacklisted");
                $this->declineAction($context, $this->_('PapGeoip: Country %s is blacklisted', $countryCode));
                $context->debug('      PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded');
                return true;
            }
        } else {
            $context->debug("    Country is not blacklisted");
        }

        $context->debug('      PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded');
        return true;

    }
    /**
     *
     * @param Pap_Db_Visit $visit
     * @return Pap_Contexts_Action
     */
    private function processAccount(Pap_Db_Visit $visit) {
        $context = new Pap_Contexts_Action();
        $context->setVisit($visit);
        $context->setDoCommissionsSave(true);
        $context->setDoTrackerSave(true);

        $this->accountRecognizer->recognize($context);
        Gpf_Plugins_Engine::extensionPoint('Pap_Tracking_Action_ActionProcessor.processAccount', $context);
        return $context;
    }
    /**
     * checks for duplicate records from same IP
     *
     * @param Pap_Contexts_Action $context
     * @return string
     */
    private function checkSalesFromBannedIP(Pap_Contexts_Action $context) {
        $checkIt = Gpf_Settings::get(Pap_Settings::BANNEDIPS_SALES);
        if($checkIt != Gpf::YES) {
            $context->debug('    Check for sales / leads with banned IP is not turned on');
            return true;
        }

        $context->debug('    Checking banned IP address of sales / leads started');


        $bannedIPAddresses = Gpf_Net_Ip::getBannedIPAddresses(Pap_Settings::BANNEDIPS_LIST_SALES);

        if($bannedIPAddresses === false) {
            $context->debug("List of banned IP addresses is invalid or empty, stop checking");
            return true;
        }

        $checkAction = Gpf_Settings::get(Pap_Settings::BANNEDIPS_SALES_ACTION);
        if($checkAction != self::ACTION_DECLINE && $checkAction != self::ACTION_DONTSAVE) {
            $context->debug("Action after check is not correct: '$checkAction'");
            return true;
        }

        $ip = $context->getIp();
        if(Gpf_Net_Ip::ipMatchRange($ip, $bannedIPAddresses)) {
            if($checkAction == self::ACTION_DONTSAVE) {
                $context->debug("    STOPPING (setting setDoCommissionsSave(false), IP: $ip is banned");
                $context->setDoCommissionsSave(false);
                $context->debug('      Checking banned IP of sales / leads endeded');
                return false;

            } else {
                $context->debug("  DECLINING, IP is banned: $ip");

                $message = Gpf_Settings::get(Pap_Settings::BANNEDIPS_SALES_MESSAGE);

                $this->declineAction($context, $message);

                $context->debug('      Checking banned IP of sales / leads endeded');
                return true;
            }
        } else {
            $context->debug("    IP $ip is not banned");
        }

        $context->debug('      Checking banned IP of sales / leads endeded');
        return true;
    }