From df22da013b657e753b0f7578e621f530eac7a5f9 Mon Sep 17 00:00:00 2001
From: virmaior <70625876+virmaior@users.noreply.github.com>
Date: Wed, 13 Jul 2022 21:02:32 +0900
Subject: [PATCH 01/55] Create wz_mini_web.css
css part
---
SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.css | 22 +++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.css
diff --git a/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.css b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.css
new file mode 100644
index 0000000..e3719b0
--- /dev/null
+++ b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.css
@@ -0,0 +1,22 @@
+.ii_info_line {
+ font-weight:bold;
+}
+.ii {
+ width:100%;
+ position:relative;
+ display:flex;
+}
+.ii_key_DIV {
+
+ flex:0 0 40vw;
+ font-weight:bold;
+}
+.ii_value_DIV {
+ flex: 0 0 40vw;
+ text-align:right;
+}
+.ii_value {
+ width:75%;
+}
+
+
From 815afe9083703798740ededa6a9084084e5a5d03 Mon Sep 17 00:00:00 2001
From: virmaior <70625876+virmaior@users.noreply.github.com>
Date: Wed, 13 Jul 2022 21:03:30 +0900
Subject: [PATCH 02/55] Create wz_mini_web.sh
---
SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100644 SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
diff --git a/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
new file mode 100644
index 0000000..86db43e
--- /dev/null
+++ b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+# This serves a rudimentary webpage based on wz_mini.conf
+hack_ini=/opt/wz_mini/wz_mini.conf
+camver=V3
+camfirmware=$(tail -n1 /configs/app.ver | cut -f2 -d= )
+hackver="unknown"
+hostname=$(uname -n)
+title="Wyze $camver on $camfirmware running wz_mini $hackver as $hostname"
+
+
+echo "HTTP/1.1 200"
+echo ""
+#echo "Content Length: 100000"
+
+function ini_to_html_free
+{
+ printf '
' $1 $1 $2
+}
+
+function ini_to_html_tf
+{
+ printf ''
+}
+
+
+echo -ne "$title"
+echo -ne "';
+echo -ne ""
+echo -ne ''
+echo -ne "$title
";
+echo -ne ''
+echo -ne ''
From 9c065b078fde7645c6610202d238c80e03d8f420 Mon Sep 17 00:00:00 2001
From: virmaior <70625876+virmaior@users.noreply.github.com>
Date: Thu, 14 Jul 2022 23:39:25 +0900
Subject: [PATCH 03/55] Update wz_mini_web.sh
---
SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh | 111 +++++++++++++++++----
1 file changed, 93 insertions(+), 18 deletions(-)
diff --git a/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
index 86db43e..c863b13 100644
--- a/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
+++ b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh
@@ -7,29 +7,100 @@ hackver="unknown"
hostname=$(uname -n)
title="Wyze $camver on $camfirmware running wz_mini $hackver as $hostname"
-
echo "HTTP/1.1 200"
+echo -e "Content-type: text/html\n\n"
echo ""
-#echo "Content Length: 100000"
+
+
+shft() {
+ # https://stackoverflow.com/questions/3690936/change-file-name-suffixes-using-sed/3691279#3691279
+ # Change this '8' to one less than your desired maximum rollover file.
+ # Must be in reverse order for renames to work (n..1, not 1..n).
+ for suff in {8..1} ; do
+ if [[ -f "$1.${suff}" ]] ; then
+ ((nxt = suff + 1))
+ mv -f "$1.${suff}" "$1.${nxt}"
+ fi
+ done
+ mv -f "$1" "$1.1"
+}
+
+#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
+ IFS=$'\n'
+ output=wz_mini.conf.new
+ shft $output
+
+ #name our output file
+ for ARGUMENT in $(cat $hack_ini)
+ do
+ #cycle through each line of the current config
+
+ #copy through all comments
+ if [[ ${ARGUMENT:0:1} == "#" ]] ; then
+ #echo $ARGUMENT $'\n'
+ echo $ARGUMENT >> $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 $KEY="$test" >> $output
+ else
+ #if not in the fake array we use the current value
+ #echo "key not found
"
+ echo $ARGUMENT >> $output
+ fi
+
+ fi
+ done
+
+
+
+fi
+
function ini_to_html_free
{
- printf '' $1 $1 $2
+ printf '' $1 $1 $2
}
function ini_to_html_tf
{
printf '%s
' $1
- printf '
'
+ fi
+ printf '
'
}
@@ -38,27 +109,31 @@ echo -ne "';
echo -ne ""
+
+
echo -ne ''
echo -ne "$title
";
-echo -ne ''
+
+
echo -ne '