Code Duplication    Length = 30-32 lines in 2 locations

require/class.Spotter.php 1 location

@@ 626-655 (lines=30) @@
623
			}
624
		}
625
626
		if ($date_posted != "")
627
		{
628
			$date_array = explode(",", $date_posted);
629
			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
630
			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
631
632
			if ($globalTimezone != '') {
633
				date_default_timezone_set($globalTimezone);
634
				$datetime = new DateTime();
635
				$offset = $datetime->format('P');
636
			} else $offset = '+00:00';
637
638
			if ($date_array[1] != "")
639
			{
640
				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
641
				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
642
				if ($globalDBdriver == 'mysql') {
643
					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
644
				} else {
645
					$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) <= '".$date_array[1]."' ";
646
				}
647
			} else {
648
				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
649
				if ($globalDBdriver == 'mysql') {
650
					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
651
				} else {
652
					$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' ";
653
				}
654
			}
655
		}
656
657
		if ($limit != "")
658
		{

require/class.SpotterArchive.php 1 location

@@ 705-736 (lines=32) @@
702
	    }
703
	}
704
	
705
	if ($date_posted != "")
706
	{
707
	    $date_array = explode(",", $date_posted);
708
	    
709
	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
711
	    
712
	    if ($globalTimezone != '') {
713
		date_default_timezone_set($globalTimezone);
714
		$datetime = new DateTime();
715
		$offset = $datetime->format('P');
716
	    } else $offset = '+00:00';
717
718
719
	    if ($date_array[1] != "")
720
	    {                
721
		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
722
		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
723
		if ($globalDBdriver == 'mysql') {
724
			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
725
		} else {
726
			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
727
		}
728
	    } else {
729
		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
730
                if ($globalDBdriver == 'mysql') {
731
			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
732
		} else {
733
			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
734
		}
735
	    }
736
	}
737
	
738
	if ($limit != "")
739
	{