diff --git a/src/modules/selfsteal_templates.sh b/src/modules/selfsteal_templates.sh index e34c25d..5602e66 100644 --- a/src/modules/selfsteal_templates.sh +++ b/src/modules/selfsteal_templates.sh @@ -65,17 +65,18 @@ randomhtml() { rm -rf assets "README.md" "index.html" 2>/dev/null fi - # Special handling for nothing-sni - select random HTML file if [[ "$selected_url" == *"nothing-sni"* ]]; then - # Randomly select one HTML file from 1-8.html - selected_number=$((RANDOM % 8 + 1)) - RandomHTML="${selected_number}.html" + mapfile -t templates < <(find . -maxdepth 1 -type f -name "*.html" -printf '%P\n' | sort) else mapfile -t templates < <(find . -maxdepth 1 -type d -not -path . | sed 's|./||') + fi - RandomHTML="${templates[$RANDOM % ${#templates[@]}]}" + if [[ ${#templates[@]} -eq 0 ]]; then + echo "${LANG[UNPACK_ERROR]}" && exit 1 fi + RandomHTML="${templates[$RANDOM % ${#templates[@]}]}" + if [[ "$selected_url" == *"distillium"* && "$RandomHTML" == "503 error pages" ]]; then cd "$RandomHTML" || { echo "${LANG[UNPACK_ERROR]}"; exit 0; } versions=("v1" "v2") @@ -111,7 +112,7 @@ randomhtml() { -e "s|id=\"subscribe\"|id=\"sub_${random_id_suffix}\"|" \ -e "s|.*|${random_title}|" \ -e "s/<\/head>/\n\n<\/head>/" \ - -e "s//dev/null; then + if ! grep -Rql --include="*.html" -- "$random_meta_name" "/var/www/html" 2>/dev/null; then echo -e "${COLOR_RED}${LANG[FAILED_TO_MODIFY_HTML_FILES]}${COLOR_RESET}" return 1 fi