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

38
add
View File

@ -10,24 +10,21 @@
# /cgi/$user/add.html # /cgi/$user/add.html
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI" IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
cat <<-EOHead if [[ $REQUEST_METHOD != POST ]]
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/
EOHead
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then then
echo "Welcome agent $webuser"$'!\n\n' cat <<-EOHead
else Content-type: text/plain
echo 'Nice try!' 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/add.html
EOHead
exit exit
fi fi
declare -A POST declare -A POST
exprdsname='^[[:upper:][:lower:]_]+$' exprdsname='^[[:upper:][:lower:]_]+$'
exprvalue='^[[:digit:]]+$' exprvalue='^-?[[:digit:]]+$'
while read dsname value while read dsname value
do do
if [[ $dsname =~ $exprdsname ]] \ if [[ $dsname =~ $exprdsname ]] \
@ -38,6 +35,21 @@ do
done < <( done < <(
sed 's/&/\n/g;s/=/ /g' 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=( dsnames=(
AP AP

View File

@ -1,5 +1,23 @@
#!/bin/bash #!/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=( uinames=(
AP AP
@ -108,6 +126,8 @@ done
cat <<-EOHTML cat <<-EOHTML
</ul> </ul>
<input type="hidden" name="time" value="$(date +%s)" /> <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> <button type="submit" name="submit" value="send">Send</button>
</form> </form>
</body> </body>

16
index
View File

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