main
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Look up a callsign's registered city/province/country from the NXDN.csv
|
||||
// radio ID database (radiowo.com format: RADIO_ID,CALLSIGN,NAME,CITY,STATE,COUNTRY,REMARKS)
|
||||
// so configure.php can auto-fill the City/Country fields.
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$callsign = isset($_GET['callsign']) ? strtoupper(preg_replace('/[^A-Za-z0-9]/', '', $_GET['callsign'])) : '';
|
||||
$result = array('found' => false);
|
||||
|
||||
$csvFile = '/usr/local/etc/NXDN.csv';
|
||||
if ($callsign !== '' && is_readable($csvFile)) {
|
||||
if (($fh = fopen($csvFile, 'r')) !== false) {
|
||||
fgetcsv($fh); // skip header row
|
||||
while (($row = fgetcsv($fh)) !== false) {
|
||||
if (isset($row[1]) && strtoupper($row[1]) === $callsign) {
|
||||
$result['found'] = true;
|
||||
$result['city'] = isset($row[3]) ? $row[3] : '';
|
||||
$result['state'] = isset($row[4]) ? $row[4] : '';
|
||||
$result['country'] = isset($row[5]) ? $row[5] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
Reference in New Issue
Block a user