summaryrefslogtreecommitdiff
path: root/servers.sh
blob: 197893396df53782adcfc4e9fd7a032c3e1305dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
servername=`param hostname`
serverip=`param ip`
add=`param online`


echo "Content-type: text/html"
echo ""

cat ./fileparts/header.html
echo "<id><img style=\"width:32px\" src=\"data/icons/icon_servers.png\"><br/><br/></id>"
echo "<body>"

#It seems quotes are enough,see
#https://stackoverflow.com/questions/4273074/sanitize-user-input-in-bash-for-security-purposes
#Be sure servers.txt has 666 permissions (or at least make sure your web server group can write to it)
if [ "$add" = "true" ]; then
    echo "$serverip $servername" >> ./servers.txt
    echo "Server $servername added"
else
    echo ""
    #Remove the server from servers.txt
fi



echo "<p>Servers currently running Winter Survival 2 - Anarchy:<br/>"

cat ./servers.txt | while read line
do
    allparts=$(echo "$line" | tr " " "\n")
    steamip=""
    htmlname=""
    for x in $allparts
    do
        if [ "$steamip" = "" ]; then
            steamip="$x"
        else
            htmlname="$htmlname $x"
        fi
    done
    echo -n "<a href=\"steam://connect/$steamip\">$htmlname</a><br/>"
done
echo "</p>"
echo "</body>"
cat ./fileparts/footer.html