NO, 1 => YES, ]; /** * @param $value * @return string */ public static function checked($value): string { return !empty($value) ? "checked" : ""; } /** * @param float $required_score * @return bool * @throws Exception */ public static function checkRecaptcha(float $required_score = 0.5): bool { if(!defined("GOOGLE_RECAPTCHA_SECRET")) return true; $json = http::post("https://www.google.com/recaptcha/api/siteverify", [ "secret" => GOOGLE_RECAPTCHA_SECRET, "response" => http::value("g-recaptcha-response"), "remoteip" => $_SERVER["REMOTE_ADDR"] ]); if(!$json) return false; $response = json_decode($json); if(!$response) return false; if(isset($response->score)) { return $response->score >= $required_score; } return $response->success; } public static function renderYearOptions(?int $min = null, ?int $max = null, ?int $selected_value = null): void { if($min === null) $min = date("Y") - 100; if($max === null) $max = date("Y") - 16; for($i = $min; $i <= $max; $i++) { $selected = ((int) $selected_value === $i) ? "selected" : ""; ?> $threshold) { $countries_json = @file_get_contents($file); $countries = json_decode($countries_json); } else { $url = "http://country.io/names.json"; $countries_json = @file_get_contents($url); $countries = json_decode($countries_json); if($countries) { file_put_contents($file, $countries_json); } } if(!$countries) return; $country_pairs = get_object_vars($countries); sort($country_pairs); $countries = array_values($country_pairs); ?> requiredKey ?? null; /** @var Template $template */ $template = $options->template ?? null; if($required_key && $template) { $keys = $template->getKeys(); if(!in_array($required_key, $keys)) return; } switch($options->type) { case "header": self::renderHeader($options); break; case "checkbox": self::renderCheckboxField($options); break; case "dropdown": case "select": self::renderSelectField($options); break; case "radio": case "inline-radio": self::renderRadioField($options); break; case "text": self::renderTextField($options); break; case "number": self::renderNumberField($options); break; case "textarea": self::renderTextareaField($options); break; case "file": self::renderFileField($options); break; case "hr": self::renderHorizontalBar($options); break; case "time": self::renderTimeField($options); break; } } private static function renderHeader($options): void { $hidden = !empty($options->hidden) ? "hidden" : ""; ?>

>content)?>

name); $value = $options->value ?? http::value($options->name); $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; $max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : ""; $hidden = !empty($options->hidden) ? "hidden" : ""; ?>
> />
name); $value = $options->value ?? http::value($options->name); $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; $min = ($options->min ?? false) ? "min=\"$options->min\"" : ""; $max = ($options->max ?? false) ? "max=\"$options->max\"" : ""; $max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : ""; $step = $options->step ?? 1; $prepend_text = $options->prependText ?? ""; $hidden = !empty($options->hidden) ? "hidden" : ""; ?>
>
/>
name); $default_value = $options->defaultValue ?? null; $selected_value = $options->value ?? http::value($options->name); if($selected_value === null) $selected_value = $default_value; $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; ?>
name); $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; ?>
/>
name); $value = $options->value ?? http::value($options->name); $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; $max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : ""; ?>
hidden) ? "hidden" : ""; ?>
/> name); $checked = !empty($options->value) ? "checked" : ""; $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; ?>
/>
name); $default_value = $options->defaultValue ?? null; $current_value = $options->value ?? http::value($options->name); if($current_value === null) $current_value = $default_value; $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; $inline = ($options->type === "inline-radio") ? "custom-control-inline" : ""; $hidden = !empty($options->hidden) ? "hidden" : ""; ?>
>
values as $index => $value) { $display = $options->displayStrings[$index]; $checked = ($current_value === (string) $value) ? "checked" : ""; $radio_id = sprintf("%s-%s", $id, $value); if($index === 0 && $current_value === null) { $checked = "checked"; } ?>
/>
name); $value = $options->value ?? http::value($options->name); $required = ($options->required ?? false) ? "required" : ""; $help_text = $options->helpText ?? false; $hidden = !empty($options->hidden) ? "hidden" : ""; ?>
> />