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

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