Merge pull request #161 from dg9vh/modified-name-resolution

Modified name resolution
This commit is contained in:
Kim - DG9VH 2017-09-22 16:34:43 +02:00 committed by GitHub
commit 6e6cc1219d
8 changed files with 44 additions and 5 deletions

View file

@ -17,7 +17,7 @@ Required are
============ ============
* Webserver like lighttpd or similar * Webserver like lighttpd or similar
* php5 * php5
* if using sqlite3-database name resolving sqlite3 and php5-sqlite also needed
Installation Installation
============ ============
@ -56,6 +56,9 @@ Cronjob for updating DMR IDs
============================ ============================
You can use the included script to update the DMR IDs periodically. Copy the files updateDMRIDs to /etc/cron.d/ and updateDMRIDs.sh to /var/www from the cron folder in this repo. The paths may have to be aligned to your system architecture. The Update script will then be executed once every 24 hours at 3:30. For security considerations please make sure that the cron folder is not copied to your web server's www root directory. You can use the included script to update the DMR IDs periodically. Copy the files updateDMRIDs to /etc/cron.d/ and updateDMRIDs.sh to /var/www from the cron folder in this repo. The paths may have to be aligned to your system architecture. The Update script will then be executed once every 24 hours at 3:30. For security considerations please make sure that the cron folder is not copied to your web server's www root directory.
If you are using the sqlite3-database, in the database-folder you can find a update-script that updates the database from MARC-database.
Contact Contact
======= =======
Feel free to contact the author via email: dg9vh[@]darc.de Feel free to contact the author via email: dg9vh[@]darc.de

BIN
database/callsigns.db Normal file

Binary file not shown.

10
database/dbupdate.sh Executable file
View 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

View file

@ -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);

View file

@ -1,6 +1,6 @@
<?php <?php
$totalLH = count($lastHeard); $totalLH = count($lastHeard);
if (defined("ENABLEXTDLOOKUP")) { if (defined("ENABLEXTDLOOKUP") && !defined("USESQLITE")) {
$TMP_CALL_NAME = "/tmp/Callsign_Name.txt"; $TMP_CALL_NAME = "/tmp/Callsign_Name.txt";
exec("wc -l ".$TMP_CALL_NAME." | cut -f1 -d' '", $output); exec("wc -l ".$TMP_CALL_NAME." | cut -f1 -d' '", $output);
exec("wc -l ".DMRIDDATPATH." | cut -f1 -d' '", $output2); exec("wc -l ".DMRIDDATPATH." | cut -f1 -d' '", $output2);
@ -10,8 +10,8 @@ exec("wc -l ".DMRIDDATPATH." | cut -f1 -d' '", $output2);
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->
<div class="panel-heading"><?php <div class="panel-heading"><?php
echo _("Last Heard List of today's")." ".$totalLH." "._("callsigns.")." "; echo _("Last Heard List of today's")." ".$totalLH." "._("callsigns.")." ";
if (defined("ENABLEXTDLOOKUP")) { if (defined("ENABLEXTDLOOKUP") && !defined("USESQLITE")) {
echo _("Cached")." (".$output[0]."/".$output2[0].")"; echo _("Cached")." (".$output[0]."/".$output2[0].")";
} }
?><span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span></div> ?><span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span></div>
<div class="panel-body"> <div class="panel-body">

View file

@ -34,6 +34,12 @@ This short howto describes step-by-step how to install the MMDVMHost-Dashboard o
>sudo apt-get install php5-common php5-cgi php5 >sudo apt-get install php5-common php5-cgi php5
if you want to use the sqlite3-database based resolving of the operator-names you need following, too:
>sudo apt-get install sqlite3 php5-sqlite
Now continue with:
>sudo lighty-enable-mod fastcgi >sudo lighty-enable-mod fastcgi
>sudo lighty-enable-mod fastcgi-php >sudo lighty-enable-mod fastcgi-php

View file

@ -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">

View file

@ -1,3 +1,3 @@
<?php <?php
define("VERSION", "20170812-1 (".getGitVersion().")"); define("VERSION", "20170922-1 (".getGitVersion().")");
?> ?>