inserting option to change name-resolution based on a sqlite3-database instead of dmrids.dat-file
This commit is contained in:
parent
f037a72c02
commit
e373dc0810
4 changed files with 30 additions and 0 deletions
BIN
database/callsigns.db
Normal file
BIN
database/callsigns.db
Normal file
Binary file not shown.
10
database/dbupdate.sh
Executable file
10
database/dbupdate.sh
Executable file
|
@ -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
|
||||||
|
|
|
@ -867,7 +867,23 @@ function getName($callsign) {
|
||||||
if (is_numeric($callsign)) {
|
if (is_numeric($callsign)) {
|
||||||
return "---";
|
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";
|
$TMP_CALL_NAME = "/tmp/Callsign_Name.txt";
|
||||||
if (file_exists($TMP_CALL_NAME)) {
|
if (file_exists($TMP_CALL_NAME)) {
|
||||||
$callsign = trim($callsign);
|
$callsign = trim($callsign);
|
||||||
|
|
|
@ -91,6 +91,10 @@ include "include/tools.php";
|
||||||
<span class="input-group-addon" id="TALKERALIAS" style="width: 300px"><?php echo _("Show Talker Alias"); ?></span>
|
<span class="input-group-addon" id="TALKERALIAS" style="width: 300px"><?php echo _("Show Talker Alias"); ?></span>
|
||||||
<div class="panel-body"><input type="checkbox" name="TALKERALIAS" <?php if (defined("TALKERALIAS")) echo "checked" ?>></div>
|
<div class="panel-body"><input type="checkbox" name="TALKERALIAS" <?php if (defined("TALKERALIAS")) echo "checked" ?>></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-addon" id="USESQLITE" style="width: 300px"><?php echo _("Use SQLITE3-Database instead of DMRIDs.dat"); ?></span>
|
||||||
|
<div class="panel-body"><input type="checkbox" name="USESQLITE" <?php if (defined("USESQLITE")) echo "checked" ?>></div>
|
||||||
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon" id="DMRIDDATPATH" style="width: 300px"><?php echo _("Path to DMR-ID-Database-File (including filename)"); ?></span>
|
<span class="input-group-addon" id="DMRIDDATPATH" style="width: 300px"><?php echo _("Path to DMR-ID-Database-File (including filename)"); ?></span>
|
||||||
<input type="text" value="<?php echo constant("DMRIDDATPATH") ?>" name="DMRIDDATPATH" class="form-control" placeholder="/var/mmdvm/DMRIDs.dat" aria-describedby="DMRIDDATPATH">
|
<input type="text" value="<?php echo constant("DMRIDDATPATH") ?>" name="DMRIDDATPATH" class="form-control" placeholder="/var/mmdvm/DMRIDs.dat" aria-describedby="DMRIDDATPATH">
|
||||||
|
|
Loading…
Reference in a new issue