-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpgpx.php
71 lines (60 loc) · 1.5 KB
/
pgpx.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once('settings.php');
require_once(dirname(__FILE__).'/pdbconn.php');
class GPX {
private $db_id, $date, $filename;
public function __construct($id) {
global $db,$psqlAlbum;
if(is_array($id)) {
$this->db_id = $id['id'];
$this->filename = $psqlAlbum['GPXdir'];
$this->filename .= $id['filename'];
$this->date = $id['date'];
} else {
//Connect DB and fetch rows.
$this->db_id = $id;
//fetch path of photo
$db->query("SELECT * FROM gpx WHERE id = $1;", [$id]);
$result = $db->result_rows();
$this->filename = $result['filename'];
$this->date = $result['date'];
}
}
static function getGPXsInDateRange($datebegin, $dateend) {
global $db,$db_param;
$db->query("SELECT * FROM gpx WHERE date BETWEEN $1 AND $2 ORDER BY date;", [$datebegin, $dateend]);
while($db->hasMoreRows()) {
$result = $db->nextRow();
$gpxs[] = new GPX($result);
}
if(isset($gpxs)) {
return $gpxs;
} else {
return [];
}
}
static function arrayToJSON($gpxarray) {
$json = "[";
foreach($gpxarray as $gpx) {
$json .= $gpx->toJSON();
$json .= ",";
}
$json .= "];";
return $json;
}
public function toJSON() {
global $psqlAlbum;
$to_json['date'] = $this->date;
$to_json['filename'] = $this->filename;
return json_encode($to_json);
}
public function toHTML() {
global $psqlAlbum;
$date = DBConn::date_toJapanese($this->date);
//$dir = $psqlAlbum['GPXdir'];
return
<<<HEREDOC
<A href="$this->filename">GPSデータ:$date</A><BR>
HEREDOC;
}
}