Code Duplication    Length = 19-20 lines in 2 locations

other/upgrade.php 1 location

@@ 5315-5333 (lines=19) @@
5312
5313
	// Protect me from what I want! :P
5314
	clearstatcache();
5315
	if (filemtime($boarddir . '/Settings.php') === $last_settings_change)
5316
	{
5317
		// save the old before we do anything
5318
		$settings_backup_fail = !@is_writable($boarddir . '/Settings_org.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_org.php');
5319
		$settings_backup_fail = !$settings_backup_fail ? (!file_exists($boarddir . '/Settings_org.php') || filesize($boarddir . '/Settings_org.php') === 0) : $settings_backup_fail;
5320
5321
		// write out the new
5322
		$write_settings = implode('', $settingsArray);
5323
		$written_bytes = file_put_contents($boarddir . '/Settings.php', $write_settings, LOCK_EX);
5324
5325
		// survey says ...
5326
		if ($written_bytes !== strlen($write_settings) && !$settings_backup_fail)
5327
		{
5328
			if (file_exists($boarddir . '/Settings_bak.php'))
5329
				@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
5330
5331
			return throw_error('The upgrader detected a bad Settings file and reverted the changes.  Unable to migrate your Settings file to a new version.');
5332
		}
5333
	}
5334
5335
	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
5336
	// it seems that there are times it might not. So let's MAKE it dump the cache.

Sources/Subs-Admin.php 1 location

@@ 406-425 (lines=20) @@
403
404
	// Protect me from what I want! :P
405
	clearstatcache();
406
	if (filemtime($boarddir . '/Settings.php') === $last_settings_change)
407
	{
408
		// save the old before we do anything
409
		$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
410
		$settings_backup_fail = !$settings_backup_fail ? (!file_exists($boarddir . '/Settings_bak.php') || filesize($boarddir . '/Settings_bak.php') === 0) : $settings_backup_fail;
411
412
		// write out the new
413
		$write_settings = implode('', $settingsArray);
414
		$written_bytes = file_put_contents($boarddir . '/Settings.php', $write_settings, LOCK_EX);
415
416
		// survey says ...
417
		if ($written_bytes !== strlen($write_settings) && !$settings_backup_fail)
418
		{
419
			// Well this is not good at all, lets see if we can save this
420
			$context['settings_message'] = 'settings_error';
421
422
			if (file_exists($boarddir . '/Settings_bak.php'))
423
				@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
424
		}
425
	}
426
427
	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
428
	// it seems that there are times it might not. So let's MAKE it dump the cache.