FS_Security

The NextGEN Gallery FS Security class.

Defined (1)

The class is defined in the following location(s).

/freemius/includes/class-fs-security.php  
  1. class FS_Security { 
  2. /** 
  3. * @var FS_Security 
  4. * @since 1.0.3 
  5. */ 
  6. private static $_instance; 
  7. /** 
  8. * @var FS_Logger 
  9. * @since 1.0.3 
  10. */ 
  11. private static $_logger; 
  12.  
  13. public static function instance() { 
  14. if ( ! isset( self::$_instance ) ) { 
  15. self::$_instance = new FS_Security(); 
  16. self::$_logger = FS_Logger::get_logger( 
  17. WP_FS__SLUG,  
  18. WP_FS__DEBUG_SDK,  
  19. WP_FS__ECHO_DEBUG_SDK 
  20. ); 
  21.  
  22. return self::$_instance; 
  23.  
  24. private function __construct() { 
  25.  
  26. /** 
  27. * @param \FS_Scope_Entity $entity 
  28. * @param int $timestamp 
  29. * @param string $action 
  30. * @return string 
  31. */ 
  32. function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) { 
  33. return md5( 
  34. $timestamp . 
  35. $entity->id . 
  36. $entity->secret_key . 
  37. $entity->public_key . 
  38. $action 
  39. ); 
  40.  
  41. /** 
  42. * @param \FS_Scope_Entity $entity 
  43. * @param int|bool $timestamp 
  44. * @param string $action 
  45. * @return array 
  46. */ 
  47. function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) { 
  48. if ( false === $timestamp ) { 
  49. $timestamp = time(); 
  50.  
  51. return array( 
  52. 's_ctx_type' => $entity->get_type(),  
  53. 's_ctx_id' => $entity->id,  
  54. 's_ctx_ts' => $timestamp,  
  55. 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),  
  56. );