$saveas = "data_" . date("YmdHis") . ".txt"; ob_start(); $version = 1; $path = "../../../../"; require_once $path . "defaultIncludes.php"; require_once $path . "inc.serverPath.php"; $qaQcLevel = $_SESSION["qaqc_level"]; $site_id = isset($_POST["site_id"]) ? $_POST["site_id"] : 0; $time_period = isset($_POST["time_period"]) ? $_POST["time_period"] : 0; $site_query = "
\x9SELECT t2.station_name, t1.display, t1.gmap_type_id, t1.position_fixed, t1.gps_lat, t1.gps_long, t1.gps_lat_variable_id, t1.gps_long_variable_id,
\xa\x9\x9t1.show_link, t1.page_id_link, t1.display_alarms, t1.display_all_variables, t1.display_unit, t1.allow_download, t1.display_type, t1.data_precision,
\x9\x9t1.description, t1.photo, t3.table_name\xd
\x9FROM gmap_site AS t1, Station AS t2, File_Path AS t3\xd\xa WHERE t1.station_id=t2.station_id AND t1.station_id=t3.station_id AND t1.display=1 AND t1.station_id= :station_id;"; $orientationParam = array("query" => $site_query, "db" => $db, "db_type" => $db_type); $orientationStmt = vdv_prepare_query($orientationParam); $orientationStmt->execute(array(":station_id" => $site_id)); $sresult = $orientationStmt->fetchAll(PDO::FETCH_NUM); if (count($sresult) > 0) { $lline = $sresult[0]; $site_name = $lline[0]; $display = $lline[1]; $gmap_type_id = $lline[2]; $position_fixed = $lline[3]; $gps_lat = $lline[4]; $gps_long = $lline[5]; $gps_lat_variable_id = $lline[6]; $gps_long_variable_id = $lline[7]; $show_link = $lline[8]; $page_id_link = $lline[9]; $display_alarms = $lline[10]; $display_all_variables = $lline[11]; $display_unit = $lline[12]; $allow_download = $lline[13]; $display_type = $lline[14]; $data_precision = $lline[15]; $description = $lline[16]; $photo = $lline[17]; $table_name = $lline[18]; $sql_tables = array(); $sql_tables[] = $table_name; $roc_variable_found = 0; $roc_variables_array = array(); $roc_variables_array[] = array(0, 0, 0, 0, 0); if ($allow_download == 1) { echo "Site Name: {$site_name}\xd
"; echo "Saved: " . date("Y-m-d H:i:s") . "
\xd\xa"; echo "Data was saved using Vista Data Vision.\xd
\xa"; $variable_query = "\xd\xa \x9\x9SELECT t1.variable_id, t1.db_col_name, t2.english_name, t3.unit_name, t1.calculated_variable, t1.dynamic_variable, t4.value_precision\xd
\x9\x9\x9FROM Variable_Info AS t1, Variable_Name AS t2, Unit AS t3, gmap_site_variable AS t4\xd
\x9 \x9WHERE t1.variable_id=t4.variable_id AND t4.display=1 AND t1.variable_id=t2.variable_id AND t1.unit_id=t3.unit_id AND t1.station_id= :station_id\xd
\x9 ORDER BY t2.english_name;"; if ($display_all_variables == 1) { $variable_query = "
\x9 SELECT t1.variable_id, t1.db_col_name, t2.english_name, t3.unit_name, t1.calculated_variable, t1.dynamic_variable, t4.value_precision\xd
\x9\x9 FROM Variable_Info AS t1, Variable_Name AS t2, Unit AS t3, gmap_site_variable AS t4
\xa \x9\x9 WHERE t1.variable_id=t4.variable_id AND t1.variable_id=t2.variable_id AND t1.unit_id=t3.unit_id AND t1.station_id= :station_id\xd\xa\x9 \x9 ORDER BY t2.english_name;"; } $variableParam = array("query" => $variable_query, "db" => $db, "db_type" => $db_type); $variableStmt = vdv_prepare_query($variableParam); $variableStmt->execute(array(":station_id" => $site_id)); $vresult = $variableStmt->fetchAll(PDO::FETCH_NUM); $allVariables = array(); $variablePrecision = array(); for ($i1 = 0; $i1 < count($vresult); ++$i1) { $allVariables[] = $vresult[$i1][0]; $variablePrecision[$vresult[$i1][0]] = $vresult[$i1][6]; } if ($time_period == 1) { $time_ofset = 7 * 86400; } else { $time_ofset = 30 * 86400; } $start = date("Y-m-d :0", time() - $time_ofset); $stop = date("Y-m-d 0:0", time()); $result = get_vdv_data($db, $db_type, $allVariables, $start, $stop, 0, 0, $qaQcLevel, array(0), array(0), array(), 0, array(), array(), array()); $variableParam = array("query" => $variable_data_query, "db" => $db, "db_type" => $db_type); $variableStmt = vdv_prepare_query($variableParam); $variableStmt->execute(); $vresult = $variableStmt->fetchAll(PDO::FETCH_NUM); echo "Timestamp"; foreach ($result as $variable) { $variable_name = $variable["variable_name"]; $unit_name = $variable["unit_name"]; echo "\x9{$variable_name} ({$unit_name})"; } echo "
\xa"; if (count($result) > 0) { $timestamps = $result[0]["variable_time"]; foreach ($timestamps as $key => $timestamp) { echo "{$timestamp} "; foreach ($result as $vkey => $variable) { if ($vkey > 0) { echo " "; } $id = $variable["variable_id"]; $value = round($variable["variable_value"][$key], $variablePrecision[$id]); echo $value; } echo "
\xa"; } } $buffer = ob_get_contents(); header("Pragma: public"); header("Expires: "); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Transfer-Encoding: binary "); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Length: " . strlen($buffer)); header("Content-Disposition: attachment; filename="" . $saveas . """); echo $buffer; } }
$saveas = "data_" . date("YmdHis") . ".txt"; ob_start(); $version = 1; $path = "../../../../"; require_once $path . "defaultIncludes.php"; require_once $path . "inc.serverPath.php"; $qaQcLevel = $_SESSION["qaqc_level"]; $site_id = isset($_POST["site_id"]) ? $_POST["site_id"] : 0; $time_period = isset($_POST["time_period"]) ? $_POST["time_period"] : 0; $site_query = "
\x9SELECT t2.station_name, t1.display, t1.gmap_type_id, t1.position_fixed, t1.gps_lat, t1.gps_long, t1.gps_lat_variable_id, t1.gps_long_variable_id,
\xa\x9\x9t1.show_link, t1.page_id_link, t1.display_alarms, t1.display_all_variables, t1.display_unit, t1.allow_download, t1.display_type, t1.data_precision,
\x9\x9t1.description, t1.photo, t3.table_name\xd
ROM gmap_site AS t1, Station AS t2, File_Path AS t3\xd\xa WHERE t1.station_id=t2.station_id AND t1.station_id=t3.station_id AND t1.display=1 AND t1.station_id= :station_id;"; $orientationParam = array("query" => $site_query, "db" => $db, "db_type" => $db_type); $orientationStmt = vdv_prepare_query($orientationParam); $orientationStmt->execute(array(":station_id" => $site_id)); $sresult = $orientationStmt->fetchAll(PDO::FETCH_NUM); if (count($sresult) > 0) { $lline = $sresult[0]; $site_name = $lline[0]; $display = $lline[1]; $gmap_type_id = $lline[2]; $position_fixed = $lline[3]; $gps_lat = $lline[4]; $gps_long = $lline[5]; $gps_lat_variable_id = $lline[6]; $gps_long_variable_id = $lline[7]; $show_link = $lline[8]; $page_id_link = $lline[9]; $display_alarms = $lline[10]; $display_all_variables = $lline[11]; $display_unit = $lline[12]; $allow_download = $lline[13]; $display_type = $lline[14]; $data_precision = $lline[15]; $description = $lline[16]; $photo = $lline[17]; $table_name = $lline[18]; $sql_tables = array(); $sql_tables[] = $table_name; $roc_variable_found = 0; $roc_variables_array = array(); $roc_variables_array[] = array(0, 0, 0, 0, 0); if ($allow_download == 1) { echo "Site Name: {$site_name}\xd
"; echo "Saved: " . date("Y-m-d H:i:s") . "
\xd\xa"; echo "Data was saved using Vista Data Vision.\xd
\xa"; $variable_query = "\xd\xa \x9\x9SELECT t1.variable_id, t1.db_col_name, t2.english_name, t3.unit_name, t1.calculated_variable, t1.dynamic_variable, t4.value_precision\xd
\x9\x9ROM Variable_Info AS t1, Variable_Name AS t2, Unit AS t3, gmap_site_variable AS t4\xd
\x9 \x9WHERE t1.variable_id=t4.variable_id AND t4.display=1 AND t1.variable_id=t2.variable_id AND t1.unit_id=t3.unit_id AND t1.station_id= :station_id\xd
\x9 ORDER BY t2.english_name;"; if ($display_all_variables == 1) { $variable_query = "
\x9 SELECT t1.variable_id, t1.db_col_name, t2.english_name, t3.unit_name, t1.calculated_variable, t1.dynamic_variable, t4.value_precision\xd
\x9\x9 FROM Variable_Info AS t1, Variable_Name AS t2, Unit AS t3, gmap_site_variable AS t4
\xa \x9\x9 WHERE t1.variable_id=t4.variable_id AND t1.variable_id=t2.variable_id AND t1.unit_id=t3.unit_id AND t1.station_id= :station_id\xd\xa\x9 \x9 ORDER BY t2.english_name;"; } $variableParam = array("query" => $variable_query, "db" => $db, "db_type" => $db_type); $variableStmt = vdv_prepare_query($variableParam); $variableStmt->execute(array(":station_id" => $site_id)); $vresult = $variableStmt->fetchAll(PDO::FETCH_NUM); $allVariables = array(); $variablePrecision = array(); for ($i1 = 0; $i1 < count($vresult); ++$i1) { $allVariables[] = $vresult[$i1][0]; $variablePrecision[$vresult[$i1][0]] = $vresult[$i1][6]; } if ($time_period == 1) { $time_ofset = 7 * 86400; } else { $time_ofset = 30 * 86400; } $start = date("Y-m-d :0", time() - $time_ofset); $stop = date("Y-m-d 0:0", time()); $result = get_vdv_data($db, $db_type, $allVariables, $start, $stop, 0, 0, $qaQcLevel, array(0), array(0), array(), 0, array(), array(), array()); $variableParam = array("query" => $variable_data_query, "db" => $db, "db_type" => $db_type); $variableStmt = vdv_prepare_query($variableParam); $variableStmt->execute(); $vresult = $variableStmt->fetchAll(PDO::FETCH_NUM); echo "Timestamp"; foreach ($result as $variable) { $variable_name = $variable["variable_name"]; $unit_name = $variable["unit_name"]; echo "\x9{$variable_name} ({$unit_name})"; } echo "
\xa"; if (count($result) > 0) { $timestamps = $result[0]["variable_time"]; foreach ($timestamps as $key => $timestamp) { echo "{$timestamp} "; foreach ($result as $vkey => $variable) { if ($vkey > 0) { echo " "; } $id = $variable["variable_id"]; $value = round($variable["variable_value"][$key], $variablePrecision[$id]); echo $value; } echo "
\xa"; } } $buffer = ob_get_contents(); header("Pragma: public"); header("Expires: "); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Transfer-Encoding: binary "); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Length: " . strlen($buffer)); header("Content-Disposition: attachment; filename="" . $saveas . """); echo $buffer; } }
© 2023 Quttera Ltd. All rights reserved.