BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

input.class.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Input class
  5. *
  6. * An attempt to normalize and secure form inputs.
  7. */
  8. class Input {
  9. /**
  10. * passphrase
  11. */
  12. function passphrase(
  13. string $Name = 'password',
  14. string $ID = 'password',
  15. string $Placeholder = 'Passphrase',
  16. bool $Advice = false) {
  17. $ENV = ENV::go();
  18. # Input validation
  19. if (!is_string($Name) || empty($Name)) {
  20. error("Expected non-empty string, got \$Name = $Name in Input::passphrase.");
  21. }
  22. if (!empty($Advice) && $Advice !== true || $Advice !== false) {
  23. error("Expected true|false, got \$Advice = $Advice in Input::passphrase.");
  24. }
  25. $Field = <<<HTML
  26. <input type="password" name="$Name" id="$ID" placeholder="$Placeholder"
  27. minlength="$ENV->PW_MIN" maxlength="$ENV->PW_MAX"
  28. class="inputtext" autocomplete="off" required="required" />
  29. HTML;
  30. if ($Advice) {
  31. return $Field . $ENV->PW_ADVICE;
  32. } else {
  33. return $Field;
  34. }
  35. }
  36. }