Optimized login function

This commit is contained in:
Jinhill 2021-10-12 14:38:06 +08:00
parent 910649c5f5
commit 0d6864ca4a

View File

@ -21,12 +21,11 @@ log(){
#$1:url #$1:url
url_encode() { url_encode() {
echo "$1" | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | while read -r l; echo "$1" | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | while read -r l; do
do
case "$l" in case "$l" in
[-_.~a-zA-Z0-9]) printf '%s' "$l" ;; [-_.~a-zA-Z0-9]) printf '%s' "$l" ;;
"") printf '%%20' ;; "") printf '%%20' ;;
* ) printf '%%%02X' "'$l" *) printf '%%%02X' "'$l" ;;
esac esac
done done
} }
@ -69,6 +68,7 @@ login() {
if [ "${http_code}" = "302" ]; then if [ "${http_code}" = "302" ]; then
return 0 return 0
fi fi
rm -rf "${COOKIE_FILE}"
_err "geoscaling login failed for user ${GEOS_Username} bad RC from post" _err "geoscaling login failed for user ${GEOS_Username} bad RC from post"
return 1 return 1
} }
@ -83,7 +83,7 @@ get_zone() {
items=$(echo "${table}" | grep -oE '<a [^>]+><b>[^>]+>') items=$(echo "${table}" | grep -oE '<a [^>]+><b>[^>]+>')
i=1 i=1
c=$(count "$1" ".") c=$(count "$1" ".")
while [ $i -le $c ]; do while [ $i -le "$c" ]; do
d=$(echo "$1" | cut -d . -f $i-) d=$(echo "$1" | cut -d . -f $i-)
if [ -z "$d" ]; then if [ -z "$d" ]; then
return 1 return 1