%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/spotreba/
Upload File :
Create Path :
Current File : //var/www/spotreba/eliot.php

<?php
include "db.php";

$last = dibi::query("SELECT [timestamp], [high], [low] FROM [eliot] ORDER BY [timestamp] DESC %lmt", 1);
$lastHigh = 0;
$lastLow = 0;
$lastTime = 0;

if($last->getRowCount())
{
    $row = $last->fetch();
    $lastTime = $row->timestamp->getTimestamp();
    $lastHigh = $row->high;
    $lastLow = $row->low;
}

$from = ($lastTime - 7200) * 1000;

exec("curl https://app.visionq.cz/index.php -X POST -d \"email=martin%40varak.net&password=Nastenka112\" --cookie-jar /var/www/spotreba/eliot-cookie.txt -4");
exec("curl \"https://app.visionq.cz/data/pages/export/csv.php?id=2383&from=$from\" --cookie /var/www/spotreba/eliot-cookie.txt -4", $output);
array_shift($output);
print_r($output);
print_r($lastTime);
print_r($lastHigh);
print_r($lastLow);

foreach($output as $line)
{
    $csv = str_getcsv($line, ",");
    $csvTrim = array_map('trim', $csv);
    list($timeStr, $minutes, $high, $low) = $csvTrim;
    $time = new DateTimeImmutable($timeStr);

    if($time->getTimestamp() > $lastTime)
    {
        $data = array(
            'timestamp' => $time,
            'duration' => floor($minutes * 60),
            'high' => $high,
            'low' => $low,
            'delta_high' => $high - $lastHigh,
            'delta_low' => $low - $lastLow
        );
        $lastHigh = $high;
        $lastLow = $low;
        dibi::query("INSERT INTO [eliot]", $data);
    }
}

Zerion Mini Shell 1.0