Code Duplication    Length = 39-39 lines in 2 locations

other/upgrade.php 1 location

@@ 453-491 (lines=39) @@
450
			return $data;
451
		}
452
453
		function locate($file, $listing = null)
454
		{
455
			if ($listing === null)
456
				$listing = $this->list_dir('', true);
457
			$listing = explode("\n", $listing);
458
459
			@fwrite($this->connection, 'PWD' . "\r\n");
460
			$time = time();
461
			do
462
				$response = fgets($this->connection, 1024);
463
			while (substr($response, 3, 1) != ' ' && time() - $time < 5);
464
465
			// Check for 257!
466
			if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
467
				$current_dir = strtr($match[1], array('""' => '"'));
468
			else
469
				$current_dir = '';
470
471
			for ($i = 0, $n = count($listing); $i < $n; $i++)
472
			{
473
				if (trim($listing[$i]) == '' && isset($listing[$i + 1]))
474
				{
475
					$current_dir = substr(trim($listing[++$i]), 0, -1);
476
					$i++;
477
				}
478
479
				// Okay, this file's name is:
480
				$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
481
482
				if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
483
					return $listing[$i];
484
				if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
485
					return $listing[$i];
486
				if (basename($listing[$i]) == $file || $listing[$i] == $file)
487
					return $listing[$i];
488
			}
489
490
			return false;
491
		}
492
493
		function create_dir($ftp_dir)
494
		{

other/install.php 1 location

@@ 1890-1928 (lines=39) @@
1887
		return $data;
1888
	}
1889
1890
	function locate($file, $listing = null)
1891
	{
1892
		if ($listing === null)
1893
			$listing = $this->list_dir('', true);
1894
		$listing = explode("\n", $listing);
1895
1896
		@fwrite($this->connection, "PWD\r\n");
1897
		$time = time();
1898
		do
1899
			$response = fgets($this->connection, 1024);
1900
		while (substr($response, 3, 1) != ' ' && time() - $time < 5);
1901
1902
		// Check for 257!
1903
		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1904
			$current_dir = strtr($match[1], array('""' => '"'));
1905
		else
1906
			$current_dir = '';
1907
1908
		for ($i = 0, $n = count($listing); $i < $n; $i++)
1909
		{
1910
			if (trim($listing[$i]) == '' && isset($listing[$i + 1]))
1911
			{
1912
				$current_dir = substr(trim($listing[++$i]), 0, -1);
1913
				$i++;
1914
			}
1915
1916
			// Okay, this file's name is:
1917
			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1918
1919
			if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1920
				return $listing[$i];
1921
			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1922
				return $listing[$i];
1923
			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1924
				return $listing[$i];
1925
		}
1926
1927
		return false;
1928
	}
1929
1930
	function create_dir($ftp_dir)
1931
	{