From 15db1c46641861c4397462a0368d3d9c5c86a040 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 1 Aug 2022 11:38:13 -0400 Subject: [PATCH] Update history.php --- scripts/history.php | 120 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) diff --git a/scripts/history.php b/scripts/history.php index 09afbd9..3e48ab4 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -1,6 +1,13 @@ prepare("SELECT COUNT(*) FROM detections $result1 = $statement1->execute(); $totalcount = $result1->fetchArray(SQLITE3_ASSOC); +if(isset($_GET['blocation']) ) { + + header("Content-type: text/csv"); + header("Content-Disposition: attachment; filename=result_file.csv"); + header("Pragma: no-cache"); + header("Expires: 0"); + + + $user = trim(shell_exec("awk -F: '/1000/{print $1}' /etc/passwd")); + $home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd")); + + $list = array ( + array('', '', $_GET['blocation']), + array('Latitude', '', $config["LATITUDE"]), + array('Longitude', '', $config["LONGITUDE"]), + array('Date', '', date("m/d/Y", strtotime($theDate))), + array('Start Time', '', '0:00'), + array('State', '', $_GET['state']), + array('Country', '', $_GET['country']), + array('Protocol', '', $_GET['protocol']), + array('Num Observers', '', $_GET['num_observers']), + array('Duration (min)', '', '1440'), + array('All Obs Reported (Y/N)', '', 'Y'), + array('Dist Traveled (Miles)', '', $_GET['dist_traveled']), + array('Area Covered (Acres)', '', ''), + array('Notes', '', $_GET['notes']) + ); + + + $statement1 = $db->prepare("SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date == \"$theDate\" GROUP By Com_Name ORDER BY COUNT(*) DESC"); + if($statement1 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result1 = $statement1->execute(); + + $detections = []; + while($detection=$result1->fetchArray(SQLITE3_ASSOC)) + { + $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; + } + foreach($detections as $com_name=>$scount) + { + array_push($list, array($com_name,'',$scount)); + } + + $output = fopen("php://output", "w"); + foreach ($list as $row) { + fputcsv($output, $row); + } + fclose($output); + + die(); +} + ?>
+ + + +

Enter Checklist Information

+

Location Name:



+

State (2 letter code):



+

Country (2 letter code):



+

Protocol:

+

+

Number of observers:



+

Distance traveled (miles):



+

Notes:



+ +
+ +
@@ -36,7 +152,7 @@ $totalcount = $result1->fetchArray(SQLITE3_ASSOC); -

+


";