llms_track_spam_activity( string|null $ip = null )

Track spam activity.


Description Description

When we hit a certain number, the spam flag will trigger.
For now we are only tracking credit card declines their timestamps.
IP address isn’t a perfect way to track this, but it’s the best we have.


Top ↑

Parameters Parameters

$ip

(string|null) (Optional) The IP address to track activity for, or leave as null to attempt to determine current IP address.

Default value: null


Top ↑

Return Return

(bool) True if the tracking of activity was successful, or false if IP could not be determined.


Top ↑

Source Source

File: includes/llms.spam.functions.php

function llms_track_spam_activity( $ip = null ) {
	if ( empty( $ip ) ) {
		$ip = llms_get_ip_address();
	}

	// If we can't determine the IP, let's bail.
	if ( empty( $ip ) ) {
		return false;
	}

	$activity = llms_get_spam_activity( $ip );
	$now      = time(); // UTC
	array_unshift( $activity, $now );

	// If we have more than the limit, don't bother storing them.
	if ( count( $activity ) > absint( LLMS_SPAM_ACTION_NUM_LIMIT ) ) {
		rsort( $activity );
		$activity = array_slice( $activity, 0, absint( LLMS_SPAM_ACTION_NUM_LIMIT ) );
	}

	// Save to transient.
	$ip            = preg_replace( '/[^0-9a-fA-F:., ]/', '', $ip );
	$transient_key = 'llms_spam_activity_' . $ip;
	set_transient( $transient_key, $activity, (int) absint( LLMS_SPAM_ACTION_TIME_LIMIT ) );

	return true;
}


Top ↑

Changelog Changelog

Changelog
Version Description
9.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.