IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 22, 2026, 5:16:15 PM (3 months ago)
Author:
eugene
Message:

fixing for modern PHP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp.php

    r25322 r42996  
     1
    12<?php
    23
     
    45require_once "authenticate.php";
    56
     7function request_var($key, $filter = FILTER_DEFAULT, $default = null, $options = null) {
     8  $raw = $_POST[$key] ?? $_GET[$key] ?? null;
     9
     10  // Treat missing or empty as null
     11  if ($raw === '' || $raw === null) {
     12    return $default;
     13  }
     14
     15  // Apply validation
     16  $val = filter_var($raw, $filter, $options ?? []);
     17
     18  if ($val === false) {
     19    http_response_code(400);
     20    die("Invalid value for key '$key'");
     21  }
     22  return $val;
     23}
     24
     25//  $val = filter_input(INPUT_GET, $key, $filter, $options);
     26//  if ($val === false) {
     27//    http_response_code(400);
     28//    echo "<b> invalid GET key $key </b><br>";
     29//    die ("invalid GET key $key");
     30//  }
     31//  if ($val !== null) {
     32//    return $val;
     33//  }
     34//
     35//  $val = filter_input(INPUT_POST, $key, $filter, $options);
     36//  if ($val === false) {
     37//    http_response_code(400);
     38//    echo "<b> invalid POST key $key </b><br>";
     39//    die ("invalid POST key $key");
     40//  }
     41//  if ($val !== null) {
     42//    return $val;
     43//  }
     44//  return $default;
     45// }
     46
    647?>
Note: See TracChangeset for help on using the changeset viewer.