Log[in/out] parking system
Posted: 05 Dec 2013 15:58
Hello there dear people,
I am currently working on this project for college, its a parking-lot system (simulating the situation).
It worked perfectly for quiet some time now, but sadly today i found my script dead (sort of)...
the problem is the following:
After "scanning" the user pass, it hops automatically to the admin login screen...
Well that isn't really what i was expecting, especially not after i deleted all the 'Goto admin' stuff at the login menu.
So my question is... any one a idea how to fix this?
The numbers.txt is nothing more then a list of the following:
I hope someone has an idea
Thanks in advance!
Greatings,
Dwngrt
I am currently working on this project for college, its a parking-lot system (simulating the situation).
It worked perfectly for quiet some time now, but sadly today i found my script dead (sort of)...
the problem is the following:
After "scanning" the user pass, it hops automatically to the admin login screen...
Well that isn't really what i was expecting, especially not after i deleted all the 'Goto admin' stuff at the login menu.
So my question is... any one a idea how to fix this?
Code: Select all
@echo off && cls
setlocal enabledelayedexpansion
for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set tempip=%%a)
set tempip=%tempip: =%
set wake= %date% - %time:~0,8%
echo ---------------------------------------------------------- >>log.bak
echo %computername% just woke up>>log.bak
echo wake-up at: [%wake%] >>log.bak
echo woke up on: [%tempip%] >>log.bak
echo ---------------------------------------------------------- >>log.bak
:root
title Parkeerpaal
if exist numbers.txt goto setup
if not exist numbers.txt set foutcode=21-19-5-18-19 20-24-20 4-15-5-19-14-20 5-24-9-19-20 && goto users_not_found
:setup
cls
echo wilt u uitchecken of inchecken?
echo [I]nchecken
echo [U]itchecken
echo.
set choice=
CHOICE /T 1 /C iue /D e >nul
if %errorlevel%==1 set pp1=ad&& goto users_found
if %errorlevel%==2 set pp2=min&& goto uitchecken
if %errorlevel%==3 goto setup
goto setup
:users_not_found
cls
echo Er is een fout opgetreden.
echo Neem contact op met de Service desk.
echo.
echo Foutcode: [%foutcode%]
ping localhost -n 5 >NUL
goto exit_error
:exit_error
echo error_code: %foutcode%>>log.bak
echo error recieved from: [%computername%] -- IP: [%tempip%]>>log.bak
cls
echo Foutcode: [%foutcode%]
echo script word gestopt
ping localhost -n 5 >NUL
exit
:users_found
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º ######### º
echo º ######### º
echo º ## ## º
echo º ## ## º
echo º ######### º
echo º ######### º
echo º ## º
echo º ## º
echo º ## º
echo º ## º
echo º ## º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo Welkom, Scan uw pas om slagboom te openen.
echo Welcome, scan your pass to open the barrier.
echo.
:begin
set usr=
set /p usr=P/Nr:
if "%usr%"=="b" goto root
if {%usr%}=={} goto begin
set authenticated=
for /f "tokens=*" %%a in (numbers.txt) do (
if {%%a}=={%usr%} set authenticated=true
)
if not defined authenticated (cls & echo Incorrect pasnummer && goto users_found)
if exist blocked\%usr%.txt goto blocked2
cls && goto get_name
:check_in
if exist parked\%usr%.txt goto parked
echo ------------------------------------>>log.bak
echo [%date% - %time:~0,8%] Medewerker [%usr%] ingecheckt op [%tempip%]>>log.bak
echo Naam: [%name%]>>log.bak
echo Gebor: [%birth%]>>log.bak
echo ------------------------------------>>log.bak
cls
type anim\closed.txt
echo.
echo.
echo WACHTEN AUB
ping localhost -n 2 >NUL
cls
type anim\near_closed.txt
echo.
echo.
echo WAIT PLEASE
ping localhost -n 2 >NUL
cls
type anim\near_open.txt
echo.
echo.
echo WACHTEN AUB
ping localhost -n 2 >NUL
cls
type anim\open.txt
echo.
echo.
echo WAIT PLEASE
ping localhost -n 2 >NUL
cls
type anim\open.txt
echo.
echo.
ping localhost -n 2 >NUL
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo ³welkom %name%, u kunt binnen rijden.
echo ³welcome %name%, you can drive in.
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo parked >parked\%usr%.txt
ping localhost -n 5 >NUL
goto root
:uitchecken
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º ######### º
echo º ######### º
echo º ## ## º
echo º ## ## º
echo º ######### º
echo º ######### º
echo º ## º
echo º ## º
echo º ## º
echo º ## º
echo º ## º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo Welkom, Scan uw pas om slagboom te openen.
echo Welcome, scan your pass to open the barrier.
echo.
:begin2
set usr=
set /p usr=P/Nr:
if {%usr%}=={} goto :begin2
set authenticated=
for /f "tokens=*" %%a in (numbers.txt) do (
if {%%a}=={%usr%} set authenticated=true
)
if not defined authenticated (cls & echo Incorrect pasnummer & goto :uitchecken)
if exist blocked\%usr%.txt goto blocked2
cls && goto get_name
:check_out
if not exist parked\%usr%.txt goto not_parked
if exist parked\%usr%.txt del parked\%usr%.txt >NUL
echo ------------------------------------>>log.bak
echo [%date% - %time:~0,8%] Medewerker [%usr%] uitgechecked op [%tempip%]>>log.bak
echo Naam: [%name%]>>log.bak
echo Gebor: [%birth%]>>log.bak
echo ------------------------------------>>log.bak
cls
type anim\closed.txt
echo.
echo.
echo WACHTEN AUB
ping localhost -n 2 >NUL
cls
type anim\near_closed.txt
echo.
echo.
echo WAIT PLEASE
ping localhost -n 2 >NUL
cls
type anim\near_open.txt
echo.
echo.
echo WACHTEN AUB
ping localhost -n 2 >NUL
cls
type anim\open.txt
echo.
echo.
echo WAIT PLEASE
ping localhost -n 2 >NUL
cls
type anim\open.txt
echo.
echo.
ping localhost -n 2 >NUL
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo ³Tot ziens %name%, u kunt uitrijden.
echo ³Goodbye %name%, you can drive out.
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ping localhost -n 5 >NUL
goto root
:get_name
(
set /p name=
)<users\%usr%.txt
if "%choice%"=="1" goto check_in
if "%choice%"=="2" goto check_out
:admin
cls
echo Hello there %usr%, you are just a step away from the Admin panel,
echo Please login with the SUPERSECRETPASSWORD.
echo.
:HInput
Echo Enter your password below:
Set "Line="
For /F %%# In (
'"Prompt;$H&For %%# in (1) Do Rem"'
) Do Set "BS=%%#"
:HILoop
Set "Key="
For /F "delims=" %%# In (
'Xcopy /W "%~f0" "%~f0" 2^>Nul'
) Do If Not Defined Key Set "Key=%%#"
Set "Key=%Key:~-1%"
If Not Defined Key Goto :HIEnd
If %BS%==^%Key% (Set /P "=%BS% %BS%" <Nul
Set "Key="
If Defined Line Set "Line=!Line:~0,-1!"
) Else Set /P "=*" <Nul
If Not Defined Line (EndLocal &Set "Line=%Key%"
) Else For /F delims^=^ eol^= %%# In (
"!Line!") Do EndLocal &Set "Line=%%#%Key%"
Goto :HILoop
:HIEnd
if "!Line!"=="%pp1%%pp2%" goto adpan
goto root
:adpan
cls
set /a !wait!=%time:~3,2%
set cnt=0
for %%A in (parked\*) do set /a cnt+=1
if %cnt%==50 set status=parkeerplaats is vol
set /a vrij=50-%cnt%
echo ------------------------------
echo Parked spaces = %cnt%
echo Free spaces = %vrij%
echo ------------------------------
echo.
echo [1] get log
echo [2] get parked list
echo [3] get blocked list
echo --------------
echo [4] block usr
echo [5] add usr
echo --------------
echo [6] clear log
echo [7] sys nfo
echo [8] Connection test
echo --------------
echo [9] Start screen
echo [0] usernames
echo.
set p=
set /p p=:
set /a %wait%=%wait%+2
if %wait% LSS %time:~3,2% goto admin
if "%p%"=="1" goto log
if "%p%"=="2" goto P_list
if "%p%"=="3" goto blocked
if "%p%"=="4" goto block
if "%p%"=="5" goto add
if "%p%"=="6" goto clear_log
if "%p%"=="7" goto sys_info
if "%p%"=="8" goto con_test
if "%p%"=="9" goto root
if "%p%"=="0" goto usernames
goto adpan
:log
cls
type log.bak
pause>NUL
goto admin
:P_list
cls
for /r . %%g in (parked\*.txt) do echo %%~nxg
pause>NUL
goto admin
:parked
cls
echo U bent al geregistreerd als geparkeerd, u kunt helaas geen 2 keer
echo de parkeer garage binnen rijden.
echo.
echo Neem contact op met de Service Desk.
Pause>NUL
goto root
:blocked
cls
for /r . %%g in (blocked\*.txt) do echo %%~nxg
pause>NUL
goto admin
:block
cls
echo Insert P/Nr to instantaniously block this card.
echo.
set p=
set /p p=nr:
echo blocked>blocked\%p%.txt
goto admin
:add
cls
echo Insert info to add new person.
echo.
set p=
set t=
set /p p=nr:
set /p t=full name:
echo %t%>users\%p%.txt
echo %p%>>numbers.txt
goto admin
:clear_log
cls
echo Are you sure you want to delete the Log file?
echo.
set p=
set /p p=[y/n]:
if "%p%"=="y" del log.bak && goto admin
if "%p%"=="n" goto admin
:usernames
cls
for /f %%A in ('dir users\ ^| find "File(s)"') do set cnt=%%A
set /a y=10000
type users\%y%.txt && echo.
:loop
set /a y=y+1
type users\%y%.txt && echo.
if "%y%"=="100%cnt%" goto non_loop
goto loop
:non_loop
pause>NUL
goto admin
:sys_info
cls
echo Machine: [%computername%]
echo IP: [%tempip%]
echo User: [%username%]
echo Sys time: [%time%]
echo Sys date: [%date%]
echo Session: [%sessionname%]
pause>NUL
goto admin
:con_test
cls
set ip=google.nl
ping -n 1 %ip% | find "TTL"
if not errorlevel 1 set error=Yes
if errorlevel 1 set error=No
cls
echo Online: [%error%]
pause>NUL
goto admin
:not_parked
cls
echo U bent niet als geparkeerd geregistreerd, neem contact op met de Service Desk
echo You ain't registered as parked, please contact the Service Desk.
ping localhost -n 5 >NUL
goto root
:blocked2
cls
echo Het lijkt er op dat uw pas geblokeerd is, neem contact op met de Service Desk.
echo.
echo It seems like your pass is blocked, please contact the Service Desk.
ping localhost -n 5 >NUL
goto root
The numbers.txt is nothing more then a list of the following:
- 10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10052
10055
I hope someone has an idea
Thanks in advance!
Greatings,
Dwngrt