/**
     * checks for duplicate signups from same IP
     *
     * @return boolean
     */
    private function checkMultipleSignupsFromSameIp(Pap_Signup_SignupFormContext $context) {
        $checkIt = Gpf_Settings::get(Pap_Settings::REPEATING_SIGNUPS_SETTING_NAME);
        if($checkIt != Gpf::YES) {
            return true;
        }

        $checkPeriod = Gpf_Settings::get(Pap_Settings::REPEATING_SIGNUPS_SECONDS_SETTING_NAME);
        $checkAction = Gpf_Settings::get(Pap_Settings::REPEATING_SIGNUPS_ACTION_SETTING_NAME);
        if($checkPeriod == '' || $checkPeriod == '0' || !is_numeric($checkPeriod)) {
            return true;
        }
        if($checkAction != self::ACTION_DECLINE && $checkAction != self::ACTION_DONTSAVE) {
            return true;
        }

        $userObject = new Pap_Common_User();

        $recordsCount = $userObject->getNumberOfUsersFromSameIP($context->getIp(), $checkPeriod);
        if(($recordsCount > 0) && ($checkAction == self::ACTION_DONTSAVE)) {
            $context->getForm()->setErrorMessage($this->_("Not saved by fraud protection"));
            $context->setAllowSave(false);
            return false;
        } else if (($recordsCount > 0) && ($checkAction == self::ACTION_DECLINE)) {
            $context->getRow()->setStatus(Gpf_Db_User::DECLINED);
        }
        return true;
    }
Ejemplo n.º 2
0
    public function checkSignupFraudProtection(Pap_Signup_SignupFormContext $context) {
        $checkIt = Gpf_Settings::get(Pap_Settings::GEOIP_AFFILIATES);
        if($checkIt != Gpf::YES) {
            return;
        }

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

        if($blacklistedCountries == '') {
            return;
        }
        if($checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DECLINE && $checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) {
            return;
        }

        $countryContext = new Gpf_Data_Record(
        array(Pap_Db_Table_RawImpressions::IP, Pap_Db_Table_Impressions::COUNTRYCODE), array($context->getIp(), ''));
        $this->getCountryCode($countryContext);

        if (!strlen($countryContext->get(Pap_Db_Table_Impressions::COUNTRYCODE))) {
            return;
        }

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

        if(in_array(strtoupper($countryContext->get(Pap_Db_Table_Impressions::COUNTRYCODE)), $arrBlacklist)) {
            if($checkAction == Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) {
                $context->getForm()->setErrorMessage($this->_("Not saved by geoip fraud protection - country code %s is blacklisted by merchant.", $countryContext->get(Pap_Db_Table_Impressions::COUNTRYCODE)));
                $context->setAllowSave(false);
            } else if ($checkAction == Pap_Tracking_Click_FraudProtection::ACTION_DECLINE) {
                $context->getRow()->setStatus(Gpf_Db_User::DECLINED);
            }
        }
    }