webForumDet fria alternativet

Förbättra script...

ASPur ASP

2 svar · 289 visningar · startad av J0han

Frågan#1

Hur kan man göra för att se till att folk inte "missbrukar" denna räknare?

<html>
<%
Set File = Server.CreateObject("Scripting.FileSystemObject")
Set Edit = File.OpenTextFile(Server.MapPath("counter.txt"), 1)
antal = Edit.ReadLine
Edit.Close
antal = antal + 1
Set Edit = File.OpenTextFile(Server.MapPath("counter.txt"), 2)
Edit.WriteLine antal
Edit.Close
%>
<%=antal%>
</html>

Det borde väl gå med sessions eller nåt..?

------------------
portrait of authOrity

Medlem sedan juni 2000373 inlägg
#2

Tjena,
Japp, det går att lösa med cookies.

<html>
<%
Set File = Server.CreateObject("Scripting.FileSystemObject")
Set Edit = File.OpenTextFile(Server.MapPath("counter.txt"), 1)
antal = Edit.ReadLine
Edit.Close
antal = antal + 1
inget = antal + 0
Set Edit = File.OpenTextFile(Server.MapPath("counter.txt"), 2)

If Request.Cookies("haha") = "1" Then
Edit.WriteLine inget
Else
Edit.WriteLine antal
Response.Cookies("haha") = "1"
Response.Cookies("haha").Expires = "December 1, 2001"

End If
Edit.Close
%>
<%=antal%>
</html>

------------------
Hälsningar Ricki
www.ricki.nu

Medlem sedan dec. 19996 721 inlägg
#3

Varför skriva något till filen överhuvud taget, när inget ska läggas till?

141 ms totalt · 3 externa anrop · v20260731065814-full.55e59744
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
138 ms — hämta tråd, inlägg och bilagor (db)