BSF_Envato_Activate::validate_token( string $token, int $product_id )

Validate Token.


Description


Parameters

$token

(string) (Required) Token.

$product_id

(int) (Required) Product ID.


Return

(bool.)


Source

File: admin/bsf-core/class-bsf-envato-activate.php

	protected function validate_token( $token, $product_id ) {

		$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );

		if ( sha1( $stored_token ) === $token ) {
			$token_atts = explode( '|', $stored_token );

			$stored_id = $token_atts[0];

			if ( $stored_id !== $product_id ) {
				// Token is invalid.
				return false;
			}

			$timestamp   = (int) $token_atts[1];
			$valid_ultil = $timestamp + 900;

			if ( current_time( 'timestamp' ) > $valid_ultil ) {
				// Timestamp has expired.
				return false;
			}

			// If above conditions did not meet, the token is valid.
			return true;
		}

		return false;
	}


User Contributed Notes

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