本文整理汇总了PHP中c_ws_plugin__s2member_utils_urls::parse_url方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_urls::parse_url方法的具体用法?PHP c_ws_plugin__s2member_utils_urls::parse_url怎么用?PHP c_ws_plugin__s2member_utils_urls::parse_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c_ws_plugin__s2member_utils_urls
的用法示例。
在下文中一共展示了c_ws_plugin__s2member_utils_urls::parse_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_wp_systematic_use_specific_page
/**
* Determines if a specific Post/Page ID, or URI, is WordPress Systematic.
*
* @package s2Member\Systematics
* @since 111002
*
* @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
* @param string $uri Optional. A request URI to test against.
*
* @return bool True if WordPress Systematic, else false.
*/
public static function is_wp_systematic_use_specific_page($singular_id = '', $uri = '')
{
$ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
$singular_id = $singular_id && is_numeric($singular_id) ? (int) $singular_id : FALSE;
// Force types.
$uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : FALSE;
if ($uri && preg_match('/\\/wp-admin(?:\\/|\\?|$)/' . $ci, $uri)) {
// Inside a WordPress administrative area?
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars());
}
if ($uri && preg_match('/^\\/(?:wp-.+?|xmlrpc)\\.php$/' . $ci, c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_PATH))) {
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars());
}
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', FALSE, get_defined_vars());
}
示例2: is_wp_systematic_use_specific_page
/**
* Determines if a specific Post/Page ID, or URI, is WordPress Systematic.
*
* @package s2Member\Systematics
* @since 111002
*
* @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
* @param string $uri Optional. A request URI to test against.
* @return bool True if WordPress Systematic, else false.
*/
public static function is_wp_systematic_use_specific_page($singular_id = FALSE, $uri = FALSE)
{
$singular_id = $singular_id && is_numeric($singular_id) ? (int) $singular_id : false;
// Force types.
$uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : false;
if ($uri && preg_match("/\\/wp-admin(?:\\/|\\?|\$)/", $uri)) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", true, get_defined_vars());
} else {
if ($uri && preg_match("/^\\/(?:wp-.+?|xmlrpc)\\.php\$/", c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_PATH))) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", true, get_defined_vars());
} else {
// Otherwise, we return false (i.e. it's NOT a WordPress Systematic Use Page).
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", false, get_defined_vars());
}
}
}
示例3: fill_login_redirect_rc_vars
/**
* Fills Replacement Codes in Special Redirection URLs.
*
* @package s2Member\Login_Redirects
* @since 3.5
*
* @param string $url A URL with possible Replacement Codes in it.
* @param object $user Optional. A `WP_User` object. Defaults to the current User, if logged-in.
* @param bool $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
*
* @return string|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
*/
public static function fill_login_redirect_rc_vars($url = '', $user = NULL, $root_returns_false = FALSE)
{
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_before_fill_login_redirect_rc_vars', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
$url = (string) $url;
// Force ``$url`` to a string value.
$orig_url = $url;
// Record the original URL that was passed in.
$user = (is_object($user) || is_object($user = wp_get_current_user())) && !empty($user->ID) ? $user : NULL;
$user_id = $user ? (string) $user->ID : '';
$user_login = $user ? (string) strtolower($user->user_login) : '';
$user_nicename = $user ? (string) strtolower($user->user_nicename) : '';
$user_level = (string) c_ws_plugin__s2member_user_access::user_access_level($user);
$user_role = (string) c_ws_plugin__s2member_user_access::user_access_role($user);
$user_ccaps = (string) implode('-', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
$user_logins = $user ? (string) (int) get_user_option('s2member_login_counter', $user_id) : '-1';
$url = preg_replace('/%%current_user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_login)), $url);
$url = preg_replace('/%%current_user_nicename%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_nicename)), $url);
$url = preg_replace('/%%current_user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url);
$url = preg_replace('/%%current_user_level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_level)), $url);
$url = preg_replace('/%%current_user_role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_role)), $url);
$url = preg_replace('/%%current_user_ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_ccaps)), $url);
$url = preg_replace('/%%current_user_logins%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_logins)), $url);
if ($url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url($url, -1, FALSE)) || !empty($parse['path']) && strpos($parse['path'], '//') !== FALSE)) {
$url = home_url('/');
}
// Defaults to Home Page. We don't return invalid URLs produced by empty Replacement Codes ( i.e., with `//` ).
if ($root_returns_false && c_ws_plugin__s2member_utils_conds::is_site_root($url)) {
// Used by s2Member's security gate.
$url = FALSE;
}
// In case we need to return false on root URLs (i.e., don't protect the Home Page inadvertently).
return apply_filters('ws_plugin__s2member_fill_login_redirect_rc_vars', $url, get_defined_vars());
}
示例4: s2member_sig_ok
/**
* Verifies an s2Member-generated signature; in a full URL, a partial URI, or in just a query string.
*
* @package s2Member\Utilities
* @since 111106
*
* @param str $url_uri_query A full URL, a partial URI, or just a query string. Must have an s2Member-generated signature to validate.
* @param bool $check_time Optional. Defaults to false. If true, s2Member will also check if the signature has expired, based on ``$exp_secs``.
* @param str|int $exp_secs Optional. Defaults to (int)10. If ``$check_time`` is true, s2Member will check if the signature has expired, based on ``$exp_secs``.
* @param str $sig_var Optional. The name of the s2Member-generated signature variable. Defaults to `_s2member_sig`.
* @return bool True if the s2Member-generated signature is OK, else false.
*/
public static function s2member_sig_ok($url_uri_query = FALSE, $check_time = FALSE, $exp_secs = FALSE, $sig_var = FALSE)
{
$url_uri_query = $query = c_ws_plugin__s2member_utils_strings::trim((string) $url_uri_query, false, "?&=");
if (preg_match("/^(?:[a-z]+\\:\\/\\/|\\/)/i", $url_uri_query)) {
$query = trim(c_ws_plugin__s2member_utils_urls::parse_url($url_uri_query, PHP_URL_QUERY), "?&=");
}
/**/
$check_time = $check_time ? true : false;
$exp_secs = is_numeric($exp_secs) ? (int) $exp_secs : 10;
$sig_var = $sig_var && is_string($sig_var) ? $sig_var : "_s2member_sig";
/**/
$key = c_ws_plugin__s2member_utils_encryption::key();
/**/
if (preg_match_all("/" . preg_quote($sig_var, "/") . "\\=([0-9]+)-([^&\$]+)/", $query, $sigs)) {
$query = c_ws_plugin__s2member_utils_urls::remove_s2member_sigs($query, $sig_var);
/**/
wp_parse_str($query, $vars);
$vars = c_ws_plugin__s2member_utils_arrays::remove_0b_strings(c_ws_plugin__s2member_utils_strings::trim_deep($vars));
$vars = serialize(c_ws_plugin__s2member_utils_arrays::ksort_deep($vars));
/**/
($time = $sigs[1][$i = count($sigs[1]) - 1]) . ($sig = $sigs[2][$i]) . ($valid_sig = md5($key . $time . $vars));
/**/
if ($check_time) {
return $sig === $valid_sig && $time >= strtotime("-" . $exp_secs . " seconds");
} else {
/* Ignoring time? Just need to compare signatures in this case. */
return $sig === $valid_sig;
}
} else {
/* Return false. No ``$query``, or no ``$sigs``. */
return false;
}
}
示例5: __construct
//.........这里部分代码省略.........
echo '<th>' . "\n";
echo '<label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros">' . "\n";
echo 'Auto-Configure your Amazon S3/CloudFront combination?' . "\n";
echo '</label>' . "\n";
echo '</th>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<input type="checkbox" name="ws_plugin__s2member_amazon_cf_files_auto_configure_distros" id="ws-plugin--s2member-amazon-cf-files-auto-configure-distros" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-amazon-cf-files-auto-configure-distros")) . '"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros"><strong>Yes</strong>, automatically configure my Amazon CloudFront Distributions & Amazon S3 ACLs for me.</label><br />' . "\n";
echo '<em>s2Member will auto-configure and/or delete & re-configure your Amazon CloudFront Distributions for you.</em>' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<input type="checkbox" name="ws_plugin__s2member_amazon_cf_files_auto_configure_distros_w_cnames" id="ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames")) . '"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames"><strong>Yes</strong>, I want s2Member to auto-configure using custom CNAMES that I\'ll setup.</label><br />' . "\n";
echo '<em>* Optional, do NOT check this box unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</tbody>' . "\n";
echo '</table>' . "\n";
echo '<div id="ws-plugin--s2member-amazon-cf-files-auto-configure-distro-cnames" style="display:none;">' . "\n";
echo '<table class="form-table">' . "\n";
echo '<tbody>' . "\n";
echo '<tr>' . "\n";
echo '<th>' . "\n";
echo '<label for="ws-plugin--s2member-amazon-cf-files-downloads-distro-cname">' . "\n";
echo 'Amazon CloudFront CNAME for File Downloads (optional):' . "\n";
echo '</label>' . "\n";
echo '</th>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_cf_files_distro_downloads_cname" id="ws-plugin--s2member-amazon-cf-files-downloads-distro-cname" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]) . '" /><br />' . "\n";
echo 'Example: <code>s2-file-downloads.' . esc_html(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) . '</code>.<br />' . "\n";
echo '<em>* Optional, do NOT fill this in unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<th>' . "\n";
echo '<label for="ws-plugin--s2member-amazon-cf-files-streaming-distro-cname">' . "\n";
echo 'Amazon CloudFront CNAME for Streaming Files (optional):' . "\n";
echo '</label>' . "\n";
echo '</th>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_cf_files_distro_streaming_cname" id="ws-plugin--s2member-amazon-cf-files-streaming-distro-cname" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) . '" /><br />' . "\n";
echo 'Example: <code>s2-streaming-files.' . esc_html(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) . '</code>.<br />' . "\n";
echo '<em>* Optional, do NOT fill this in unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</tbody>' . "\n";
echo '</table>' . "\n";
echo '</div>' . "\n";
echo '</div>' . "\n";
echo '</div>' . "\n";
do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_amazon_cf", get_defined_vars());
}
if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_rtmp_streaming", true, get_defined_vars())) {
do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_rtmp_streaming", get_defined_vars());
echo '<div class="ws-menu-page-group" title="JW Player v6 & RTMP Protocol Examples">' . "\n";
echo '<div class="ws-menu-page-section ws-plugin--s2member-rtmp-streaming-section">' . "\n";
echo '<h3>JW Player v6 & RTMP Protocol Examples</h3>' . "\n";
echo '<a href="http://www.longtailvideo.com/players/" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/jwplayer-logo.png" class="ws-menu-page-right" style="width:179px; height:58px; border:0; border-radius:3px; background:#FFFFFF; padding:15px;" alt="." /></a>' . "\n";
echo '<p>While it is possible to serve audio/video files protected by s2Member, without needing to integrate Amazon S3 or CloudFront; we DO highly recommend that you integrate both Amazon S3 and Amazon CloudFront in order to maximize speed and compatibility across various viewing platforms. That being said, there are code samples below that will serve audio/video files both with and without Amazon S3/CloudFront. You can also check the <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Forum URI")) . '" target="_blank" rel="external">s2Member Support Forums</a> for tips/tricks if you like.</p>' . "\n";
echo '<p><strong>One of the great things about Amazon CloudFront</strong>, is its ability to <strong>stream/seek media files</strong> in the truest sense of the word. For sites delivering protected <em>FLV/MP4/OGG/WEBM</em> and other streaming audio/video file types over the <em>RTMP</em> protocol, Amazon CloudFront is our recommendation. Once you\'ve successfully configured s2Member to use both Amazon S3 and Amazon CloudFront together, please review the code samples below. s2Member can automatically serve your protected files over the <em>RTMP</em> protocol using an Amazon CloudFront Streaming Distribution.</p>' . "\n";
示例6: is_wp_systematic_use_page
/**
* Determines if the current page is WordPress® Systematic.
*
* @package s2Member\Systematics
* @since 111002
*
* @return bool True if WordPress® Systematic, else false.
*
* @note The results of this function are cached staticially.
* Do NOT call upon this until the `init` Hook is fired.
*/
public static function is_wp_systematic_use_page()
{
static $is_wp_systematic;
/* For optimization. */
/**/
if (isset($is_wp_systematic)) {
return $is_wp_systematic;
/* Filters will have already been applied here. */
} else {
if (is_admin()) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
if (defined("WP_INSTALLING") && WP_INSTALLING) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
if (defined("APP_REQUEST") && APP_REQUEST) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
if (defined("XMLRPC_REQUEST") && XMLRPC_REQUEST) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
if (defined("DOING_CRON") && DOING_CRON || strcasecmp(PHP_SAPI, "CLI") === 0) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
if (preg_match("/^\\/(?:wp-.+?|xmlrpc)\\.php\$/", c_ws_plugin__s2member_utils_urls::parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH))) {
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
} else {
/* Otherwise, we return false ( it's NOT a WordPress® Systematic Use Page ). */
return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", false, get_defined_vars());
}
}
}
}
}
}
}
}
示例7: fill_login_redirect_rc_vars
/**
* Fills Replacement Codes in Special Redirection URLs.
*
* @package s2Member\Login_Redirects
* @since 3.5
*
* @param str $url A URL with possible Replacement Codes in it.
* @param obj $user Optional. A `WP_User` object. Defaults to the current User, if logged-in.
* @param bool $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
* @return str|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
*/
public static function fill_login_redirect_rc_vars($url = FALSE, $user = FALSE, $root_returns_false = FALSE)
{
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars());
unset($__refs, $__v);
$url = (string) $url;
$orig_url = $url;
$user = (is_object($user) || is_object($user = is_user_logged_in() ? wp_get_current_user() : false)) && !empty($user->ID) ? $user : false;
$user_id = $user ? (string) $user->ID : "";
$user_login = $user ? (string) strtolower($user->user_login) : "";
$user_level = (string) c_ws_plugin__s2member_user_access::user_access_level($user);
$user_role = (string) c_ws_plugin__s2member_user_access::user_access_role($user);
$user_ccaps = (string) implode("-", c_ws_plugin__s2member_user_access::user_access_ccaps($user));
$user_logins = $user ? (string) (int) get_user_option("s2member_login_counter", $user_id) : "-1";
$url = preg_replace("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_login), $url);
$url = preg_replace("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $url);
$url = preg_replace("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_level), $url);
$url = preg_replace("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_role), $url);
$url = preg_replace("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_ccaps), $url);
$url = preg_replace("/%%current_user_logins%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_logins), $url);
if ($url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url($url, -1, false)) || !empty($parse["path"]) && strpos($parse["path"], "//") !== false)) {
$url = site_url("/");
}
if ($root_returns_false && c_ws_plugin__s2member_utils_conds::is_site_root($url)) {
$url = false;
}
return apply_filters("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars());
}
示例8: exit
<?php
if (!defined('WPINC')) {
// MUST have WordPress.
exit('Do not access this file directly.');
}
global $base;
$ws_plugin__s2member_temp_s_base = !empty($base) ? $base : c_ws_plugin__s2member_utils_urls::parse_url(network_home_url('/'), PHP_URL_PATH);
// This works on Multisite installs too. The function ``network_home_url ()`` defaults to ``home_url ()`` on standard WordPress installs.
// Do NOT use ``site`` URL. Must use the `home` URL here, because that's what WordPress uses in its own `mod_rewrite` implementation.
?>
<IfModule rewrite_module>
RewriteEngine On
RewriteBase <?php
echo $ws_plugin__s2member_temp_s_base . "\n";
?>
RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
RewriteRule .* - [E=no-gzip:1]
</IfModule>
<?php
unset($ws_plugin__s2member_temp_s_base);
示例9: is_site_root
/**
* Checks to see if a URL/URI leads to the site root.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param str $url_uri Either a full URL, or a partial URI to test.
* @return bool True if the URL or URI leads to the site root, else false.
*/
public static function is_site_root($url_uri = FALSE)
{
if (is_array($parse = c_ws_plugin__s2member_utils_urls::parse_url($url_uri))) {
$parse["path"] = !empty($parse["path"]) ? strpos($parse["path"], "/") === 0 ? $parse["path"] : "/" . $parse["path"] : "/";
if (empty($parse["host"]) || strcasecmp($parse["host"], c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) === 0) {
if ($parse["path"] === "/" || rtrim($parse["path"], "/") === rtrim(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_PATH), "/")) {
if (get_option("permalink_structure") || empty($_GET["post_id"]) && empty($_GET["page_id"]) && empty($_GET["p"])) {
return true;
}
}
}
}
return false;
// Default return false.
}
示例10: is_wp_systematic_use_page
/**
* Determines if the current page is WordPress Systematic.
*
* @package s2Member\Systematics
* @since 111002
*
* @return bool True if WordPress Systematic, else false.
*
* @note The results of this function are cached staticially.
* Do NOT call upon this until the `init` Hook is fired.
*/
public static function is_wp_systematic_use_page()
{
static $is_wp_systematic;
// For optimization.
if (isset($is_wp_systematic)) {
// Already cached statically? Saves time.
return $is_wp_systematic;
}
// Filters will have already been applied here.
$ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
if (is_admin()) {
// In the admin area? All administrational pages are considered Systematic.
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
if (defined('WP_INSTALLING') && WP_INSTALLING) {
// Installing? All WordPress installs are considered Systematic.
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
if (defined('APP_REQUEST') && APP_REQUEST) {
// App request? All WordPress app requests are considered Systematic.
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
// An XML-RPC request? All of these are considered Systematic too.
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
if (defined('DOING_CRON') && DOING_CRON || strcasecmp(PHP_SAPI, 'CLI') === 0) {
// CLI or CRON job.
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
if (preg_match('/^\\/(?:wp-.+?|xmlrpc)\\.php$/' . $ci, c_ws_plugin__s2member_utils_urls::parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars());
}
return $is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', FALSE, get_defined_vars());
}
示例11: is_site_root
/**
* Checks to see if a URL/URI leads to the site root.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param string $url_uri Either a full URL, or a partial URI to test.
*
* @return bool True if the URL or URI leads to the site root, else false.
*/
public static function is_site_root($url_uri = '')
{
if (is_array($parse = c_ws_plugin__s2member_utils_urls::parse_url($url_uri))) {
$ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
$parse['path'] = !empty($parse['path']) ? strpos($parse['path'], '/') === 0 ? $parse['path'] : '/' . $parse['path'] : '/';
$parse['query'] = !empty($parse['query']) ? $parse['query'] : '';
// Has a query string?
if (empty($parse['host']) || strcasecmp($parse['host'], c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_HOST)) === 0) {
if ($parse['path'] === '/' || preg_match('/^' . preg_quote(rtrim($parse['path'], '/'), '/') . '$/' . $ci, rtrim(c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_PATH), '/'))) {
if (get_option('permalink_structure') || empty($_REQUEST['post_id']) && empty($_REQUEST['page_id']) && empty($_REQUEST['p']) && empty($_REQUEST['s'])) {
return TRUE;
}
}
}
if (empty($parse['host']) || strcasecmp($parse['host'], c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) === 0) {
if ($parse['path'] === '/' || preg_match('/^' . preg_quote(rtrim($parse['path'], '/'), '/') . '$/' . $ci, rtrim(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_PATH), '/'))) {
if (get_option('permalink_structure') || empty($_REQUEST['post_id']) && empty($_REQUEST['page_id']) && empty($_REQUEST['p']) && empty($_REQUEST['s'])) {
return TRUE;
}
}
}
}
return FALSE;
// Default return false.
}
示例12: fill_login_redirect_rc_vars
/**
* Fills Replacement Codes in Special Redirection URLs.
*
* @package s2Member\Login_Redirects
* @since 3.5
*
* @param str $url A URL with possible Replacement Codes in it.
* @param obj $user Optional. A `WP_User` object. Defaults to the current User, if logged-in.
* @param bool $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
* @return str|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
*/
public static function fill_login_redirect_rc_vars($url = FALSE, $user = FALSE, $root_returns_false = FALSE)
{
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __refs, __v. */
/**/
$url = (string) $url;
/* Force ``$url`` to a string value. */
$orig_url = $url;
/* Record the original URL that was passed in. */
/**/
$user = (is_object($user) || is_object($user = is_user_logged_in() ? wp_get_current_user() : false)) && !empty($user->ID) ? $user : false;
/**/
$user_id = $user ? (string) $user->ID : "";
$user_login = $user ? (string) strtolower($user->user_login) : "";
/**/
$user_level = (string) c_ws_plugin__s2member_user_access::user_access_level($user);
$user_role = (string) c_ws_plugin__s2member_user_access::user_access_role($user);
$user_ccaps = (string) implode("-", c_ws_plugin__s2member_user_access::user_access_ccaps($user));
$user_logins = $user ? (string) (int) get_user_option("s2member_login_counter", $user_id) : "-1";
/**/
$url = preg_replace("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_login), $url);
$url = preg_replace("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $url);
$url = preg_replace("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_level), $url);
$url = preg_replace("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_role), $url);
$url = preg_replace("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_ccaps), $url);
$url = preg_replace("/%%current_user_logins%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_logins), $url);
/**/
if ($url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url($url, -1, false)) || !empty($parse["path"]) && strpos($parse["path"], "//") !== false)) {
$url = site_url("/");
}
/* Defaults to Home Page. We don't return invalid URLs produced by empty Replacement Codes ( i.e. with `//` ). */
/**/
if ($root_returns_false && c_ws_plugin__s2member_utils_conds::is_site_root($url)) {
$url = false;
}
/* In case we need to return false on root URLs ( i.e. don't protect the Home Page inadvertently ). */
/**/
return apply_filters("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars());
}
示例13: create_file_download_url
/**
* Generates a File Download URL for access to a file protected by s2Member.
*
* @package s2Member\Files
* @since 110926
*
* @param array $config Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine.
* Possible ``$config`` array elements: `file_download` *(required)*, `file_download_key`, `file_stream`, `file_inline`, `file_storage`, `file_remote`, `file_ssl`, `file_rewrite`, `file_rewrite_base`, `skip_confirmation`, `url_to_storage_source`, `count_against_user`, `check_user`.
* @param bool $get_streamer_array Optional. Defaults to `false`. If `true`, this function will return an array with the following elements: `streamer`, `file`, `url`. For further details, please review this section in your Dashboard: `s2Member → Download Options → JW Player & RTMP Protocol Examples`.
*
* @return string A File Download URL string on success; or an array on success, with elements `streamer`, `file`, `url` when/if ``$get_streamer_array`` is true; else false on any type of failure.
*
* @see s2Member\API_Functions\s2member_file_download_url()
*/
public static function create_file_download_url($config = array(), $get_streamer_array = FALSE)
{
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_before_create_file_download_url', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
$config = is_array($config) ? $config : array();
// This absolutely MUST be an array.
$config['file_download'] = isset($config['file_download']) && is_string($config['file_download']) ? trim($config['file_download'], '/') : '';
$config['file_download_key'] = !empty($config['file_download_key']) && is_string($config['file_download']) ? c_ws_plugin__s2member_files::file_download_key($config['file_download'], in_array($config['file_download_key'], array('ip-forever', 'universal', 'cache-compatible')) ? $config['file_download_key'] : FALSE) : '';
$config['url_to_storage_source'] = $get_streamer_array ? TRUE : @$config['url_to_storage_source'];
// Force a streaming URL here via ``$get_streamer_array``?
$config['file_stream'] = $get_streamer_array ? TRUE : @$config['file_stream'];
// Force a streaming URL here via ``$get_streamer_array``?
if ($url_ = c_ws_plugin__s2member_files_in::check_file_download_access($config)) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_create_file_download_url', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
$extension = strtolower(substr($config['file_download'], strrpos($config['file_download'], '.') + 1));
$streaming = isset($config['file_stream']) ? filter_var($config['file_stream'], FILTER_VALIDATE_BOOLEAN) : (in_array($extension, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_stream_extensions'])) ? TRUE : FALSE);
$ssl = isset($config['file_ssl']) ? filter_var($config['file_ssl'], FILTER_VALIDATE_BOOLEAN) : (is_ssl() ? TRUE : FALSE);
if ($get_streamer_array && $streaming && ($cfx = '/cfx/st') && ($cfx_pos = strpos($url_, $cfx)) !== FALSE && ($streamer = substr($url_, 0, $cfx_pos + strlen($cfx))) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array('file_stream' => FALSE, 'check_user' => FALSE, 'count_against_user' => FALSE))))) {
$return = array('streamer' => $streamer, 'prefix' => $extension . ':', 'file' => preg_replace('/^' . preg_quote($streamer, '/') . '\\//', '', $url_), 'url' => preg_replace('/^.+?\\:/', $ssl ? 'https:' : 'http:', $url));
} else {
if ($get_streamer_array && $streaming && is_array($ups = c_ws_plugin__s2member_utils_urls::parse_url($url_)) && isset($ups['scheme'], $ups['host']) && ($streamer = $ups['scheme'] . '://' . $ups['host'] . (!empty($ups['port']) ? ':' . $ups['port'] : '')) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array('file_stream' => FALSE, 'check_user' => FALSE, 'count_against_user' => FALSE))))) {
$return = array('streamer' => $streamer, 'prefix' => '', 'file' => preg_replace('/^' . preg_quote($streamer, '/') . '\\//', '', $url_), 'url' => preg_replace('/^.+?\\:/', $ssl ? 'https:' : 'http:', $url));
} else {
if ($get_streamer_array) {
// If streamer, we MUST return false here; unable to acquire streamer/file.
$return = FALSE;
} else {
// Else return URL string ( ``$get_streamer_array`` is false ).
$return = $url_;
}
}
}
// Else return URL string.
}
return apply_filters('ws_plugin__s2member_create_file_download_url', isset($return) ? $return : FALSE, get_defined_vars());
}
示例14: s2member_sig_ok
/**
* Verifies an s2Member-generated signature; in a full URL, a partial URI, or in just a query string.
*
* @package s2Member\Utilities
* @since 111106
*
* @param string $url_uri_query A full URL, a partial URI, or just a query string. Must have an s2Member-generated signature to validate.
* @param bool $check_time Optional. Defaults to false. If true, s2Member will also check if the signature has expired, based on ``$exp_secs``.
* @param string|int $exp_secs Optional. Defaults to (int)10. If ``$check_time`` is true, s2Member will check if the signature has expired, based on ``$exp_secs``.
* @param string $sig_var Optional. The name of the s2Member-generated signature variable. Defaults to `_s2member_sig`.
* @return bool True if the s2Member-generated signature is OK, else false.
*/
public static function s2member_sig_ok($url_uri_query = FALSE, $check_time = FALSE, $exp_secs = FALSE, $sig_var = FALSE)
{
$url_uri_query = $query = c_ws_plugin__s2member_utils_strings::trim((string) $url_uri_query, false, '?&=');
if (preg_match('/^(?:[a-z]+\\:\\/\\/|\\/)/i', $url_uri_query)) {
// Is this a full URL or a partial URI?
$query = trim(c_ws_plugin__s2member_utils_urls::parse_url($url_uri_query, PHP_URL_QUERY), '?&=');
}
$check_time = (bool) $check_time;
// Check time?
$exp_secs = is_numeric($exp_secs) ? (int) $exp_secs : 10;
$sig_var = $sig_var && is_string($sig_var) ? $sig_var : '_s2member_sig';
$key = c_ws_plugin__s2member_utils_encryption::key();
// Obtain key.
if (preg_match_all('/' . preg_quote($sig_var, '/') . '\\=([0-9]+)-([^&$]+)/', $query, $sigs)) {
$query = c_ws_plugin__s2member_utils_urls::remove_s2member_sigs($query, $sig_var);
wp_parse_str($query, $vars);
// Parse the query string into an array of ``$vars``.
$vars = c_ws_plugin__s2member_utils_arrays::remove_0b_strings(c_ws_plugin__s2member_utils_strings::trim_deep($vars));
$vars = serialize(c_ws_plugin__s2member_utils_arrays::ksort_deep($vars));
$i = count($sigs[1]) - 1;
// Last one.
$time = $sigs[1][$i];
// Timestamp.
$sig = $sigs[2][$i];
// Signature.
$valid_sig = md5($key . $time . $vars);
if ($check_time) {
// This must NOT be older than ``$exp_secs`` seconds ago.
return $sig === $valid_sig && $time >= strtotime('-' . $exp_secs . ' seconds');
}
return $sig === $valid_sig;
}
return false;
// False, it's NOT ok.
}
示例15: is_site_root
/**
* Checks to see if a URL/URI leads to the site root.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param str $url_uri Either a full URL, or a partial URI to test.
* @return bool True if the URL or URI leads to the site root, else false.
*/
public static function is_site_root($url_uri = FALSE)
{
if (is_array($parse = c_ws_plugin__s2member_utils_urls::parse_url($url_uri))) {
$parse["path"] = !empty($parse["path"]) ? strpos($parse["path"], "/") === 0 ? $parse["path"] : "/" . $parse["path"] : "/";
/**/
if (empty($parse["host"]) || strcasecmp($parse["host"], c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) === 0) {
if ($parse["path"] === "/" || rtrim($parse["path"], "/") === rtrim(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_PATH), "/")) {
return true;
}
}
}
return false;
/* Default return false. */
}