12 || $_POST['age_day'] < 1 || $_POST['age_day'] > 31 ) { wp_redirect( cws_age_verification::plugin_url() . '?wrongformat=1&redirect_to=' . urlencode( stripslashes( $_POST['redirect_to'] ) ) ); die(); } $dob = $_POST['age_year'] . '-' . zeroise( $_POST['age_month'], 2 ) . '-' . zeroise( $_POST['age_day'], 2 ); cws_age_verification::set_dob($dob); wp_safe_redirect( $_POST['redirect_to'] ); die(); } else { ?> Age Verification Required

Age Verification Required

This site requires your date of birth, but your browser isn't accepting cookies. Please enable cookies and try visiting this site again.

You are not old enough to access this site!

Your date of birth must be in the format MM DD YYYY and must be a valid date!

You must be years old to access this site. Please provide your date of birth:

"; die(); } function check() { if ( current_user_can( 'read' ) && get_option( 'cws_age_verification_skip_registered' ) ) { // nothing -- let them pass } elseif ( !$_COOKIE['cws_age_verification_dob'] ) { cws_age_verification::set_test(); wp_redirect( cws_age_verification::plugin_url() . '?redirect_to=http://' . $_SERVER['HTTP_HOST'] . urlencode($_SERVER['REQUEST_URI'] ) ); die(); } elseif ( cws_age_verification::age_required() > cws_age_verification::dob_to_age( $_COOKIE['cws_age_verification_dob'] ) ) { cws_age_verification::set_test(); wp_redirect( cws_age_verification::plugin_url() . '?notoldenough=1&redirect_to=http://' . $_SERVER['HTTP_HOST'] . urlencode($_SERVER['REQUEST_URI'] ) ); die(); } else { cws_age_verification::set_dob( $_COOKIE['cws_age_verification_dob'] ); // keep-alive } } function plugin_url() { return get_option( 'siteurl' ) . '/' . PLUGINDIR . '/' . plugin_basename( __FILE__ ); } function age_required() { return absint( get_option( 'cws_age_verification_age' ) ); } function timeout_minutes() { return absint( get_option( 'cws_age_verification_timeout' ) ); } function timeout_seconds() { return 60 * cws_age_verification::timeout_minutes(); } function set_test() { setcookie( 'cws_age_verification_cookie_check', '1', time() + 3600, COOKIEPATH, COOKIE_DOMAIN ); setcookie( 'cws_age_verification_cookie_check', '1', time() + 3600, SITECOOKIEPATH, COOKIE_DOMAIN ); } function set_dob( $dob ) { setcookie( 'cws_age_verification_dob', $dob, time() + cws_age_verification::timeout_seconds(), COOKIEPATH, COOKIE_DOMAIN ); setcookie( 'cws_age_verification_dob', $dob, time() + cws_age_verification::timeout_seconds(), SITECOOKIEPATH, COOKIE_DOMAIN ); } function dob_to_age( $birthdate ) { // birthdate should be in yyyy-mm-dd form if ( $birthdate ) { $birth = date( 'Ymd', strtotime( $birthdate ) ); $age = date( 'Y' ) - substr( $birth, 0, 4 ); if ( date( 'md' ) < substr( $birth, 4, 4 ) ) --$age; return $age; } } function admin() { if ( !empty( $_POST ) ) { if ( function_exists( 'current_user_can' ) && !current_user_can( 'manage_options' ) ) die( __( 'Cheatin’ uh?' ) ); check_admin_referer( 'cws-age-verification-update-settings' ); update_option( 'cws_age_verification_age', absint( $_POST['cws-age-setting'] ) ); update_option( 'cws_age_verification_timeout', absint( $_POST['cws-timeout-setting'] ) ); update_option( 'cws_age_verification_skip_registered', ( $_POST['cws-registered-setting'] ) ? '1' : '0' ); update_option( 'cws_age_verification_use_dropdowns', ( $_POST['cws-dropdown-setting'] ) ? '1' : '0' ); } if ( !empty($_POST ) ) { ?>

Age Verification Settings

Users must be at least years old to access this site, and will have to reverify their age after minutes of inactivity.

value="1" name="cws-registered-setting" id="cws-registered-setting" />

Age verification should use inputs.