PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/s2member/includes/syscon.inc.php

https://gitlab.com/Gashler/sg
PHP | 622 lines | 506 code | 28 blank | 88 comment | 6 complexity | 9e8e0e7ef2a9d96705980e02fb948402 MD5 | raw file
  1. <?php
  2. /**
  3. * System configuration for the s2Member plugin.
  4. *
  5. * **WARNING:** This is a system configuration file, please DO NOT EDIT this file directly.
  6. * Instead, use the plugin options panel in WordPress to override these settings.
  7. *
  8. * Copyright: © 2009-2011
  9. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  10. * (coded in the USA)
  11. *
  12. * Released under the terms of the GNU General Public License.
  13. * You should have received a copy of the GNU General Public License,
  14. * along with this software. In the main directory, see: /licensing/
  15. * If not, see: {@link http://www.gnu.org/licenses/}.
  16. *
  17. * @package s2Member
  18. * @since 3.0
  19. */
  20. if(!defined('WPINC')) // MUST have WordPress.
  21. exit('Do not access this file directly.');
  22. /*
  23. Determine the directory.
  24. */
  25. $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir'] = dirname(dirname(__FILE__));
  26. /*
  27. Determine the base directory name.
  28. */
  29. $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_base'] = basename(dirname(dirname(__FILE__)));
  30. /*
  31. Determine the full URL to the directory this plugin resides in.
  32. */
  33. $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'] = (stripos(__FILE__, WP_CONTENT_DIR) !== 0) ? // Have to assume plugins dir?
  34. plugins_url('/'.basename(dirname(dirname(__FILE__)))) : // Otherwise, this gives it a chance to live anywhere in the content dir.
  35. content_url(preg_replace('/^(.*?)\/'.preg_quote(basename(WP_CONTENT_DIR), '/').'/', '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(dirname(__FILE__)))));
  36. /*
  37. Determine full URL to the s2Member-only file that loads WordPress with only s2Member active.
  38. */
  39. $GLOBALS['WS_PLUGIN__']['s2member']['c']['s2o_url'] = $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/'.preg_replace('/\.php$/', '-o.php', basename($GLOBALS['WS_PLUGIN__']['s2member']['l']));
  40. /*
  41. Determine correct ``plugin_basename()`` here. WordPress has a few issues with its ``plugin_basename()`` function across different platforms.
  42. */
  43. $GLOBALS['WS_PLUGIN__']['s2member']['c']['plugin_basename'] = basename(dirname($GLOBALS['WS_PLUGIN__']['s2member']['l'])).'/'.basename($GLOBALS['WS_PLUGIN__']['s2member']['l']);
  44. /*
  45. Configure the number of Membership Levels being used with s2Member. This is now possible. All areas of s2Member are now capable of adapting to this.
  46. */
  47. $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] = 4; // Hard coded in at 4 Levels. This can only be extended when/if s2Member Pro is installed.
  48. $GLOBALS['WS_PLUGIN__']['s2member']['c']['min_levels'] = 1; // A lower limit to protect the integrity of the s2Member software application.
  49. $GLOBALS['WS_PLUGIN__']['s2member']['c']['max_levels'] = apply_filters('ws_plugin__s2member_max_levels', 100); // Filterable.
  50. /*
  51. Configure regular expression matches for Membership Access Item Numbers (including those with only Custom Capabilities).
  52. */
  53. $GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'] = '/^([1-9][0-9]*)(?:(?:\:((?:-all\+|\+-all|-all|\+)?[a-z_0-9,\+]*)?)?(?:\:([0-9]+ [A-Z])?)?)?$/';
  54. $GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_wo_level_regex'] = '/^(\*)(?:(?:\:((?:-all\+|\+-all|-all|\+)?[a-z_0-9,\+]*)?)?(?:\:([0-9]+ [A-Z])?)?)?$/';
  55. $GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_or_wo_level_regex'] = '/^([1-9][0-9]*|\*)(?:(?:\:((?:-all\+|\+-all|-all|\+)?[a-z_0-9,\+]*)?)?(?:\:([0-9]+ [A-Z])?)?)?$/';
  56. /*
  57. Configure regular expression match for Specific Post/Page Access Item Numbers (all elements required here).
  58. */
  59. $GLOBALS['WS_PLUGIN__']['s2member']['c']['sp_access_item_number_regex'] = '/^(sp)(?:(?:\:([1-9][0-9,]*))(?:\:([1-9][0-9]*)))$/';
  60. /*
  61. Configure multibyte detection order when charset is unknown ( used by calls to `mb_convert_encoding()` ).
  62. */
  63. $GLOBALS['WS_PLUGIN__']['s2member']['c']['mb_detection_order'] = 'UTF-8, ISO-8859-1, WINDOWS-1252, ASCII, JIS, EUC-JP, SJIS';
  64. /*
  65. Configure an array of file extensions associated with streaming media file types. See: <http://www.spartanicus.utvinternet.ie/streaming.htm> Also see: <http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12539/supported-video-and-audio-formats>
  66. */
  67. $GLOBALS['WS_PLUGIN__']['s2member']['c']['streaming_file_extns'] = array_unique(array('avi', 'wav', 'mpa', 'mpeg', 'mpv', 'mps', 'm1v', 'm2v', 'mp4', 'mp3', 'm3u', 'mp4', 'flv', 'f4v', '3gp', '3g2', 'aac', 'm4a', 'webm', 'ogg', 'ogv', 'pls', 'm3u', 'ogm', 'm4u', 'mov', 'qtl', 'mp4', 'asf', 'wmv', 'wvx', 'wma', 'wax', 'ra', 'rm', 'ram'));
  68. /*
  69. Configure directory and .htaccess for files protected by s2Member.
  70. */
  71. $GLOBALS['WS_PLUGIN__']['s2member']['c']['default_files_dir'] = dirname(dirname(__FILE__)).'-files'.((stripos(PHP_OS, 'win') === 0 && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') === FALSE) ? '/app_data' : '');
  72. $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir'] = apply_filters('ws_plugin__s2member_files_dir', $GLOBALS['WS_PLUGIN__']['s2member']['c']['default_files_dir']);
  73. $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_no_gzip_htaccess'] = dirname(__FILE__).'/templates/cfg-files/s2member-files-no-gzip.php';
  74. $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir_htaccess'] = dirname(__FILE__).'/templates/cfg-files/s2member-files.php';
  75. /*
  76. Configure the directory for logs protected by s2Member.
  77. */
  78. $GLOBALS['WS_PLUGIN__']['s2member']['c']['default_logs_dir'] = dirname(dirname(__FILE__)).'-logs'.((stripos(PHP_OS, 'win') === 0 && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') === FALSE) ? '/app_data' : '');
  79. $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'] = apply_filters('ws_plugin__s2member_logs_dir', $GLOBALS['WS_PLUGIN__']['s2member']['c']['default_logs_dir']);
  80. $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir_htaccess'] = dirname(__FILE__).'/templates/cfg-files/s2member-logs.php';
  81. /*
  82. Configure the global reCaptcha (www.websharks-inc.net / or any domain). These public/private keys work on any installation.
  83. */
  84. $GLOBALS['WS_PLUGIN__']['s2member']['c']['recaptcha'] = array('public_key' => '6LeCANsSAAAAAIIrlB3FrXe42mr0OSSZpT0pkpFK', 'private_key' => '6LeCANsSAAAAAGBXMIKAirv6G4PmaGa-ORxdD-oZ', 'lang' => _x('en', 's2member-front recaptcha-lang-code', 's2member'));
  85. /*
  86. Configure the right menu options panel for s2Member.
  87. */
  88. $GLOBALS['WS_PLUGIN__']['s2member']['c']['menu_pages'] = array('updates' => TRUE, 'upsell-pro' => TRUE, 'installation' => FALSE, 'tools' => FALSE, 'kb' => TRUE, 'videos' => TRUE, 'support' => TRUE, 'donations' => TRUE, 'beta' => TRUE);
  89. /*
  90. Check if s2Member has been configured *should be set after the first config via options panel*.
  91. */
  92. $GLOBALS['WS_PLUGIN__']['s2member']['c']['configured'] = get_option('ws_plugin__s2member_configured');
  93. /*
  94. This is a special option cache that holds some additional information autoloaded into WordPress.
  95. */
  96. $GLOBALS['WS_PLUGIN__']['s2member']['c']['cache'] = get_option('ws_plugin__s2member_cache');
  97. /*
  98. Configure checksum time for the syscon.inc.php file.
  99. */
  100. $GLOBALS['WS_PLUGIN__']['s2member']['c']['checksum'] = filemtime(__FILE__);
  101. /*
  102. Configure an array of pluggable functions handled by s2Member.
  103. */
  104. $GLOBALS['WS_PLUGIN__']['s2member']['c']['pluggables'] = array();
  105. /*
  106. Configure & validate all of the s2Member options; and set their defaults.
  107. */
  108. if(!function_exists('ws_plugin__s2member_configure_options_and_their_defaults'))
  109. {
  110. /**
  111. * Configures an options array for the s2Member plugin.
  112. *
  113. * **WARNING:** This is a system configuration function, please DO NOT EDIT this function directly.
  114. * Instead, use the plugin options panel in WordPress to override these settings.
  115. *
  116. * @package s2Member
  117. * @since 3.0
  118. *
  119. * @param boolean|array $options Optional. An array of new options, to be merged with the defaults.
  120. *
  121. * @return array This merged array of options: ``$GLOBALS['WS_PLUGIN__']['s2member']['o']``
  122. */
  123. function ws_plugin__s2member_configure_options_and_their_defaults($options = FALSE)
  124. {
  125. global $current_site, $current_blog;
  126. $default_options['options_checksum'] = '';
  127. $default_options['options_version'] = '1.0';
  128. $default_options['gateway_debug_logs'] = '0';
  129. $default_options['gateway_debug_logs_extensive'] = '0';
  130. $default_options['lazy_load_css_js'] = '0';
  131. $default_options['sc_conds_allow_arbitrary_php'] = '0';
  132. $default_options['sec_encryption_key'] = '';
  133. $default_options['sec_encryption_key_history'] = array();
  134. $default_options['s_badge_status_enabled'] = '0';
  135. $default_options['max_ip_restriction'] = '5';
  136. $default_options['max_ip_restriction_time'] = '3600';
  137. $default_options['max_failed_login_attempts'] = '5';
  138. $default_options['max_simultaneous_logins'] = '0';
  139. $default_options['max_simultaneous_logins_timeout'] = '30 minutes';
  140. $default_options['run_uninstall_routines'] = '0';
  141. $default_options['custom_reg_fields'] = '';
  142. $default_options['custom_reg_names'] = '1';
  143. $default_options['custom_reg_display_name'] = 'full';
  144. $default_options['custom_reg_password'] = '0';
  145. $default_options['custom_reg_password_min_length'] = '8'; // Minimum characters.
  146. $default_options['custom_reg_password_min_strength'] = 'good'; // `weak`, `good` or `strong`.
  147. $default_options['custom_reg_opt_in'] = '1';
  148. $default_options['custom_reg_opt_in_label'] = _x('Yes, I want to receive updates via email.', 's2member-front', 's2member');
  149. $default_options['custom_reg_auto_opt_outs'] = array();
  150. $default_options['custom_reg_auto_opt_out_transitions'] = '0';
  151. $default_options['custom_reg_fields_4bp'] = array();
  152. $default_options['custom_reg_force_personal_emails'] = '';
  153. $default_options['allow_subscribers_in'] = '0';
  154. $default_options['force_admin_lockouts'] = '0';
  155. $default_options['filter_wp_query'] = array('all');
  156. $default_options['default_url_shortener'] = 'tiny_url';
  157. $default_options['default_url_shortener_key'] = '';
  158. $default_options['default_custom_str_url_shortener'] = '';
  159. $default_options['mms_auto_patch'] = '1';
  160. $default_options['mms_registration_file'] = 'wp-login';
  161. $default_options['mms_registration_grants'] = 'none';
  162. for($n = 0, $v = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++, $v = $v + 5)
  163. $default_options['mms_registration_blogs_level'.$n] = (string)$v;
  164. $default_options['login_welcome_page'] = '';
  165. $default_options['login_redirection_override'] = '';
  166. $default_options['login_redirection_always_http'] = '1';
  167. $default_options['membership_options_page'] = '';
  168. $default_options['membership_options_page_vars_enable'] = '1';
  169. $default_options['membership_options_page_ga_vars_enable'] = '1';
  170. $default_options['login_reg_design_enabled'] = '1';
  171. $default_options['login_reg_background_color'] = 'FFFFFF';
  172. $default_options['login_reg_background_image'] = $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/images/bg.png';
  173. $default_options['login_reg_background_image_repeat'] = 'repeat';
  174. $default_options['login_reg_background_text_color'] = '000000';
  175. $default_options['login_reg_background_text_shadow_color'] = 'EEEEEE';
  176. $default_options['login_reg_background_box_shadow_color'] = 'EEEEEE';
  177. $default_options['login_reg_logo_src'] = $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/images/logo.png';
  178. $default_options['login_reg_logo_src_width'] = '550';
  179. $default_options['login_reg_logo_src_height'] = '100';
  180. $default_options['login_reg_logo_url'] = home_url('/');
  181. $default_options['login_reg_logo_title'] = get_bloginfo('name');
  182. $default_options['login_reg_font_size'] = '12px';
  183. $default_options['login_reg_font_family'] = "'Verdana', 'Arial', sans-serif";
  184. $default_options['login_reg_font_field_size'] = '18px';
  185. $default_options['login_reg_footer_backtoblog'] = '0';
  186. $default_options['login_reg_footer_design'] = '';
  187. $default_options['reg_email_from_name'] = get_bloginfo('name');
  188. $default_options['reg_email_from_email'] = get_bloginfo('admin_email');
  189. $default_options['reg_email_support_link'] = 'mailto:'.get_bloginfo('admin_email');
  190. $default_options['new_user_emails_enabled'] = '0';
  191. $default_options['new_user_email_subject'] = sprintf(_x('[%s] Username/Password', 's2member-front', 's2member'), get_bloginfo('name'));
  192. $default_options['new_user_email_message'] = sprintf(_x("Your Username/Password for:\n%s\n\nUsername: %%%%user_login%%%%\nPassword: %%%%user_pass%%%%\n%%%%wp_login_url%%%%", 's2member-front', 's2member'), get_bloginfo('name'));
  193. $default_options['new_user_admin_email_recipients'] = get_bloginfo('admin_email');
  194. $default_options['new_user_admin_email_subject'] = sprintf(_x('[%s] New User Registration', 's2member-front', 's2member'), get_bloginfo('name'));
  195. $default_options['new_user_admin_email_message'] = sprintf(_x("New User Registration on your site:\n%s\n\nUser ID: %%%%user_id%%%%\nUsername: %%%%user_login%%%%\nEmail: %%%%user_email%%%%\nIP Address: %%%%user_ip%%%%", 's2member-front', 's2member'), get_bloginfo('name'));
  196. $default_options['paypal_sandbox'] = '0';
  197. $default_options['paypal_business'] = '';
  198. $default_options['paypal_merchant_id'] = '';
  199. $default_options['paypal_api_username'] = '';
  200. $default_options['paypal_api_password'] = '';
  201. $default_options['paypal_api_signature'] = '';
  202. $default_options['paypal_identity_token'] = '';
  203. $default_options['paypal_btn_encryption'] = '0';
  204. $default_options['paypal_payflow_api_username'] = '';
  205. $default_options['paypal_payflow_api_partner'] = 'PayPal';
  206. $default_options['paypal_payflow_api_vendor'] = '';
  207. $default_options['paypal_payflow_api_password'] = '';
  208. $default_options['signup_tracking_codes'] = '';
  209. $default_options['modification_tracking_codes'] = '';
  210. $default_options['ccap_tracking_codes'] = '';
  211. $default_options['sp_tracking_codes'] = '';
  212. $default_options['signup_email_recipients'] = '"%%full_name%%" <%%payer_email%%>';
  213. $default_options['signup_email_subject'] = _x('Congratulations! (your membership has been approved)', 's2member-front', 's2member');
  214. $default_options['signup_email_message'] = sprintf(_x("Thanks %%%%first_name%%%%! Your membership has been approved.\n\nIf you haven't already done so, the next step is to Register a Username.\n\nComplete your registration here:\n%%%%registration_url%%%%\n\nIf you have any trouble, please feel free to contact us.\n\nBest Regards,\n%s", 's2member-front', 's2member'), get_bloginfo('name'));
  215. $default_options['modification_email_recipients'] = '"%%full_name%%" <%%payer_email%%>';
  216. $default_options['modification_email_subject'] = _x('Thank you! Your account has been updated.', 's2member-front', 's2member');
  217. $default_options['modification_email_message'] = sprintf(_x("Thanks %%%%first_name%%%%! Your account now has access to: %%%%item_name%%%%.\n\nIf you have any trouble, please feel free to contact us.\n\nBest Regards,\n%s", 's2member-front', 's2member'), get_bloginfo('name'));
  218. $default_options['ccap_email_recipients'] = '"%%full_name%%" <%%payer_email%%>';
  219. $default_options['ccap_email_subject'] = _x('Thank you! Your account has been updated.', 's2member-front', 's2member');
  220. $default_options['ccap_email_message'] = sprintf(_x("Thanks %%%%first_name%%%%! Your account now has access to: %%%%item_name%%%%.\n\nIf you have any trouble, please feel free to contact us.\n\nBest Regards,\n%s", 's2member-front', 's2member'), get_bloginfo('name'));
  221. $default_options['sp_email_recipients'] = '"%%full_name%%" <%%payer_email%%>';
  222. $default_options['sp_email_subject'] = _x('Thank You! (instructions for access)', 's2member-front', 's2member');
  223. $default_options['sp_email_message'] = sprintf(_x("Thanks %%%%first_name%%%%!\n\n%%%%item_name%%%%\n\nYour order can be retrieved here:\n%%%%sp_access_url%%%%\n(link expires in %%%%sp_access_exp%%%%)\n\nIf you have any trouble, please feel free to contact us.\n\nBest Regards,\n%s", 's2member-front', 's2member'), get_bloginfo('name'));
  224. $default_options['mailchimp_api_key'] = '';
  225. $default_options['getresponse_api_key'] = '';
  226. $default_options['aweber_api_key'] = '';
  227. $default_options['aweber_internal_api_key'] = '';
  228. $default_options['aweber_api_type'] = 'api';
  229. if($GLOBALS['WS_PLUGIN__']['s2member']['c']['configured'])
  230. $default_options['aweber_api_type'] = 'email';
  231. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  232. $default_options['level'.$n.'_mailchimp_list_ids'] = '';
  233. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  234. $default_options['level'.$n.'_getresponse_list_ids'] = '';
  235. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  236. $default_options['level'.$n.'_aweber_list_ids'] = '';
  237. $default_options['signup_notification_urls'] = '';
  238. $default_options['registration_notification_urls'] = '';
  239. $default_options['payment_notification_urls'] = '';
  240. $default_options['modification_notification_urls'] = '';
  241. $default_options['cancellation_notification_urls'] = '';
  242. $default_options['eot_del_notification_urls'] = '';
  243. $default_options['ref_rev_notification_urls'] = '';
  244. $default_options['sp_sale_notification_urls'] = '';
  245. $default_options['sp_ref_rev_notification_urls'] = '';
  246. $default_options['signup_notification_recipients'] = '';
  247. $default_options['registration_notification_recipients'] = '';
  248. $default_options['payment_notification_recipients'] = '';
  249. $default_options['modification_notification_recipients'] = '';
  250. $default_options['cancellation_notification_recipients'] = '';
  251. $default_options['eot_del_notification_recipients'] = '';
  252. $default_options['ref_rev_notification_recipients'] = '';
  253. $default_options['sp_sale_notification_recipients'] = '';
  254. $default_options['sp_ref_rev_notification_recipients'] = '';
  255. for($n = 0, $l = array(_x('Free Subscriber', 's2member-front', 's2member'), _x('Bronze Member', 's2member-front', 's2member'), _x('Silver Member', 's2member-front', 's2member'), _x('Gold Member', 's2member-front', 's2member'), _x('Platinum Member', 's2member-front', 's2member')); $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++) $default_options['level'.$n.'_label'] = (!empty($l[$n])) ? $l[$n] : sprintf(_x('Level %s Member', 's2member-front', 's2member'), $n);
  256. $default_options['apply_label_translations'] = '0';
  257. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  258. $default_options['level'.$n.'_file_downloads_allowed'] = '';
  259. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  260. $default_options['level'.$n.'_file_downloads_allowed_days'] = '';
  261. $default_options['file_download_limit_exceeded_page'] = '';
  262. $default_options['file_download_inline_extensions'] = '';
  263. $default_options['file_download_stream_extensions'] = '';
  264. $default_options['file_download_content_encodong_none'] = '0';
  265. $default_options['amazon_s3_files_bucket'] = '';
  266. $default_options['amazon_s3_files_bucket_region'] = '';
  267. $default_options['amazon_s3_files_access_key'] = '';
  268. $default_options['amazon_s3_files_secret_key'] = '';
  269. $default_options['amazon_cf_files_private_key'] = '';
  270. $default_options['amazon_cf_files_private_key_id'] = '';
  271. $default_options['amazon_cf_files_distros_access_id'] = '';
  272. $default_options['amazon_cf_files_distros_s3_access_id'] = '';
  273. $default_options['amazon_cf_files_distro_downloads_id'] = '';
  274. $default_options['amazon_cf_files_distro_downloads_cname'] = '';
  275. $default_options['amazon_cf_files_distro_downloads_dname'] = '';
  276. $default_options['amazon_cf_files_distro_streaming_id'] = '';
  277. $default_options['amazon_cf_files_distro_streaming_cname'] = '';
  278. $default_options['amazon_cf_files_distro_streaming_dname'] = '';
  279. $default_options['amazon_cf_files_distros_auto_config_status'] = '';
  280. $default_options['ruris_case_sensitive'] = '0'; // No by default.
  281. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  282. $default_options['level'.$n.'_ruris'] = '';
  283. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  284. $default_options['level'.$n.'_catgs'] = '';
  285. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  286. $default_options['level'.$n.'_ptags'] = '';
  287. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  288. $default_options['level'.$n.'_posts'] = '';
  289. for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++)
  290. $default_options['level'.$n.'_pages'] = '';
  291. $default_options['specific_ids'] = '';
  292. $default_options['triggers_immediate_eot'] = 'reversals';
  293. $default_options['membership_eot_behavior'] = 'demote';
  294. $default_options['eot_time_ext_behavior'] = 'extend';
  295. $default_options['auto_eot_system_enabled'] = '1';
  296. $default_options['eots_remove_ccaps'] = '1';
  297. $default_options['eot_grace_time'] = '86400';
  298. $default_options['wp_footer_code'] = '';
  299. $default_options = apply_filters('ws_plugin__s2member_default_options', $default_options);
  300. unset($n, $v, $l); // Unset/cleanup these working variables from the routines above.
  301. /*
  302. Here they are merged. User options will overwrite some or all default values.
  303. */
  304. $GLOBALS['WS_PLUGIN__']['s2member']['o'] = array_merge($default_options, (($options !== FALSE) ? (array)$options : (array)get_option('ws_plugin__s2member_options')));
  305. /*
  306. * Ditch this old option key; no longer in use.
  307. */
  308. if(isset($GLOBALS['WS_PLUGIN__']['s2member']['o']['run_deactivation_routines'])) unset($GLOBALS['WS_PLUGIN__']['s2member']['o']['run_deactivation_routines']);
  309. /*
  310. This builds an MD5 checksum for the full array of options. This also includes the config checksum and the current set of default options.
  311. */
  312. $checksum = md5(($checksum_prefix = $GLOBALS['WS_PLUGIN__']['s2member']['c']['checksum'].serialize($default_options)).serialize(array_merge($GLOBALS['WS_PLUGIN__']['s2member']['o'], array('options_checksum' => 0))));
  313. /*
  314. Validate each option, possibly reverting back to the default value in some cases. This is only processed when/if the checksum is not up-to-date.
  315. */
  316. if($options !== FALSE || ($GLOBALS['WS_PLUGIN__']['s2member']['o']['options_checksum'] !== $checksum && $GLOBALS['WS_PLUGIN__']['s2member']['o'] !== $default_options))
  317. {
  318. foreach($GLOBALS['WS_PLUGIN__']['s2member']['o'] as $key => &$value)
  319. {
  320. if(!isset($default_options[$key]) && !preg_match('/^pro_/', $key))
  321. unset($GLOBALS['WS_PLUGIN__']['s2member']['o'][$key]);
  322. else if($key === 'options_checksum' && (!is_string($value) || !strlen($value)))
  323. $value = $default_options[$key];
  324. else if($key === 'options_version' && (!is_string($value) || !is_numeric($value)))
  325. $value = $default_options[$key];
  326. else if(preg_match('/^gateway_debug_logs|gateway_debug_logs_extensive/', $key) && (!is_string($value) || !is_numeric($value)))
  327. $value = $default_options[$key];
  328. else if($key === 'lazy_load_css_js' && (!is_string($value) || !is_numeric($value)))
  329. $value = $default_options[$key];
  330. else if($key === 'sc_conds_allow_arbitrary_php' && (!is_string($value) || !is_numeric($value)))
  331. $value = $default_options[$key];
  332. else if($key === 'sec_encryption_key' && (!is_string($value) || !strlen($value)))
  333. $value = $default_options[$key];
  334. else if($key === 'sec_encryption_key_history' && (!is_array($value) || empty($value)))
  335. $value = $default_options[$key];
  336. else if($key === 's_badge_status_enabled' && (!is_string($value) || !is_numeric($value)))
  337. $value = $default_options[$key];
  338. else if($key === 'max_ip_restriction' && (!is_string($value) || !is_numeric($value) || $value < 0 || $value > 100))
  339. $value = $default_options[$key];
  340. else if($key === 'max_ip_restriction_time' && (!is_string($value) || !is_numeric($value) || $value < 300 || $value > 31556926))
  341. $value = $default_options[$key];
  342. else if($key === 'max_failed_login_attempts' && (!is_string($value) || !is_numeric($value) || $value < 0 || $value > 100))
  343. $value = $default_options[$key];
  344. else if($key === 'max_simultaneous_logins' && (!is_string($value) || !is_numeric($value) || $value < 0))
  345. $value = $default_options[$key];
  346. else if($key === 'max_simultaneous_logins_timeout' && (!is_string($value) || !strlen($value)))
  347. $value = $default_options[$key];
  348. else if($key === 'run_uninstall_routines' && (!is_string($value) || !is_numeric($value)))
  349. $value = $default_options[$key];
  350. else if($key === 'custom_reg_fields' && (!is_string($value) || !strlen($value)))
  351. $value = $default_options[$key];
  352. else if(preg_match('/^custom_reg_(?:names|password|password_min_length|opt_in|auto_opt_out_transitions)$/', $key) && (!is_string($value) || !is_numeric($value)))
  353. $value = $default_options[$key];
  354. else if($key === 'custom_reg_password_min_strength' && (!is_string($value) || !strlen($value)))
  355. $value = $default_options[$key];
  356. else if($key === 'custom_reg_display_name' && (!is_string($value) || !preg_match('/^(?:full|first|last|login|0)$/', $value)))
  357. $value = $default_options[$key];
  358. else if($key === 'custom_reg_opt_in_label' && (!is_string($value) || !strlen($value)))
  359. $value = $default_options[$key];
  360. else if($key === 'custom_reg_auto_opt_outs' && (!is_array($value) || empty($value)))
  361. $value = $default_options[$key];
  362. else if($key === 'custom_reg_fields_4bp' && (!is_array($value) || empty($value)))
  363. $value = $default_options[$key];
  364. else if($key === 'custom_reg_force_personal_emails' && (!is_string($value) || !strlen($value = preg_replace('/\s+/', '', $value))))
  365. $value = $default_options[$key];
  366. else if($key === 'allow_subscribers_in' && (!is_string($value) || !is_numeric($value)))
  367. $value = $default_options[$key];
  368. else if($key === 'mms_auto_patch' && (!is_string($value) || !is_numeric($value)))
  369. $value = $default_options[$key];
  370. else if($key === 'mms_registration_file' && (!is_string($value) || !preg_match('/^(?:wp-login|wp-signup)$/', $value)))
  371. $value = $default_options[$key];
  372. else if($key === 'mms_registration_grants' && (!is_string($value) || !preg_match('/^(?:none|user|all)$/', $value)))
  373. $value = $default_options[$key];
  374. else if(preg_match('/^mms_registration_blogs_level[0-9]+$/', $key) && (!is_string($value) || !is_numeric($value) || $value < 0))
  375. $value = $default_options[$key];
  376. else if($key === 'force_admin_lockouts' && (!is_string($value) || !is_numeric($value)))
  377. $value = $default_options[$key];
  378. else if($key === 'filter_wp_query' && !is_array($value) /* This array CAN be empty. */)
  379. $value = $default_options[$key];
  380. else if(preg_match('/^default_(?:custom_str_)?url_shortener$/', $key) && (!is_string($value) || !strlen($value)))
  381. $value = $default_options[$key];
  382. else if($key === 'login_welcome_page' && (!is_string($value) || !is_numeric($value)))
  383. $value = $default_options[$key];
  384. else if($key === 'login_redirection_override' && (!is_string($value) || !strlen($value)))
  385. $value = $default_options[$key];
  386. else if($key === 'login_redirection_always_http' && (!is_string($value) || !is_numeric($value)))
  387. $value = $default_options[$key];
  388. else if($key === 'membership_options_page' && (!is_string($value) || !is_numeric($value)))
  389. $value = $default_options[$key];
  390. else if($key === 'membership_options_page_vars_enable' && (!is_string($value) || !is_numeric($value)))
  391. $value = $default_options[$key];
  392. else if($key === 'membership_options_page_ga_vars_enable' && (!is_string($value) || !is_numeric($value)))
  393. $value = $default_options[$key];
  394. else if($key === 'login_reg_design_enabled' && (!is_string($value) || !is_numeric($value)))
  395. $value = $default_options[$key];
  396. else if($key === 'login_reg_background_image' && !is_string($value) /* This is optional. */)
  397. $value = $default_options[$key];
  398. else if($key === 'login_reg_background_image_repeat' && (!is_string($value) || !preg_match('/^(?:repeat|repeat-x|repeat-y|no-repeat)$/', $value)))
  399. $value = $default_options[$key];
  400. else if(preg_match('/^login_reg_(?:background|logo|font|footer)_/', $key) && !preg_match('/background_image/', $key) && (!is_string($value) || !strlen($value)))
  401. $value = $default_options[$key];
  402. else if($key === 'login_reg_footer_backtoblog' && (!is_string($value) || !is_numeric($value)))
  403. $value = $default_options[$key];
  404. else if(preg_match('/^reg_email_(?:from_name|from_email|support_link)$/', $key) && (!is_string($value) || !strlen($value)))
  405. $value = $default_options[$key];
  406. else if($key === 'new_user_emails_enabled' && (!is_string($value) || !is_numeric($value)))
  407. $value = $default_options[$key];
  408. else if(preg_match('/^new_user_email_(?:subject|message)$/', $key) && (!is_string($value) || !strlen($value)))
  409. $value = $default_options[$key];
  410. else if(preg_match('/^new_user_admin_email_(?:recipients|subject|message)$/', $key) && (!is_string($value) || !strlen($value)))
  411. $value = $default_options[$key];
  412. else if($key === 'paypal_sandbox' && (!is_string($value) || !is_numeric($value)))
  413. $value = $default_options[$key];
  414. else if(preg_match('/^paypal_(?:business|merchant_id|api_username|api_password|api_signature|identity_token)$/', $key) && (!is_string($value) || !strlen($value)))
  415. $value = $default_options[$key];
  416. else if(preg_match('/^paypal_payflow(?:api_username|api_partner|api_vendor|api_password)$/', $key) && (!is_string($value) || !strlen($value)))
  417. $value = $default_options[$key];
  418. else if($key === 'paypal_btn_encryption' && (!is_string($value) || !is_numeric($value)))
  419. $value = $default_options[$key];
  420. else if(preg_match('/^(?:signup|modification|ccap|sp)_tracking_codes$/', $key) && (!is_string($value) || !strlen($value)))
  421. $value = $default_options[$key];
  422. else if(preg_match('/^(?:signup|modification|ccap|sp)_email_recipients$/', $key) && !is_string($value) /* Can be empty. */)
  423. $value = $default_options[$key];
  424. else if(preg_match('/^(?:signup|modification|ccap|sp)_email_(?:subject|message)$/', $key) && (!is_string($value) || !strlen($value)))
  425. $value = $default_options[$key];
  426. else if($key === 'aweber_api_type' && (!is_string($value) || !preg_match('/^(?:api|email)$/', $value)))
  427. $value = $default_options[$key];
  428. else if(preg_match('/^(?:mailchimp|getresponse|aweber)(?:_internal)?_api_key$/', $key) && (!is_string($value) || !strlen($value)))
  429. $value = $default_options[$key];
  430. else if(preg_match('/^level[0-9]+_mailchimp_list_ids$/', $key) && (!is_string($value) || !strlen($value = preg_replace('/['."\r\n\t".']+/', '', $value))))
  431. $value = $default_options[$key];
  432. else if(preg_match('/^level[0-9]+_getresponse_list_ids$/', $key) && (!is_string($value) || !strlen($value = preg_replace('/\s+/', '', $value))))
  433. $value = $default_options[$key];
  434. else if(preg_match('/^level[0-9]+_aweber_list_ids$/', $key) && (!is_string($value) || !strlen($value = preg_replace('/\s+/', '', $value))))
  435. $value = $default_options[$key];
  436. else if(preg_match('/^(?:signup|registration|payment|modification|cancellation|eot_del|ref_rev|sp_sale|sp_ref_rev)_notification_urls$/', $key) && (!is_string($value) || !strlen($value)))
  437. $value = $default_options[$key];
  438. else if(preg_match('/^(?:signup|registration|payment|modification|cancellation|eot_del|ref_rev|sp_sale|sp_ref_rev)_notification_recipients$/', $key) && (!is_string($value) || !strlen($value)))
  439. $value = $default_options[$key];
  440. else if(preg_match('/^level[0-9]+_label$/', $key) && (!is_string($value) || !strlen($value)))
  441. $value = $default_options[$key];
  442. else if($key === 'apply_label_translations' && (!is_string($value) || !is_numeric($value)))
  443. $value = $default_options[$key];
  444. else if(preg_match('/^level[0-9]+_file_downloads_allowed$/', $key) && (!is_string($value) || !is_numeric($value) || $value < 0))
  445. $value = $default_options[$key];
  446. else if(preg_match('/^level[0-9]+_file_downloads_allowed_days$/', $key) && (!is_string($value) || !is_numeric($value) || $value < 0))
  447. $value = $default_options[$key];
  448. else if($key === 'file_download_limit_exceeded_page' && (!is_string($value) || !is_numeric($value)))
  449. $value = $default_options[$key];
  450. else if(preg_match('/^file_download_(?:inline|stream)_extensions$/', $key) && (!is_string($value) || !($value = strtolower(preg_replace('/\s+/', '', $value)))))
  451. $value = $default_options[$key];
  452. else if(preg_match('/^amazon_(?:s3|cf)_files_/', $key) && (!is_string($value) || !strlen($value)))
  453. $value = $default_options[$key];
  454. else if($key === 'ruris_case_sensitive' && (!is_string($value) || !is_numeric($value)))
  455. $value = $default_options[$key];
  456. else if(preg_match('/^level[0-9]+_ruris$/', $key) && (!is_string($value) || !strlen($value)))
  457. $value = $default_options[$key];
  458. else if(preg_match('/^level[0-9]+_catgs$/', $key) && (!is_string($value) || !($value = ((strcasecmp($value, 'all') === 0) ? strtolower($value) : trim(preg_replace('/[^0-9,]/', '', $value), ',')))))
  459. $value = $default_options[$key];
  460. else if(preg_match('/^level[0-9]+_ptags$/', $key) && (!is_string($value) || !($value = ((strcasecmp($value, 'all') === 0) ? strtolower($value) : trim(preg_replace('/ +/', ' ', trim(preg_replace('/ *, */', ',', $value))), ',')))))
  461. $value = $default_options[$key];
  462. else if(preg_match('/^level[0-9]+_posts$/', $key) && (!is_string($value) || !($value = trim( /* Supports `all` or `1,2,3,all-[type]s`. */
  463. preg_replace('/[^a-z0-9_\-,]/', '', strtolower($value)), ',')))
  464. ) $value = $default_options[$key];
  465. else if(preg_match('/^level[0-9]+_pages$/', $key) && (!is_string($value) || !($value = ((strcasecmp($value, 'all') === 0) ? strtolower($value) : trim(preg_replace('/[^0-9,]/', '', $value), ',')))))
  466. $value = $default_options[$key];
  467. else if($key === 'specific_ids' && (!is_string($value) || !($value = trim(preg_replace('/[^0-9,]/', '', $value), ','))))
  468. $value = $default_options[$key];
  469. else if($key === 'triggers_immediate_eot' && (!is_string($value) || !preg_match('/^(?:none|refunds|reversals|refunds,reversals|refunds,partial_refunds,reversals)$/', $value)))
  470. $value = $default_options[$key];
  471. else if($key === 'membership_eot_behavior' && (!is_string($value) || !preg_match('/^(?:demote|delete)$/', $value)))
  472. $value = $default_options[$key];
  473. else if($key === 'eot_time_ext_behavior' && (!is_string($value) || !preg_match('/^(?:extend|reset)$/', $value)))
  474. $value = $default_options[$key];
  475. else if(preg_match('/^(?:auto_eot_system_enabled|eot_grace_time|eots_remove_ccaps)$/', $key) && (!is_string($value) || !is_numeric($value)))
  476. $value = $default_options[$key];
  477. else if($key === 'wp_footer_code' && (!is_string($value) || !strlen($value)))
  478. $value = $default_options[$key];
  479. }
  480. if($options !== FALSE && is_string($options['sec_encryption_key']) && strlen($options['sec_encryption_key']) && !in_array($options['sec_encryption_key'], $GLOBALS['WS_PLUGIN__']['s2member']['o']['sec_encryption_key_history']))
  481. {
  482. array_unshift($GLOBALS['WS_PLUGIN__']['s2member']['o']['sec_encryption_key_history'], $options['sec_encryption_key']);
  483. $GLOBALS['WS_PLUGIN__']['s2member']['o']['sec_encryption_key_history'] = array_slice($GLOBALS['WS_PLUGIN__']['s2member']['o']['sec_encryption_key_history'], 0, 10);
  484. }
  485. $GLOBALS['WS_PLUGIN__']['s2member']['o'] = apply_filters_ref_array('ws_plugin__s2member_options_before_checksum', array(&$GLOBALS['WS_PLUGIN__']['s2member']['o']));
  486. $GLOBALS['WS_PLUGIN__']['s2member']['o']['options_checksum'] = md5($checksum_prefix.serialize(array_merge($GLOBALS['WS_PLUGIN__']['s2member']['o'], array('options_checksum' => 0))));
  487. }
  488. $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in_label'] = _x($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in_label'], 's2member-front', 's2member');
  489. return apply_filters_ref_array('ws_plugin__s2member_options', array(&$GLOBALS['WS_PLUGIN__']['s2member']['o']));
  490. }
  491. }