--- C:/Users/arittner/Downloads/cystats.0.9.8/cystats/includes/cystats.class.php	Thu Oct 23 23:07:10 2008
+++ C:/Users/arittner/Downloads/cystats.class.php	Wed Dec 15 10:19:16 2010
@@ -1605,6 +1605,8 @@
 			// check last time ip stored 
 			#$tm_start = array_sum(explode(' ', microtime()));
 			#echo $secs_total = array_sum(explode(' ', microtime())) - $tm_start;
+				// Older Daterange
+				$delta2=$info['timestamp']-(2*get_option('cystats_visit_deltatime'));
 
 				$delta=$info['timestamp']-get_option('cystats_visit_deltatime');
 				// maybe this query i faster than the query below due to the LIMIT 1 and
@@ -1621,12 +1623,23 @@
 				#            AND remote_addr=\''.$info['remote_addr'].'\')
 				#            ORDER BY stamp DESC';
 				$locked=$wpdb->get_var($q);
+
 				$this->debugstring.=$this->getDebug("Timedelta:",$delta);
 				$this->debugstring.=$this->getDebug("Locked query:",$q);
 				$this->debugstring.=$this->getDebug("Locked query error:",mysql_error());
 				$this->debugstring.=$this->getDebug("Locked:",$locked);
 				
-				if($locked==0){
+				if($locked==2){
+					$q='SELECT count(stamp)
+						FROM '.$wpdb->prefix.CYSTATS_TABLE_STATISTICS_RAW.'
+						WHERE   (stamp between \''.$delta2.'\' AND \''.$delta1.'\' 
+							AND remote_addr=\''.($info['remote_addr']+0).'\')
+							ORDER BY stamp DESC LIMIT 1';
+
+					$lockedOld=$wpdb->get_var($q);
+
+					if($lockedOld == 0) {
+
 				// update visits/all
 					if(isset($stats['visits'])){
 						$updates[]=array('visits',CYSTATS_VISITS,0,0);
@@ -1707,6 +1720,7 @@
 						else{
 							$inserts[]=array('visits_day_nobots',CYSTATS_VISITSDAY_NOBOTS,$year,$day);
 						}
+					}
 					
 					}
 				}

