diff --git a/class/main.class.php b/class/main.class.php index 9649133..d7a5e5f 100644 --- a/class/main.class.php +++ b/class/main.class.php @@ -207,7 +207,57 @@ class CWV3 { } public function check_data() { - return cwv3_auth_reply(); + global $post; + + if ( is_feed() ) { + //Don't want to hender the feed, just in case. + return true; + } + + $cData = array( + // check isset before access (edit by @jgraup) + 'pages' => ! isset( $_COOKIE['cwv3_pages'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_pages'] ), true ), + 'posts' => ! isset( $_COOKIE['cwv3_posts'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_posts'] ), true ), + 'categories' => ! isset( $_COOKIE['cwv3_cats'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_cats'] ), true ) + ); + + $sw = get_option( 'cwv3_sitewide' ); + $hm = get_option( 'cwv3_homepage' ); + $mi = get_option( 'cwv3_misc' ); + + if ( ! empty( $sw ) ) { + return ! empty( $cData['pages']['sitewide'] ) ? $cData['pages']['sitewide'] : false; + } + + if ( is_front_page() && ! empty( $hm ) ) { + return ! empty( $cData['pages']['home'] ) ? $cData['pages']['home'] : false; + } + + if ( ( is_archive() || is_search() ) && ! empty( $mi ) ) { + // Protect misc pages aswell + return ! empty( $cData['pages']['other'] ) ? $cData['pages']['other'] : false; + } + + if ( is_page() && 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) ) { + $c = $cData['pages'][ $post->ID ]; + return ! empty( $c ) ? $c : false; + } + + $id = ( is_attachment() ? $post->post_parent : $post->ID ); + // First see if categories are setup in the admin side. + $catData = get_option( 'cwv3_cat_list' ); + $curCat = get_the_category( $id ); + if ( 'post' == get_post_type( $id ) && $this->in_cat( $catData, $curCat ) ) { + // If the current category is selected in the admin page, that means the administrator wishes to protect it. + // respect the admin's wishes and do it. + return ! empty( $cData['categories'][ $post->ID ] ) ? $cData['categories'][ $id ] : false; + } + // Since that's not the case, we need to check post_meta data and see if this post is protected. + if ( 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) && ! is_front_page() ) { + return ! empty( $cData['posts'][ $post->ID ] ) ? $cData['posts'][ $id ] : false; + } + + return true; } public function in_cat( $catIDs, $catArray ) { @@ -227,8 +277,34 @@ class CWV3 { public function render_dialog() { - cwv3_the_dialog(); + $d = get_option( 'cwv3_denial' ); + if ( 3 == $this->check_data() && 'enabled' == $d[0] ) { + $dtype = true; + }else { + $dtype = false; + } + $etxt = get_option( 'cwv3_enter_txt', 'Enter' ); + $extxt = get_option( 'cwv3_exit_txt', 'Exit' ); + $cwv3_title = ( true == $dtype ) ? get_option( 'cwv3_den_title' ) : get_option( 'cwv3_d_title' ); + $cwv3_content = ( true == $dtype ) ? get_option( 'cwv3_den_msg' ) : get_option( 'cwv3_d_msg' ); + +?> + +
+ +