@echo off
setlocal DisableDelayedExpansion
set "NETPING_USER=visor"
set "NETPING_PASSWORD=Lambo002"
set "LOG_FILE=%~dp0NetPing-debug.log"
set "URL="
if "%~1"=="44" goto :host44
if "%~1"=="45" goto :host45
if "%~1"=="46" goto :host46
if "%~1"=="47" goto :host47
>>"%LOG_FILE%" echo [%date% %time%] UNKNOWN HOST: "%~1" FILE: "%~f0"
exit /b 2
:host44
set "URL=http://192.168.88.38/relay.cgi?r1=0"
goto :send
:host45
set "URL=http://192.168.88.38/relay.cgi?r2=0"
goto :send
:host46
set "URL=http://192.168.88.39/relay.cgi?r1=0"
goto :send
:host47
set "URL=http://192.168.88.39/relay.cgi?r2=0"
goto :send
:send
set "RESPONSE_FILE=%TEMP%\netping_off_%RANDOM%_%RANDOM%.tmp"
>>"%LOG_FILE%" echo [%date% %time%] FILE="%~f0" HOST="%~1" URL="%URL%"
set "CURL_EXE=curl.exe"
if exist "%~dp0curl.exe" set "CURL_EXE=%~dp0curl.exe"
"%CURL_EXE%" --silent --show-error --fail --anyauth ^
--noproxy "*" ^
--connect-timeout 5 --max-time 10 ^
--user "%NETPING_USER%:%NETPING_PASSWORD%" ^
"%URL%" ^
>"%RESPONSE_FILE%" 2>>"%LOG_FILE%"
set "CURL_CODE=%errorlevel%"
type "%RESPONSE_FILE%" >>"%LOG_FILE%"
>>"%LOG_FILE%" echo.
if not "%CURL_CODE%"=="0" (
del "%RESPONSE_FILE%" 2>nul
exit /b 10
)
findstr /i /l /c:"relay_result('ok')" "%RESPONSE_FILE%" >nul
if errorlevel 1 (
del "%RESPONSE_FILE%" 2>nul
exit /b 11
)
del "%RESPONSE_FILE%" 2>nul
exit /b 0