diff --git a/database/callsigns.db b/database/callsigns.db new file mode 100644 index 0000000..f8f89f3 Binary files /dev/null and b/database/callsigns.db differ diff --git a/database/dbupdate.sh b/database/dbupdate.sh new file mode 100755 index 0000000..df331d4 --- /dev/null +++ b/database/dbupdate.sh @@ -0,0 +1,10 @@ +#!/bin/bash +echo Downloading DMR-IDs from MARC-database +curl 'http://dmr-marc.net/cgi-bin/trbo-database/datadump.cgi?table=users&format=csv&header=0' 2>/dev/null | sed -e 's/\t//g' | awk -F"," '/,/{gsub(/ /, "", $2); printf "%s;%s;%s\n", $1, $2, $3}' | sed -e 's/\(.\) .*/\1/g' > dmrids.dat + +echo Removing IDs from local database +echo -e 'delete from callsign where 1;' | sqlite3 callsigns.db + +echo inserting new ID-list into local database +echo -e '.separator ";" \n.import dmrids.dat callsign' | sqlite3 callsigns.db + diff --git a/include/functions.php b/include/functions.php index 5ecb666..d1f39b3 100644 --- a/include/functions.php +++ b/include/functions.php @@ -867,7 +867,23 @@ function getName($callsign) { if (is_numeric($callsign)) { return "---"; } + if (defined("USESQLITE")) { + return resolveNameFromDB($callsign); + } else { + return resolveNameFromFile($callsign); + } +} +function resolveNameFromDB($callsign) { + $db = new SQLite3('database/callsigns.db'); + $results = $db->query("SELECT distinct name FROM callsign where callsign = '$callsign'"); + while ($row = $results->fetchArray()) { + return $row['name']; + } + return "---"; +} + +function resolveNameFromFile($callsign) { $TMP_CALL_NAME = "/tmp/Callsign_Name.txt"; if (file_exists($TMP_CALL_NAME)) { $callsign = trim($callsign); diff --git a/setup.php b/setup.php index e8fe66e..a9f67e7 100644 --- a/setup.php +++ b/setup.php @@ -91,6 +91,10 @@ include "include/tools.php";
>
+
+ +
>
+
" name="DMRIDDATPATH" class="form-control" placeholder="/var/mmdvm/DMRIDs.dat" aria-describedby="DMRIDDATPATH">