1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
DateTime au;
au = DateTime.Now;
string midenti;
string yidenti;
string fichier_identi;
string ip = Request.ServerVariables["REMOTE_ADDR"];
midenti = au.ToString("%M");
yidenti = au.ToString("yyyy");
Application.Lock();
string list_ip;
TimeSpan dure;
DateTime date_ip = new DateTime();
if (Application["ip"] != null && Application["date_ip"] != null)
{
list_ip = Convert.ToString(Application["ip"]);
date_ip = Convert.ToDateTime(Application["date_ip"]);
dure = au - date_ip;
if (dure.Minutes > 5)
{
list_ip = "";
}
if (list_ip.IndexOf(ip) == -1)
{
// ecriture dans le fichier texte
fichier_identi = "/chambagri/consult/log/identi-" + midenti + "-" + yidenti + ".txt";
System.IO.StreamWriter monstream = new System.IO.StreamWriter(Server.MapPath(fichier_identi), true);
string lachaine;
lachaine = au.ToString() + " | | | | observatoire | | " + ip ;
monstream.WriteLine(lachaine);
monstream.Close();
}
list_ip = list_ip + ip + ";";
}
else
{
list_ip = ip + ";";
// ecriture dans le fichier texte
fichier_identi = "/chambagri/consult/log/identi-" + midenti + "-" + yidenti + ".txt";
System.IO.StreamWriter monstream = new System.IO.StreamWriter(Server.MapPath(fichier_identi), true);
string lachaine;
lachaine = au.ToString() + " | | | | observatoire | | " + ip; ;
monstream.WriteLine(lachaine);
monstream.Close();
}
Application["ip"] = list_ip;
Application["date_ip"] = au;
Application.UnLock();
} |