X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/30634c0b3869d459552df1da06ec264fb1e6b086..ebadc5e4019929d4e1686516160ee01a114d9b8a:/WEB-INF/lib/common.lib.php diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index f483b3d4..e09a943f 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -165,7 +165,7 @@ function check_extension($ext) // isTrue is a helper function to return correct false for older config.php values defined as a string 'false'. function isTrue($val) { - return ($val === true); + return (defined($val) && constant($val) === true); } // ttValidString is used to check user input to validate a string. @@ -406,3 +406,14 @@ function ttDateToUserFormat($date) $o_date = new DateAndTime(DB_DATEFORMAT, $date); return $o_date->toString($user->date_format); } + +// ttRandomString generates a random alphanumeric string. +function ttRandomString($length = 32) { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; +}