s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members) - Version 2.8.4

Version Description

  • A new option was added under s2Member -> General Options -> De-Activation Safeguards. This new option allows you to disable the de-activation routines for the s2Member plugin, so that s2Member Roles, Capabilities, and your Configuration Options will be preserved in case s2Member is de-activated inadvertently. We recommend that you Safeguard all s2Member data on your system; so please have a look at this new option.
  • A bug was found in the Shortcode processor, related specifically to Buy Now buttons for Lifetime access. This bug has been corrected in s2Member v2.8.4.
  • Stable tag updated in support of tagged releases within the repository at WordPress.org.
Download this release

Release Info

Developer PriMoThemes
Plugin Icon 128x128 s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members)
Version 2.8.4
Comparing to
See all releases

Version 2.8.4

Files changed (160) hide show
  1. images/bg.fla +0 -0
  2. images/bg.png +0 -0
  3. images/brand-bg.fla +0 -0
  4. images/brand-bg.png +0 -0
  5. images/brand-dark.fla +0 -0
  6. images/brand-dark.png +0 -0
  7. images/brand-donations.fla +0 -0
  8. images/brand-donations.jpg +0 -0
  9. images/brand-favicon.fla +0 -0
  10. images/brand-favicon.png +0 -0
  11. images/brand-gradient-bg.fla +0 -0
  12. images/brand-gradient-bg.png +0 -0
  13. images/brand-icon.fla +0 -0
  14. images/brand-icon.png +0 -0
  15. images/brand-light.fla +0 -0
  16. images/brand-light.png +0 -0
  17. images/brand-tips.fla +0 -0
  18. images/brand-tips.png +0 -0
  19. images/brand-tools.fla +0 -0
  20. images/brand-tools.png +0 -0
  21. images/brand-updates.fla +0 -0
  22. images/brand-updates.png +0 -0
  23. images/brand-xlink.fla +0 -0
  24. images/brand-xlink.png +0 -0
  25. images/index.php +0 -0
  26. images/logo.fla +0 -0
  27. images/logo.png +0 -0
  28. images/promos/150x150.jpg +0 -0
  29. images/promos/300x225.jpg +0 -0
  30. images/promos/590x300.jpg +0 -0
  31. images/promos/80x80.jpg +0 -0
  32. images/promos/900x285.jpg +0 -0
  33. images/promos/900x385.jpg +0 -0
  34. images/promos/index.php +0 -0
  35. images/wordpress-dark.fla +0 -0
  36. images/wordpress-dark.png +0 -0
  37. images/wordpress-light.fla +0 -0
  38. images/wordpress-light.png +0 -0
  39. includes/funcs.inc.php +24 -0
  40. includes/functions/activate-deactivate.inc.php +185 -0
  41. includes/functions/admin-lockout.inc.php +30 -0
  42. includes/functions/admin-notices.inc.php +78 -0
  43. includes/functions/catg-level-access.inc.php +103 -0
  44. includes/functions/constants.inc.php +189 -0
  45. includes/functions/email-configs.inc.php +36 -0
  46. includes/functions/file-download-access.inc.php +124 -0
  47. includes/functions/hide-some-systematics.inc.php +31 -0
  48. includes/functions/index.php +0 -0
  49. includes/functions/is-systematic.inc.php +64 -0
  50. includes/functions/js-globals.inc.php +125 -0
  51. includes/functions/login-customizations.inc.php +70 -0
  52. includes/functions/login-redirection.inc.php +40 -0
  53. includes/functions/max-download-period.inc.php +44 -0
  54. includes/functions/menu-pages.inc.php +297 -0
  55. includes/functions/min-level-4-downloads.inc.php +41 -0
  56. includes/functions/nocache.inc.php +80 -0
  57. includes/functions/page-level-access.inc.php +61 -0
  58. includes/functions/paypal-notify.inc.php +301 -0
  59. includes/functions/paypal-postvars.inc.php +71 -0
  60. includes/functions/paypal-register.inc.php +40 -0
  61. includes/functions/paypal-return.inc.php +274 -0
  62. includes/functions/post-level-access.inc.php +58 -0
  63. includes/functions/profile-modifications.inc.php +73 -0
  64. includes/functions/ptag-level-access.inc.php +87 -0
  65. includes/functions/readme-parsing.inc.php +92 -0
  66. includes/functions/register-access.inc.php +198 -0
  67. includes/functions/ruri-level-access.inc.php +45 -0
  68. includes/functions/shortcodes.inc.php +59 -0
  69. includes/functions/translations.inc.php +64 -0
  70. includes/functions/user-access-level.inc.php +47 -0
  71. includes/functions/user-deletions.inc.php +39 -0
  72. includes/functions/user-downloads.inc.php +58 -0
  73. includes/functions/users-list.inc.php +129 -0
  74. includes/functions/utilities.inc.php +200 -0
  75. includes/hooks.inc.php +71 -0
  76. includes/index.php +0 -0
  77. includes/markdown/index.php +0 -0
  78. includes/markdown/nc-markdown.inc.php +1469 -0
  79. includes/menu-pages/api-ops.inc.php +268 -0
  80. includes/menu-pages/button.html +32 -0
  81. includes/menu-pages/buttons.inc.php +281 -0
  82. includes/menu-pages/con-samps/current_user_access_label.php +3 -0
  83. includes/menu-pages/con-samps/current_user_access_level.php +13 -0
  84. includes/menu-pages/con-samps/current_user_custom.php +3 -0
  85. includes/menu-pages/con-samps/current_user_display_name.php +3 -0
  86. includes/menu-pages/con-samps/current_user_downloads_allowed.php +3 -0
  87. includes/menu-pages/con-samps/current_user_downloads_allowed_days.php +3 -0
  88. includes/menu-pages/con-samps/current_user_downloads_allowed_is_unlimited.php +2 -0
  89. includes/menu-pages/con-samps/current_user_downloads_currently.php +3 -0
  90. includes/menu-pages/con-samps/current_user_email.php +3 -0
  91. includes/menu-pages/con-samps/current_user_fields.php +7 -0
  92. includes/menu-pages/con-samps/current_user_first_name.php +3 -0
  93. includes/menu-pages/con-samps/current_user_id.php +3 -0
  94. includes/menu-pages/con-samps/current_user_ip.php +3 -0
  95. includes/menu-pages/con-samps/current_user_is_logged_in.php +3 -0
  96. includes/menu-pages/con-samps/current_user_last_name.php +3 -0
  97. includes/menu-pages/con-samps/current_user_login.php +3 -0
  98. includes/menu-pages/con-samps/current_user_profile_modification_page_url.php +8 -0
  99. includes/menu-pages/con-samps/current_user_registration_days.php +15 -0
  100. includes/menu-pages/con-samps/current_user_registration_time.php +3 -0
  101. includes/menu-pages/con-samps/current_user_subscr_id.php +5 -0
  102. includes/menu-pages/con-samps/file_download_limit_exceeded_page_url.php +3 -0
  103. includes/menu-pages/con-samps/level1_file_downloads_allowed.php +3 -0
  104. includes/menu-pages/con-samps/level1_file_downloads_allowed_days.php +3 -0
  105. includes/menu-pages/con-samps/level1_label.php +3 -0
  106. includes/menu-pages/con-samps/level2_file_downloads_allowed.php +3 -0
  107. includes/menu-pages/con-samps/level2_file_downloads_allowed_days.php +3 -0
  108. includes/menu-pages/con-samps/level2_label.php +3 -0
  109. includes/menu-pages/con-samps/level3_file_downloads_allowed.php +3 -0
  110. includes/menu-pages/con-samps/level3_file_downloads_allowed_days.php +3 -0
  111. includes/menu-pages/con-samps/level3_label.php +3 -0
  112. includes/menu-pages/con-samps/level4_file_downloads_allowed.php +3 -0
  113. includes/menu-pages/con-samps/level4_file_downloads_allowed_days.php +3 -0
  114. includes/menu-pages/con-samps/level4_label.php +3 -0
  115. includes/menu-pages/con-samps/login_page_url.php +4 -0
  116. includes/menu-pages/con-samps/login_welcome_page_url.php +4 -0
  117. includes/menu-pages/con-samps/logout_page_url.php +4 -0
  118. includes/menu-pages/con-samps/membership_options_page_url.php +4 -0
  119. includes/menu-pages/con-samps/paypal_business.php +3 -0
  120. includes/menu-pages/con-samps/paypal_endpoint.php +3 -0
  121. includes/menu-pages/con-samps/paypal_notify_url.php +3 -0
  122. includes/menu-pages/con-samps/paypal_return_url.php +3 -0
  123. includes/menu-pages/con-samps/reg_email_from_email.php +3 -0
  124. includes/menu-pages/con-samps/reg_email_from_name.php +3 -0
  125. includes/menu-pages/cur-samps.php +33 -0
  126. includes/menu-pages/down-ops.inc.php +189 -0
  127. includes/menu-pages/drip-samps.php +9 -0
  128. includes/menu-pages/events.inc.php +118 -0
  129. includes/menu-pages/index.php +0 -0
  130. includes/menu-pages/info.inc.php +56 -0
  131. includes/menu-pages/menu-pages.css +458 -0
  132. includes/menu-pages/menu-pages.js +217 -0
  133. includes/menu-pages/mod-samps.php +33 -0
  134. includes/menu-pages/options.inc.php +964 -0
  135. includes/menu-pages/paypal-ops.inc.php +241 -0
  136. includes/menu-pages/s2m-samps.php +33 -0
  137. includes/menu-pages/scripting.inc.php +318 -0
  138. includes/menu-pages/shortcode.html +1 -0
  139. includes/menu-pages/trk-ops.inc.php +118 -0
  140. includes/mime-types.ini +313 -0
  141. includes/profile.inc.php +124 -0
  142. includes/s2member-min.js +1 -0
  143. includes/s2member.js +105 -0
  144. includes/syscon.inc.php +295 -0
  145. index.php +0 -0
  146. licensing/gpl.txt +339 -0
  147. licensing/index.php +0 -0
  148. licensing/license.txt +33 -0
  149. readme.txt +249 -0
  150. s2member.php +85 -0
  151. screenshot-1.png +0 -0
  152. screenshot-10.png +0 -0
  153. screenshot-2.png +0 -0
  154. screenshot-3.png +0 -0
  155. screenshot-4.png +0 -0
  156. screenshot-5.png +0 -0
  157. screenshot-6.png +0 -0
  158. screenshot-7.png +0 -0
  159. screenshot-8.png +0 -0
  160. screenshot-9.png +0 -0
images/bg.fla ADDED
Binary file
images/bg.png ADDED
Binary file
images/brand-bg.fla ADDED
Binary file
images/brand-bg.png ADDED
Binary file
images/brand-dark.fla ADDED
Binary file
images/brand-dark.png ADDED
Binary file
images/brand-donations.fla ADDED
Binary file
images/brand-donations.jpg ADDED
Binary file
images/brand-favicon.fla ADDED
Binary file
images/brand-favicon.png ADDED
Binary file
images/brand-gradient-bg.fla ADDED
Binary file
images/brand-gradient-bg.png ADDED
Binary file
images/brand-icon.fla ADDED
Binary file
images/brand-icon.png ADDED
Binary file
images/brand-light.fla ADDED
Binary file
images/brand-light.png ADDED
Binary file
images/brand-tips.fla ADDED
Binary file
images/brand-tips.png ADDED
Binary file
images/brand-tools.fla ADDED
Binary file
images/brand-tools.png ADDED
Binary file
images/brand-updates.fla ADDED
Binary file
images/brand-updates.png ADDED
Binary file
images/brand-xlink.fla ADDED
Binary file
images/brand-xlink.png ADDED
Binary file
images/index.php ADDED
File without changes
images/logo.fla ADDED
Binary file
images/logo.png ADDED
Binary file
images/promos/150x150.jpg ADDED
Binary file
images/promos/300x225.jpg ADDED
Binary file
images/promos/590x300.jpg ADDED
Binary file
images/promos/80x80.jpg ADDED
Binary file
images/promos/900x285.jpg ADDED
Binary file
images/promos/900x385.jpg ADDED
Binary file
images/promos/index.php ADDED
File without changes
images/wordpress-dark.fla ADDED
Binary file
images/wordpress-dark.png ADDED
Binary file
images/wordpress-light.fla ADDED
Binary file
images/wordpress-light.png ADDED
Binary file
includes/funcs.inc.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Include all of the functions that came with this plugin.
18
+ */
19
+ if (is_dir(dirname(__FILE__) . "/functions"))
20
+ if ($ws_plugin__s2member_temp_r = opendir(dirname(__FILE__) . "/functions"))
21
+ while (($ws_plugin__s2member_temp_s = readdir($ws_plugin__s2member_temp_r)) !== false)
22
+ if (preg_match("/\.php#x2F;", $ws_plugin__s2member_temp_s) && !preg_match("/^index\.php#x2F;i", $ws_plugin__s2member_temp_s))
23
+ include_once dirname(__FILE__) . "/functions/" . $ws_plugin__s2member_temp_s;
24
+ ?>
includes/functions/activate-deactivate.inc.php ADDED
@@ -0,0 +1,185 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for handling activation routines.
18
+ This function should match the array key for this plugin:
19
+ ws_plugin__$plugin_key_activate() is called by our themes.
20
+
21
+ We also initialize some option values here.
22
+ Initializing these options will force them to be
23
+ autoloaded into WordPress® instead of generating
24
+ extra queries before they are set.
25
+ */
26
+ function ws_plugin__s2member_activate ()
27
+ {
28
+ add_role ("s2member_level1", "s2Member Level 1");
29
+ add_role ("s2member_level2", "s2Member Level 2");
30
+ add_role ("s2member_level3", "s2Member Level 3");
31
+ add_role ("s2member_level4", "s2Member Level 4");
32
+ /**/
33
+ $role = &get_role ("s2member_level1");
34
+ $role->add_cap ("read");
35
+ $role->add_cap ("level_0");
36
+ $role->add_cap ("access_s2member_level1");
37
+ /**/
38
+ $role = &get_role ("s2member_level2");
39
+ $role->add_cap ("read");
40
+ $role->add_cap ("level_0");
41
+ $role->add_cap ("access_s2member_level2");
42
+ $role->add_cap ("access_s2member_level1");
43
+ /**/
44
+ $role = &get_role ("s2member_level3");
45
+ $role->add_cap ("read");
46
+ $role->add_cap ("level_0");
47
+ $role->add_cap ("access_s2member_level3");
48
+ $role->add_cap ("access_s2member_level2");
49
+ $role->add_cap ("access_s2member_level1");
50
+ /**/
51
+ $role = &get_role ("s2member_level4");
52
+ $role->add_cap ("read");
53
+ $role->add_cap ("level_0");
54
+ $role->add_cap ("access_s2member_level4");
55
+ $role->add_cap ("access_s2member_level3");
56
+ $role->add_cap ("access_s2member_level2");
57
+ $role->add_cap ("access_s2member_level1");
58
+ /**/
59
+ $role = &get_role ("administrator");
60
+ $role->add_cap ("access_s2member_level1");
61
+ $role->add_cap ("access_s2member_level2");
62
+ $role->add_cap ("access_s2member_level3");
63
+ $role->add_cap ("access_s2member_level4");
64
+ /**/
65
+ $role = &get_role ("editor");
66
+ $role->add_cap ("access_s2member_level1");
67
+ $role->add_cap ("access_s2member_level2");
68
+ $role->add_cap ("access_s2member_level3");
69
+ $role->add_cap ("access_s2member_level4");
70
+ /**/
71
+ $role = &get_role ("author");
72
+ $role->add_cap ("access_s2member_level1");
73
+ $role->add_cap ("access_s2member_level2");
74
+ $role->add_cap ("access_s2member_level3");
75
+ $role->add_cap ("access_s2member_level4");
76
+ /**/
77
+ $role = &get_role ("contributor");
78
+ $role->add_cap ("access_s2member_level1");
79
+ $role->add_cap ("access_s2member_level2");
80
+ $role->add_cap ("access_s2member_level3");
81
+ $role->add_cap ("access_s2member_level4");
82
+ /**/
83
+ if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
84
+ if (is_writable (dirname ($files_dir)))
85
+ mkdir ($files_dir, 0777);
86
+ /**/
87
+ if (is_dir ($files_dir) && is_writable ($files_dir))
88
+ if (!file_exists ($htaccess = $files_dir . "/.htaccess"))
89
+ file_put_contents ($htaccess, "deny from all");
90
+ /**/
91
+ if (!is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
92
+ if (is_writable (dirname ($logs_dir)))
93
+ mkdir ($logs_dir, 0777);
94
+ /**/
95
+ if (is_dir ($logs_dir) && is_writable ($logs_dir))
96
+ if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
97
+ file_put_contents ($htaccess, "deny from all");
98
+ /**/
99
+ if (!is_numeric (get_option ("ws_plugin__s2member_configured")))
100
+ update_option ("ws_plugin__s2member_configured", "0");
101
+ /**/
102
+ if (!is_array (get_option ("ws_plugin__s2member_cache")))
103
+ update_option ("ws_plugin__s2member_cache", array ());
104
+ /**/
105
+ if (!is_array (get_option ("ws_plugin__s2member_notices")))
106
+ update_option ("ws_plugin__s2member_notices", array ());
107
+ /**/
108
+ if (!is_array (get_option ("ws_plugin__s2member_options")))
109
+ update_option ("ws_plugin__s2member_options", array ());
110
+ /**/
111
+ return;
112
+ }
113
+ /*
114
+ Function for handling de-activation cleanup routines.
115
+ This function should match the array key for this plugin:
116
+ ws_plugin__$plugin_key_deactivate() is called by our themes.
117
+ */
118
+ function ws_plugin__s2member_deactivate ()
119
+ {
120
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
121
+ {
122
+ remove_role ("s2member_level1");
123
+ remove_role ("s2member_level2");
124
+ remove_role ("s2member_level3");
125
+ remove_role ("s2member_level4");
126
+ /**/
127
+ $role = &get_role ("administrator");
128
+ $role->remove_cap ("access_s2member_level1");
129
+ $role->remove_cap ("access_s2member_level2");
130
+ $role->remove_cap ("access_s2member_level3");
131
+ $role->remove_cap ("access_s2member_level4");
132
+ /**/
133
+ $role = &get_role ("editor");
134
+ $role->remove_cap ("access_s2member_level1");
135
+ $role->remove_cap ("access_s2member_level2");
136
+ $role->remove_cap ("access_s2member_level3");
137
+ $role->remove_cap ("access_s2member_level4");
138
+ /**/
139
+ $role = &get_role ("author");
140
+ $role->remove_cap ("access_s2member_level1");
141
+ $role->remove_cap ("access_s2member_level2");
142
+ $role->remove_cap ("access_s2member_level3");
143
+ $role->remove_cap ("access_s2member_level4");
144
+ /**/
145
+ $role = &get_role ("contributor");
146
+ $role->remove_cap ("access_s2member_level1");
147
+ $role->remove_cap ("access_s2member_level2");
148
+ $role->remove_cap ("access_s2member_level3");
149
+ $role->remove_cap ("access_s2member_level4");
150
+ /**/
151
+ if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
152
+ {
153
+ if (file_exists ($htaccess = $files_dir . "/.htaccess"))
154
+ if (is_writable ($htaccess))
155
+ unlink ($htaccess);
156
+ /**/
157
+ @rmdir ($files_dir);
158
+ }
159
+ /**/
160
+ if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
161
+ {
162
+ if (file_exists ($htaccess = $logs_dir . "/.htaccess"))
163
+ if (is_writable ($htaccess))
164
+ unlink ($htaccess);
165
+ /**/
166
+ if (file_exists ($log = $logs_dir . "/paypal-ipn.log"))
167
+ if (is_writable ($log))
168
+ unlink ($log);
169
+ /**/
170
+ if (file_exists ($log = $logs_dir . "/paypal-rtn.log"))
171
+ if (is_writable ($log))
172
+ unlink ($log);
173
+ /**/
174
+ @rmdir ($logs_dir);
175
+ }
176
+ /**/
177
+ delete_option ("ws_plugin__s2member_configured");
178
+ delete_option ("ws_plugin__s2member_cache");
179
+ delete_option ("ws_plugin__s2member_notices");
180
+ delete_option ("ws_plugin__s2member_options");
181
+ }
182
+ /**/
183
+ return;
184
+ }
185
+ ?>
includes/functions/admin-lockout.inc.php ADDED
@@ -0,0 +1,30 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for handling admin lockouts.
18
+ Attach to: add_action("admin_init");
19
+ */
20
+ function ws_plugin__s2member_admin_lockout ()
21
+ {
22
+ /* This prevents users ( who cannot edit ) from gaining any access to the admin area. */
23
+ /* WordPress® handles most of this on its own, but this prevents profile access also. */
24
+ if (!current_user_can ("edit_posts") /* In other words, if they are a subscriber or a member. */
25
+ && wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) !== "nill")
26
+ exit;
27
+ /**/
28
+ return;
29
+ }
30
+ ?>
includes/functions/admin-notices.inc.php ADDED
@@ -0,0 +1,78 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function displays an admin notice immediately.
18
+ */
19
+ function ws_plugin__s2member_display_admin_notice ($notice = FALSE, $error = FALSE)
20
+ {
21
+ if ($notice && $error) /* Special format for errors. */
22
+ {
23
+ echo '<div class="error fade"><p>' . $notice . '</p></div>';
24
+ }
25
+ else if ($notice) /* Otherwise, we just send it as an update notice. */
26
+ {
27
+ echo '<div class="updated fade"><p>' . $notice . '</p></div>';
28
+ }
29
+ /**/
30
+ return;
31
+ }
32
+ /*
33
+ Function that enqueues admin notices.
34
+ */
35
+ function ws_plugin__s2member_enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE)
36
+ {
37
+ if ($notice && is_string ($notice)) /* If we have a valid string. */
38
+ {
39
+ $notices = (array)get_option ("ws_plugin__s2member_notices");
40
+ /**/
41
+ array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time));
42
+ /**/
43
+ update_option ("ws_plugin__s2member_notices", ws_plugin__s2member_array_unique ($notices));
44
+ }
45
+ /**/
46
+ return;
47
+ }
48
+ /*
49
+ Function that displays admin notices.
50
+ Attach to: add_action("admin_notices");
51
+ */
52
+ function ws_plugin__s2member_admin_notices ()
53
+ {
54
+ global $pagenow; /* This holds the current page filename. */
55
+ /**/
56
+ if (is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
57
+ {
58
+ foreach ($notices as $key => $notice) /* Check time on each notice. */
59
+ {
60
+ if (empty ($notice["on_pages"]) || $pagenow === $notice["on_pages"] || in_array ($pagenow, (array)$notice["on_pages"]) || $_GET["page"] === $notice["on_pages"] || in_array ($_GET["page"], (array)$notice["on_pages"]))
61
+ {
62
+ if (strtotime ("now") >= $notice["time"]) /* Time to show it? */
63
+ {
64
+ unset ($notices[$key]); /* Clear this notice & display it. */
65
+ /**/
66
+ ws_plugin__s2member_display_admin_notice ($notice["notice"], $notice["error"]);
67
+ }
68
+ }
69
+ }
70
+ /**/
71
+ $notices = array_merge ($notices); /* Re-index array keys. */
72
+ /**/
73
+ update_option ("ws_plugin__s2member_notices", $notices);
74
+ }
75
+ /**/
76
+ return;
77
+ }
78
+ ?>
includes/functions/catg-level-access.inc.php ADDED
@@ -0,0 +1,103 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for handling category level access permissions.
18
+ Attach to: add_action("template_redirect");
19
+ */
20
+ function ws_plugin__s2member_check_catg_level_access ()
21
+ {
22
+ global $post; /* get_the_ID() not yet available here. */
23
+ /**/
24
+ if ((is_category () && ($cat_ID = get_query_var ("cat"))) || (is_single () && !is_page () && is_object ($post) && ($post_ID = $post->ID)))
25
+ {
26
+ if (!ws_plugin__s2member_is_systematic_use_page ()) /* Never restrict systematic use pages. */
27
+ {
28
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
29
+ /**/
30
+ if (is_category () && $cat_ID) /* We also check if this is a child category of a restricted category. */
31
+ {
32
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=1")) !== "nill")
33
+ exit;
34
+ /**/
35
+ else if (in_array ($cat_ID, ($level1_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=1")) !== "nill")
36
+ exit;
37
+ /**/
38
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=2")) !== "nill")
39
+ exit;
40
+ /**/
41
+ else if (in_array ($cat_ID, ($level2_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=2")) !== "nill")
42
+ exit;
43
+ /**/
44
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=3")) !== "nill")
45
+ exit;
46
+ /**/
47
+ else if (in_array ($cat_ID, ($level3_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=3")) !== "nill")
48
+ exit;
49
+ /**/
50
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
51
+ exit;
52
+ /**/
53
+ else if (in_array ($cat_ID, ($level4_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
54
+ exit;
55
+ /**/
56
+ foreach ($level1_catgs as $catg)
57
+ if (cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=1")) !== "nill")
58
+ exit;
59
+ /**/
60
+ foreach ($level2_catgs as $catg)
61
+ if (cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=2")) !== "nill")
62
+ exit;
63
+ /**/
64
+ foreach ($level3_catgs as $catg)
65
+ if (cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=3")) !== "nill")
66
+ exit;
67
+ /**/
68
+ foreach ($level4_catgs as $catg)
69
+ if (cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
70
+ exit;
71
+ }
72
+ else if (is_single () && !is_page () && $post_ID)
73
+ {
74
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=1")) !== "nill")
75
+ exit;
76
+ /**/
77
+ else if (($level1_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"])) && (in_category ($level1_catgs, $post_ID) || ws_plugin__s2member_in_descendant_category ($level1_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=1")) !== "nill")
78
+ exit;
79
+ /**/
80
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=2")) !== "nill")
81
+ exit;
82
+ /**/
83
+ else if (($level2_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"])) && (in_category ($level2_catgs, $post_ID) || ws_plugin__s2member_in_descendant_category ($level2_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=2")) !== "nill")
84
+ exit;
85
+ /**/
86
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=3")) !== "nill")
87
+ exit;
88
+ /**/
89
+ else if (($level3_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"])) && (in_category ($level3_catgs, $post_ID) || ws_plugin__s2member_in_descendant_category ($level3_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=3")) !== "nill")
90
+ exit;
91
+ /**/
92
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
93
+ exit;
94
+ /**/
95
+ else if (($level4_catgs = preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"])) && (in_category ($level4_catgs, $post_ID) || ws_plugin__s2member_in_descendant_category ($level4_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
96
+ exit;
97
+ }
98
+ }
99
+ }
100
+ /**/
101
+ return;
102
+ }
103
+ ?>
includes/functions/constants.inc.php ADDED
@@ -0,0 +1,189 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Define several API Constants for s2Member.
18
+ Note that these are duplicated into the JavaScript API as well.
19
+ Attach to: add_action("init");
20
+ */
21
+ function ws_plugin__s2member_constants ()
22
+ {
23
+ $links = ws_plugin__s2member_constant_links ();
24
+ $metas = ws_plugin__s2member_constant_metas ();
25
+ $level = ws_plugin__s2member_user_access_level ();
26
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
27
+ $file_downloads = ws_plugin__s2member_user_downloads ("", $metas["s2member_file_download_access_log"]);
28
+ $login_redirection_override = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
29
+ /**/
30
+ define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", (($level >= 1) ? true : false)); /* This will always be (bool) true or false. False if they are not currently logged in. */
31
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", (int)$level); /* This will always be (int) negative 1 thru positive 4. -1 if user is not logged in. 0 if logged in w/o access. */
32
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]); /* This will always be a (string). Empty if not logged in. */
33
+ define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($metas["s2member_subscr_id"]) ? $metas["s2member_subscr_id"] : $current_user->ID) : "")); /* Empty if not logged in. */
34
+ define ("S2MEMBER_CURRENT_USER_CUSTOM", (($current_user) ? $metas["s2member_custom"] : "")); /* This will always a (string). However, it will be empty if not logged in. */
35
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", (($current_user) ? strtotime ($current_user->user_registered) : 0)); /* Always an (int). Or 0 if they're not logged in. */
36
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", (($current_user) ? floor ((strtotime ("now") - strtotime ($current_user->user_registered)) / 86400) : 0)); /* (int). */
37
+ define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", (($current_user) ? $current_user->display_name : "")); /* This will always be a (string). Empty if not logged in. */
38
+ define ("S2MEMBER_CURRENT_USER_FIRST_NAME", (($current_user) ? $current_user->user_firstname : "")); /* This will always be a (string). Empty if not logged in. */
39
+ define ("S2MEMBER_CURRENT_USER_LAST_NAME", (($current_user) ? $current_user->user_lastname : "")); /* This will always be a (string). Empty if not logged in. */
40
+ define ("S2MEMBER_CURRENT_USER_LOGIN", (($current_user) ? $current_user->user_login : "")); /* This will always be a (string). Empty if not logged in. */
41
+ define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? $current_user->user_email : "")); /* This will always be a (string). Empty if not logged in. */
42
+ define ("S2MEMBER_CURRENT_USER_IP", $_SERVER["REMOTE_ADDR"]); /* This will always be a (string). It may be empty if the user is browsing anonymously. */
43
+ define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0)); /* This will always be an (int). Zero if not logged in. */
44
+ define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? serialize (array_merge /* Always a serialized (array). This includes custom fields. */
45
+ (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN,/**/
46
+ "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME,/**/
47
+ "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), $metas["s2member_custom_fields"])) : serialize (array ())));
48
+ /**/
49
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
50
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false)); /* This will always be (bool). */
51
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", (int)$file_downloads["currently"]); /* This will always be an integer value (int) >= 0 where 0 means none currently. */
52
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", (int)$file_downloads["allowed_days"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
53
+ /**/
54
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]); /* The exceeded page id (int). */
55
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]); /* Options page id, always an (int). */
56
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]); /* The welcome page id, always an (int). */
57
+ /**/
58
+ define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", get_bloginfo ("url") . "/?s2member_profile=1"); /* Where a user modifies their profile. */
59
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", $links["file_download_limit_exceeded_page"]); /* Always a string. URL to limit exceeded page. */
60
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", $links["membership_options_page"]); /* Always a string. This is the URL to the membership options page. */
61
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", (($login_redirection_override) ? $login_redirection_override : $links["login_welcome_page"])); /* Always a string. */
62
+ define ("S2MEMBER_LOGOUT_PAGE_URL", wp_logout_url ()); /* This is always the same, it is the default wordpress action=logout url generated by wp_logout_url(). */
63
+ define ("S2MEMBER_LOGIN_PAGE_URL", wp_login_url ()); /* This is always the same, it is the default wordpress login url that is generated by wp_login_url(). */
64
+ /**/
65
+ define ("S2MEMBER_LEVEL1_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]); /* This is the (string) label that you created for membership level number 1. */
66
+ define ("S2MEMBER_LEVEL2_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]); /* This is the (string) label that you created for membership level number 2. */
67
+ define ("S2MEMBER_LEVEL3_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]); /* This is the (string) label that you created for membership level number 3. */
68
+ define ("S2MEMBER_LEVEL4_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]); /* This is the (string) label that you created for membership level number 4. */
69
+ /**/
70
+ define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
71
+ define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
72
+ define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
73
+ define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
74
+ /**/
75
+ define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]); /* This is (int) allowed days. */
76
+ define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]); /* This is (int) allowed days. */
77
+ define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]); /* This is (int) allowed days. */
78
+ define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]); /* This is (int) allowed days. */
79
+ /**/
80
+ define ("S2MEMBER_REG_EMAIL_FROM_NAME", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]); /* This is the name that outgoing email messages are sent by. */
81
+ define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]); /* This is the email that outgoing messages are sent by. */
82
+ /**/
83
+ define ("S2MEMBER_PAYPAL_NOTIFY_URL", get_bloginfo ("url") . "/?s2member_paypal_notify=1"); /* This will always be a (string), and it will never be an empty value. */
84
+ define ("S2MEMBER_PAYPAL_RETURN_URL", get_bloginfo ("url") . "/?s2member_paypal_return=1"); /* This will always be a (string), and it will never be an empty value. */
85
+ define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")); /* Using sandbox? */
86
+ define ("S2MEMBER_PAYPAL_BUSINESS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]); /* This is the email address that identifies your paypal business. */
87
+ /**/
88
+ return;
89
+ }
90
+ /*
91
+ This function pulls all of the page links needed for Constants.
92
+ Page links are cached into the s2member options on 15 min intervals.
93
+ This allows the API Constants to provide quick access to them without being
94
+ forced to execute get_page_link() all the time, which piles up DB queries.
95
+ */
96
+ function ws_plugin__s2member_constant_links ()
97
+ {
98
+ $cache_minutes = 15; /* Could be higher? */
99
+ /**/
100
+ $l["login_welcome_page"] = (string)"";
101
+ $l["membership_options_page"] = (string)"";
102
+ $l["file_download_limit_exceeded_page"] = (string)"";
103
+ /**/
104
+ $login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
105
+ $membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
106
+ $file_download_limit_exceeded_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
107
+ /**/
108
+ $login_welcome_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
109
+ $membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
110
+ $file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
111
+ /**/
112
+ if ($login_welcome_page && $login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["link"] && $login_welcome_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
113
+ {
114
+ $l["login_welcome_page"] = $login_welcome_page_cache["link"];
115
+ }
116
+ else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
117
+ {
118
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = strtotime ("now");
119
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $login_welcome_page;
120
+ $l["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($login_welcome_page);
121
+ /**/
122
+ $cache_needs_updating = true;
123
+ }
124
+ /**/
125
+ if ($membership_options_page && $membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["link"] && $membership_options_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
126
+ {
127
+ $l["membership_options_page"] = $membership_options_page_cache["link"];
128
+ }
129
+ else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
130
+ {
131
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = strtotime ("now");
132
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $membership_options_page;
133
+ $l["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($membership_options_page);
134
+ /**/
135
+ $cache_needs_updating = true;
136
+ }
137
+ /**/
138
+ if ($file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["link"] && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
139
+ {
140
+ $l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
141
+ }
142
+ else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
143
+ {
144
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = strtotime ("now");
145
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $file_download_limit_exceeded_page;
146
+ $l["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($file_download_limit_exceeded_page);
147
+ /**/
148
+ $cache_needs_updating = true;
149
+ }
150
+ /**/
151
+ if ($cache_needs_updating) /* The cache is also reset when options are updated from a menu page. */
152
+ {
153
+ update_option ("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]);
154
+ }
155
+ /**/
156
+ return $l; /* Links. */
157
+ }
158
+ /*
159
+ This function pulls all of the usermeta details needed for Constants.
160
+ Pulling them all at once helps to prevent repeated database queries.
161
+ */
162
+ function ws_plugin__s2member_constant_metas ()
163
+ {
164
+ global $wpdb; /* The global database object. */
165
+ /**/
166
+ $m["s2member_file_download_access_log"] = array ();
167
+ $m["s2member_custom_fields"] = array ();
168
+ $m["s2member_subscr_id"] = (string)"";
169
+ $m["s2member_custom"] = (string)"";
170
+ /**/
171
+ if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
172
+ {
173
+ if (is_array ($results = $wpdb->get_results ("SELECT `meta_key`, `meta_value` FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $current_user->ID . "' AND (meta_key = 's2member_file_download_access_log' OR meta_key = 's2member_subscr_id' OR meta_key = 's2member_custom') LIMIT 3")))
174
+ {
175
+ foreach ($results as $r) /* Fill in the array we need. */
176
+ if ($r->meta_key === "s2member_file_download_access_log")
177
+ $m["s2member_file_download_access_log"] = (array)maybe_unserialize ($r->meta_value);
178
+ else if ($result->meta_key === "s2member_custom_fields")
179
+ $m["s2member_custom_fields"] = (array)maybe_unserialize ($r->meta_value);
180
+ else if ($r->meta_key === "s2member_subscr_id")
181
+ $m["s2member_subscr_id"] = (string)$r->meta_value;
182
+ else if ($result->meta_key === "s2member_custom")
183
+ $m["s2member_custom"] = (string)$r->meta_value;
184
+ }
185
+ }
186
+ /**/
187
+ return $m; /* Metas. */
188
+ }
189
+ ?>
includes/functions/email-configs.inc.php ADDED
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Functions that modify the email From: name/address.
18
+ */
19
+ function ws_plugin__s2member_email_config ()
20
+ {
21
+ add_filter ("wp_mail_from", "_ws_plugin__s2member_email_config_email");
22
+ add_filter ("wp_mail_from_name", "_ws_plugin__s2member_email_config_name");
23
+ /**/
24
+ return;
25
+ }
26
+ /**/
27
+ function _ws_plugin__s2member_email_config_email ($email = FALSE)
28
+ {
29
+ return $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"];
30
+ }
31
+ /**/
32
+ function _ws_plugin__s2member_email_config_name ($name = FALSE)
33
+ {
34
+ return $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"];
35
+ }
36
+ ?>
includes/functions/file-download-access.inc.php ADDED
@@ -0,0 +1,124 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for handling download access permissions.
18
+ Attach to: add_action("init");
19
+ */
20
+ function ws_plugin__s2member_check_file_download_access ()
21
+ {
22
+ if ($_GET["s2member_file_download"])
23
+ {
24
+ if (!$_GET["s2member_free_file_download_key"] || ws_plugin__s2member_xdecrypt ($_GET["s2member_free_file_download_key"]) !== $_GET["s2member_file_download"])
25
+ {
26
+ $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/");
27
+ /**/
28
+ $file_download_access_is_allowed = $minimum_level_required_to_download_files = ws_plugin__s2member_min_level_4_downloads ();
29
+ /**/
30
+ if (!($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false) && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=" . urlencode ($minimum_level_required_to_download_files))) !== "nill")
31
+ exit;
32
+ /**/
33
+ else if (!$file_download_access_is_allowed) /* Have file downloads even been enabled? */
34
+ {
35
+ header ("HTTP/1.0 503 Service Temporarily Unavailable");
36
+ echo '503 File Downloads Are Not Enabled.';
37
+ exit;
38
+ }
39
+ /**/
40
+ else if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
41
+ {
42
+ header ("HTTP/1.0 404 Not Found"); /* The file does not even exist. */
43
+ echo '404 File Download Not Found.';
44
+ exit;
45
+ }
46
+ /**/
47
+ else if ((!is_array ($file_downloads = ws_plugin__s2member_user_downloads ()) || !$file_downloads["allowed"] || !$file_downloads["allowed_days"])/**/
48
+ && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]), "s2member_file_download=" . urlencode ($_GET["s2member_file_download"]))) !== "nill")
49
+ exit;
50
+ /**/
51
+ $previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
52
+ $maximum_days_logged = ws_plugin__s2member_maximum_download_period (); /* The longest period in days. */
53
+ $file_download_access_log = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_log");
54
+ $file_download_access_arc = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_arc");
55
+ /**/
56
+ foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
57
+ {
58
+ if (strtotime ($file_download_access_log_entry["date"]) < strtotime ("-" . $maximum_days_logged . " days"))
59
+ {
60
+ unset ($file_download_access_log[$file_download_access_log_entry_key]);
61
+ $file_download_access_arc[] = $file_download_access_log_entry;
62
+ }
63
+ else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
64
+ {
65
+ $previous_file_downloads++;
66
+ /* Here we check if this file has already been downloaded. */
67
+ if ($file_download_access_log_entry["file"] === $_GET["s2member_file_download"])
68
+ $already_downloaded = true;
69
+ }
70
+ }
71
+ /**/
72
+ if (!$already_downloaded && $previous_file_downloads >= $file_downloads["allowed"] /* They have NOT already downloaded this file, and they're over their limit. */
73
+ && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]), "s2member_file_download=" . urlencode ($_GET["s2member_file_download"]))) !== "nill")
74
+ exit;
75
+ /**/
76
+ if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
77
+ $file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
78
+ update_usermeta ($current_user->ID, "s2member_file_download_access_arc", ws_plugin__s2member_array_unique ($file_download_access_arc));
79
+ update_usermeta ($current_user->ID, "s2member_file_download_access_log", ws_plugin__s2member_array_unique ($file_download_access_log));
80
+ }
81
+ else /* This is a free download that we just need to check on the existence of. */
82
+ {
83
+ $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/");
84
+ /**/
85
+ if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
86
+ {
87
+ header ("HTTP/1.0 404 Not Found"); /* The file does not exist. */
88
+ echo '404 File Download Not Found.';
89
+ exit;
90
+ }
91
+ }
92
+ /*
93
+ Here we are going to put together all of the file download information.
94
+ */
95
+ $mimetypes = parse_ini_file (dirname (dirname (dirname (__FILE__))) . "/includes/mime-types.ini");
96
+ /**/
97
+ $pathinfo = pathinfo ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]);
98
+ /**/
99
+ $extension = strtolower ($pathinfo["extension"]); /* Convert file extension to lowercase format for MIME type lookup. */
100
+ /**/
101
+ $mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream"; /* Lookup MIME type. */
102
+ /**/
103
+ $length = filesize ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]);
104
+ /*
105
+ Now send the file to the browser. Be sure to turn off output compression.
106
+ */
107
+ ini_set ("zlib.output_compression", 0);
108
+ /**/
109
+ header ("Content-Encoding: none");
110
+ header ("Content-Type: " . $mimetype);
111
+ header ("Content-Length: " . $length);
112
+ header ('Content-Disposition: attachment; filename="' . $pathinfo["basename"] . '"');
113
+ header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
114
+ header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
115
+ header ("Cache-Control: no-cache, must-revalidate, max-age=0");
116
+ header ("Cache-Control: post-check=0, pre-check=0", false);
117
+ header ("Pragma: no-cache");
118
+ /**/
119
+ readfile ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]);
120
+ /**/
121
+ exit;
122
+ }
123
+ }
124
+ ?>
includes/functions/hide-some-systematics.inc.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function that hides some of the systematic use pages.
18
+ Attach to: add_filter("posts_where");
19
+ */
20
+ function ws_plugin__s2member_hide_some_systematics ($where = FALSE)
21
+ {
22
+ global $wpdb; /* Need this to get the table name. */
23
+ /**/
24
+ if (is_search()) /* Here we exclude a few systematic use pages from the search query. */
25
+ {
26
+ $where .= " AND " . $wpdb->posts . ".ID NOT IN ('" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] . "', '" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] . "', '" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] . "')";
27
+ }
28
+ /**/
29
+ return $where;
30
+ }
31
+ ?>
includes/functions/index.php ADDED
File without changes
includes/functions/is-systematic.inc.php ADDED
@@ -0,0 +1,64 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function that determines whether we are on a systematic use page.
18
+ */
19
+ function ws_plugin__s2member_is_systematic_use_page ()
20
+ {
21
+ static $is_systematic; /* For optimization. */
22
+ /**/
23
+ if (isset ($is_systematic)) /* Already cached? */
24
+ {
25
+ return $is_systematic; /* Saves time. */
26
+ }
27
+ else if (is_admin ()) /* In the admin area? */
28
+ {
29
+ return ($is_systematic = true);
30
+ }
31
+ else if (preg_match ("/^cli#x2F;i", PHP_SAPI))
32
+ {
33
+ return ($is_systematic = true);
34
+ }
35
+ else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"])
36
+ {
37
+ return ($is_systematic = true);
38
+ }
39
+ else if (preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
40
+ {
41
+ return ($is_systematic = true);
42
+ }
43
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
44
+ {
45
+ return ($is_systematic = true);
46
+ }
47
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]))
48
+ {
49
+ return ($is_systematic = true);
50
+ }
51
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))
52
+ {
53
+ return ($is_systematic = true);
54
+ }
55
+ else if (preg_match ("/^s2member/", $_SERVER["QUERY_STRING"]) && ($_SERVER["REQUEST_URI"] === "/" || strtolower (rtrim (get_bloginfo ("url"), "/")) === rtrim (strtolower ("http://" . $_SERVER["HTTP_HOST"]) . $_SERVER["REQUEST_URI"], "/")))
56
+ {
57
+ return ($is_systematic = true); /* Only true when the request starts with /?s2member from the root URL of the domain, or from the root URL of the WordPress® installation. */
58
+ }
59
+ else /* Otherwise, we return false. */
60
+ {
61
+ return ($is_systematic = false);
62
+ }
63
+ }
64
+ ?>
includes/functions/js-globals.inc.php ADDED
@@ -0,0 +1,125 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for adding script to the header.
18
+ This function is fired in the admin area also.
19
+ Do NOT enqueue the script in the admin area.
20
+ Attach to: add_action("wp_print_scripts");
21
+ */
22
+ function ws_plugin__s2member_add_js_w_globals ()
23
+ {
24
+ if (!is_admin ()) /* Not in the admin. */
25
+ {
26
+ if (is_user_logged_in ())
27
+ {
28
+ $a = get_defined_constants (true);
29
+ $c = (array)$a["user"];
30
+ unset ($a);
31
+ /**/
32
+ foreach ($c as $k => $v)
33
+ if (preg_match ("/^S2MEMBER_/i", $k))
34
+ $s2member[$k] = $v;
35
+ /**/
36
+ $md5 = md5 (serialize ($s2member)); /* This is a hash based on the global key => values. */
37
+ /* The md5 hash allows the script to be cached in the browser until the globals happen to change. */
38
+ /* For instance, the global variables may change when a user who is logged-in changes their profile. */
39
+ wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("url") . "/?ws_plugin__s2member_js_w_globals=1&s2ABC=1&qcABC=1&" . $md5, array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
40
+ }
41
+ else /* Else if they are not logged in, we distinguish the script by not including the md5 hash. */
42
+ { /* This essentially creates 2 versions of the script. One while logged in & another when not. */
43
+ wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("url") . "/?ws_plugin__s2member_js_w_globals=1&s2ABC=1&qcABC=1", array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
44
+ }
45
+ }
46
+ /**/
47
+ return;
48
+ }
49
+ /*
50
+ Function for adding s2member.js with globals.
51
+ Attach to: add_action("init");
52
+ */
53
+ function ws_plugin__s2member_js_w_globals ()
54
+ {
55
+ if ($_GET["ws_plugin__s2member_js_w_globals"])
56
+ {
57
+ header ("Content-Type: text/javascript; charset=utf-8");
58
+ header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
59
+ header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
60
+ header ("Cache-Control: max-age=604800");
61
+ header ("Pragma: public");
62
+ /**/
63
+ $g = "var S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
64
+ $g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
65
+ $g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
66
+ $g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
67
+ $g .= "S2MEMBER_CURRENT_USER_CUSTOM = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_CUSTOM) . "',";
68
+ $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_REGISTRATION_TIME . ",";
69
+ $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_REGISTRATION_DAYS . ",";
70
+ $g .= "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_DISPLAY_NAME) . "',";
71
+ $g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_FIRST_NAME) . "',";
72
+ $g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_LAST_NAME) . "',";
73
+ $g .= "S2MEMBER_CURRENT_USER_LOGIN = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_LOGIN) . "',";
74
+ $g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_EMAIL) . "',";
75
+ $g .= "S2MEMBER_CURRENT_USER_IP = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_IP) . "',";
76
+ $g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
77
+ /**/
78
+ $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED . ",";
79
+ $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = " . ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false") . ",";
80
+ $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = " . S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY . ",";
81
+ $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS . ",";
82
+ /**/
83
+ $g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = " . S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID . ",";
84
+ $g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID . ",";
85
+ $g .= "S2MEMBER_LOGIN_WELCOME_PAGE_ID = " . S2MEMBER_LOGIN_WELCOME_PAGE_ID . ",";
86
+ /**/
87
+ $g .= "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL) . "',";
88
+ $g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL) . "',";
89
+ $g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL) . "',";
90
+ $g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGOUT_PAGE_URL) . "',";
91
+ $g .= "S2MEMBER_LOGIN_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGIN_PAGE_URL) . "',";
92
+ /**/
93
+ $g .= "S2MEMBER_LEVEL1_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_LEVEL1_LABEL) . "',";
94
+ $g .= "S2MEMBER_LEVEL2_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_LEVEL2_LABEL) . "',";
95
+ $g .= "S2MEMBER_LEVEL3_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_LEVEL3_LABEL) . "',";
96
+ $g .= "S2MEMBER_LEVEL4_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_LEVEL4_LABEL) . "',";
97
+ /**/
98
+ $g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED . ",";
99
+ $g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED . ",";
100
+ $g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED . ",";
101
+ $g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED . ",";
102
+ /**/
103
+ $g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
104
+ $g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
105
+ $g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
106
+ $g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
107
+ /**/
108
+ $g .= "S2MEMBER_REG_EMAIL_FROM_NAME = '" . preg_replace ("/'/", "\'", S2MEMBER_REG_EMAIL_FROM_NAME) . "',";
109
+ $g .= "S2MEMBER_REG_EMAIL_FROM_EMAIL = '" . preg_replace ("/'/", "\'", S2MEMBER_REG_EMAIL_FROM_EMAIL) . "',";
110
+ /**/
111
+ $g .= "S2MEMBER_PAYPAL_NOTIFY_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_NOTIFY_URL) . "',";
112
+ $g .= "S2MEMBER_PAYPAL_RETURN_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_RETURN_URL) . "',";
113
+ $g .= "S2MEMBER_PAYPAL_ENDPOINT = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_ENDPOINT) . "',";
114
+ $g .= "S2MEMBER_PAYPAL_BUSINESS = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_BUSINESS) . "',";
115
+ /**/
116
+ $g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
117
+ $j = file_get_contents (dirname (dirname (__FILE__)) . "/s2member-min.js");
118
+ $j = preg_replace ("/('|\")%%globals%%('|\");/", $g, $j);
119
+ /**/
120
+ echo $j;
121
+ /**/
122
+ exit;
123
+ }
124
+ }
125
+ ?>
includes/functions/login-customizations.inc.php ADDED
@@ -0,0 +1,70 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for filtering the login logo url.
18
+ Attach to: add_filter("login_headerurl");
19
+ */
20
+ function ws_plugin__s2member_login_header_url ($url = FALSE)
21
+ {
22
+ $url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_url"];
23
+ /**/
24
+ return $url;
25
+ }
26
+ /*
27
+ Function for filtering the login logo title.
28
+ Attach to: add_filter("login_headertitle");
29
+ */
30
+ function ws_plugin__s2member_login_header_title ($title = FALSE)
31
+ {
32
+ $title = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_title"];
33
+ /**/
34
+ return $title;
35
+ }
36
+ /*
37
+ Function for creating the styles for the login panel.
38
+ Attach to: add_action("login_head");
39
+ */
40
+ function ws_plugin__s2member_login_header_styles ()
41
+ {
42
+ echo "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>' . "\n";
43
+ echo '<script type="text/javascript" src="' . get_bloginfo ("url") . '/?ws_plugin__s2member_js_w_globals=1&amp;no-cache=' . urlencode (md5 (mt_rand ())) . '"></script>' . "\n";
44
+ /**/
45
+ echo "\n" . '<style type="text/css">' . "\n";
46
+ /**/
47
+ echo 'html, body { border: 0 !important; background: none !important; }' . "\n"; /* Clear borders & existing background. */
48
+ echo 'html { background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; }' . "\n";
49
+ echo 'html { background-image: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ') !important; }' . "\n";
50
+ /**/
51
+ echo 'p#backtoblog a, p#backtoblog a:hover, p#backtoblog a:active, p#backtoblog a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . ' !important; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . ' !important; top: 15px !important; left: 15px !important; padding: 10px !important; border:1px solid #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; -moz-border-radius:3px !important; -webkit-border-radius:3px !important; border-radius:3px !important; }' . "\n";
52
+ /**/
53
+ echo 'div#login { width: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"] . 'px !important; }' . "\n";
54
+ echo 'div#login h1 a { background: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"] . ') no-repeat top center !important; }' . "\n";
55
+ echo 'div#login h1 a { display: block !important; width: 100% !important; height: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_height"] . 'px !important; }' . "\n";
56
+ echo 'div#login p#nav, div#login p#nav a, div#login p#nav a:hover, div#login p#nav a:active, div#login p#nav a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . ' !important; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . ' !important; }' . "\n";
57
+ echo 'div#login form { -moz-box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; -webkit-box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; -khtml-box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; }' . "\n";
58
+ echo 'div#login form input[type="submit"], div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color: #333333 !important; border: 1px solid #666666 !important; background: #CCCCCC !important; padding: 5px !important; -moz-border-radius: 3px !important; -webkit-border-radius: 3px !important; -khtml-border-radius: 3px !important; border-radius: 3px !important; }' . "\n";
59
+ echo 'div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color: #000000 !important; border: 1px solid #000000 !important; }' . "\n";
60
+ /**/
61
+ echo 'div#login form input.ws-plugin--s2member-custom-reg-field { background:none repeat scroll 0 0 #FBFBFB; border:1px solid #E5E5E5; font-size:24px; margin-bottom:16px; margin-right:6px; margin-top:2px; padding:3px; width:97%; }' . "\n";
62
+ /**/
63
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
64
+ echo 'p#reg_passmail { display: none; }' . "\n";
65
+ /**/
66
+ echo '</style>' . "\n\n";
67
+ /**/
68
+ return;
69
+ }
70
+ ?>
includes/functions/login-redirection.inc.php ADDED
@@ -0,0 +1,40 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for handling login redirections.
18
+ Attach to: add_action("wp_login");
19
+ */
20
+ function ws_plugin__s2member_login_redirect ()
21
+ {
22
+ /* Note that current_user_can() will not work here because the cookie was just set. */
23
+ global $user; /* Available during the login routine just before wp_login is hooked in. */
24
+ /**/
25
+ $uzer = new WP_User ($user->ID); /* Now lets get a user object to check capabilities. */
26
+ /**/
27
+ if (!$uzer->has_cap ("edit_posts")) /* In other words, all subscribers & members. */
28
+ {
29
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])
30
+ wp_redirect ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]);
31
+ /**/
32
+ else /* Otherwise, use the Login Welcome Page. */
33
+ wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
34
+ /**/
35
+ exit;
36
+ }
37
+ /**/
38
+ return;
39
+ }
40
+ ?>
includes/functions/max-download-period.inc.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function determines the maximum period in days for download access.
18
+ Returns number of days, where 0 means no access to files has been allowed.
19
+ */
20
+ function ws_plugin__s2member_maximum_download_period ()
21
+ {
22
+ if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
23
+ {
24
+ $maximum = ($maximum < $days) ? $days : $maximum;
25
+ }
26
+ /**/
27
+ if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
28
+ {
29
+ $maximum = ($maximum < $days) ? $days : $maximum;
30
+ }
31
+ /**/
32
+ if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
33
+ {
34
+ $maximum = ($maximum < $days) ? $days : $maximum;
35
+ }
36
+ /**/
37
+ if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
38
+ {
39
+ $maximum = ($maximum < $days) ? $days : $maximum;
40
+ }
41
+ /**/
42
+ return ($maximum > 365) ? 365 : (int)$maximum;
43
+ }
44
+ ?>
includes/functions/menu-pages.inc.php ADDED
@@ -0,0 +1,297 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function for saving all options from any page.
18
+ */
19
+ function ws_plugin__s2member_update_all_options ()
20
+ {
21
+ if (($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-options-save"))
22
+ {
23
+ $options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]; /* Get current options. */
24
+ /**/
25
+ foreach ($_POST as $key => $value) /* Go through each post variable and look for s2member. */
26
+ {
27
+ if (preg_match ("/^" . preg_quote ("ws_plugin__s2member", "/") . "/", $key)) /* Look for keys. */
28
+ {
29
+ if ($key === "ws_plugin__s2member_configured") /* This is a special configuration option. */
30
+ {
31
+ update_option ("ws_plugin__s2member_configured", trim (stripslashes ($value))); /* Update this option separately. */
32
+ /**/
33
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = trim (stripslashes ($value)); /* Update configuration on-the-fly. */
34
+ }
35
+ else /* We need to place this option into the array. Here we remove the ws_plugin__s2member_ portion on the beginning. */
36
+ {
37
+ (is_array ($value)) ? array_shift ($value) : null; /* Arrays should be padded, 1st key is removed. */
38
+ $options[preg_replace ("/^" . preg_quote ("ws_plugin__s2member_", "/") . "/", "", $key)] = $value;
39
+ }
40
+ }
41
+ }
42
+ /**/
43
+ $options["options_version"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] + 0.001; /* Increment options version. */
44
+ /**/
45
+ $options = ws_plugin__s2member_configure_options_and_their_defaults ($options); /* Also updates the global options array. */
46
+ /**/
47
+ update_option ("ws_plugin__s2member_options", $options) . update_option ("ws_plugin__s2member_cache", array ());
48
+ /**/
49
+ ws_plugin__s2member_display_admin_notice ('<strong>Options saved.</strong>'); /* Display admin notice. */
50
+ }
51
+ /**/
52
+ return;
53
+ }
54
+ /*
55
+ Add the options menus & sub-menus.
56
+ Attach to: add_action("admin_menu");
57
+ */
58
+ function ws_plugin__s2member_add_admin_options ()
59
+ {
60
+ add_filter ("plugin_action_links", "_ws_plugin__s2member_add_settings_link", 10, 2);
61
+ /**/
62
+ add_menu_page ("s2Member Options", "s2Member", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
63
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member General Options", "General Options", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
64
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member PayPal Options", "PayPal® Options", "edit_plugins", "ws-plugin--s2member-paypal-ops", "ws_plugin__s2member_paypal_ops_page");
65
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member PayPal® Buttons", "PayPal® Buttons", "edit_plugins", "ws-plugin--s2member-buttons", "ws_plugin__s2member_buttons_page");
66
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member File Download Options", "Download Options", "edit_plugins", "ws-plugin--s2member-down-ops", "ws_plugin__s2member_down_ops_page");
67
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Tracking", "API / Tracking", "edit_plugins", "ws-plugin--s2member-trk-ops", "ws_plugin__s2member_trk_ops_page");
68
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Notifications", "API / Notifications", "edit_plugins", "ws-plugin--s2member-api-ops", "ws_plugin__s2member_api_ops_page");
69
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Scripting", "API / Scripting", "edit_plugins", "ws-plugin--s2member-scripting", "ws_plugin__s2member_scripting_page");
70
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member Flow Of Events", "Flow Of Events", "edit_plugins", "ws-plugin--s2member-events", "ws_plugin__s2member_events_page");
71
+ add_submenu_page ("ws-plugin--s2member-options", "s2Member Information", "s2Member Info", "edit_plugins", "ws-plugin--s2member-info", "ws_plugin__s2member_info_page");
72
+ /**/
73
+ return;
74
+ }
75
+ /*
76
+ A sort of callback function to add the settings link.
77
+ */
78
+ function _ws_plugin__s2member_add_settings_link ($links = array (), $file = "")
79
+ {
80
+ if (preg_match ("/" . preg_quote ($file, "/") . "#x2F;", $GLOBALS["WS_PLUGIN__"]["s2member"]["l"]) && is_array ($links))
81
+ {
82
+ $settings = '<a href="admin.php?page=ws-plugin--s2member-options">Settings</a>';
83
+ array_unshift ($links, $settings);
84
+ }
85
+ /**/
86
+ return $links;
87
+ }
88
+ /*
89
+ Add scripts to admin panels.
90
+ Attach to: add_action("admin_print_scripts");
91
+ */
92
+ function ws_plugin__s2member_add_admin_scripts ()
93
+ {
94
+ if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
95
+ {
96
+ wp_enqueue_script ("jquery");
97
+ wp_enqueue_script ("thickbox");
98
+ wp_enqueue_script ("media-upload");
99
+ wp_enqueue_script ("ws-plugin--s2member-menu-pages", get_bloginfo ("url") . "/?ws_plugin__s2member_menu_pages_js=1", array ("jquery", "thickbox", "media-upload"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
100
+ }
101
+ /**/
102
+ return;
103
+ }
104
+ /*
105
+ Add styles to admin panels.
106
+ Attach to: add_action("admin_print_styles");
107
+ */
108
+ function ws_plugin__s2member_add_admin_styles ()
109
+ {
110
+ if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
111
+ {
112
+ wp_enqueue_style ("thickbox");
113
+ wp_enqueue_style ("ws-plugin--s2member-menu-pages", get_bloginfo ("url") . "/?ws_plugin__s2member_menu_pages_css=1", array ("thickbox"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
114
+ }
115
+ /**/
116
+ return;
117
+ }
118
+ /*
119
+ Function that outputs the JS for menu pages.
120
+ Attach to: add_action("init");
121
+ */
122
+ function ws_plugin__s2member_menu_pages_js ()
123
+ {
124
+ if ($_GET["ws_plugin__s2member_menu_pages_js"] && is_user_logged_in () && current_user_can ("edit_plugins"))
125
+ {
126
+ header ("Content-Type: text/javascript; charset=utf-8");
127
+ header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
128
+ header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
129
+ header ("Cache-Control: no-cache, must-revalidate, max-age=0");
130
+ header ("Pragma: no-cache");
131
+ /**/
132
+ $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
133
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
134
+ /**/
135
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.js";
136
+ /**/
137
+ exit;
138
+ }
139
+ }
140
+ /*
141
+ Function that outputs the CSS for menu pages.
142
+ Attach to: add_action("init");
143
+ */
144
+ function ws_plugin__s2member_menu_pages_css ()
145
+ {
146
+ if ($_GET["ws_plugin__s2member_menu_pages_css"] && is_user_logged_in () && current_user_can ("edit_plugins"))
147
+ {
148
+ header ("Content-Type: text/css; charset=utf-8");
149
+ header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
150
+ header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
151
+ header ("Cache-Control: no-cache, must-revalidate, max-age=0");
152
+ header ("Pragma: no-cache");
153
+ /**/
154
+ $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
155
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
156
+ /**/
157
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.css";
158
+ /**/
159
+ exit;
160
+ }
161
+ }
162
+ /*
163
+ Function for building and handling the General Options page.
164
+ */
165
+ function ws_plugin__s2member_options_page ()
166
+ {
167
+ ws_plugin__s2member_update_all_options ();
168
+ /**/
169
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/options.inc.php";
170
+ /**/
171
+ return;
172
+ }
173
+ /*
174
+ Function for building and handling the Paypal Options page.
175
+ */
176
+ function ws_plugin__s2member_paypal_ops_page ()
177
+ {
178
+ ws_plugin__s2member_update_all_options ();
179
+ /**/
180
+ $logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
181
+ /**/
182
+ if (!is_dir ($logs_dir) && is_writable (dirname ($logs_dir)))
183
+ mkdir ($logs_dir, 0777);
184
+ /**/
185
+ $htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] . "/.htaccess";
186
+ /**/
187
+ if (is_dir ($logs_dir) && is_writable ($logs_dir) && !file_exists ($htaccess))
188
+ file_put_contents ($htaccess, "deny from all");
189
+ /**/
190
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_debug"]) /* If logging is enabled. */
191
+ {
192
+ if (!is_dir ($logs_dir)) /* If the security-enabled logs directory does not exist yet. */
193
+ ws_plugin__s2member_display_admin_notice ("The security-enabled logs directory ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $logs_dir) . "</code> ) does not exist. Please create this directory manually &amp; make it writable ( chmod 777 ).", true);
194
+ /**/
195
+ else if (!is_writable ($logs_dir)) /* If the logs directory is not writable yet. */
196
+ ws_plugin__s2member_display_admin_notice ("Permissions error. The security-enabled logs directory ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $logs_dir) . "</code> ) is not writable. Please make this directory writable ( chmod 777 ).", true);
197
+ /**/
198
+ if (!file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
199
+ ws_plugin__s2member_display_admin_notice ("The .htaccess protection file ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess) . "</code> ) does not exist. Please create this file manually. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
200
+ /**/
201
+ else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
202
+ ws_plugin__s2member_display_admin_notice ("Unprotected. The .htaccess protection file ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess) . "</code> ) does not contain <code>deny from all</code>. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
203
+ }
204
+ /**/
205
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/paypal-ops.inc.php";
206
+ /**/
207
+ return;
208
+ }
209
+ /*
210
+ Function for building and handling the Download Options page.
211
+ */
212
+ function ws_plugin__s2member_down_ops_page ()
213
+ {
214
+ ws_plugin__s2member_update_all_options ();
215
+ /**/
216
+ $files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
217
+ /**/
218
+ if (!is_dir ($files_dir) && is_writable (dirname ($files_dir)))
219
+ mkdir ($files_dir, 0777);
220
+ /**/
221
+ $htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/.htaccess";
222
+ /**/
223
+ if (is_dir ($files_dir) && is_writable ($files_dir) && !file_exists ($htaccess))
224
+ file_put_contents ($htaccess, "deny from all");
225
+ /**/
226
+ if (!is_dir ($files_dir)) /* If the security-enabled files directory does not exist yet. */
227
+ ws_plugin__s2member_display_admin_notice ("The security-enabled files directory ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $files_dir) . "</code> ) does not exist. Please create this directory manually.", true);
228
+ /**/
229
+ if (!file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
230
+ ws_plugin__s2member_display_admin_notice ("The .htaccess protection file ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess) . "</code> ) does not exist. Please create this file manually. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
231
+ /**/
232
+ else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
233
+ ws_plugin__s2member_display_admin_notice ("Unprotected. The .htaccess protection file ( <code>" . preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess) . "</code> ) does not contain <code>deny from all</code>. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
234
+ /**/
235
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/down-ops.inc.php";
236
+ /**/
237
+ return;
238
+ }
239
+ /*
240
+ Function for building and handling the API Tracking options page.
241
+ */
242
+ function ws_plugin__s2member_trk_ops_page ()
243
+ {
244
+ ws_plugin__s2member_update_all_options ();
245
+ /**/
246
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/trk-ops.inc.php";
247
+ /**/
248
+ return;
249
+ }
250
+ /*
251
+ Function for building and handling the API Notifications page.
252
+ */
253
+ function ws_plugin__s2member_api_ops_page ()
254
+ {
255
+ ws_plugin__s2member_update_all_options ();
256
+ /**/
257
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/api-ops.inc.php";
258
+ /**/
259
+ return;
260
+ }
261
+ /*
262
+ Function for building the PayPal Button Generator page.
263
+ */
264
+ function ws_plugin__s2member_buttons_page ()
265
+ {
266
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/buttons.inc.php";
267
+ /**/
268
+ return;
269
+ }
270
+ /*
271
+ Function for building the API Scripting page.
272
+ */
273
+ function ws_plugin__s2member_scripting_page ()
274
+ {
275
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
276
+ /**/
277
+ return;
278
+ }
279
+ /*
280
+ Function for building the Flow Of Events page.
281
+ */
282
+ function ws_plugin__s2member_events_page ()
283
+ {
284
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/events.inc.php";
285
+ /**/
286
+ return;
287
+ }
288
+ /*
289
+ Function for building the s2Member Info page.
290
+ */
291
+ function ws_plugin__s2member_info_page ()
292
+ {
293
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
294
+ /**/
295
+ return;
296
+ }
297
+ ?>
includes/functions/min-level-4-downloads.inc.php ADDED
@@ -0,0 +1,41 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function determines the minimum level required for file download access.
18
+ Returns 0-4, where 0 means no access to file downloads has been allowed.
19
+ */
20
+ function ws_plugin__s2member_min_level_4_downloads ()
21
+ {
22
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
23
+ {
24
+ $file_download_access_is_allowed = $minimum_level_required_to_download_files = 1;
25
+ }
26
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
27
+ {
28
+ $file_download_access_is_allowed = $minimum_level_required_to_download_files = 2;
29
+ }
30
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
31
+ {
32
+ $file_download_access_is_allowed = $minimum_level_required_to_download_files = 3;
33
+ }
34
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
35
+ {
36
+ $file_download_access_is_allowed = $minimum_level_required_to_download_files = 4;
37
+ }
38
+ /**/
39
+ return (int)$minimum_level_required_to_download_files;
40
+ }
41
+ ?>
includes/functions/nocache.inc.php ADDED
@@ -0,0 +1,80 @@
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Handles no-cache headers and compatible constants for s2Member.
18
+ This is compatible with Quick Cache and also with WP Super Cache.
19
+ Attach to: add_action("init");
20
+ */
21
+ function ws_plugin__s2member_nocache ()
22
+ {
23
+ ws_plugin__s2member_nocache_constants () . ws_plugin__s2member_nocache_headers ();
24
+ /**/
25
+ return;
26
+ }
27
+ /*
28
+ Define compatible nocache constants for s2Member.
29
+ This is compatible with Quick Cache and also with WP Super Cache.
30
+ Quick Cache uses: QUICK_CACHE_ALLOWED, and Super Cache uses: DONOTCACHEPAGE.