PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 111017
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v111017
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / includes / classes / sc-files-in.inc.php

sc-files-in.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 111017, at includes/classes/sc-files-in.inc.php

87 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode `[s2File /]` ( inner processing routines ).
4 *
5 * Copyright: © 2009-2011
6 * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7 * ( coded in the USA )
8 *
9 * Released under the terms of the GNU General Public License.
10 * You should have received a copy of the GNU General Public License,
11 * along with this software. In the main directory, see: /licensing/
12 * If not, see: {@link http://www.gnu.org/licenses/}.
13 *
14 * @package s2Member\s2File
15 * @since 110926
16 */
17 if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18 exit ("Do not access this file directly.");
19 /**/
20 if (!class_exists ("c_ws_plugin__s2member_sc_files_in"))
21 {
22 /**
23 * Shortcode `[s2File /]` ( inner processing routines ).
24 *
25 * @package s2Member\s2File
26 * @since 110926
27 */
28 class c_ws_plugin__s2member_sc_files_in
29 {
30 /**
31 * Handles the Shortcode for: `[s2File /]`.
32 *
33 * @package s2Member\s2File
34 * @since 110926
35 *
36 * @attaches-to: ``add_shortcode("s2File");``
37 *
38 * @param array $attr An array of Attributes.
39 * @param str $content Content inside the Shortcode.
40 * @param str $shortcode The actual Shortcode name itself.
41 * @return str Value of requested File Download URL, streamer array element; or null on failure.
42 */
43 public static function sc_get_file ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
44 {
45 eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
46 do_action ("ws_plugin__s2member_before_sc_get_file", get_defined_vars ());
47 unset ($__refs, $__v); /* Unset defined __refs, __v. */
48 /**/
49 $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep ((array)$attr); /* Force array; trim quote entities. */
50 /**/
51 $attr = shortcode_atts (array ("download" => "", "download_key" => "", "stream" => "", "inline" => "", "storage" => "", "remote" => "", "ssl" => "", "rewrite" => "", "rewrite_base" => "", "skip_confirmation" => "", "url_to_storage_source" => "", "count_against_user" => "", "check_user" => "", /* Shortcode-specifics » */ "get_streamer_json" => "", "get_streamer_array" => ""), $attr);
52 /**/
53 eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
54 do_action ("ws_plugin__s2member_before_sc_get_file_after_shortcode_atts", get_defined_vars ());
55 unset ($__refs, $__v); /* Unset defined __refs, __v. */
56 /**/
57 $get_streamer_json = filter_var ($attr["get_streamer_json"], FILTER_VALIDATE_BOOLEAN); /* Getting streamer? */
58 $get_streamer_array = filter_var ($attr["get_streamer_array"], FILTER_VALIDATE_BOOLEAN); /* Streamer? */
59 $get_streamer_json = $get_streamer_array = ($get_streamer_array || $get_streamer_json) ? true : false;
60 /**/
61 foreach ($attr as $key => $value) /* Now we need to go through and a `file_` prefix to certain Attribute keys, for compatibility. */
62 if (strlen ($value) && in_array ($key, array ("download", "download_key", "stream", "inline", "storage", "remote", "ssl", "rewrite", "rewrite_base")))
63 $config["file_" . $key] = $value; /* Set prefixed config parameter here so we can pass properly in ``$config`` array. */
64 else if (strlen ($value) && !in_array ($key, array ("get_streamer_json", "get_streamer_array"))) /* Else, exclude? */
65 $config[$key] = $value;
66 /**/
67 unset ($key, $value); /* Ditch these now. We don't want these bleeding into Hooks/Filters anyway. */
68 /**/
69 if (!empty ($config) && isset ($config["file_download"])) /* Looking for a File Download URL? */
70 {
71 $_get = c_ws_plugin__s2member_files::create_file_download_url ($config, $get_streamer_array);
72 /**/
73 if ($get_streamer_array && $get_streamer_json && is_array ($_get))
74 $get = json_encode ($_get);
75 /**/
76 else if ($get_streamer_array && $get_streamer_json)
77 $get = "null"; /* Null object value. */
78 /**/
79 else if (!empty ($_get)) /* Else ``$get``. */
80 $get = $_get; /* Default return. */
81 }
82 /**/
83 return apply_filters ("ws_plugin__s2member_sc_get_file", ((isset ($get)) ? $get : null), get_defined_vars ());
84 }
85 }
86 }
87 ?>