Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<?php
2
 
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2005                                                *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
10
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
 
13
 
14
include ("inc.php3");
15
include_ecrire("inc_statistiques.php3");
16
 
17
 
18
// Donne la hauteur du graphe en fonction de la valeur maximale
19
// Doit etre un entier "rond", pas trop eloigne du max, et dont
20
// les graduations (divisions par huit) soient jolies :
21
// on prend donc le plus proche au-dessus de x de la forme 12,16,20,40,60,80,100
22
function maxgraph($max) {
23
	$max = max(10,$max);
24
	$p = pow(10, strlen($max)-2);
25
	$m = $max/$p;
26
	foreach (array(100,80,60,40,20,16,12,10) as $l)
27
		if ($m<=$l) $maxgraph = $l*$p;
28
	return $maxgraph;
29
}
30
 
31
function http_img_rien($width, $height, $style='', $title='') {
32
	return http_img_pack('rien.gif', $title,
33
		"width='$width' height='$height'"
34
		. (!$style ? '' : (" style='$style'"))
35
		. (!$title ? '' : (" title=\"$title\"")));
36
}
37
 
38
if ($id_article = intval($id_article)){
39
	$query = "SELECT titre, visites, popularite FROM spip_articles WHERE statut='publie' AND id_article ='$id_article'";
40
	$result = spip_query($query);
41
 
42
	if ($row = spip_fetch_array($result)) {
43
		$titre = typo($row['titre']);
44
		$total_absolu = $row['visites'];
45
		$val_popularite = round($row['popularite']);
46
	}
47
}
48
else {
49
	$query = "SELECT SUM(visites) AS total_absolu FROM spip_visites";
50
	$result = spip_query($query);
51
 
52
	if ($row = spip_fetch_array($result)) {
53
		$total_absolu = $row['total_absolu'];
54
	}
55
}
56
 
57
 
58
if ($titre) $pourarticle = " "._T('info_pour')." &laquo; $titre &raquo;";
59
 
60
if ($origine) {
61
	debut_page(_T('titre_page_statistiques_referers'), "suivi", "statistiques");
62
	echo "<br><br>";
63
	gros_titre(_T('titre_liens_entrants'));
64
	barre_onglets("statistiques", "referers");
65
 
66
	debut_gauche();
67
	debut_boite_info();
68
	echo "<FONT FACE='Verdana,Arial,Sans,sans-serif' SIZE=2>";
69
	echo "<P align=left>"._T('info_gauche_statistiques_referers')."</P></FONT>";
70
	fin_boite_info();
71
 
72
	debut_droite();
73
 
74
}
75
else {
76
	debut_page(_T('titre_page_statistiques_visites').$pourarticle, "suivi", "statistiques");
77
	echo "<br><br>";
78
	gros_titre(_T('titre_evolution_visite')."<html>".aide("confstat")."</html>");
79
//	barre_onglets("statistiques", "evolution");
80
	if ($titre) gros_titre($titre);
81
 
82
	debut_gauche();
83
 
84
	echo "<p>";
85
 
86
	echo "<div class='iconeoff' style='padding: 5px;'>";
87
	echo "<font face='Verdana,Arial,Sans,sans-serif' size=2>";
88
	echo typo(_T('info_afficher_visites'));
89
	echo "<ul>";
90
	if ($id_article>0) {
91
		echo "<li><b><a href='statistiques_visites.php3'>"._T('info_tout_site')."</a></b>";
92
	} else {
93
		echo "<li><b>"._T('titre_page_articles_tous')."</b>";
94
	}
95
 
96
		echo "</ul>";
97
		echo "</font>";
98
		echo "</div>";
99
 
100
 
101
	// Par popularite
102
	$articles_recents[] = "0";
103
	$query = "SELECT id_article FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY date DESC LIMIT 0,10";
104
	$result = spip_query($query);
105
	while ($row = spip_fetch_array($result)) {
106
		$articles_recents[] = $row['id_article'];
107
	}
108
	$articles_recents = join($articles_recents, ",");
109
 
110
	// Par popularite
111
	$query = "SELECT id_article, titre, popularite, visites FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY popularite DESC";
112
	$result = spip_query($query);
113
 
114
	$nombre_articles = spip_num_rows($result);
115
	if ($nombre_articles > 0) {
116
		echo "<p>";
117
		echo "<div class='iconeoff' style='padding: 5px;'>";
118
		echo "<font face='Verdana,Arial,Sans,sans-serif' size=2>";
119
		echo typo(_T('info_visites_plus_populaires'));
120
		echo "<ol style='padding-left:25 px;'>";
121
		echo "<font size=1 color='#666666'>";
122
		while ($row = spip_fetch_array($result)) {
123
			$titre = typo($row['titre']);
124
			$l_article = $row['id_article'];
125
			$visites = $row['visites'];
126
			$popularite = round($row['popularite']);
127
			$liste++;
128
			$classement[$l_article] = $liste;
129
 
130
			if ($liste <= 30) {
131
				$articles_vus[] = $l_article;
132
 
133
				if ($l_article == $id_article){
134
					echo "\n<li value='$liste'><b>$titre</b>";
135
				} else {
136
					echo "\n<li value='$liste'><a href='statistiques_visites.php3?id_article=$l_article' title='"._T('info_popularite', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a>";
137
				}
138
			}
139
		}
140
		$articles_vus = join($articles_vus, ",");
141
 
142
		// Par popularite
143
		$query_suite = "SELECT id_article, titre, popularite, visites FROM spip_articles WHERE statut='publie' AND id_article IN ($articles_recents) AND id_article NOT IN ($articles_vus) ORDER BY popularite DESC";
144
		$result_suite = spip_query($query_suite);
145
 
146
		if (spip_num_rows($result_suite) > 0) {
147
			echo "<br><br>[...]<br><br>";
148
			while ($row = spip_fetch_array($result_suite)) {
149
				$titre = typo($row['titre']);
150
				$l_article = $row['id_article'];
151
				$visites = $row['visites'];
152
				$popularite = round($row['popularite']);
153
				$numero = $classement[$l_article];
154
 
155
				if ($l_article == $id_article){
156
					echo "\n<li value='$numero'><b>$titre</b></li>";
157
				} else {
158
					echo "\n<li value='$numero'><a href='statistiques_visites.php3?id_article=$l_article' title='"._T('info_popularite_3', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a></li>";
159
				}
160
			}
161
		}
162
 
163
		echo "</ol>";
164
 
165
		echo "<b>"._T('info_comment_lire_tableau')."</b><br>"._T('texte_comment_lire_tableau');
166
 
167
		echo "</font>";
168
		echo "</font>";
169
		echo "</div>";
170
	}
171
 
172
 
173
	// Par visites depuis le debut
174
	$query = "SELECT id_article, titre, popularite, visites FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY visites DESC LIMIT 0,30";
175
	$result = spip_query($query);
176
 
177
	if (spip_num_rows($result) > 0) {
178
		creer_colonne_droite();
179
 
180
		echo "<p></p><div class='iconeoff' style='padding: 5px;'>";
181
		echo "<font face='Verdana,Arial,Sans,sans-serif' size=2>";
182
		echo typo(_T('info_affichier_visites_articles_plus_visites'));
183
		echo "<ol style='padding-left:25 px;'>";
184
		echo "<font size=1 color='#666666'>";
185
 
186
		while ($row = spip_fetch_array($result)) {
187
			$titre = typo($row['titre']);
188
			$l_article = $row['id_article'];
189
			$visites = $row['visites'];
190
			$popularite = round($row['popularite']);
191
				$numero = $classement[$l_article];
192
 
193
				if ($l_article == $id_article){
194
					echo "\n<li value='$numero'><b>$titre</b></li>";
195
				} else {
196
					echo "\n<li value='$numero'><a href='statistiques_visites.php3?id_article=$l_article' title='"._T('info_popularite_4', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a></li>";
197
				}
198
		}
199
		echo "</ol>";
200
		echo "</font>";
201
 
202
		echo "</font>";
203
		echo "</div>";
204
	}
205
 
206
 
207
	//
208
	// Afficher les boutons de creation d'article et de breve
209
	//
210
	if ($connect_statut == '0minirezo') {
211
		if ($id_article > 0) {
212
			debut_raccourcis();
213
			icone_horizontale(_T('icone_retour_article'), "articles.php3?id_article=$id_article", "article-24.gif","rien.gif");
214
			fin_raccourcis();
215
		}
216
	}
217
 
218
 
219
 
220
	debut_droite();
221
}
222
 
223
 
224
 
225
if ($connect_statut != '0minirezo') {
226
	echo _T('avis_non_acces_page');
227
	fin_page();
228
	exit;
229
}
230
 
231
 
232
 
233
 
234
//////
235
 
236
if (!$aff_jours) $aff_jours = 105;
237
 
238
if (!$origine) {
239
 
240
 
241
 
242
 
243
	if ($id_article) {
244
		$table = "spip_visites_articles";
245
		$table_ref = "spip_referers_articles";
246
		$where = "id_article=$id_article";
247
	} else {
248
		$table = "spip_visites";
249
		$table_ref = "spip_referers";
250
		$where = "1";
251
	}
252
 
253
	$query="SELECT UNIX_TIMESTAMP(date) AS date_unix FROM $table ".
254
		"WHERE $where ORDER BY date LIMIT 0,1";
255
	$result = spip_query($query);
256
	while ($row = spip_fetch_array($result)) {
257
		$date_premier = $row['date_unix'];
258
	}
259
 
260
	$query="SELECT UNIX_TIMESTAMP(date) AS date_unix, visites FROM $table ".
261
		"WHERE $where AND date > DATE_SUB(NOW(),INTERVAL $aff_jours DAY) ORDER BY date";
262
	$result=spip_query($query);
263
 
264
	while ($row = spip_fetch_array($result)) {
265
		$date = $row['date_unix'];
266
		$visites = $row['visites'];
267
 
268
		$log[$date] = $visites;
269
		if ($i == 0) $date_debut = $date;
270
		$i++;
271
	}
272
 
273
	// Visites du jour
274
	if ($id_article) {
275
		$query = "SELECT COUNT(DISTINCT ip) AS visites FROM spip_visites_temp WHERE type = 'article' AND id_objet = $id_article";
276
		$result = spip_query($query);
277
	} else {
278
		$query = "SELECT COUNT(DISTINCT ip) AS visites FROM spip_visites_temp";
279
		$result = spip_query($query);
280
	}
281
	if ($row = @spip_fetch_array($result))
282
		$visites_today = $row['visites'];
283
	else
284
		$visites_today = 0;
285
 
286
	if (count($log)>0) {
287
		$max = max(max($log),$visites_today);
288
		$date_today = time();
289
		$nb_jours = floor(($date_today-$date_debut)/(3600*24));
290
 
291
		$maxgraph = maxgraph($max);
292
		$rapport = 200 / $maxgraph;
293
 
294
		if (count($log) < 420) $largeur = floor(450 / ($nb_jours+1));
295
		if ($largeur < 1) {
296
			$largeur = 1;
297
			$agreg = ceil(count($log) / 420);
298
		} else {
299
			$agreg = 1;
300
		}
301
		if ($largeur > 50) $largeur = 50;
302
 
303
		debut_cadre_relief("statistiques-24.gif");
304
 
305
 
306
		$largeur_abs = 420 / $aff_jours;
307
 
308
		if ($largeur_abs > 1) {
309
			$inc = ceil($largeur_abs / 5);
310
			$aff_jours_plus = 420 / ($largeur_abs - $inc);
311
			$aff_jours_moins = 420 / ($largeur_abs + $inc);
312
		}
313
 
314
		if ($largeur_abs == 1) {
315
			$aff_jours_plus = 840;
316
			$aff_jour_moins = 210;
317
		}
318
 
319
		if ($largeur_abs < 1) {
320
			$aff_jours_plus = 420 * ((1/$largeur_abs) + 1);
321
			$aff_jours_moins = 420 * ((1/$largeur_abs) - 1);
322
		}
323
 
324
//		$aff_jours_plus = round($aff_jours * 1.5);
325
//		$aff_jours_moins = round($aff_jours / 1.5);
326
 
327
 
328
 
329
		if ($id_article) $pour_article="&id_article=$id_article";
330
 
331
		if ($date_premier < $date_debut)
332
		  echo http_href_img("statistiques_visites.php3?aff_jours=$aff_jours_plus$pour_article",
333
				     'loupe-moins.gif',
334
				     "border='0' valign='center'",
335
				     _T('info_zoom'). '-'), "&nbsp;";
336
		if ( (($date_today - $date_debut) / (24*3600)) > 30)
337
		  echo http_href_img("statistiques_visites.php3?aff_jours=$aff_jours_moins$pour_article",
338
				     'loupe-plus.gif',
339
				     "border='0' valign='center'",
340
				     _T('info_zoom'). '+'), "&nbsp;";
341
 
342
		/*
343
		if ($spip_svg_plugin == 'oui') {
344
			echo "<div>";
345
			echo "<object data='statistiques_svg.php3?id_article=$id_article&aff_jours=$aff_jours' width='450' height='310' type='image/svg+xml'>";
346
			echo "<embed src='statistiques_svg.php3?id_article=$id_article&aff_jours=$aff_jours'  width='450' height='310' type='image/svg+xml' />";
347
			echo "</object>";
348
			echo "</div>";
349
		}
350
		else {
351
		*/
352
			echo "<table cellpadding=0 cellspacing=0 border=0><tr>",
353
			  "<td background='", _DIR_IMG_PACK, "fond-stats.gif'>";
354
			echo "<table cellpadding=0 cellspacing=0 border=0><tr>";
355
 
356
			echo "<td bgcolor='black'>", http_img_rien(1,200), "</td>";
357
 
358
			// Presentation graphique
359
			while (list($key, $value) = each($log)) {
360
 
361
				$test_agreg ++;
362
 
363
				if ($test_agreg == $agreg) {
364
 
365
				$test_agreg = 0;
366
				$n++;
367
 
368
				if ($decal == 30) $decal = 0;
369
				$decal ++;
370
				$tab_moyenne[$decal] = $value;
371
 
372
				// Inserer des jours vides si pas d'entrees
373
				if ($jour_prec > 0) {
374
					$ecart = floor(($key-$jour_prec)/((3600*24)*$agreg)-1);
375
 
376
					for ($i=0; $i < $ecart; $i++){
377
						if ($decal == 30) $decal = 0;
378
						$decal ++;
379
						$tab_moyenne[$decal] = $value;
380
 
381
						$ce_jour=date("Y-m-d", $jour_prec+(3600*24*($i+1)));
382
						$jour = nom_jour($ce_jour).' '.affdate_jourcourt($ce_jour);
383
 
384
						reset($tab_moyenne);
385
						$moyenne = 0;
386
						while (list(,$val_tab) = each($tab_moyenne))
387
							$moyenne += $val_tab;
388
						$moyenne = $moyenne / count($tab_moyenne);
389
 
390
						$hauteur_moyenne = round(($moyenne) * $rapport) - 1;
391
						echo "<td valign='bottom' width=$largeur>";
392
						$difference = ($hauteur_moyenne) -1;
393
						$moyenne = round($moyenne,2); // Pour affichage harmonieux
394
						$tagtitle= attribut_html(supprimer_tags("$jour | "
395
						._T('info_visites')." | "
396
						._T('info_moyenne')." $moyenne"));
397
						if ($difference > 0) {
398
						  echo http_img_rien($largeur,1, 'background-color:#333333;', $tagtitle);
399
						  echo http_img_rien($largeur, $hauteur_moyenne, '', $tagtitle);
400
						}
401
						echo
402
						    http_img_rien($largeur,1,'background-color:black;', $tagtitle);
403
						echo "</td>";
404
						$n++;
405
					}
406
				}
407
 
408
				$ce_jour=date("Y-m-d", $key);
409
				$jour = nom_jour($ce_jour).' '.affdate_jourcourt($ce_jour);
410
 
411
				$total_loc = $total_loc + $value;
412
				reset($tab_moyenne);
413
 
414
				$moyenne = 0;
415
				while (list(,$val_tab) = each($tab_moyenne))
416
					$moyenne += $val_tab;
417
				$moyenne = $moyenne / count($tab_moyenne);
418
 
419
				$hauteur_moyenne = round($moyenne * $rapport) - 1;
420
				$hauteur = round($value * $rapport) - 1;
421
				$moyenne = round($moyenne,2); // Pour affichage harmonieux
422
				echo "<td valign='bottom' width=$largeur>";
423
 
424
				$tagtitle= attribut_html(supprimer_tags("$jour | "
425
				._T('info_visites')." ".$value));
426
 
427
				if ($hauteur > 0){
428
					if ($hauteur_moyenne > $hauteur) {
429
						$difference = ($hauteur_moyenne - $hauteur) -1;
430
						echo http_img_rien($largeur, 1,'background-color:#333333;',$tagtitle);
431
						echo http_img_rien($largeur, $difference, '', $tagtitle);
432
						echo http_img_rien($largeur,1, "background-color:$couleur_foncee;", $tagtitle);
433
						if (date("w",$key) == "0") // Dimanche en couleur foncee
434
						  echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle);
435
						else
436
						  echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle);
437
					} else if ($hauteur_moyenne < $hauteur) {
438
						$difference = ($hauteur - $hauteur_moyenne) -1;
439
						echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle);
440
						if (date("w",$key) == "0") // Dimanche en couleur foncee
441
							$couleur =  $couleur_foncee;
442
						else
443
							$couleur = $couleur_claire;
444
						echo http_img_rien($largeur, $difference, "background-color:$couleur;", $tagtitle);
445
						echo http_img_rien($largeur,1,"background-color:#333333;", $tagtitle);
446
						echo http_img_rien($largeur, $hauteur_moyenne, "background-color:$couleur;", $tagtitle);
447
					} else {
448
					  echo http_img_rien($largeur, 1, "background-color:$couleur_foncee;", $tagtitle);
449
						if (date("w",$key) == "0") // Dimanche en couleur foncee
450
						  echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle);
451
						else
452
						  echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle);
453
					}
454
				}
455
				echo http_img_rien($largeur, 1, 'background-color:black;', $tagtitle);
456
				echo "</td>\n";
457
 
458
				$jour_prec = $key;
459
				$val_prec = $value;
460
			}
461
			}
462
 
463
			// Dernier jour
464
			$hauteur = round($visites_today * $rapport)	- 1;
465
			$total_absolu = $total_absolu + $visites_today;
466
			echo "<td valign='bottom' width=$largeur>";
467
			if ($hauteur > 0){
468
			  echo http_img_rien($largeur, 1, "background-color:$couleur_foncee;");
469
 
470
				// prevision de visites jusqu'a minuit
471
				// basee sur la moyenne (site) ou popularite (article)
472
				if (! $id_article) $val_popularite = $moyenne;
473
				$prevision = (1 - (date("H")*60 - date("i"))/(24*60)) * $val_popularite;
474
				$hauteurprevision = ceil($prevision * $rapport);
475
				$prevision = round($prevision,0)+$visites_today; // Pour affichage harmonieux
476
				$tagtitle= attribut_html(supprimer_tags(_T('info_aujourdhui')." $visites_today &rarr; $prevision"));
477
				echo http_img_rien($largeur, $hauteurprevision,'background-color:#eeeeee;', $tagtitle);
478
 
479
				echo http_img_rien($largeur, $hauteur, 'background-color:#cccccc;', $tagtitle);
480
			}
481
			echo http_img_rien($largeur, 1, 'background-color:black;');
482
			echo "</td>";
483
 
484
			echo "<td bgcolor='black'>",http_img_rien(1, 1),"</td>";
485
			echo "</tr></table>";
486
			echo "</td>",
487
			  "<td background='", _DIR_IMG_PACK, "fond-stats.gif' valign='bottom'>", http_img_rien(3, 1, 'background-color:black;'),"</td>";
488
			echo "<td>", http_img_rien(5, 1),"</td>";
489
			echo "<td valign='top'><font face='Verdana,Arial,Sans,sans-serif' size=2>";
490
			echo "<table cellpadding=0 cellspacing=0 border=0>";
491
			echo "<tr><td height=15 valign='top'>";
492
			echo "<font face='arial,helvetica,sans-serif' size=1><b>".round($maxgraph)."</b></font>";
493
			echo "</td></tr>";
494
			echo "<tr><td height=25 valign='middle'>";
495
			echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(7*($maxgraph/8))."</font>";
496
			echo "</td></tr>";
497
			echo "<tr><td height=25 valign='middle'>";
498
			echo "<font face='arial,helvetica,sans-serif' size=1>".round(3*($maxgraph/4))."</font>";
499
			echo "</td></tr>";
500
			echo "<tr><td height=25 valign='middle'>";
501
			echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(5*($maxgraph/8))."</font>";
502
			echo "</td></tr>";
503
			echo "<tr><td height=25 valign='middle'>";
504
			echo "<font face='arial,helvetica,sans-serif' size=1><b>".round($maxgraph/2)."</b></font>";
505
			echo "</td></tr>";
506
			echo "<tr><td height=25 valign='middle'>";
507
			echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(3*($maxgraph/8))."</font>";
508
			echo "</td></tr>";
509
			echo "<tr><td height=25 valign='middle'>";
510
			echo "<font face='arial,helvetica,sans-serif' size=1>".round($maxgraph/4)."</font>";
511
			echo "</td></tr>";
512
			echo "<tr><td height=25 valign='middle'>";
513
			echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(1*($maxgraph/8))."</font>";
514
			echo "</td></tr>";
515
			echo "<tr><td height=10 valign='bottom'>";
516
			echo "<font face='arial,helvetica,sans-serif' size=1><b>0</b></font>";
517
			echo "</td>";
518
 
519
 
520
			echo "</table>";
521
			echo "</font></td>";
522
			echo "</td></tr></table>";
523
 
524
			echo "<div style='position: relative; height: 15px;'>";
525
			$gauche_prec = -50;
526
			for ($jour = $date_debut; $jour <= $date_today; $jour = $jour + (24*3600)) {
527
				$ce_jour = date("d", $jour);
528
 
529
				if ($ce_jour == "1") {
530
					$afficher = nom_mois(date("Y-m-d", $jour));
531
					if (date("m", $jour) == 1) $afficher = "<b>".annee(date("Y-m-d", $jour))."</b>";
532
 
533
 
534
					$gauche = ($jour - $date_debut) * $largeur / ((24*3600)*$agreg);
535
 
536
					if ($gauche - $gauche_prec >= 40 OR date("m", $jour) == 1) {
537
						echo "<div class='arial0' style='border-$spip_lang_left: 1px solid black; padding-$spip_lang_left: 2px; padding-top: 3px; position: absolute; $spip_lang_left: ".$gauche."px; top: -1px;'>".$afficher."</div>";
538
						$gauche_prec = $gauche;
539
					}
540
				}
541
			}
542
			echo "</div>";
543
 
544
		//}
545
 
546
		// cette ligne donne la moyenne depuis le debut
547
		// (desactive au profit de la moeynne "glissante")
548
		# $moyenne =  round($total_absolu / ((date("U")-$date_premier)/(3600*24)));
549
 
550
		echo "<font face='arial,helvetica,sans-serif' size=1>"._T('texte_statistiques_visites')."</font>";
551
		echo "<p><table cellpadding=0 cellspacing=0 border=0 width='100%'><tr width='100%'>";
552
		echo "<td valign='top' width='33%'><font face='Verdana,Arial,Sans,sans-serif'>";
553
		echo _T('info_maximum')." ".$max;
554
		echo "<br>"._T('info_moyenne')." ".round($moyenne);
555
		echo "</td>";
556
		echo "<td valign='top' width='33%'><font face='Verdana,Arial,Sans,sans-serif'>";
557
		echo _T('info_aujourdhui').' '.$visites_today;
558
		if ($val_prec > 0) echo "<br>"._T('info_hier').' '.$val_prec;
559
		if ($id_article) echo "<br>"._T('info_popularite_5').' '.$val_popularite;
560
 
561
		echo "</td>";
562
		echo "<td valign='top' width='33%'><font face='Verdana,Arial,Sans,sans-serif'>";
563
		echo "<b>"._T('info_total')." ".$total_absolu."</b>";
564
 
565
		if ($id_article) {
566
			if ($classement[$id_article] > 0) {
567
				if ($classement[$id_article] == 1)
568
				      $ch = _T('info_classement_1', array('liste' => $liste));
569
				else
570
				      $ch = _T('info_classement_2', array('liste' => $liste));
571
				echo "<br>".$classement[$id_article].$ch;
572
			}
573
		} else {
574
			echo "<font size=1>";
575
			echo "<br>"._T('info_popularite_2')." ";
576
			echo ceil(lire_meta('popularite_total'));
577
			echo "</font>";
578
		}
579
		echo "</td></tr></table>";
580
	}
581
 
582
	if (count($log) > 60) {
583
		echo "<p>";
584
		echo "<font face='verdana,arial,helvetica,sans-serif' size='2'><b>"._T('info_visites_par_mois')."</b></font>";
585
 
586
		echo "<div align='left'>";
587
		///////// Affichage par mois
588
		$query="SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(date),'%Y-%m') AS date_unix, SUM(visites) AS total_visites  FROM $table ".
589
			"WHERE $where AND date > DATE_SUB(NOW(),INTERVAL 2700 DAY) GROUP BY date_unix ORDER BY date";
590
		$result=spip_query($query);
591
 
592
		$i = 0;
593
		while ($row = spip_fetch_array($result)) {
594
			$date = $row['date_unix'];
595
			$visites = $row['total_visites'];
596
			$i++;
597
			$entrees["$date"] = $visites;
598
		}
599
 
600
		if (count($entrees)>0){
601
 
602
			$max = max($entrees);
603
			$maxgraph = maxgraph($max);
604
			$rapport = 200/$maxgraph;
605
 
606
			$largeur = floor(420 / (count($entrees)));
607
			if ($largeur < 1) $largeur = 1;
608
			if ($largeur > 50) $largeur = 50;
609
		}
610
 
611
		echo "<table cellpadding=0 cellspacing=0 border=0><tr>",
612
		  "<td background='", _DIR_IMG_PACK, "fond-stats.gif'>";
613
		echo "<table cellpadding=0 cellspacing=0 border=0><tr>";
614
		echo "<td bgcolor='black'>", http_img_rien(1, 200),"</td>";
615
 
616
		// Presentation graphique
617
		$n = 0;
618
		$decal = 0;
619
		$tab_moyenne = "";
620
 
621
		while (list($key, $value) = each($entrees)) {
622
			$n++;
623
 
624
			$mois = affdate_mois_annee($key);
625
 
626
			if ($decal == 30) $decal = 0;
627
			$decal ++;
628
			$tab_moyenne[$decal] = $value;
629
 
630
			$total_loc = $total_loc + $value;
631
			reset($tab_moyenne);
632
 
633
			$moyenne = 0;
634
			while (list(,$val_tab) = each($tab_moyenne))
635
				$moyenne += $val_tab;
636
			$moyenne = $moyenne / count($tab_moyenne);
637
 
638
			$hauteur_moyenne = round($moyenne * $rapport) - 1;
639
			$hauteur = round($value * $rapport) - 1;
640
			echo "<td valign='bottom' width=$largeur>";
641
 
642
			$tagtitle= attribut_html(supprimer_tags("$mois | "
643
			._T('info_visites')." ".$value));
644
 
645
			if ($hauteur > 0){
646
				if ($hauteur_moyenne > $hauteur) {
647
					$difference = ($hauteur_moyenne - $hauteur) -1;
648
					echo http_img_rien($largeur, 1, 'background-color:#333333;');
649
					echo http_img_rien($largeur, $difference, '', $tagtitle);
650
					echo http_img_rien($largeur,1,"background-color:$couleur_foncee;");
651
					if (ereg("-01",$key)){ // janvier en couleur foncee
652
					  echo http_img_rien($largeur,$hauteur,"background-color:$couleur_foncee;", $tagtitle);
653
					}
654
					else {
655
					  echo http_img_rien($largeur,$hauteur,"background-color:$couleur_claire;", $tagtitle);
656
					}
657
				}
658
				else if ($hauteur_moyenne < $hauteur) {
659
					$difference = ($hauteur - $hauteur_moyenne) -1;
660
					echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle);
661
					if (ereg("-01",$key)){ // janvier en couleur foncee
662
						$couleur =  $couleur_foncee;
663
					}
664
					else {
665
						$couleur = $couleur_claire;
666
					}
667
					echo http_img_rien($largeur,$difference, "background-color:$couleur;", $tagtitle);
668
					echo http_img_rien($largeur,1,'background-color:#333333;',$tagtitle);
669
					echo http_img_rien($largeur,$hauteur_moyenne,"background-color:$couleur;", $tagtitle);
670
				}
671
				else {
672
				  echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle);
673
					if (ereg("-01",$key)){ // janvier en couleur foncee
674
					  echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle);
675
					}
676
					else {
677
					  echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle);
678
					}
679
				}
680
			}
681
			echo http_img_rien($largeur,1,'background-color:black;', $tagtitle);
682
			echo "</td>\n";
683
 
684
			$jour_prec = $key;
685
			$val_prec = $value;
686
		}
687
 
688
		echo "<td bgcolor='black'>", http_img_rien(1, 1),"</td>";
689
		echo "</tr></table>";
690
		echo "</td>",
691
		  "<td background='", _DIR_IMG_PACK, "fond-stats.gif' valign='bottom'>", http_img_rien(3, 1, 'background-color:black;'),"</td>";
692
		echo "<td>", http_img_rien(5, 1),"</td>";
693
		echo "<td valign='top'><font face='Verdana,Arial,Sans,sans-serif' size=2>";
694
		echo "<table cellpadding=0 cellspacing=0 border=0>";
695
		echo "<tr><td height=15 valign='top'>";
696
		echo "<font face='arial,helvetica,sans-serif' size=1><b>".round($maxgraph)."</b></font>";
697
		echo "</td></tr>";
698
		echo "<tr><td height=25 valign='middle'>";
699
		echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(7*($maxgraph/8))."</font>";
700
		echo "</td></tr>";
701
		echo "<tr><td height=25 valign='middle'>";
702
		echo "<font face='arial,helvetica,sans-serif' size=1>".round(3*($maxgraph/4))."</font>";
703
		echo "</td></tr>";
704
		echo "<tr><td height=25 valign='middle'>";
705
		echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(5*($maxgraph/8))."</font>";
706
		echo "</td></tr>";
707
		echo "<tr><td height=25 valign='middle'>";
708
		echo "<font face='arial,helvetica,sans-serif' size=1><b>".round($maxgraph/2)."</b></font>";
709
		echo "</td></tr>";
710
		echo "<tr><td height=25 valign='middle'>";
711
		echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(3*($maxgraph/8))."</font>";
712
		echo "</td></tr>";
713
		echo "<tr><td height=25 valign='middle'>";
714
		echo "<font face='arial,helvetica,sans-serif' size=1>".round($maxgraph/4)."</font>";
715
		echo "</td></tr>";
716
		echo "<tr><td height=25 valign='middle'>";
717
		echo "<font face='arial,helvetica,sans-serif' size=1 color='#999999'>".round(1*($maxgraph/8))."</font>";
718
		echo "</td></tr>";
719
		echo "<tr><td height=10 valign='bottom'>";
720
		echo "<font face='arial,helvetica,sans-serif' size=1><b>0</b></font>";
721
		echo "</td>";
722
 
723
		echo "</tr></table>";
724
		echo "</td></tr></table>";
725
		echo "</div>";
726
	}
727
 
728
	/////
729
 
730
	fin_cadre_relief();
731
 
732
}
733
 
734
 
735
 
736
//
737
// Affichage des referers
738
//
739
 
740
// nombre de referers a afficher
741
$limit = intval($limit);	//secu
742
if ($limit == 0)
743
	$limit = 100;
744
 
745
// afficher quels referers ?
746
$vis = "visites";
747
if ($origine) {
748
	$where = "visites_jour>0";
749
	$vis = "visites_jour";
750
	$table_ref = "spip_referers";
751
}
752
 
753
$query = "SELECT referer, $vis AS vis FROM $table_ref WHERE $where ORDER BY $vis DESC";
754
 
755
 
756
echo "<br><br><br>";
757
gros_titre(_T("onglet_origine_visites"));
758
 
759
echo "<p><font face='Verdana,Arial,Sans,sans-serif' size=2>";
760
echo aff_referers ($query, $limit);
761
echo "</font></p>";
762
 
763
echo "</font>";
764
 
765
fin_page();
766
 
767
?>