<html> <head> <meta http-equiv="refresh" content="300"> </head> <body> <?php echo "Last reload: " . date('Y-m-d H:i:s'); ?> <pre><?php require_once "../db/db.php"; require_once "../dropbox_token.php"; $db = new TesouroDB("../db/Tesouro.db"); // dropbox require_once "../dropbox/autoload.php"; use Dropbox as dbx; $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0"); $f = fopen("Tesouro.db", "w+b"); if (flock($f, LOCK_EX)) { // acquire an exclusive lock ftruncate($f, 0); // truncate file $fileMetadata = $dbxClient->getFile("/Tesouro.db", $f); fflush($f); // flush output before releasing the lock flock($f, LOCK_UN); // release the lock } else { echo "Couldn't get the lock!"; } fclose($f); $results = $db->exec("ATTACH '" . getcwd() . "\\Tesouro.db' as toMerge;\n BEGIN;\n insert INTO taxa (titulo_id, valor, timestamp) SELECT titulo_id, valor, timestamp from toMerge.taxa;\n COMMIT;\n DETACH toMerge;");
<?php //error_reporting(0); require_once "/db/db.php"; $db = new TesouroDB('db/Tesouro.db'); $r = $db->query("SELECT ti.id, ti.nome, ti.tipo, ti.ano, ti.vencimento, ti.cor, ti.cor_HEX, ta.valor FROM titulo ti INNER JOIN taxa ta ON (ti.id = ta.titulo_id) GROUP BY titulo_id ORDER BY ti.id ASC, ta.timestamp DESC"); while ($row = $r->fetchArray()) { $i = $row['id']; $titulos[$i]['id'] = $row['id']; $titulos[$i]['nome'] = $row['nome']; $titulos[$i]['tipo'] = $row['tipo']; $titulos[$i]['ano'] = $row['ano']; $titulos[$i]['vencimento'] = $row['vencimento']; $titulos[$i]['valor'] = $row['valor']; $titulos[$i]['cor'] = $row['cor']; $titulos[$i]['cor_HEX'] = $row['cor_HEX']; } if (isset($titulos[$_GET['id']])) { $id = $_GET['id']; } else { $id = 1; } $r = $db->query("SELECT * FROM (SELECT * from taxa WHERE titulo_id=" . $id . " ORDER BY timestamp DESC limit 15) order by timestamp ASC"); $i = 0; while ($row = $r->fetchArray()) { //var_dump($row); $labels[] = date("Y-m-d", $row['timestamp']); $data[] = $row['valor']; } function hex2rgba($color, $opacity = false) {