Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

xanburzum

[Resolvido] Log File Text

Recommended Posts

LogFile.asp

 

<%
Dim blnValidEntry       ' Log variable


'Primeiro defina que este registro é válido
blnValidEntry = True

'Se a variável de sessão" Login "não é vazia
'isso significa essa pessoa já esta registrada
'Defina como False blnValidEntry


If not IsEmpty(Session("LogIn")) then blnValidEntry = False


'Aqui você pode adicionar restrições diferentes 
'Se a URL de referência é do mesmo site 
'Então não há necessidade de escrever no arquivo de log


If Left(Request.ServerVariables("HTTP_REFERER"), 17)="http://seu site.com"  Then 
 blnValidEntry = False
End If


If Left(Request.ServerVariables("HTTP_REFERER"), 21)="http://www.seu site.com"  Then
 blnValidEntry = False
End If


'Agora, se for verdade, então blnValidEntry entrar no arquivo de log


If blnValidEntry  Then  
 Const ForAppending = 8
 Const Create = true
 Dim FSO
 Dim TS
 Dim MyFileName
 Dim strLog
 
 MyFileName = Server.MapPath("MyLogFile.txt")


  Set FSO = Server.CreateObject("Scripting.FileSystemObject")
 Set TS = FSO.OpenTextFile(MyFileName, ForAppending, Create)
   
 ' Guarde todas as informações necessárias em uma seqüência Chamado strLog


 strLog = "<br><P><B>" & NOW() & "</B> "
 strLog = strLog & Request.ServerVariables("REMOTE_ADDR") & " "
 strLog = strLog & Request.ServerVariables("HTTP_REFERER") & " "
 strLog = strLog & Request.ServerVariables("HTTP_USER_AGENT") & "<BR>"


 ' Escreva as informações atuais para Log arquivo de texto.
 
 TS.write strLog
 TS.Writeline ""


'Agora Crie um varialvel sessão para verificação na próxima vez para ValidEntry


 Session("LogIn") = "yes"
 Set TS = Nothing
 Set FSO = Nothing
End If
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.