Code Duplication    Length = 27-27 lines in 2 locations

other/upgrade.php 1 location

@@ 968-994 (lines=27) @@
965
		{
966
			// Attempt to register the site etc.
967
			$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
968
			if ($fp)
969
			{
970
				$out = 'GET /smf/stats/register_stats.php?site=' . base64_encode($boardurl) . ' HTTP/1.1' . "\r\n";
971
				$out .= 'Host: www.simplemachines.org' . "\r\n";
972
				$out .= 'Connection: Close' . "\r\n\r\n";
973
				fwrite($fp, $out);
974
975
				$return_data = '';
976
				while (!feof($fp))
977
					$return_data .= fgets($fp, 128);
978
979
				fclose($fp);
980
981
				// Get the unique site ID.
982
				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
983
984
				if (!empty($ID[1]))
985
					$smcFunc['db_insert']('replace',
986
						$db_prefix . 'settings',
987
						array('variable' => 'string', 'value' => 'string'),
988
						array(
989
							array('sm_stats_key', $ID[1]),
990
							array('enable_sm_stats', 1),
991
						),
992
						array('variable')
993
					);
994
			}
995
		}
996
		else
997
		{

other/install.php 1 location

@@ 1295-1321 (lines=27) @@
1292
1293
		// Attempt to register the site etc.
1294
		$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1295
		if ($fp)
1296
		{
1297
			$out = 'GET /smf/stats/register_stats.php?site=' . base64_encode($boardurl) . ' HTTP/1.1' . "\r\n";
1298
			$out .= 'Host: www.simplemachines.org' . "\r\n";
1299
			$out .= 'Connection: Close' . "\r\n\r\n";
1300
			fwrite($fp, $out);
1301
1302
			$return_data = '';
1303
			while (!feof($fp))
1304
				$return_data .= fgets($fp, 128);
1305
1306
			fclose($fp);
1307
1308
			// Get the unique site ID.
1309
			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1310
1311
			if (!empty($ID[1]))
1312
				$smcFunc['db_insert']('replace',
1313
					$db_prefix . 'settings',
1314
					array('variable' => 'string', 'value' => 'string'),
1315
					array(
1316
						array('sm_stats_key', $ID[1]),
1317
						array('enable_sm_stats', 1),
1318
					),
1319
					array('variable')
1320
				);
1321
		}
1322
	}
1323
	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1324
	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))