-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_miglocations.php
executable file
·57 lines (50 loc) · 1.84 KB
/
edit_miglocations.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
<?php
session_start();
include("./db.php");
include("functions.php");
$user_id = $_SESSION['userid'];
$today = getdate();
$currentSeason = ($today['mon'] > 6) ? $today['year'] : $today['year'] - 1;
// again if we are on php4
if (!function_exists("stripos")) {
function stripos($str,$needle,$offset=0)
{
return strpos(strtolower($str),strtolower($needle),$offset);
}
}
$q = strtolower($_GET["q"]);
if (!$q) return;
$locations = getAllMyLocationData($user_id, $connect);
$mylocations = array();
$where = "";
if(!empty($locations)) {
foreach($locations as $location) {
$mylocations[] = $location['location_id'];
}
$myloc_ids = implode(", ", $mylocations);
$where = "WHERE location_id NOT IN($myloc_ids)";
}
$sql = "SELECT location_id, location_name, city, district, latitude, longitude, state ";
$sql.= "FROM migwatch_locations l ";
$sql.= "INNER JOIN migwatch_states s ";
$sql.= "ON l.state_id = s.state_id $where ORDER BY s.state";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$locid = $row['location_id'];
$sql1 = "SELECT obs_start,frequency FROM migwatch_l1 WHERE location_id='$locid' " .
"AND user_id = '$user_id' AND obs_start >'$currentSeason-06-30' AND obs_type = 'first' AND deleted = '0' ORDER BY sighting_date DESC LIMIT 0,1";
$result1 = mysql_query($sql1);
$data1 = mysql_fetch_assoc($result1);
$key1 = $row['location_name'];
$key1.= ', '.$row['city'];
$key1.= ', '.$row['district'];
$key1.= ', '.$row['state'];
$items[$key1] = $row['location_id']."|".$row['location_name']."|".$row['city']."|".$row['district']."|".$row['state']."|".$row['latitude']."|".$row['longitude']."|".$data1['obs_start']."|".$data1['frequency'];
}
foreach ($items as $key=>$value) {
if (stripos(strtolower($key), $q) !== false) {
echo "$key|$value\n";
}
}
//print_r($mylocations);
?>