entities
10 years ago
managers
10 years ago
sdk
10 years ago
class-freemius-abstract.php
10 years ago
class-freemius.php
10 years ago
class-fs-api.php
10 years ago
class-fs-logger.php
10 years ago
class-fs-plugin-updater.php
10 years ago
class-fs-security.php
10 years ago
fs-core-functions.php
10 years ago
fs-plugin-functions.php
10 years ago
i18n.php
10 years ago
class-fs-security.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package Freemius |
| 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 6 | * @since 1.0.3 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' ); |
| 14 | |
| 15 | class FS_Security { |
| 16 | /** |
| 17 | * @var FS_Security |
| 18 | * @since 1.0.3 |
| 19 | */ |
| 20 | private static $_instance; |
| 21 | /** |
| 22 | * @var FS_Logger |
| 23 | * @since 1.0.3 |
| 24 | */ |
| 25 | private static $_logger; |
| 26 | |
| 27 | public static function instance() { |
| 28 | if ( ! isset( self::$_instance ) ) { |
| 29 | self::$_instance = new FS_Security(); |
| 30 | self::$_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK ); |
| 31 | } |
| 32 | |
| 33 | return self::$_instance; |
| 34 | } |
| 35 | |
| 36 | private function __construct() { |
| 37 | } |
| 38 | |
| 39 | function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) { |
| 40 | return md5( |
| 41 | $timestamp . |
| 42 | $entity->id . |
| 43 | $entity->secret_key . |
| 44 | $entity->public_key . |
| 45 | $action |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) { |
| 50 | if ( false === $timestamp ) { |
| 51 | $timestamp = time(); |
| 52 | } |
| 53 | |
| 54 | return array( |
| 55 | 's_ctx_type' => $entity->get_type(), |
| 56 | 's_ctx_id' => $entity->id, |
| 57 | 's_ctx_ts' => $timestamp, |
| 58 | 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ), |
| 59 | ); |
| 60 | } |
| 61 | } |