here is my attempt to capture where my users are going on the internet using proxy+(proxyplus), a http proxy server that does some other services as well and it can run as a windows service.
The version is 3.00 build no 264.
The proxy+ server can archive a copy of the logs created up to 31 periods , you can set the period(interval of days or weeks, or something else).
It calls this log rollover. The program keeps active logs opened and locked, so you can not access them unless the program is not running and we want it to always be running as a service. If any future version of this program does the same and increases the number of back logs higher that 31, this program will handle it.
So i wrote this program to grab the archived(rolled over) logs and create logs elsewhere on the computer. After retrieving data inside the logs files, i then erase the original archived log file.
There are six log files and this program saves all 6.
I intend this program to be run as a windows service, but this program listing as is will not run as a service, you will have to just remove some remarked lines out.
You can edit the program to save the files in directories of individual days, but i thought that was just too much so i changed it place logs into directories by year and month.
I place some code in the program to speed up the process, where certain files do not exist. I just try to open files and do not view a directory to see what files are there.
It would be nice to read the registry for some information, but i have not ever done that and i am looking into it now. It would be nice to not have this program hard code to where certain information is stored, but it will handle proxy+'s default setup.
I have not tried this program on VISTA yet or even as a service yet, but it should work as a service, that is the next step.
Proxy+ does not really increment the log numbers, it renames the oldest log file, the highest number. So a log file with a lower number is more current than a log file with a higher number.
If the original log file has zero bytes in it(empty), then nothing is saved. That also means because there are 6 log files for the program, these logs are not saved as a set, so to say.
While running this program, it would seem logical there are not going to be no more that 31x6 files in a single directory for one particular month, but this program will handle much much more than that if a user manually decides to rollover the log files to escape detection of where he goes on the internet.
The version is 3.00 build no 264.
The proxy+ server can archive a copy of the logs created up to 31 periods , you can set the period(interval of days or weeks, or something else).
It calls this log rollover. The program keeps active logs opened and locked, so you can not access them unless the program is not running and we want it to always be running as a service. If any future version of this program does the same and increases the number of back logs higher that 31, this program will handle it.
So i wrote this program to grab the archived(rolled over) logs and create logs elsewhere on the computer. After retrieving data inside the logs files, i then erase the original archived log file.
There are six log files and this program saves all 6.
I intend this program to be run as a windows service, but this program listing as is will not run as a service, you will have to just remove some remarked lines out.
You can edit the program to save the files in directories of individual days, but i thought that was just too much so i changed it place logs into directories by year and month.
I place some code in the program to speed up the process, where certain files do not exist. I just try to open files and do not view a directory to see what files are there.
It would be nice to read the registry for some information, but i have not ever done that and i am looking into it now. It would be nice to not have this program hard code to where certain information is stored, but it will handle proxy+'s default setup.
I have not tried this program on VISTA yet or even as a service yet, but it should work as a service, that is the next step.
Proxy+ does not really increment the log numbers, it renames the oldest log file, the highest number. So a log file with a lower number is more current than a log file with a higher number.
If the original log file has zero bytes in it(empty), then nothing is saved. That also means because there are 6 log files for the program, these logs are not saved as a set, so to say.
While running this program, it would seem logical there are not going to be no more that 31x6 files in a single directory for one particular month, but this program will handle much much more than that if a user manually decides to rollover the log files to escape detection of where he goes on the internet.
Code:
proxypluslog.bas 'pbwin 9.01 complier ' ' this program reads log files from proxy+ (proxyplus) version 3.09 build 264 ' then saves them else where on the hard drive ' the directory created is "\systemplus" that is hidden in the root directory ' a subdirectory in the directory \systemplus is created called proxyplus where ' log files are placed by date 'ex "c:\systemplus\proxyplus\20091231" 'files names are incremented to keep from losing log data from the proxyplus 'after the log files from proxyplus are read and new ones created under the '"\systemplus\proxyplus" directory, the original log files are deleted. 'you can set the number of logs to create and the number of days in each period before logs are archieved(rolledover) 'there seems to be a maximum of 31 periods ' 'proxyplus keeps data information in the registry 'there is information in the registry but at this time this program does not read or make changes to the registry #COMPILE EXE "ProxyPlusLog.exe" #DIM ALL #REGISTER NONE #INCLUDE "WIN32API.INC" FUNCTION PBMAIN () AS LONG DIM pathlogdirectory AS STRING DIM newpathlogdirectory AS STRING DIM todaysdate AS STRING DIM fileexist AS LONG DIM filenametemp AS STRING DIM homedrive AS STRING DIM ProgramFiles AS STRING DIM temp AS STRING DIM I AS LONG DIM J AS LONG DIM K AS LONG DIM L AS LONG DIM M AS LONG DIM proxypluslogdirectory AS STRING DIM proxypluslogfilenamebase(6) AS STRING DIM proxypluslogfilenameext AS STRING DIM proxypluslogfilename AS STRING DIM newlogfilename AS STRING DIM fileno1 AS LONG DIM fileno2 AS LONG DIM filecontents AS STRING ' unremark the next line if you want to run this program as a service. 'SLEEP 240000 '4 minutes before program starts ' some of these variables are in the registry, but this program does not read the registry proxypluslogdirectory= TRIM$("C:\Program Files\ProxyPlus\Logs ") proxypluslogfilenamebase(1)= TRIM$("AccessLog_ ") proxypluslogfilenamebase(2)= TRIM$("ProxyLog_ ") proxypluslogfilenamebase(3)= TRIM$("DialLog_ ") proxypluslogfilenamebase(4)= TRIM$("MailLog_ ") proxypluslogfilenamebase(5)= TRIM$("ErrLog_ ") proxypluslogfilenamebase(6)= TRIM$("SecLog_ ") proxypluslogfilenameext= TRIM$(".TXT ") startprocessing: homedrive=ENVIRON$("HOMEDRIVE") ProgramFiles=ENVIRON$("ProgramFiles") pathlogdirectory=homedrive+"\systemplus" MKDIR pathlogdirectory SETATTR pathlogdirectory, %HIDDEN + %SYSTEM + %NORMAL pathlogdirectory=pathlogdirectory+"\proxypluslogs" MKDIR pathlogdirectory logitagain: todaysdate=DATE$ ' next line will store all logs in a directory by a specfic year and month newpathlogdirectory=pathlogdirectory+"\"+MID$(todaysdate,7,4)+MID$(todaysdate,1,2) ' unremarking the next line will store all logs in a directory by a specfic year, month and day ' newpathlogdirectory=pathlogdirectory+"\"+MID$(todaysdate,7,4)+MID$(todaysdate,1,2)+MID$(todaysdate,4,2) MKDIR newpathlogdirectory ' find the file name with the highest number in it M = 0& L = 0& FOR I = 0& TO 99999& IF (I MOD 10&)= 0& THEN SLEEP 30& IF L = 300& THEN EXIT FOR ' this stop the program if more than 50 straight log files are not found ' proxyplus seems to limit log files to a maximum of 31 logfiles on a rollover basis FOR K = 1& TO 6& filenametemp=proxypluslogdirectory+"\"+proxypluslogfilenamebase(k)+TRIM$(STR$(I))+proxypluslogfilenameext IF NOT ISFILE(filenametemp)THEN INCR L:ITERATE IF ISFILE(filenametemp)THEN M=I:L=0&:ITERATE:ITERATE NEXT K NEXT I IF M = 0& THEN GOTO endprocessing FOR I = M TO 0& STEP -1& FOR K = 1& TO 6& filecontents = "" filenametemp = proxypluslogdirectory+"\"+proxypluslogfilenamebase(K)+TRIM$(STR$(I))+proxypluslogfilenameext IF NOT ISFILE(filenametemp)THEN ITERATE TRY fileno1 = FREEFILE OPEN filenametemp FOR BINARY ACCESS READ LOCK WRITE AS #fileno1 CATCH CLOSE #fileno1 EXIT TRY FINALLY IF LOF(fileno1) = 0& THEN CLOSE #fileno1 KILL filenametemp ITERATE EXIT TRY END IF filecontents = "" GET$ fileno1, LOF(fileno1),filecontents CLOSE #fileno1 L = 0& END TRY FOR J=1& TO 9999999& newlogfilename = newpathlogdirectory+"\"+proxypluslogfilenamebase(K)+TRIM$(STR$(J))+proxypluslogfilenameext IF ISFILE(newlogfilename)THEN ITERATE fileno2 = FREEFILE TRY OPEN newlogfilename FOR BINARY ACCESS READ WRITE LOCK READ WRITE AS #fileno2 CATCH CLOSE #fileno2 EXIT TRY FINALLY PUT$ fileno2, filecontents CLOSE #fileno2 KILL filenametemp EXIT FOR END TRY NEXT J NEXT K IF (I MOD 10&) = 0& THEN SLEEP 20 NEXT I endprocessing: TEMP = UCASE$(COMMAND$) REPLACE " " WITH "" IN TEMP IF INSTR(TEMP,"QUIT") THEN EXIT FUNCTION ELSE 'unremark the next two lines if running this program as a windows service ' SLEEP 60000 'capture the logs files once every every 60 seconds ' GOTO startprocessing END IF END FUNCTION
Comment