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
		{

Sources/Subs-Package.php 1 location

@@ 1029-1043 (lines=15) @@
1026
		$files = packageRequireFTP($destination_url, $files, $return);
1027
		return $files;
1028
	}
1029
	elseif (isset($_POST['ftp_username']))
1030
	{
1031
		require_once($sourcedir . '/Class-Package.php');
1032
		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
1033
1034
		if ($ftp->error === false)
1035
		{
1036
			// Common mistake, so let's try to remedy it...
1037
			if (!$ftp->chdir($_POST['ftp_path']))
1038
			{
1039
				$ftp_error = $ftp->last_message;
1040
				$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
1041
			}
1042
		}
1043
	}
1044
1045
	if (!isset($ftp) || $ftp->error !== false)
1046
	{

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
		{