"
}
if [[ $REQUEST_METHOD = 'GET' ]]; then
#since ash does not handle arrays we create variables using eval
IFS='&'
for PAIR in $QUERY_STRING
do
K=$(echo $PAIR | cut -f1 -d=)
VA=$(echo $PAIR | cut -f2 -d=)
eval GET_$K=$VA
done
if [[ "$GET_action" = "reboot" ]]; then
reboot_camera
fi
if [[ "$GET_action" = "revert" ]]; then
revert_config "$GET_version"
fi
if [[ "$GET_action" = "show_revert" ]]; then
hack_ini="$hack_ini.$GET_version"
fi
fi
#test for post
if [[ $REQUEST_METHOD = 'POST' ]]; then
if [ "$CONTENT_LENGTH" -gt 0 ]; then
read -n $CONTENT_LENGTH POST_DATA <&0
while read line
do eval "echo ${line}"
done
fi
#since ash does not handle arrays we create variables using eval
IFS='&'
for PAIR in $POST_DATA
do
K=$(echo $PAIR | cut -f1 -d=)
VA=$(echo $PAIR | cut -f2 -d=)
VB=\"${VA//%3A/:}\"
#echo "
$K=$VB
"
eval POST_$K=\"$VB\"
done
#switch back to going through the config file
output="$hack_ini.new"
#name our output file
while IFS= read -r \ARGUMENT; do
#cycle through each line of the current config
#copy through all comments
if [ -z "$ARGUMENT" ]; then
echo -ne "\n" >> $output
elif [[ ${ARGUMENT:0:1} == "#" ]] ; then
#echo $ARGUMENT $'\n'
echo -ne $ARGUMENT"\n" >> $output
else
#for non-comments check to see if we have an entry in the POST data by deciphering the key from the ini file and using eval for our fake array
KEY=$(echo $ARGUMENT | cut -f1 -d=)
test=$(eval echo \$POST_$KEY)
#echo "key was $KEY test was ... $test "
if [[ "$test" ]]; then
#if in the fake array then we use the new value
#echo "
matched
"
echo -ne $KEY=\"$test\""\n" >> $output
else
#if not in the fake array we use the current value
#echo "
key not found
"
echo -ne $ARGUMENT"\n" >> $output
fi
fi
done < $hack_ini
shft $hack_ini
mv $output $hack_ini
updated=true
fi
function documentation_to_html
{
if [[ -f "$www_dir$1.md" ]]; then
printf '
'
cat "$web_dir$1.md"
printf '
'
fi
}
function ini_to_html_free
{
classes=""
if [ "$1" = "USB_DIRECT_MAC_ADDR" ]; then
classes=" mac_addr"
fi
if grep -q -wi "$1" numerics.txt; then
classes=" numeric"
fi
printf '