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
64
65
66
67
68
69
70
71
72
|
#include "main.h"
int main(void)
{
char article[50] = "...", *env;
char* tmp_h = NULL;
int num = 0, i;
env = getenv("QUERY_STRING");
if(!env || sscanf(env, "article=%d", &num) != 1)
num = 0;
if( env >= 0)
{
int nb_CR = 0, c;
FILE* fichier = fopen("article/_liste", "r");
if(!fichier)
erreur("Impossible de charger la page. Veuillez reessayer ultérieurement.");
for(nb_CR=-1;nb_CR < num && fgets(article, 50, fichier);++nb_CR);
if(nb_CR != num)
erreur("Article introuvable");
for(tmp_h=article;*tmp_h;tmp_h++)
if( isspace(*tmp_h) )
*tmp_h = '\0';
}
char date[20], titre[50] = "Vive la lettre H !", ident[50];
int type = getinfo(article, titre, date, ident);
if( titre )
start(titre, "Site d'ache : Articles et présentation de mes projets");
else
start("Ache", "Site d'ache : Articles et présentation de mes projets");
{ // LOG
char chemin[50] = "";
char command[100] = "";
time_t rawtime;
struct tm* UTCTime;
FILE* log;
time( &rawtime );
UTCTime = gmtime( &rawtime );
sprintf(chemin, "logs/%.2d.%.2d.%.2d.txt", UTCTime->tm_mday, UTCTime->tm_mon, UTCTime->tm_year);
log = fopen(chemin, "a");
if( log )
{
fprintf(log, "[%.2d:%.2d:%.2d]<%s-%s>%d\n", UTCTime->tm_hour, UTCTime->tm_min, UTCTime->tm_sec, getenv("REMOTE_ADDR"), getenv("HTTP_USER_AGENT"), num);
fclose(log);
}
else
{
printf("Voir %s", chemin);
perror( "Erreur :");
return 1;
}
if( getenv("REMOTE_ADDR") ) {
sprintf(command, "wget -q -O - ipinfo.io/%s | tr \"\\n\" \" \" | tr -s ' ' >> %s", getenv("REMOTE_ADDR"), chemin);
system(command);
sprintf(command, "echo ' ' >> %s",chemin);
system(command);
}
}
sideBar();
//sommaire();
contenu(article, num);
voirAussi();
end();
return 0;
}
|