// isTrue is a helper function to return correct false for older config.php values defined as a string 'false'.
function isTrue($val)
{
- return ($val == false || $val === 'false') ? false : true;
+ return ($val === true);
}
// ttValidString is used to check user input to validate a string.
return ($emptyValid ? true : false);
global $user;
- $decimal = $user->decimal_mark;
+ $decimal = $user->getDecimalMark();
if (!preg_match('/^-?[0-9'.$decimal.']+$/', $val))
return false;
if (stristr($val, '<script>') || stristr($val, '<script '))
return false;
- if (!preg_match("/^count\s?>\s?\d+$/", $val))
+ if (!preg_match("/^count\s?(=|[<>]=?|<>)\s?\d+$/", $val))
return false;
return true;
return false;
}
+
+// ttStartsWith functions checks if a string starts with a given substring.
+function ttStartsWith($string, $startString)
+{
+ $len = strlen($startString);
+ return (substr($string, 0, $len) === $startString);
+}
+
+// ttDateToUserFormat converts a date from database format to user format.
+function ttDateToUserFormat($date)
+{
+ global $user;
+ $o_date = new DateAndTime(DB_DATEFORMAT, $date);
+ return $o_date->toString($user->date_format);
+}