vsgallery/lib/helpers.class.php

36 lines
844 B
PHP
Raw Permalink Normal View History

2022-01-08 16:22:16 +00:00
<?php
class Helpers {
// Add trailing / to path if missing
public static function end_dir($dir) {
if (mb_substr($dir, -1) == '/' ) {
return $dir;
} else {
return $dir.'/';
}
}
2022-02-18 09:08:22 +00:00
// Check if a Variable is an Integer and in the defined Range
public static function validate_int($int, $min, $max) {
if (is_string($int) && !ctype_digit($int)) {
return false; // contains non digit characters
}
if (!is_int((int) $int)) {
return false; // other non-integer value or exceeds PHP_MAX_INT
}
return ($int >= $min && $int <= $max);
}
// Check Search String for Valid Characters
public static function validate_search($search) {
2023-06-05 16:52:07 +00:00
if (!preg_match("#^[a-zA-Z0-9äöüÄÖÜ _\-\.\*\?\:\(\)\']+$#", $search)) {
2022-02-18 09:08:22 +00:00
return false;
} else {
return true;
}
}
2022-01-08 16:22:16 +00:00
}
?>