IngRRD/lib/read_query_string
2015-02-06 17:10:02 +01:00

59 lines
1.5 KiB
Bash

#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
read_query_string() {
local \
exprgraph \
exprtime \
name \
query_data \
value \
if [ -n "$QUERY_STRING" ]
then
query_data="${QUERY_STRING//&/
}"
exprtime='[[:alnum:]-]+'
exprgraph='[[:alpha:]_]+'
exprprev='[[:digit:]]+[(d(ay)?)(w(eek)?)(month)(y(ear)?)]'
while read name value
do
case $name in
start)
[[ $value =~ $exprtime ]] && start=$value
;;
end)
[[ $value =~ $exprtime ]] && end=$value
;;
hist|trend)
show_graphs=1
;;
graph)
[[ $value =~ $exprgraph ]] && graph=$value
;;
show)
[[ $value == all ]] && show_all=1
;;
prevperiod)
[[ $value =~ $exprprev ]] && prevperiod=$value
;;
esac
done <<<"${query_data//=/ }"
fi
}