c_ws_plugin__s2member_files
public class c_ws_plugin__s2member_files
3.5
( 13 Methods ) Method Summary | |
---|---|
public static bool|array | amazon_cf_auto_configure_distros() Auto-configures Amazon® CloudFront distros. |
public static bool|array | amazon_s3_auto_configure_acls() Auto-configures an Amazon® S3 Bucket's ACLs. |
public static null|str | check_file_download_access(array $create_file_download_url) Handles Download Access permissions. |
public static str | create_file_download_url(array $config, bool $get_streamer_array) Generates a File Download URL for access to a file protected by s2Member. |
public static str | file_download_key(str $file, str $directive) Creates a File Download Key. |
public static int | Determines the max period (in days), for Download Access. |
public static bool|int | Determines the minimum Level required for File Download Access. |
public static bool | no_gzip_rules_in_root_htaccess() Checks for GZIP rules in root |
public static bool | remove_no_gzip_from_root_htaccess() Removes no GZIP rules in root |
public static int | total_downloads_of(str $file, str|int $user_id, bool $check_archives_too) Total downloads of a particular file; possibly by a particular User. |
public static int | total_unique_downloads_of(str $file, str|int $user_id, bool $check_archives_too) Total unique downloads of a particular file; possibly by a particular User. |
public static array | user_downloads(obj $user, str $not_counting_this_particular_file, array $user_log, array $user_arc) Download details on a per-User basis. |
public static bool | write_no_gzip_into_root_htaccess() Writes no GZIP rules into root |
public static bool|array amazon_cf_auto_configure_distros()
Auto-configures Amazon® CloudFront distros.
130209
bool|array - True on success, else array on failure. Failure array will contain a failure code
, and a failure message
.
public static bool|array amazon_s3_auto_configure_acls()
Auto-configures an Amazon® S3 Bucket's ACLs.
110926
bool|array - True on success, else array on failure. Failure array will contain a failure code
, and a failure message
.
public static null|str check_file_download_access(array $create_file_download_url)
Handles Download Access permissions.
110524RC
add_action("init");
API Function s2Member\API_Functions → s2member_file_download_url(), w/ $create_file_download_url
param.
array $create_file_download_url - Optional. If this function is called directly, we can pass arguments through this array. Possible array elements: file_download
(required), file_download_key
, file_stream
, file_inline
, file_storage
, file_remote
, file_ssl
, file_rewrite
, file_rewrite_base
, skip_confirmation
, url_to_storage_source
, count_against_user
, check_user
.
null|str - If called directly with $create_file_download_url
, returns a string with the URL, based on configuration. Else, this function may exit script execution after serving a File Download.
public static str create_file_download_url(array $config, bool $get_streamer_array)
Generates a File Download URL for access to a file protected by s2Member.
110926
array $config - Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine. Possible $config
array elements: file_download
(required), file_download_key
, file_stream
, file_inline
, file_storage
, file_remote
, file_ssl
, file_rewrite
, file_rewrite_base
, skip_confirmation
, url_to_storage_source
, count_against_user
, check_user
.
bool $get_streamer_array - Optional. Defaults to false
. If true
, this function will return an array with the following elements: streamer
, file
, url
. For further details, please review this section in your Dashboard: s2Member -› Download Options -› JW Player® & RTMP Protocol Examples
.
str - A File Download URL string on success; or an array on success, with elements streamer
, file
, url
when/if $get_streamer_array
is true; else false on any type of failure.
s2Member\API_Functions → s2member_file_download_url()
public static str file_download_key(str $file, str $directive)
Creates a File Download Key.
Builds a hash of: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file
.
3.5
str $file - Location of your protected file, relative to the /s2member-files/
directory. In other words, just the name of the file (i.e. file.zip
).
str $directive - Optional. One of ip-forever|universal|cache-compatible
. ip-forever
= a Download Key that never expires, tied only to a specific file and IP address. universal
and/or cache-compatible
= a Download Key which never expires, and is NOT tied to any specific User. Use at your own risk.
str - A Download Key. MD5 hash, 32 characters, URL-safe.
public static int max_download_period()
Determines the max period (in days), for Download Access.
3.5
int - Number of days, where 0 means no access to files is allowed. Will not return a value > 365
, because this routine also controls the age of download logs to archives.
Deprecated in v111029. This function is no longer used by s2Member.
public static bool|int min_level_4_downloads()
Determines the minimum Level required for File Download Access.
3.5
bool|int - False if no access is allowed, else Level number (int) 0+.
public static bool no_gzip_rules_in_root_htaccess()
Checks for GZIP rules in root .htaccess
file.
120212
bool - True if rules exist, else false.
public static bool remove_no_gzip_from_root_htaccess()
Removes no GZIP rules in root .htaccess
file.
120212
bool - True if successful, else false on any type of failure.
public static int total_downloads_of(str $file, str|int $user_id, bool $check_archives_too)
Total downloads of a particular file; possibly by a particular User.
111026
str $file - Required. Location of the file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
str|int $user_id - Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively (i.e among all Users/Members).
bool $check_archives_too - Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if $user_id
is specified, based solely on a specific User's allowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level.
int - The total for this particular $file
, based on configuration of function arguments.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
public static int total_unique_downloads_of(str $file, str|int $user_id, bool $check_archives_too)
Total unique downloads of a particular file; possibly by a particular User.
111026
str $file - Required. Location of the file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
str|int $user_id - Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively (i.e among all Users/Members).
bool $check_archives_too - Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if $user_id
is specified, based solely on a specific User's allowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level.
int - The total for this particular $file
, based on configuration of function arguments.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
public static array user_downloads(obj $user, str $not_counting_this_particular_file, array $user_log, array $user_arc)
Download details on a per-User basis.
3.5
obj $user - Optional. A WP_User
object. Defaults to the current User's object.
str $not_counting_this_particular_file - Optional. If you want to exclude a particular file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
array $user_log - Optional. Prevents another database connection (i.e. the User's log does not need to be pulled again).
array $user_arc - Optional. Prevents another database connection (i.e. the User's archive does not need to be pulled again).
array - An array with the following elements... File Downloads allowed for this User: (int)allowed
, Download Period for this User in days: (int)allowed_days
, Files downloaded by this User in the current Period: (int)currently
, log of all Files downloaded in the current Period, with file names/dates: (array)log
, archive of all Files downloaded in prior Periods, with file names/dates: (array)archive
.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
public static bool write_no_gzip_into_root_htaccess()
Writes no GZIP rules into root .htaccess
file.
120212
bool - True if successfull, else false on any type of failure.
File Download routines for s2Member.