36 lines
No EOL
844 B
PHP
36 lines
No EOL
844 B
PHP
<?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.'/';
|
|
}
|
|
}
|
|
|
|
// 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) {
|
|
if (!preg_match("#^[a-zA-Z0-9äöüÄÖÜ _\-\.\*\?\:\(\)\']+$#", $search)) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
?>
|