Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
37dbfb8
Bump softprops/action-gh-release in the all-actions group
dependabot[bot] Jun 23, 2025
86aa96a
Merge pull request #15 from AMTM-OSR/dependabot/github_actions/develo…
ExtremeFiretop Jun 23, 2025
f095729
Improved Messaging
Martinski4GitHub Jul 22, 2025
7e487b4
Merge pull request #16 from Martinski4GitHub/develop
Martinski4GitHub Jul 22, 2025
3f6480c
Code Improvements
Martinski4GitHub Jul 28, 2025
5f865b6
Merge pull request #17 from Martinski4GitHub/develop
Martinski4GitHub Jul 28, 2025
306d9e3
Bump actions/checkout from 4.2.2 to 4.3.0 in the all-actions group
dependabot[bot] Aug 11, 2025
238a6fb
Merge pull request #18 from AMTM-OSR/dependabot/github_actions/develo…
ExtremeFiretop Aug 12, 2025
953625c
Bump actions/checkout from 4.3.0 to 5.0.0 in the all-actions group
dependabot[bot] Aug 18, 2025
e408d36
Merge pull request #19 from AMTM-OSR/dependabot/github_actions/develo…
ExtremeFiretop Aug 18, 2025
eec962d
Bump softprops/action-gh-release in the all-actions group
dependabot[bot] Sep 8, 2025
a3bcb41
Merge pull request #20 from AMTM-OSR/dependabot/github_actions/develo…
ExtremeFiretop Sep 8, 2025
b4a1b71
Bump softprops/action-gh-release in the all-actions group
dependabot[bot] Oct 6, 2025
2d46f4e
Merge pull request #21 from AMTM-OSR/dependabot/github_actions/develo…
ExtremeFiretop Oct 6, 2025
9462bf4
Bump softprops/action-gh-release in the all-actions group
dependabot[bot] Oct 13, 2025
6ed4103
Merge pull request #22 from AMTM-OSR/dependabot/github_actions/develo…
Martinski4GitHub Oct 15, 2025
afea7f0
Update .gitattributes
Martinski4GitHub Oct 26, 2025
2760db6
Code Improvements
Martinski4GitHub Oct 26, 2025
24d2f40
Merge pull request #23 from Martinski4GitHub/develop
Martinski4GitHub Oct 26, 2025
9431a94
Removed Tomato JS Dependencies
Martinski4GitHub Oct 30, 2025
c409e03
Merge pull request #24 from Martinski4GitHub/develop
Martinski4GitHub Oct 30, 2025
d63c004
Update uiDivStats.sh
Martinski4GitHub Oct 31, 2025
9736ca2
Merge pull request #25 from Martinski4GitHub/develop
Martinski4GitHub Oct 31, 2025
3bbb54b
Logging with Process ID
Martinski4GitHub Nov 5, 2025
d33fe03
Merge pull request #26 from Martinski4GitHub/develop
Martinski4GitHub Nov 5, 2025
a5a3937
Update README.md
Martinski4GitHub Nov 8, 2025
cebad91
Merge pull request #27 from Martinski4GitHub/develop
Martinski4GitHub Nov 8, 2025
07fdc2a
Merge branch 'master' into develop
Martinski4GitHub Nov 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
*.tar.gz binary
* text eol=lf
*.sh text eol=lf
*.awk text eol=lf
*.md text eol=lf
*.asp text eol=lf
*.js text eol=lf
*.css text eol=lf
*.md5 text eol=lf
*.awk text eol=lf
*.gz binary
*.png binary
*.jpg binary
*.jpeg binary
*.zip binary
*.tar.gz binary
4 changes: 2 additions & 2 deletions .github/workflows/Create-NewReleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
# 1--- Check out master so we tag the exact merge commit
- name: Checkout source code
uses: actions/checkout@v4.2.2
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
ref: 'master'
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:

# 7--- Publish a GitHub Release with auto-generated notes
- name: Create Release with Automated Release Notes
uses: softprops/action-gh-release@v2.2.2
uses: softprops/action-gh-release@v2.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.nextver.outputs.tag }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# uiDivStats - WebUI for Diversion statistics

## v4.0.11
### Updated on 2025-June-21
## v4.0.12
### Updated on 2025-Nov-07

## About
A graphical representation of domain blocking performed by Diversion.
Expand Down
133 changes: 90 additions & 43 deletions uiDivStats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## Forked from https://github.com/jackyaz/uiDivStats ##
## ##
###################################################################
# Last Modified: 2025-Jun-21
# Last Modified: 2025-Nov-04
#------------------------------------------------------------------

################# Shellcheck directives ###############
Expand All @@ -35,9 +35,9 @@

### Start of script variables ###
readonly SCRIPT_NAME="uiDivStats"
readonly SCRIPT_VERSION="v4.0.11"
readonly SCRIPT_VERSTAG="25062121"
SCRIPT_BRANCH="master"
readonly SCRIPT_VERSION="v4.0.12"
readonly SCRIPT_VERSTAG="25110422"
SCRIPT_BRANCH="develop"
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d"
readonly SCRIPT_CONF="$SCRIPT_DIR/config"
Expand Down Expand Up @@ -68,7 +68,9 @@ readonly trimTMPOldsFile="${SCRIPT_USB_DIR}/uiDivStats_Olds.TMP"
readonly scriptVersRegExp="v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})"
readonly webPageFileRegExp="user([1-9]|[1-2][0-9])[.]asp"
readonly webPageLineRegExp="\{url: \"$webPageFileRegExp\", tabName: \"$SCRIPT_NAME\"\}"
readonly scriptVERINFO="[${SCRIPT_VERSION}_${SCRIPT_VERSTAG}, Branch: $SCRIPT_BRANCH]"
readonly branchxStr_TAG="[Branch: $SCRIPT_BRANCH]"
readonly versionDev_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}"
readonly versionMod_TAG="$SCRIPT_VERSION on $ROUTER_MODEL"

readonly oneKByte=1024
readonly oneMByte=1048576
Expand Down Expand Up @@ -99,6 +101,7 @@ readonly CLEARFORMAT="\\e[0m"
readonly CLRct="\033[0m"
readonly REDct="\033[1;31m"
readonly GRNct="\033[1;32m"
readonly MGNTct="\e[1;35m"
readonly CritIREDct="\e[41m"
readonly CritBREDct="\e[30;101m"
readonly PassBGRNct="\e[30;102m"
Expand Down Expand Up @@ -129,7 +132,7 @@ Print_Output()
"$PASS") prioNum=6 ;; #INFO#
*) prioNum=5 ;; #NOTICE#
esac
logger -t "$SCRIPT_NAME" -p $prioNum "$2"
logger -t "${SCRIPT_NAME}_[$$]" -p $prioNum "$2"
fi
printf "${BOLD}${3}%s${CLEARFORMAT}\n\n" "$2"
}
Expand Down Expand Up @@ -956,7 +959,7 @@ Mount_WebUI()
Get_WebUI_Page "$SCRIPT_DIR/uidivstats_www.asp"
if [ "$MyWebPage" = "NONE" ]
then
Print_Output true "**ERROR** Unable to mount $SCRIPT_NAME WebUI page, exiting" "$CRIT"
Print_Output true "**ERROR** Unable to mount $SCRIPT_NAME WebUI page." "$CRIT"
Clear_Lock
exit 1
fi
Expand Down Expand Up @@ -2297,7 +2300,7 @@ _SQLGetDBLogTimeStamp_()
{ printf "[$(date +"$sqlDBLogDateTime")]" ; }

##----------------------------------------##
## Modified by Martinski W. [2025-Jun-21] ##
## Modified by Martinski W. [2025-Jul-20] ##
##----------------------------------------##
readonly errorMsgsRegExp="Parse error|Runtime error|Error:"
readonly corruptedBinExp="Illegal instruction|SQLite header and source version mismatch"
Expand Down Expand Up @@ -2385,7 +2388,7 @@ _ApplyDatabaseSQLCmds_()
fi
if "$foundError" || "$foundLocked"
then
Print_Output true "SQLite process ${resultStr}" "$ERR"
Print_Output true "SQLite process[$callFlag] ${resultStr}" "$ERR"
fi
}

Expand Down Expand Up @@ -2752,26 +2755,55 @@ _WaitForYESorNO_()
fi
}

##-------------------------------------##
## Added by Martinski W. [2025-Oct-25] ##
##-------------------------------------##
_CenterTextStr_()
{
if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] || \
! echo "$2" | grep -qE "^[1-9][0-9]+$"
then echo ; return 1
fi
local stringLen="${#1}"
local space1Len="$((($2 - stringLen)/2))"
local space2Len="$space1Len"
local totalLen="$((space1Len + stringLen + space2Len))"

if [ "$totalLen" -lt "$2" ]
then space2Len="$((space2Len + 1))"
elif [ "$totalLen" -gt "$2" ]
then space1Len="$((space1Len - 1))"
fi
if [ "$space1Len" -gt 0 ] && [ "$space2Len" -gt 0 ]
then printf "%*s%s%*s" "$space1Len" '' "$1" "$space2Len" ''
else printf "%s" "$1"
fi
}

##----------------------------------------##
## Modified by Martinski W. [2025-Oct-25] ##
##----------------------------------------##
ScriptHeader()
{
clear
printf "\\n"
printf "${BOLD}###################################################################${CLEARFORMAT}\\n"
printf "${BOLD}## ##${CLEARFORMAT}\\n"
printf "${BOLD}## _ _____ _ _____ _ _ ##${CLEARFORMAT}\\n"
printf "${BOLD}## (_)| __ \ (_) / ____|| | | | ##${CLEARFORMAT}\\n"
printf "${BOLD}## _ _ _ | | | | _ __ __| (___ | |_ __ _ | |_ ___ ##${CLEARFORMAT}\\n"
printf "${BOLD}## | | | || || | | || |\ \ / / \___ \ | __|/ _ || __|/ __| ##${CLEARFORMAT}\\n"
printf "${BOLD}## | |_| || || |__| || | \ V / ____) || |_| (_| || |_ \__ \ ##${CLEARFORMAT}\\n"
printf "${BOLD}## \__,_||_||_____/ |_| \_/ |_____/ \__|\__,_| \__||___/ ##${CLEARFORMAT}\\n"
printf "${BOLD}## ##${CLEARFORMAT}\\n"
printf "${BOLD}## %9s on %-18s ##${CLEARFORMAT}\n" "$SCRIPT_VERSION" "$ROUTER_MODEL"
printf "${BOLD}## ##${CLEARFORMAT}\\n"
printf "${BOLD}## https://github.com/AMTM-OSR/uiDivStats ##${CLEARFORMAT}\\n"
printf "${BOLD}## Forked from https://github.com/jackyaz/uiDivStats ##${CLEARFORMAT}\\n"
printf "${BOLD}## ##${CLEARFORMAT}\\n"
printf "${BOLD}###################################################################${CLEARFORMAT}\\n"
printf "\\n"
local spaceLen=61 colorCT
[ "$SCRIPT_BRANCH" = "master" ] && colorCT="$GRNct" || colorCT="$MGNTct"
echo
printf "${BOLD}###################################################################${CLRct}\n"
printf "${BOLD}## _ _____ _ _____ _ _ ##${CLRct}\n"
printf "${BOLD}## (_)| __ \ (_) / ____|| | | | ##${CLRct}\n"
printf "${BOLD}## _ _ _ | | | | _ __ __| (___ | |_ __ _ | |_ ___ ##${CLRct}\n"
printf "${BOLD}## | | | || || | | || |\ \ / / \___ \ | __|/ _ || __|/ __| ##${CLRct}\n"
printf "${BOLD}## | |_| || || |__| || | \ V / ____) || |_| (_| || |_ \__ \ ##${CLRct}\n"
printf "${BOLD}## \__,_||_||_____/ |_| \_/ |_____/ \__|\__,_| \__||___/ ##${CLRct}\n"
printf "${BOLD}## ##${CLRct}\n"
printf "${BOLD}## ${GRNct}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$versionMod_TAG" "$spaceLen")"
printf "${BOLD}## ${colorCT}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$branchxStr_TAG" "$spaceLen")"
printf "${BOLD}## ##${CLRct}\n"
printf "${BOLD}## https://github.com/AMTM-OSR/uiDivStats ##${CLRct}\n"
printf "${BOLD}## Forked from https://github.com/jackyaz/uiDivStats ##${CLRct}\n"
printf "${BOLD}## ##${CLRct}\n"
printf "${BOLD}###################################################################${CLRct}\n\n"
}

##----------------------------------------##
Expand Down Expand Up @@ -3165,6 +3197,7 @@ Menu_Startup()
Auto_Cron delete 2>/dev/null
/opt/etc/init.d/S90taildns stop >/dev/null 2>&1
fi
Set_Version_Custom_Settings local "$SCRIPT_VERSION"
Auto_ServiceEvent create 2>/dev/null
Shortcut_Script create
Mount_WebUI
Expand Down Expand Up @@ -3373,25 +3406,36 @@ Menu_Uninstall()
Print_Output true "Uninstall completed" "$PASS"
}

##----------------------------------------##
## Modified by Martinski W. [2025-Jul-27] ##
##----------------------------------------##
NTP_Ready()
{
local theSleepDelay=15 ntpMaxWaitSecs=600 ntpWaitSecs

if [ "$(nvram get ntp_ready)" -eq 0 ]
then
Check_Lock
ntpwaitcount=0
while [ "$(nvram get ntp_ready)" -eq 0 ] && [ "$ntpwaitcount" -lt 600 ]
ntpWaitSecs=0
Print_Output true "Waiting for NTP to sync..." "$WARN"

while [ "$(nvram get ntp_ready)" -eq 0 ] && [ "$ntpWaitSecs" -lt "$ntpMaxWaitSecs" ]
do
ntpwaitcount="$((ntpwaitcount + 30))"
Print_Output true "Waiting for NTP to sync..." "$WARN"
sleep 30
if [ "$ntpWaitSecs" -gt 0 ] && [ "$((ntpWaitSecs % 30))" -eq 0 ]
then
Print_Output true "Waiting for NTP to sync [$ntpWaitSecs secs]..." "$WARN"
fi
sleep "$theSleepDelay"
ntpWaitSecs="$((ntpWaitSecs + theSleepDelay))"
done
if [ "$ntpwaitcount" -ge 600 ]

if [ "$ntpWaitSecs" -ge "$ntpMaxWaitSecs" ]
then
Print_Output true "NTP failed to sync after 10 minutes. Please resolve!" "$CRIT"
Clear_Lock
exit 1
else
Print_Output true "NTP synced, $SCRIPT_NAME will now continue" "$PASS"
Print_Output true "NTP has synced [$ntpWaitSecs secs]. $SCRIPT_NAME will now continue." "$PASS"
Clear_Lock
fi
fi
Expand All @@ -3403,7 +3447,7 @@ NTP_Ready()
##----------------------------------------##
Entware_Ready()
{
local theSleepDelay=5 maxSleepTimer=100 sleepTimerSecs
local theSleepDelay=5 maxSleepTimer=120 sleepTimerSecs
local doExitNotFound=true

if [ $# -eq 1 ] && [ "$1" = "false" ]
Expand All @@ -3422,11 +3466,12 @@ Entware_Ready()
do
if [ "$((sleepTimerSecs % 10))" -eq 0 ]
then
Print_Output true "Entware NOT found, sleeping for $theSleepDelay secs [$sleepTimerSecs secs]..." "$WARN"
Print_Output true "Entware NOT found. Wait for Entware to be ready [$sleepTimerSecs secs]..." "$WARN"
fi
sleep "$theSleepDelay"
sleepTimerSecs="$((sleepTimerSecs + theSleepDelay))"
done

if [ ! -f /opt/bin/opkg ]
then
if "$doExitNotFound"
Expand All @@ -3438,7 +3483,7 @@ Entware_Ready()
Clear_Lock ; return 1
fi
else
Print_Output true "Entware found, $SCRIPT_NAME will now continue" "$PASS"
Print_Output true "Entware found [$sleepTimerSecs secs]. $SCRIPT_NAME will now continue." "$PASS"
Clear_Lock
fi
fi
Expand All @@ -3450,8 +3495,8 @@ Entware_Ready()
##----------------------------------------##
Show_About()
{
printf "About ${MGNTct}${SCRIPT_VERS_INFO}${CLRct}\n"
cat <<EOF
About $SCRIPT_VERS_INFO
$SCRIPT_NAME provides a graphical representation of domain
blocking performed by Diversion.

Expand All @@ -3474,8 +3519,8 @@ EOF
##----------------------------------------##
Show_Help()
{
printf "HELP ${MGNTct}${SCRIPT_VERS_INFO}${CLRct}\n"
cat <<EOF
HELP $SCRIPT_VERS_INFO
Available commands:
$SCRIPT_NAME about explains functionality
$SCRIPT_NAME update checks for updates
Expand All @@ -3490,8 +3535,8 @@ Available commands:
$SCRIPT_NAME trimdb run maintenance on database (this runs automatically every night)
$SCRIPT_NAME enableprocs re-enable background processing of Diversion statistics
$SCRIPT_NAME disableprocs disable background processing of Diversion statistics
$SCRIPT_NAME develop switch to development branch
$SCRIPT_NAME stable switch to stable branch
$SCRIPT_NAME develop switch to development branch version
$SCRIPT_NAME stable switch to stable/production branch version
EOF
printf "\n"
}
Expand All @@ -3509,9 +3554,9 @@ else sqlDBLogFilePath="/tmp/var/tmp/$sqlDBLogFileName"
fi
_SQLCheckDBLogFileSize_

if [ "$SCRIPT_BRANCH" != "develop" ]
if [ "$SCRIPT_BRANCH" = "master" ]
then SCRIPT_VERS_INFO=""
else SCRIPT_VERS_INFO="$scriptVERINFO"
else SCRIPT_VERS_INFO="[$versionDev_TAG]"
fi

dbBackgProcsEnabled="$(_ToggleBackgroundProcsEnabled_ check)"
Expand Down Expand Up @@ -3541,6 +3586,7 @@ then
Auto_Cron delete 2>/dev/null
/opt/etc/init.d/S90taildns stop >/dev/null 2>&1
fi
Set_Version_Custom_Settings local "$SCRIPT_VERSION"
Auto_ServiceEvent create 2>/dev/null
Shortcut_Script create
_CheckFor_WebGUI_Page_
Expand All @@ -3559,7 +3605,8 @@ case "$1" in
exit 0
;;
startup)
Menu_Startup "$2"
shift
Menu_Startup "$@"
exit 0
;;
generate)
Expand Down
4 changes: 1 addition & 3 deletions uidivstats_www.asp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ p{font-weight:bolder}thead.collapsible-jquery{color:#fff;padding:0;width:100%;bo
<script language="JavaScript" type="text/javascript" src="/popup.js"></script>
<script language="JavaScript" type="text/javascript" src="/help.js"></script>
<script language="JavaScript" type="text/javascript" src="/ext/shared-jy/detect.js"></script>
<script language="JavaScript" type="text/javascript" src="/tmhist.js"></script>
<script language="JavaScript" type="text/javascript" src="/tmmenu.js"></script>
<script language="JavaScript" type="text/javascript" src="/client_function.js"></script>
<script language="JavaScript" type="text/javascript" src="/validator.js"></script>
<script>

/**----------------------------------------**/
/** Modified by Martinski W. [2025-Feb-08] **/
/** Modified by Martinski W. [2025-Oct-27] **/
/**----------------------------------------**/

var custom_settings;
Expand Down