diff --git a/README.md b/README.md index 75d98b4..61b9797 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Required are ============ * Webserver like lighttpd or similar * php5 - +* if using sqlite3-database name resolving sqlite3 and php5-sqlite also needed 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. +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 ======= Feel free to contact the author via email: dg9vh[@]darc.de 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/include/lh_ajax.php b/include/lh_ajax.php index d1ca5e6..19b6765 100644 --- a/include/lh_ajax.php +++ b/include/lh_ajax.php @@ -1,6 +1,6 @@