Por favor, desculpe-me, eu decidi fazer em outro idioma onde me sinto mais confortável.
Muito obrigado pelos exemplos mostrados aqui.
A linguagem de programação:
link
nomainwin
[loop]
'Sleep 500ms
CALLDLL #kernel32 , "Sleep" , 500 AS Long , rc AS Void
'Call sub and read last line
gosub [log]
'Find by filter in string, if exist abuse call sub
if instr(lastline$,"xampp/cgi-bin/php") then gosub [htaccess]
'If ip not exists in htaccess
gosub [save]
goto [loop]
end
'SUBS
[htaccess]
'Read .htaccess
open "C:\xampp\htdocs\.htaccess" for input as #handle1
while EOF(#handle1)=0
line input #handle1, htaccess$
if instr(htaccess$,delim2$) then
exists=1
else
exists=0
end if
wend
close #handle1
RETURN
[log]
'Sets the maximum size of an array
dim array2$(999999)
'Read errorlog file line by line
open "C:\xampp\apache\logs\error.log" for input as #handle2
while EOF(#handle2)=0
input #handle2, array2$(errorlog)
errorlog=errorlog+1
wend
close #handle2
'Put last line in string
lastline$ = array2$(errorlog-1)
'Remove text to the string and get ip
delim$ = word$(lastline$, 4, "]")
delim1$ = word$(delim$, 1, ":")
delim2$ = trim$(mid$(delim1$, 10, 50))
RETURN
[save]
'Save new entries in .htaccess
if exists = 0 then
'Create string and put parameter in front of the ip
ip$ = "deny from " ; delim2$
'Read .htaccesst file and put content in string
open "C:\xampp\htdocs\.htaccess" for input as #f
htaccesst$ = input$(#f, lof(#f))
close #f
'Clean .htaccesst file and put content within the file
open "C:\xampp\htdocs\.htaccess" for output as #f
print #f, htaccesst$
print #f, ip$;
close #f
end if
RETURN