270 public function get_request(
string $aName=
"",
string|
int|array|
float|
bool|
null $aDefault=
null,
string $type=
"",
string|array $range=
"")
278 if (
false === $this->strict_looking_inside)
281 if (strtoupper($_SERVER[
'REQUEST_METHOD']) ==
"POST")
283 $return_value = (
true === array_key_exists ($aName , $_POST) ) ? $_POST[$aName] : $aDefault;
287 $return_value = (
true === array_key_exists ($aName , $_GET) ) ? $_GET[$aName] : $aDefault;
292 switch ($this->strict_looking_inside)
295 $return_value = $_POST[$aName] ?? $aDefault;
299 $return_value = $_GET[$aName] ?? $aDefault;
303 $return_value = $_REQUEST[$aName] ?? $aDefault;
307 $return_value = $_SESSION[$aName] ?? $aDefault;
311 $return_value = $_SERVER[$aName] ?? $aDefault;
315 $return_value =
null;
324 if (is_array($return_value) && ($type !=
"array"))
326 foreach ($return_value as $key => &$tempValue)
328 $tempValue = $this->
filterValue($tempValue, $type, $aDefault, $range);
333 $return_value = $this->
filterValue($return_value, $type, $aDefault, $range);
336 return $return_value;
547 string|
int|array|
float|
bool|
null $return_value,
549 string|
int|array|
float|
bool|
null $aDefault=
null,
550 string|array $range=
""
551 ): string|int|array|float|bool|null
553 switch (strtolower($type))
559 $return_value = intval($return_value);
560 if (!is_int($return_value)) {
561 $return_value = $aDefault;
563 if (
true === is_array($range) )
565 $this->check_range($type, $return_value, $aDefault, $range);
572 $return_value = intval($return_value);
573 if (!is_int($return_value))
575 $return_value = $aDefault;
578 if ($return_value <= 0)
580 $return_value = $aDefault;
583 if (
true === is_array($range) )
585 $this->check_range($type, $return_value, $aDefault, $range);
591 $return_value = intval($return_value);
592 if (!is_int($return_value))
594 $return_value = $aDefault;
597 if ( $return_value >= 0)
599 $return_value = $aDefault;
602 if (
true === is_array($range) )
604 $this->check_range($type, $return_value, $aDefault, $range);
621 $sPattern =
"/[^0-9-,\.]/i";
622 $return_value = preg_replace (
625 (
string)$return_value
629 $return_value = str_replace(
",",
".", $return_value);
632 $aTemp = explode(
".", $return_value);
635 if(count($aTemp) > 2)
637 $sPrefix = array_pop($aTemp);
638 $return_value = implode(
"", $aTemp).
".".$sPrefix;
642 if (
true === is_array($range) )
644 $this->check_range($type, $return_value, $aDefault, $range);
650 $return_value = intval(eval(
"return ".$return_value.
";"));
652 if (
true === is_array($range))
654 $this->check_range($type, $return_value, $aDefault, $range);
662 if (!is_string($return_value))
664 $return_value = $aDefault;
667 if (
true === is_array($range))
669 $this->check_range($type, $return_value, $aDefault, $range);
675 if (!is_string($return_value))
677 $return_value = $aDefault;
681 $return_value = htmlspecialchars(strip_tags($return_value));
688 if (!is_string((
string)$return_value))
690 $return_value = $aDefault;
694 $return_value = lib_lepton::getToolInstance(
"htmlpurifier")->purify($return_value);
695 $return_value = htmlspecialchars($return_value);
700 case 'string_allowed':
702 if (!is_string((
string)$return_value))
704 $return_value = $aDefault;
708 $return_value = strip_tags($return_value, $range);
713 case 'string_secure':
716 $return_value = $aDefault;
722 if (!is_string($return_value))
724 $return_value = $aDefault;
728 $return_value = $aDefault;
734 if (!is_string($return_value))
736 $return_value = $aDefault;
740 $return_value = $aDefault;
746 if (!is_string($return_value))
748 $return_value = $aDefault;
752 $return_value = $aDefault;
760 $d = DateTime::createFromFormat($format, $return_value);
761 $result = $d && $d->format($format) == $return_value;
762 if ($result ===
false) {
763 $return_value = $aDefault;
769 $format =
'Y-m-d H:i:s';
770 $d = DateTime::createFromFormat($format, $return_value);
771 $result = $d && $d->format($format) == $return_value;
772 if ($result ===
false) {
773 $return_value = $aDefault;
778 case 'datetime_local':
779 $format =
'Y-m-d\TH:i:s';
780 $d = DateTime::createFromFormat($format, $return_value);
781 $result = $d && $d->format($format) == $return_value;
782 if ($result ===
false) {
783 $return_value = $aDefault;
790 $d = DateTime::createFromFormat($format, $return_value);
791 $result = $d && $d->format($format) == $return_value;
792 if ($result ===
false) {
793 $return_value = $aDefault;
800 $d = DateTime::createFromFormat($format, $return_value);
801 $result = $d && $d->format($format) == $return_value;
802 if ($result ===
false) {
803 $return_value = $aDefault;
810 $result = preg_match(
"/^[1-9][0-9]{3}[-][W][0-9]{2}$/", $return_value);
812 $return_value = $aDefault;
818 if (!is_array($return_value))
820 $return_value = $aDefault;
826 if ((
true === is_array($range)) && (isset($range[
'pattern'])))
828 $test = preg_match($range[
'pattern'], $return_value);
831 $return_value = $range[
'default'] ?? $aDefault;
838 $return_value = filter_var(
840 FILTER_VALIDATE_BOOLEAN,
841 [
'flags' => FILTER_NULL_ON_FAILURE]
851 return $return_value;