nsbin/add.wddb-to-fsdb
Nico Schottelius df2daf524d init
Signed-off-by: Nico Schottelius <nico@manager.schottelius.org>
2017-07-19 17:15:41 +02:00

80 lines
1.8 KiB
Text
Executable file

BASEDIR=/home/server/www/org/wddb/www/
tmp=/tmp/wddb-$$
function report()
{
# sender
UFLINE
# return path
RPLINE
# we
RECIPIENT
# delivered to..
DTLINE
# set
}
function init()
{
cat > $tmp
}
# continent
continent=`grep "^continent" "$1" | sed 's/.*="\(.*\)"/\1/'`
case "$continent" in
africa|asia|australia|europe|northamerica|southamerica) ;;
*) report "Allowed continents: africa|asia|australia|europe|northamerica|southamerica" ;;
esac
# other vars
essid=`grep "^essid" "$1" | sed 's/.*="\(.*\)"/\1/'`
# remove possible dots
country=`grep "^country" "$1" | sed 's/.*="\(.*\)"/\1/' | sed 's/\.\.//g'`
area=`grep "^area" "$1" | sed 's/.*="\(.*\)"/\1/' | sed 's/\//-/g' | sed 's/ //c'`
mac=`grep "^mac" "$1" | sed 's/.*="\(.*\)"/\1/'`
rate=`grep "^rate" "$1" | sed 's/.*="\(.*\)"/\1/'`
wep=`grep "^wep" "$1" | sed 's/.*="\(.*\)"/\1/'`
hints=`grep "^hints" "$1" | sed 's/.*="\(.*\)"/\1/'`
location=`grep "^location" "$1" | sed 's/.*="\(.*\)"/\1/'`
# check for empty fields
for a in essid country area mac rate wep hints location; do
eval tmp="\$$a"
if [ -z "$tmp" ]; then
report "Empty field: $a"
fi
done
if [ ! -f $BASEDIR/$continent/$country/$area.html ]; then
cat << EOF > "$1"
<html>
<head>
<title>wddb.org - WarDriver's DataBase</title>
</head>
<BODY bgcolor="#000000" color="#ef0000" font-color="#ef0000">
<FONT COLOR="#ef0000">
else
lines=`cat "$BASEDIR/$continent/$country/$area.html" | wc |awk '{ print $1 }'`
use_lines=$[$lines-7]
head -n $use_lines "$BASEDIR/$continent/$country/$area.html" > "$1"
fi
cat << EOF >> "$1"
</TABLE>
<HR>
<A HREF="../index.html"> << One step back</A>
<P><A HREF="/submit-new.html">Submit new network or changes<A>
</FONT>
</BODY>
</HTML>
EOF