Code Duplication    Length = 18-18 lines in 2 locations

engine/lib/elgglib.php 1 location

@@ 368-385 (lines=18) @@
365
 *
366
 * @return string
367
 */
368
function sanitise_filepath($path, $append_slash = true) {
369
	// Convert to correct UNIX paths
370
	$path = str_replace('\\', '/', $path);
371
	$path = str_replace('../', '/', $path);
372
	// replace // with / except when preceeded by :
373
	$path = preg_replace("/([^:])\/\//", "$1/", $path);
374
375
	// Sort trailing slash
376
	$path = trim($path);
377
	// rtrim defaults plus /
378
	$path = rtrim($path, " \n\t\0\x0B/");
379
380
	if ($append_slash) {
381
		$path = $path . '/';
382
	}
383
384
	return $path;
385
}
386
387
/**
388
 * Queues a message to be displayed.

engine/lib/upgrades/create_upgrade.php 1 location

@@ 206-223 (lines=18) @@
203
 *
204
 * @return string
205
 */
206
function sanitise_filepath($path, $append_slash = TRUE) {
207
	// Convert to correct UNIX paths
208
	$path = str_replace('\\', '/', $path);
209
	$path = str_replace('../', '/', $path);
210
	// replace // with / except when preceeded by :
211
	$path = preg_replace("/([^:])\/\//", "$1/", $path);
212
213
	// Sort trailing slash
214
	$path = trim($path);
215
	// rtrim defaults plus /
216
	$path = rtrim($path, " \n\t\0\x0B/");
217
218
	if ($append_slash) {
219
		$path = $path . '/';
220
	}
221
222
	return $path;
223
}