Code Duplication    Length = 14-15 lines in 3 locations

Sources/PackageGet.php 1 location

@@ 122-136 (lines=15) @@
119
120
	if ($context['package_download_broken'])
121
	{
122
		if (isset($_POST['ftp_username']))
123
		{
124
			require_once($sourcedir . '/Class-Package.php');
125
			$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
126
127
			if ($ftp->error === false)
128
			{
129
				// I know, I know... but a lot of people want to type /home/xyz/... which is wrong, but logical.
130
				if (!$ftp->chdir($_POST['ftp_path']))
131
				{
132
					$ftp_error = $ftp->error;
133
					$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
134
				}
135
			}
136
		}
137
138
		if (!isset($ftp) || $ftp->error !== false)
139
		{

other/install.php 1 location

@@ 633-646 (lines=14) @@
630
631
		$incontext['ftp_errors'] = array();
632
		require_once('Sources/Class-Package.php');
633
		if (isset($_POST['ftp_username']))
634
		{
635
			$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
636
637
			if ($ftp->error === false)
638
			{
639
				// Try it without /home/abc just in case they messed up.
640
				if (!$ftp->chdir($_POST['ftp_path']))
641
				{
642
					$incontext['ftp_errors'][] = $ftp->last_message;
643
					$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
644
				}
645
			}
646
		}
647
648
		if (!isset($ftp) || $ftp->error !== false)
649
		{

Sources/Subs-Package.php 1 location

@@ 1042-1056 (lines=15) @@
1039
		$files = packageRequireFTP($destination_url, $files, $return);
1040
		return $files;
1041
	}
1042
	elseif (isset($_POST['ftp_username']))
1043
	{
1044
		require_once($sourcedir . '/Class-Package.php');
1045
		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
1046
1047
		if ($ftp->error === false)
1048
		{
1049
			// Common mistake, so let's try to remedy it...
1050
			if (!$ftp->chdir($_POST['ftp_path']))
1051
			{
1052
				$ftp_error = $ftp->last_message;
1053
				$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
1054
			}
1055
		}
1056
	}
1057
1058
	if (!isset($ftp) || $ftp->error !== false)
1059
	{