Skip to content

Commit 24d2f40

Browse files
Merge pull request #23 from Martinski4GitHub/develop
Code Improvements
2 parents 6ed4103 + 2760db6 commit 24d2f40

3 files changed

Lines changed: 66 additions & 27 deletions

File tree

.gitattributes

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
*.tar.gz binary
1+
* text eol=lf
22
*.sh text eol=lf
3-
*.awk text eol=lf
43
*.md text eol=lf
54
*.asp text eol=lf
65
*.js text eol=lf
76
*.css text eol=lf
87
*.md5 text eol=lf
8+
*.awk text eol=lf
9+
*.gz binary
10+
*.png binary
11+
*.jpg binary
12+
*.jpeg binary
13+
*.zip binary
14+
*.tar.gz binary

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# uiDivStats - WebUI for Diversion statistics
22

33
## v4.0.12
4-
### Updated on 2025-Jul-27
4+
### Updated on 2025-Oct-25
55

66
## About
77
A graphical representation of domain blocking performed by Diversion.

uiDivStats.sh

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## Forked from https://github.com/jackyaz/uiDivStats ##
1414
## ##
1515
###################################################################
16-
# Last Modified: 2025-Jul-27
16+
# Last Modified: 2025-Oct-25
1717
#------------------------------------------------------------------
1818

1919
################# Shellcheck directives ###############
@@ -36,7 +36,7 @@
3636
### Start of script variables ###
3737
readonly SCRIPT_NAME="uiDivStats"
3838
readonly SCRIPT_VERSION="v4.0.12"
39-
readonly SCRIPT_VERSTAG="25072723"
39+
readonly SCRIPT_VERSTAG="25102522"
4040
SCRIPT_BRANCH="develop"
4141
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
4242
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d"
@@ -68,8 +68,9 @@ readonly trimTMPOldsFile="${SCRIPT_USB_DIR}/uiDivStats_Olds.TMP"
6868
readonly scriptVersRegExp="v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})"
6969
readonly webPageFileRegExp="user([1-9]|[1-2][0-9])[.]asp"
7070
readonly webPageLineRegExp="\{url: \"$webPageFileRegExp\", tabName: \"$SCRIPT_NAME\"\}"
71-
readonly branchx_TAG="Branch: $SCRIPT_BRANCH"
72-
readonly version_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}"
71+
readonly branchxStr_TAG="[Branch: $SCRIPT_BRANCH]"
72+
readonly versionDev_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}"
73+
readonly versionMod_TAG="$SCRIPT_VERSION on $ROUTER_MODEL"
7374

7475
readonly oneKByte=1024
7576
readonly oneMByte=1048576
@@ -2754,26 +2755,55 @@ _WaitForYESorNO_()
27542755
fi
27552756
}
27562757

2758+
##-------------------------------------##
2759+
## Added by Martinski W. [2025-Oct-25] ##
2760+
##-------------------------------------##
2761+
_CenterTextStr_()
2762+
{
2763+
if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] || \
2764+
! echo "$2" | grep -qE "^[1-9][0-9]+$"
2765+
then echo ; return 1
2766+
fi
2767+
local stringLen="${#1}"
2768+
local space1Len="$((($2 - stringLen)/2))"
2769+
local space2Len="$space1Len"
2770+
local totalLen="$((space1Len + stringLen + space2Len))"
2771+
2772+
if [ "$totalLen" -lt "$2" ]
2773+
then space2Len="$((space2Len + 1))"
2774+
elif [ "$totalLen" -gt "$2" ]
2775+
then space1Len="$((space1Len - 1))"
2776+
fi
2777+
if [ "$space1Len" -gt 0 ] && [ "$space2Len" -gt 0 ]
2778+
then printf "%*s%s%*s" "$space1Len" '' "$1" "$space2Len" ''
2779+
else printf "%s" "$1"
2780+
fi
2781+
}
2782+
2783+
##----------------------------------------##
2784+
## Modified by Martinski W. [2025-Oct-25] ##
2785+
##----------------------------------------##
27572786
ScriptHeader()
27582787
{
27592788
clear
2760-
printf "\\n"
2761-
printf "${BOLD}###################################################################${CLEARFORMAT}\\n"
2762-
printf "${BOLD}## ##${CLEARFORMAT}\\n"
2763-
printf "${BOLD}## _ _____ _ _____ _ _ ##${CLEARFORMAT}\\n"
2764-
printf "${BOLD}## (_)| __ \ (_) / ____|| | | | ##${CLEARFORMAT}\\n"
2765-
printf "${BOLD}## _ _ _ | | | | _ __ __| (___ | |_ __ _ | |_ ___ ##${CLEARFORMAT}\\n"
2766-
printf "${BOLD}## | | | || || | | || |\ \ / / \___ \ | __|/ _ || __|/ __| ##${CLEARFORMAT}\\n"
2767-
printf "${BOLD}## | |_| || || |__| || | \ V / ____) || |_| (_| || |_ \__ \ ##${CLEARFORMAT}\\n"
2768-
printf "${BOLD}## \__,_||_||_____/ |_| \_/ |_____/ \__|\__,_| \__||___/ ##${CLEARFORMAT}\\n"
2769-
printf "${BOLD}## ##${CLEARFORMAT}\\n"
2770-
printf "${BOLD}## %9s on %-18s ##${CLEARFORMAT}\n" "$SCRIPT_VERSION" "$ROUTER_MODEL"
2771-
printf "${BOLD}## ##${CLEARFORMAT}\\n"
2772-
printf "${BOLD}## https://github.com/AMTM-OSR/uiDivStats ##${CLEARFORMAT}\\n"
2773-
printf "${BOLD}## Forked from https://github.com/jackyaz/uiDivStats ##${CLEARFORMAT}\\n"
2774-
printf "${BOLD}## ##${CLEARFORMAT}\\n"
2775-
printf "${BOLD}###################################################################${CLEARFORMAT}\\n"
2776-
printf "\\n"
2789+
local spaceLen=61 colorCT
2790+
[ "$SCRIPT_BRANCH" = "master" ] && colorCT="$GRNct" || colorCT="$MGNTct"
2791+
echo
2792+
printf "${BOLD}###################################################################${CLRct}\n"
2793+
printf "${BOLD}## _ _____ _ _____ _ _ ##${CLRct}\n"
2794+
printf "${BOLD}## (_)| __ \ (_) / ____|| | | | ##${CLRct}\n"
2795+
printf "${BOLD}## _ _ _ | | | | _ __ __| (___ | |_ __ _ | |_ ___ ##${CLRct}\n"
2796+
printf "${BOLD}## | | | || || | | || |\ \ / / \___ \ | __|/ _ || __|/ __| ##${CLRct}\n"
2797+
printf "${BOLD}## | |_| || || |__| || | \ V / ____) || |_| (_| || |_ \__ \ ##${CLRct}\n"
2798+
printf "${BOLD}## \__,_||_||_____/ |_| \_/ |_____/ \__|\__,_| \__||___/ ##${CLRct}\n"
2799+
printf "${BOLD}## ##${CLRct}\n"
2800+
printf "${BOLD}## ${GRNct}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$versionMod_TAG" "$spaceLen")"
2801+
printf "${BOLD}## ${colorCT}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$branchxStr_TAG" "$spaceLen")"
2802+
printf "${BOLD}## ##${CLRct}\n"
2803+
printf "${BOLD}## https://github.com/AMTM-OSR/uiDivStats ##${CLRct}\n"
2804+
printf "${BOLD}## Forked from https://github.com/jackyaz/uiDivStats ##${CLRct}\n"
2805+
printf "${BOLD}## ##${CLRct}\n"
2806+
printf "${BOLD}###################################################################${CLRct}\n\n"
27772807
}
27782808

27792809
##----------------------------------------##
@@ -3167,6 +3197,7 @@ Menu_Startup()
31673197
Auto_Cron delete 2>/dev/null
31683198
/opt/etc/init.d/S90taildns stop >/dev/null 2>&1
31693199
fi
3200+
Set_Version_Custom_Settings local "$SCRIPT_VERSION"
31703201
Auto_ServiceEvent create 2>/dev/null
31713202
Shortcut_Script create
31723203
Mount_WebUI
@@ -3524,8 +3555,8 @@ fi
35243555
_SQLCheckDBLogFileSize_
35253556

35263557
if [ "$SCRIPT_BRANCH" = "master" ]
3527-
then SCRIPT_VERS_INFO="[$branchx_TAG]"
3528-
else SCRIPT_VERS_INFO="[$version_TAG, $branchx_TAG]"
3558+
then SCRIPT_VERS_INFO=""
3559+
else SCRIPT_VERS_INFO="[$versionDev_TAG]"
35293560
fi
35303561

35313562
dbBackgProcsEnabled="$(_ToggleBackgroundProcsEnabled_ check)"
@@ -3555,6 +3586,7 @@ then
35553586
Auto_Cron delete 2>/dev/null
35563587
/opt/etc/init.d/S90taildns stop >/dev/null 2>&1
35573588
fi
3589+
Set_Version_Custom_Settings local "$SCRIPT_VERSION"
35583590
Auto_ServiceEvent create 2>/dev/null
35593591
Shortcut_Script create
35603592
_CheckFor_WebGUI_Page_
@@ -3573,7 +3605,8 @@ case "$1" in
35733605
exit 0
35743606
;;
35753607
startup)
3576-
Menu_Startup "$2"
3608+
shift
3609+
Menu_Startup "$@"
35773610
exit 0
35783611
;;
35793612
generate)

0 commit comments

Comments
 (0)