Beiträge von realpapla

    <?php

    class DumpHTTPRequestToFile {

    public function execute($targetFile) {

    $data = sprintf(

    "%s\n",

    $_SERVER['REQUEST_URI']

    );

    $fp = fopen('./dumprequest.txt', 'a');//opens file in append mode

    $query = parse_url($data, PHP_URL_QUERY);

    parse_str($query, $params);

    $humidity = $params['hum'];

    $temperature = $params['temp'];

    $timeStamp = time();

    $parseData = sprintf("%s %d %s %s\n", date('Y-m-d H:i:s'), $timeStamp, $temperature, $humidity);

    fwrite($fp, $parseData);

    fclose($fp);

    echo("Done!\n\n");

    }

    }


    (new DumpHTTPRequestToFile)->execute('./dumprequest.txt');


    Creates a file, here called dumprequest.txt and add 2 types of timestamps and temperature and humidity in §1 line

    2021-08-16 14:30:04 1629124204 23.62 58

    2021-08-16 14:30:12 1629124212 23.62 58