From d7f3313ff4514e38c9f53439cd1a1287e56e45f7 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 11 Nov 2018 17:19:26 +0100 Subject: reboot folder --- app/fn/fn.php | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 app/fn/fn.php (limited to 'app/fn/fn.php') diff --git a/app/fn/fn.php b/app/fn/fn.php new file mode 100644 index 0000000..8bfdee8 --- /dev/null +++ b/app/fn/fn.php @@ -0,0 +1,155 @@ +getMessage()); + } + return $bdd; +} + + +function secure() +{ + if (!isset($_SESSION['id'])) { + header("location: ./"); + } +} + +function head($title) +{ + ?> + + + + + <?= $title ?> + + y > 1) return $str . $diff->y . ' years'; + if ($diff->y == 1) return $str . ' 1 year and ' . $diff->m . ' months'; + if ($diff->m > 1) return $str . $diff->m . ' months'; + if ($diff->m == 1) return $str . ' 1 month and ' . $diff->d . ($diff->d > 1 ? ' days' : ' day'); + if ($diff->d > 1) return $str . $diff->d . ' days'; + if ($diff->d == 1) return $str . ' 1 day and ' . $diff->h . ($diff->h > 1 ? ' hours' : ' hour'); + if ($diff->h > 1) return $str . $diff->h . ' hours'; + if ($diff->h == 1) return $str . ' 1 hour and ' . $diff->i . ($diff->i > 1 ? ' minutes' : ' minute'); + if ($diff->i > 1) return $str . $diff->i . ' minutes'; + if ($diff->i == 1) return $str . ' 1 minute'; + return $str . ' a few secondes'; +} + + + +function arrayclean($input) +{ + $output = []; + foreach ($input as $key => $value) { + if (is_array($value)) { + $output[$key] = array_filter($value); + } else { + $output[$key] = $value; + } + } + return $output; +} + + + + +function array_update($base, $new) +{ + foreach ($base as $key => $value) { + if (array_key_exists($key, $new)) { + if (gettype($base[$key]) == gettype($new[$key])) { + $base[$key] = $new[$key]; + } + } + } + return $base; +} + +function contains($needle, $haystack) +{ + return strpos($haystack, $needle) !== false; +} + + +function str_clean(string $string) +{ + return str_replace(' ', '_', strtolower(strip_tags($string))); +} + + + + +function changekey($array, $oldkey, $newkey) +{ + if (!array_key_exists($oldkey, $array)) + return $array; + + $keys = array_keys($array); + $keys[array_search($oldkey, $keys)] = $newkey; + + return array_combine($keys, $array); +} + + + + +?> \ No newline at end of file -- cgit v1.2.3