keep start / end settings

This commit is contained in:
Vincent Riquer 2014-06-20 17:07:23 +02:00
parent 31b695e2f2
commit 17524b675c
3 changed files with 54 additions and 22 deletions

28
add
View File

@ -10,24 +10,21 @@
# /cgi/$user/add.html
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
if [[ $REQUEST_METHOD != POST ]]
then
cat <<-EOHead
Content-type: text/plain
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
refresh: 0,url=/cgi/$webuser/
refresh: 0,url=/cgi/$webuser/add.html
EOHead
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then
echo "Welcome agent $webuser"$'!\n\n'
else
echo 'Nice try!'
exit
fi
declare -A POST
exprdsname='^[[:upper:][:lower:]_]+$'
exprvalue='^[[:digit:]]+$'
exprvalue='^-?[[:digit:]]+$'
while read dsname value
do
if [[ $dsname =~ $exprdsname ]] \
@ -38,6 +35,21 @@ do
done < <(
sed 's/&/\n/g;s/=/ /g'
)
cat <<-EOHead
Content-type: text/plain
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]}
EOHead
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then
echo "Welcome agent $webuser"$'!\n\n'
else
echo 'Nice try!'
exit
fi
dsnames=(
AP

View File

@ -1,5 +1,23 @@
#!/bin/bash
exec 2>&1
if [ -n "$QUERY_STRING" ]
then
query_data="${QUERY_STRING//&/
}"
exprtime='[[:alnum:]-]+'
exprgraph='[[:alpha:]_]+'
while read name value
do
case $name in
start)
[[ $value =~ $exprtime ]] && start=$value
;;
end)
[[ $value =~ $exprtime ]] && end=$value
;;
esac
done <<<"${query_data//=/ }"
fi
uinames=(
AP
@ -108,6 +126,8 @@ done
cat <<-EOHTML
</ul>
<input type="hidden" name="time" value="$(date +%s)" />
<input type="hidden" name="start" value="$start" />
<input type="hidden" name="end" value="$end" />
<button type="submit" name="submit" value="send">Send</button>
</form>
</body>

16
index
View File

@ -263,7 +263,7 @@ then
cat <<-EOHTML
<a
style="color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -283,7 +283,7 @@ then
cat <<-EOHTML
<a
style="color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -303,7 +303,7 @@ then
cat <<-EOHTML
<a
style="color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -323,7 +323,7 @@ then
cat <<-EOHTML
<a
style="color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -367,7 +367,7 @@ then
cat <<-EOHTML
<a
style="background:#$(printf %02x%02x $redlevel $greenlevel )00;color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -396,7 +396,7 @@ then
cat <<-EOHTML
<a
style="background:#$(printf %02x%02x $redlevel $greenlevel )00;color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -425,7 +425,7 @@ then
cat <<-EOHTML
<a
style="background:#$(printf %02x%02x $redlevel $greenlevel )00;color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"
@ -454,7 +454,7 @@ then
cat <<-EOHTML
<a
style="background:#$(printf %02x%02x $redlevel $greenlevel )00;color:black;text-decoration:none"
href="?hist#$stat">
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
width="30"
height="30"