case "create": if (isset($_GET['apikey']) && $apikey == $_GET['apikey']) { print $phpfina->create($id, array("interval" => get('interval'), "columns" => get('columns'))); } break; case "post": if (isset($_GET['apikey']) && $apikey == $_GET['apikey']) { $time = time(); print json_encode($phpfina->post($id, $time, explode(",", get('values')))); } break; case "data": print json_encode($phpfina->get_data($id, get('start'), get('end'), get('interval'), get('skipmissing'), get('limitinterval'))); break; case "lastvalue": print json_encode($phpfina->lastvalue($id)); break; } function get($index) { $val = null; if (isset($_GET[$index])) { $val = $_GET[$index]; } if (get_magic_quotes_gpc()) { $val = stripslashes($val); } return $val; } class EmonLogger {
$dirset = false; $dir = ""; switch ($query) { case "scandir": $dirset = true; $dir = $_GET['dir']; $_SESSION['last_saved_dir'] = $dir; $scan = scandir($dir); $phpfina->dir = $dir; $feeds = array(); foreach ($scan as $item) { if (strpos($item, ".dat") !== false) { $parts = explode(".", $item); $feedid = (int) $parts[0]; $meta = $phpfina->get_meta($feedid); $timeval = $phpfina->lastvalue($feedid); $feeds[] = array("feedid" => $feedid, "interval" => $meta->interval, "start" => $meta->start_time, "npoints" => $phpfina->get_npoints($feedid), "lastvalue" => $timeval["value"], "size" => $phpfina->get_feed_size($feedid)); } } print json_encode($feeds); break; case "data": $dir = $_GET['dir']; $feedid = (int) $_GET['id']; $start = (int) $_GET['start']; $end = (int) $_GET['end']; $interval = (int) $_GET['interval']; $phpfina->dir = $dir; print json_encode($phpfina->get_data($feedid, $start, $end, $interval, 1, 1)); break; }