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

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

other/install.php 1 location

@@ 622-635 (lines=14) @@
619
620
		$incontext['ftp_errors'] = array();
621
		require_once('Sources/Class-Package.php');
622
		if (isset($_POST['ftp_username']))
623
		{
624
			$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
625
626
			if ($ftp->error === false)
627
			{
628
				// Try it without /home/abc just in case they messed up.
629
				if (!$ftp->chdir($_POST['ftp_path']))
630
				{
631
					$incontext['ftp_errors'][] = $ftp->last_message;
632
					$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
633
				}
634
			}
635
		}
636
637
		if (!isset($ftp) || $ftp->error !== false)
638
		{