ID; global $current_user; $current_user = wp_get_current_user(); $uid = $current_user->ID; global $wpdb; $table = $wpdb->prefix."cookies"; /* check for cookies */ $namecheck = "2stepauth_rem_".$current_user->ID; // If cookie corresponding to $namecheck is present, proceed. if(isset($_COOKIE[$namecheck])){ // Get the value of user browser cookie in $id $id = $_COOKIE[$namecheck]; $date1 = date('y-m-d'); // Get all valid cookie values from DB $cookieArr = $wpdb->get_results('Select cookie from '.$table.' where userid='.$userid.' AND date>'.$date1); if ( $cookieArr ) { foreach ( $cookieArr as $ck ) { $cookieVal[] = $ck->cookie; } foreach ( $cookieVal as $c ) { // Compare browser cookie value with values in DB if ( $c == $id ) { //echo "Cookie matched"; update_option( '2stepauth_verificationdone_'.$uid, 1 ); wp_redirect( admin_url() ); } } } } /*end check for cookies */ if ( $_POST['submit'] ) { // Start if-post submit $code = get_option( '2stepauth_emailcode_'.$uid ); $input = $_POST['code']; $input = intval($input); // if code matches if ( $code == $input ) { // If Remember Me is checked if ( $_POST['remember'] ) { $randomval = send111(); $cookie = $userid.$randomval; $data['userid'] = $current_user->ID; $data['cookie'] = $cookie; $ts = strtotime( '+2 weeks' ); $data['date'] = date( 'y-m-d', $ts ); global $wpdb; $table1 = $wpdb->prefix."cookies"; $wpdb->insert($table1,$data); $name = "2stepauth_rem_".$current_user->ID; setcookie($name, $cookie, time()+(60*60*24*14),"/"); } update_option( '2stepauth_verificationdone_'.$uid, 1 ); wp_redirect( admin_url() ); } // code does not match, show the form and error msg else { ?> ' type='text/css' media='all' /> ' type='text/css' media='all' />
". __( "Validation code is sent to your email *****".$email.". Please enter it below.", '2step_auth' ) . "