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))
@@ 218-219 (lines=2) @@
215
216
	// message and subject always need a bit more work
217
	preparsecode($draft['body']);
218
	if ($smcFunc['strlen']($draft['subject']) > 100)
219
		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
220
221
	// Modifying an existing PM draft?
222
	if (!empty($id_pm_draft) && !empty($draft_info))

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/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(

Sources/MoveTopic.php 1 location

@@ 213-214 (lines=2) @@
210
	{
211
		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
212
		// Keep checking the length.
213
		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
214
			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
215
216
		// If it's still valid move onwards and upwards.
217
		if ($_POST['custom_subject'] != '')

Sources/PersonalMessage.php 1 location

@@ 3220-3221 (lines=2) @@
3217
		{
3218
			$_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => '&#044;'));
3219
3220
			if ($smcFunc['strlen']($_POST['label']) > 30)
3221
				$_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30);
3222
			if ($_POST['label'] != '')
3223
			{
3224
				$the_labels[] = $_POST['label'];

Sources/Post.php 4 locations

@@ 1872-1873 (lines=2) @@
1869
	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1870
1871
	// At this point, we want to make sure the subject isn't too long.
1872
	if ($smcFunc['strlen']($_POST['subject']) > 100)
1873
		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1874
1875
	// Same with the "why did you edit this" text.
1876
	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
@@ 1876-1877 (lines=2) @@
1873
		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1874
1875
	// Same with the "why did you edit this" text.
1876
	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1877
		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1878
1879
	// Make the poll...
1880
	if (isset($_REQUEST['poll']))
@@ 2769-2770 (lines=2) @@
2766
		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2767
2768
		// Maximum number of characters.
2769
		if ($smcFunc['strlen']($_POST['subject']) > 100)
2770
			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2771
	}
2772
	elseif (isset($_POST['subject']))
2773
	{
@@ 2829-2830 (lines=2) @@
2826
		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2827
2828
		// Maximum number of characters.
2829
		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2830
			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2831
	}
2832
2833
	if (empty($post_errors))

Sources/Subs-Calendar.php 1 location

@@ 952-953 (lines=2) @@
949
		// No title?
950
		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
951
			fatal_lang_error('no_event_title', false);
952
		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
953
			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
954
		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
955
	}
956
}

SSI.php 1 location

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