Code Duplication    Length = 2-2 lines in 16 locations

Sources/Drafts.php 2 locations

@@ 69-70 (lines=2) @@
66
67
	// message and subject still need a bit more work
68
	preparsecode($draft['body']);
69
	if ($smcFunc['strlen']($draft['subject']) > 100)
70
		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
71
72
	// Modifying an existing draft, like hitting the save draft button or autosave enabled?
73
	if (!empty($id_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ 220-221 (lines=2) @@
217
218
	// message and subject always need a bit more work
219
	preparsecode($draft['body']);
220
	if ($smcFunc['strlen']($draft['subject']) > 100)
221
		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
222
223
	// Modifying an existing PM draft?
224
	if (!empty($id_pm_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])

Sources/MessageIndex.php 2 locations

@@ 380-381 (lines=2) @@
377
			{
378
				// Limit them to $modSettings['preview_characters'] characters
379
				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
380
				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
381
					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
382
383
				// Censor the subject and message preview.
384
				censorText($row['first_subject']);
@@ 396-397 (lines=2) @@
393
				else
394
				{
395
					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
396
					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
397
						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
398
399
					censorText($row['last_subject']);
400
					censorText($row['last_body']);

Sources/MoveTopic.php 1 location

@@ 226-227 (lines=2) @@
223
	{
224
		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
225
		// Keep checking the length.
226
		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
227
			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
228
229
		// If it's still valid move onwards and upwards.
230
		if ($_POST['custom_subject'] != '')

Sources/PersonalMessage.php 1 location

@@ 3226-3227 (lines=2) @@
3223
		{
3224
			$_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => '&#044;'));
3225
3226
			if ($smcFunc['strlen']($_POST['label']) > 30)
3227
				$_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30);
3228
			if ($_POST['label'] != '')
3229
			{
3230
				$the_labels[] = $_POST['label'];

Sources/Recent.php 3 locations

@@ 57-58 (lines=2) @@
54
	censorText($row['body']);
55
56
	$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => '&#10;')));
57
	if ($smcFunc['strlen']($row['body']) > 128)
58
		$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
59
60
	// Send the data.
61
	return array(
@@ 1207-1208 (lines=2) @@
1204
		{
1205
			// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
1206
			$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
1207
			if ($smcFunc['strlen']($row['first_body']) > 128)
1208
				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1209
			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1210
			if ($smcFunc['strlen']($row['last_body']) > 128)
1211
				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
@@ 1210-1211 (lines=2) @@
1207
			if ($smcFunc['strlen']($row['first_body']) > 128)
1208
				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1209
			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1210
			if ($smcFunc['strlen']($row['last_body']) > 128)
1211
				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1212
1213
			// Censor the subject and message preview.
1214
			censorText($row['first_subject']);

Sources/Subs-Recent.php 1 location

@@ 62-63 (lines=2) @@
59
		censorText($row['body']);
60
61
		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
62
		if ($smcFunc['strlen']($row['body']) > 128)
63
			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
64
65
		// Build the array.
66
		$posts[] = array(

SSI.php 1 location

@@ 561-562 (lines=2) @@
558
	while ($row = $smcFunc['db_fetch_assoc']($request))
559
	{
560
		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
561
		if ($smcFunc['strlen']($row['body']) > 128)
562
			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
563
564
		// Censor the subject.
565
		censorText($row['subject']);

Sources/Post.php 4 locations

@@ 1837-1838 (lines=2) @@
1834
	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1835
1836
	// At this point, we want to make sure the subject isn't too long.
1837
	if ($smcFunc['strlen']($_POST['subject']) > 100)
1838
		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1839
1840
	// Same with the "why did you edit this" text.
1841
	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
@@ 1841-1842 (lines=2) @@
1838
		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1839
1840
	// Same with the "why did you edit this" text.
1841
	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1842
		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1843
1844
	// Make the poll...
1845
	if (isset($_REQUEST['poll']))
@@ 2734-2735 (lines=2) @@
2731
		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2732
2733
		// Maximum number of characters.
2734
		if ($smcFunc['strlen']($_POST['subject']) > 100)
2735
			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2736
	}
2737
	elseif (isset($_POST['subject']))
2738
	{
@@ 2794-2795 (lines=2) @@
2791
		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2792
2793
		// Maximum number of characters.
2794
		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2795
			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2796
	}
2797
2798
	if (empty($post_errors))

Sources/Subs-Calendar.php 1 location

@@ 833-834 (lines=2) @@
830
		// No title?
831
		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
832
			fatal_lang_error('no_event_title', false);
833
		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
834
			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
835
		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
836
	}
837
}