geoplugin_countryName; $usertime = time(); $cookievalue = $visitor_ip.'_'.$usertime; if(is_user_logged_in()){ $current_user = wp_get_current_user(); $useradblockid = $current_user->ID ; } if(isset($_COOKIE["unique_adblock"])){ global $wpdb; $str = explode("_",$_COOKIE["unique_adblock"]); $queryipcount = "SELECT COUNT(*) as co FROM ".$wpdb->prefix ."adblock WHERE ip='".$str[0]."' AND usertime=".$str[1]; $rowipcount = $wpdb->get_row($queryipcount) or die('not run1'); $queryip = "SELECT ip,usertime FROM ".$wpdb->prefix ."adblock WHERE ip='".$str[0]."' AND usertime=".$str[1]; $rowip = $wpdb->get_row($queryip) ; $countip = $rowip->ip; $countusertime = $rowip->usertime; if($rowipcount->co > 0){ /* When cookie is set and and user again enable the add on */ global $wpdb; $wpdb->update($wpdb->prefix.'adblock', array('adblock_status'=>'NO'), array('ip'=>$countip,'usertime' => $countusertime)) ; }else{ /* When cookie is set and user detail is not available in database */ $data = array( 'ip' => $visitor_ip, 'usertime' => $usertime, 'userloginid' => $useradblockid, 'usercountry' => $usercountry, 'adblock_status' => 'NO' ); global $wpdb; $wpdb->insert($wpdb->prefix.'adblock', $data); //Reset Cookie value setcookie("unique_adblock", $cookievalue); } }else{ // Setting Cookie setcookie("unique_adblock", $cookievalue); /* Inserting user informaion in Database */ $data = array( 'ip' => $visitor_ip, 'usertime' => $usertime, 'userloginid' => $useradblockid, 'usercountry' => $usercountry, 'adblock_status' => 'NO' ); global $wpdb; $wpdb->insert($wpdb->prefix.'adblock', $data); } } /* Add On Disable Hook */ function adblockvisitordis_callback(){ $str = explode("_",$_COOKIE["unique_adblock"]); global $wpdb; $wpdb->update($wpdb->prefix.'adblock', array('adblock_status'=>'YES'), array('ip'=>$str[0],'usertime'=>$str[1])) or die('nor run') ; } function addblock() { $userumsg = get_option( 'usermsg' ) ; $userimagepath = get_option( 'imagepath' ) ; if($userimagepath == "images/large.png") { $actualImagePath = plugin_dir_url(__FILE__).$userimagepath; } else{ $path_array = wp_upload_dir(); $actualImagePath = $path_array['baseurl'].$userimagepath; } ?>