Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail

Package s2Member\Files

s2member\includes\classes\files.inc.php at line #28

Class c_ws_plugin__s2member_files

c_ws_plugin__s2member_files

public class c_ws_plugin__s2member_files

File Download routines for s2Member.

Since:

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

max_download_period()

Determines the max period (in days), for Download Access.

public static bool|int

min_level_4_downloads()

Determines the minimum Level required for File Download Access.

public static bool

no_gzip_rules_in_root_htaccess()

Checks for GZIP rules in root .htaccess file.

public static bool

remove_no_gzip_from_root_htaccess()

Removes no GZIP rules in root .htaccess file.

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 .htaccess file.

( 13 Methods )
Method Detail

s2member\includes\classes\files.inc.php at line #90

amazon_cf_auto_configure_distros()

public static bool|array amazon_cf_auto_configure_distros()

Auto-configures Amazon® CloudFront distros.

Since:

130209

Returns:

bool|array - True on success, else array on failure. Failure array will contain a failure code, and a failure message.

[ back to top ]

s2member\includes\classes\files.inc.php at line #77

amazon_s3_auto_configure_acls()

public static bool|array amazon_s3_auto_configure_acls()

Auto-configures an Amazon® S3 Bucket's ACLs.

Since:

110926

Returns:

bool|array - True on success, else array on failure. Failure array will contain a failure code, and a failure message.

[ back to top ]

s2member\includes\classes\files.inc.php at line #44

check_file_download_access()

public static null|str check_file_download_access(array $create_file_download_url)

Handles Download Access permissions.

Since:

110524RC

Attaches-to:

add_action("init");

Also-called-by:

API Function s2Member\API_Functionss2member_file_download_url(), w/ $create_file_download_url param.

Parameters:

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.

Returns:

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.

[ back to top ]

s2member\includes\classes\files.inc.php at line #64

create_file_download_url()

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.

Since:

110926

Parameters:

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.

Returns:

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.

See Also:

s2Member\API_Functionss2member_file_download_url()

[ back to top ]

s2member\includes\classes\files.inc.php at line #152

file_download_key()

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.

Since:

3.5

Parameters:

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.

Returns:

str - A Download Key. MD5 hash, 32 characters, URL-safe.

[ back to top ]

s2member\includes\classes\files.inc.php at line #105

max_download_period()

public static int max_download_period()

Determines the max period (in days), for Download Access.

Since:

3.5

Returns:

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:

Deprecated in v111029. This function is no longer used by s2Member.

[ back to top ]

s2member\includes\classes\files.inc.php at line #125

min_level_4_downloads()

public static bool|int min_level_4_downloads()

Determines the minimum Level required for File Download Access.

Since:

3.5

Returns:

bool|int - False if no access is allowed, else Level number (int) 0+.

[ back to top ]

s2member\includes\classes\files.inc.php at line #302

no_gzip_rules_in_root_htaccess()

public static bool no_gzip_rules_in_root_htaccess()

Checks for GZIP rules in root .htaccess file.

Since:

120212

Returns:

bool - True if rules exist, else false.

[ back to top ]

s2member\includes\classes\files.inc.php at line #357

remove_no_gzip_from_root_htaccess()

public static bool remove_no_gzip_from_root_htaccess()

Removes no GZIP rules in root .htaccess file.

Since:

120212

Returns:

bool - True if successful, else false on any type of failure.

[ back to top ]

s2member\includes\classes\files.inc.php at line #238

total_downloads_of()

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.

Since:

111026

Parameters:

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.

Returns:

int - The total for this particular $file, based on configuration of function arguments.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

[ back to top ]

s2member\includes\classes\files.inc.php at line #273

total_unique_downloads_of()

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.

Since:

111026

Parameters:

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.

Returns:

int - The total for this particular $file, based on configuration of function arguments.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

[ back to top ]

s2member\includes\classes\files.inc.php at line #189

user_downloads()

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.

Since:

3.5

Parameters:

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).

Returns:

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.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

[ back to top ]

s2member\includes\classes\files.inc.php at line #321

write_no_gzip_into_root_htaccess()

public static bool write_no_gzip_into_root_htaccess()

Writes no GZIP rules into root .htaccess file.

Since:

120212

Returns:

bool - True if successfull, else false on any type of failure.

[ back to top ]

Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail