From eb2e78a12505b8d41e0ef62cb1b321cdc540e5fd Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 10 Dec 2017 20:20:21 +0100 Subject: additional checks if a parameter is set; function to create paths added --- functions.common.inc.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'functions.common.inc.php') diff --git a/functions.common.inc.php b/functions.common.inc.php index 11bcefc..a9db566 100644 --- a/functions.common.inc.php +++ b/functions.common.inc.php @@ -48,4 +48,19 @@ function endsWith($haystack, $needle) { return $length === 0 || (substr($haystack, -$length) === $needle); } + +function generatePath($parts, $basePath = __DIR__) { + $path = $basePath; + if (!is_array($parts)) { + $parts = [$parts]; + } + foreach ($parts as $part) { + $path .= DIRECTORY_SEPARATOR.generatePathName($part); + } + return $path; +} + +function generatePathName($name) { + return urlencode($name); +} ?> -- cgit v1.2.3