| [ Index ] |
|
Code source de SPIP 1.9.2c |
1 <?php 2 3 /***************************************************************************\ 4 * SPIP, Systeme de publication pour l'internet * 5 * * 6 * Copyright (c) 2001-2007 * 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 if (!defined("_ECRIRE_INC_VERSION")) return; 14 15 include_spip('inc/presentation'); 16 include_spip('inc/statistiques'); 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 // http://doc.spip.org/@maxgraph 23 function maxgraph($max) { 24 $max = max(10,$max); 25 $p = pow(10, strlen($max)-2); 26 $m = $max/$p; 27 foreach (array(100,80,60,40,20,16,12,10) as $l) 28 if ($m<=$l) $maxgraph = $l*$p; 29 return $maxgraph; 30 } 31 32 // http://doc.spip.org/@http_img_rien 33 function http_img_rien($width, $height, $style='', $title='') { 34 return http_img_pack('rien.gif', $title, 35 "width='$width' height='$height'" 36 . (!$style ? '' : (" style='$style'")) 37 . (!$title ? '' : (" title=\"$title\""))); 38 } 39 40 // pondre les stats sous forme d'un fichier csv tres basique 41 // http://doc.spip.org/@statistiques_csv 42 function statistiques_csv($id_article) { 43 if ($id = intval($id_article)) 44 $q = "SELECT date, visites FROM spip_visites_articles WHERE id_article=$id ORDER BY date"; 45 else 46 $q = "SELECT date, visites FROM spip_visites ORDER BY date"; 47 48 if (!autoriser('voirstats', $id ? 'article':'', $id)) exit; 49 50 51 $filename = 'stats_'.($id ? 'article'.$id : 'total').'.csv'; 52 header('Content-Type: text/csv'); 53 header('Content-Disposition: attachment; filename='.$filename); 54 55 $s = spip_query($q); 56 while ($t = spip_fetch_array($s)) { 57 echo $t['date'].";".$t['visites']."\n"; 58 } 59 } 60 61 // http://doc.spip.org/@exec_statistiques_visites_dist 62 function exec_statistiques_visites_dist() 63 { 64 global 65 $aff_jours, 66 $connect_statut, 67 $couleur_claire, 68 $couleur_foncee, 69 $id_article, 70 $limit, 71 $origine, 72 $spip_lang_left; 73 74 if (_request('format') == 'csv') 75 return statistiques_csv($id_article); 76 77 78 $GLOBALS['accepte_svg'] = flag_svg(); 79 80 81 $titre = $pourarticle = ""; 82 $style = "class='arial1 spip_x-small' style='color: #999999'"; 83 84 if ($id_article = intval($id_article)){ 85 $result = spip_query("SELECT titre, visites, popularite FROM spip_articles WHERE statut='publie' AND id_article=$id_article"); 86 87 88 if ($row = spip_fetch_array($result)) { 89 $titre = typo($row['titre']); 90 $total_absolu = $row['visites']; 91 $val_popularite = round($row['popularite']); 92 } 93 } 94 else { 95 $result = spip_query("SELECT SUM(visites) AS total_absolu FROM spip_visites"); 96 97 98 if ($row = spip_fetch_array($result)) { 99 $total_absolu = $row['total_absolu']; 100 } 101 } 102 103 104 if ($titre) $pourarticle = " "._T('info_pour')." « $titre »"; 105 106 if ($origine) { 107 $commencer_page = charger_fonction('commencer_page', 'inc'); 108 echo $commencer_page(_T('titre_page_statistiques_referers'), "statistiques_visites", "statistiques"); 109 echo "<br /><br />"; 110 gros_titre(_T('titre_liens_entrants')); 111 echo barre_onglets("statistiques", "referers"); 112 113 debut_gauche(); 114 debut_boite_info(); 115 echo "<p align='left' style='font-size:small;' class='verdana1'>"._T('info_gauche_statistiques_referers')."</p>"; 116 fin_boite_info(); 117 118 debut_droite(); 119 120 } 121 else { 122 $commencer_page = charger_fonction('commencer_page', 'inc'); 123 echo $commencer_page(_T('titre_page_statistiques_visites').$pourarticle, "statistiques_visites", "statistiques"); 124 echo "<br /><br />"; 125 gros_titre(_T('titre_evolution_visite')."<html>".aide("confstat")."</html>"); 126 // barre_onglets("statistiques", "evolution"); 127 if ($titre) gros_titre($titre); 128 129 debut_gauche(); 130 131 echo "<br />"; 132 133 echo "<div class='iconeoff' style='padding: 5px;'>"; 134 echo "<div style='font-size:small;' class='verdana1'>"; 135 echo typo(_T('info_afficher_visites')); 136 echo "<ul>"; 137 if ($id_article>0) { 138 echo "<li><b><a href='" . generer_url_ecrire("statistiques_visites","") . "'>"._T('info_tout_site')."</a></b></li>"; 139 } else { 140 echo "<li><b>"._T('titre_page_articles_tous')."</b></li>"; 141 } 142 143 echo "</ul>"; 144 echo "</div>"; 145 echo "</div>"; 146 147 148 // Par popularite 149 $articles_recents[] = "0"; 150 $result = spip_query("SELECT id_article FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY date DESC LIMIT 10"); 151 152 while ($row = spip_fetch_array($result)) { 153 $articles_recents[] = $row['id_article']; 154 } 155 $articles_recents = join($articles_recents, ","); 156 157 158 // Par popularite 159 $result = spip_query("SELECT id_article, titre, popularite, visites FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY popularite DESC"); 160 161 $nombre_articles = spip_num_rows($result); 162 if ($nombre_articles > 0) { 163 echo "<br />\n"; 164 echo "<div class='iconeoff' style='padding: 5px;'>\n"; 165 echo "<div style='font-size:small;' class='verdana1'>"; 166 echo typo(_T('info_visites_plus_populaires')); 167 $open = "<ol style='padding-left:40px; font-size:x-small;color:#666666;'>"; 168 echo $open; 169 $liste = 0; 170 while ($row = spip_fetch_array($result)) { 171 $titre = typo($row['titre']); 172 $l_article = $row['id_article']; 173 $visites = $row['visites']; 174 $popularite = round($row['popularite']); 175 $liste++; 176 $classement[$l_article] = $liste; 177 178 if ($liste <= 30) { 179 $articles_vus[] = $l_article; 180 181 if ($l_article == $id_article){ 182 echo "\n<li><b>$titre</b></li>"; 183 } else { 184 echo "\n<li><a href='" . generer_url_ecrire("statistiques_visites","id_article=$l_article") . "' title='"._T('info_popularite', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a></li>"; 185 } 186 } 187 } 188 $articles_vus = join($articles_vus, ","); 189 190 // Par popularite 191 $result_suite = spip_query("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"); 192 193 if (spip_num_rows($result_suite) > 0) { 194 echo "</ol><div style='text-align: center'>[...]</div>",$open; 195 while ($row = spip_fetch_array($result_suite)) { 196 $titre = typo($row['titre']); 197 $l_article = $row['id_article']; 198 $visites = $row['visites']; 199 $popularite = round($row['popularite']); 200 $numero = $classement[$l_article]; 201 202 if ($l_article == $id_article){ 203 echo "\n<li><b>$titre</b></li>"; 204 } else { 205 echo "\n<li><a href='" . generer_url_ecrire("statistiques_visites","id_article=$l_article") . "' title='"._T('info_popularite_3', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a></li>"; 206 } 207 } 208 } 209 210 echo "</ol>"; 211 212 echo "<b>"._T('info_comment_lire_tableau')."</b><br />"._T('texte_comment_lire_tableau'); 213 214 echo "</div>"; 215 echo "</div>"; 216 echo "</div>"; 217 } 218 219 220 // Par visites depuis le debut 221 $result = spip_query("SELECT id_article, titre, popularite, visites FROM spip_articles WHERE statut='publie' AND popularite > 0 ORDER BY visites DESC LIMIT 30"); 222 223 224 if (spip_num_rows($result) > 0) { 225 creer_colonne_droite(); 226 227 echo "<br /><div class='iconeoff' style='padding: 5px;'>"; 228 echo "<div style='font-size:small;overflow:hidden;' class='verdana1'>"; 229 echo typo(_T('info_affichier_visites_articles_plus_visites')); 230 echo "<ol style='padding-left:40px; font-size:x-small;color:#666666;'>"; 231 232 while ($row = spip_fetch_array($result)) { 233 $titre = typo($row['titre']); 234 $l_article = $row['id_article']; 235 $visites = $row['visites']; 236 $popularite = round($row['popularite']); 237 $numero = $classement[$l_article]; 238 239 if ($l_article == $id_article){ 240 echo "\n<li><b>$titre</b></li>"; 241 } else { 242 echo "\n<li><a href='" . generer_url_ecrire("statistiques_visites","id_article=$l_article") . "'\ntitle='"._T('info_popularite_4', array('popularite' => $popularite, 'visites' => $visites))."'>$titre</a></li>"; 243 } 244 } 245 echo "</ol>"; 246 echo "</div>"; 247 } 248 249 250 // 251 // Afficher les boutons de creation d'article et de breve 252 // 253 if ($connect_statut == '0minirezo') { 254 if ($id_article > 0) { 255 echo bloc_des_raccourcis(icone_horizontale(_T('icone_retour_article'), generer_url_ecrire("articles","id_article=$id_article"), "article-24.gif","rien.gif", false)); 256 } 257 } 258 259 260 261 debut_droite(); 262 } 263 264 265 266 if ($connect_statut != '0minirezo') { 267 echo _T('avis_non_acces_page'); 268 echo fin_gauche(), fin_page(); 269 exit; 270 } 271 272 273 ////// 274 275 if (!($aff_jours = intval($aff_jours))) $aff_jours = 105; 276 277 if (!$origine) { 278 279 if ($id_article) { 280 $table = "spip_visites_articles"; 281 $table_ref = "spip_referers_articles"; 282 $where = "id_article=$id_article"; 283 } else { 284 $table = "spip_visites"; 285 $table_ref = "spip_referers"; 286 $where = "0=0"; 287 } 288 289 $result = spip_query("SELECT UNIX_TIMESTAMP(date) AS date_unix FROM $table WHERE $where ORDER BY date LIMIT 1"); 290 291 while ($row = spip_fetch_array($result)) { 292 $date_premier = $row['date_unix']; 293 } 294 295 $result=spip_query("SELECT UNIX_TIMESTAMP(date) AS date_unix, visites FROM $table WHERE $where AND date > DATE_SUB(NOW(),INTERVAL $aff_jours DAY) ORDER BY date"); 296 297 $date_debut = ''; 298 $log = array(); 299 while ($row = spip_fetch_array($result)) { 300 $date = $row['date_unix']; 301 if (!$date_debut) $date_debut = $date; 302 $log[$date] = $row['visites']; 303 } 304 305 306 // S'il y a au moins cinq minutes de stats :-) 307 if (count($log)>0) { 308 // les visites du jour 309 $date_today = max(array_keys($log)); 310 $visites_today = $log[$date_today]; 311 // sauf s'il n'y en a pas : 312 if (time()-$date_today>3600*24) { 313 $date_today = time(); 314 $visites_today=0; 315 } 316 317 // le nombre maximum 318 $max = max($log); 319 $nb_jours = floor(($date_today-$date_debut)/(3600*24)); 320 321 $maxgraph = maxgraph($max); 322 $rapport = 200 / $maxgraph; 323 324 if (count($log) < 420) $largeur = floor(450 / ($nb_jours+1)); 325 if ($largeur < 1) { 326 $largeur = 1; 327 $agreg = ceil(count($log) / 420); 328 } else { 329 $agreg = 1; 330 } 331 if ($largeur > 50) $largeur = 50; 332 333 debut_cadre_relief("statistiques-24.gif"); 334 335 336 $largeur_abs = 420 / $aff_jours; 337 338 if ($largeur_abs > 1) { 339 $inc = ceil($largeur_abs / 5); 340 $aff_jours_plus = 420 / ($largeur_abs - $inc); 341 $aff_jours_moins = 420 / ($largeur_abs + $inc); 342 } 343 344 if ($largeur_abs == 1) { 345 $aff_jours_plus = 840; 346 $aff_jours_moins = 210; 347 } 348 349 if ($largeur_abs < 1) { 350 $aff_jours_plus = 420 * ((1/$largeur_abs) + 1); 351 $aff_jours_moins = 420 * ((1/$largeur_abs) - 1); 352 } 353 354 $pour_article = $id_article ? "&id_article=$id_article" : ''; 355 356 if ($date_premier < $date_debut) 357 echo http_href_img(generer_url_ecrire("statistiques_visites","aff_jours=$aff_jours_plus$pour_article"), 358 'loupe-moins.gif', 359 "style='border: 0px; vertical-align:center;'", 360 _T('info_zoom'). '-'), " "; 361 if ( (($date_today - $date_debut) / (24*3600)) > 30) 362 echo http_href_img(generer_url_ecrire("statistiques_visites","aff_jours=$aff_jours_moins$pour_article"), 363 'loupe-plus.gif', 364 "style='border: 0px; vertical-align:center;'", 365 _T('info_zoom'). '+'), " "; 366 367 368 if ($GLOBALS['accepte_svg']) { 369 echo "\n<div>"; 370 echo "<object data='", generer_url_ecrire('statistiques_svg',"id_article=$id_article&aff_jours=$aff_jours"), "' width='450' height='310' type='image/svg+xml'>"; 371 echo "<embed src='", generer_url_ecrire('statistiques_svg',"id_article=$id_article&aff_jours=$aff_jours"), "' width='450' height='310' type='image/svg+xml' />"; 372 echo "</object>"; 373 echo "\n</div>"; 374 $total_absolu = $total_absolu + $visites_today; 375 $test_agreg = $decal = $jour_prec = $val_prec = $total_loc =0; 376 foreach ($log as $key => $value) { 377 # quand on atteint aujourd'hui, stop 378 if ($key == $date_today) break; 379 $test_agreg ++; 380 if ($test_agreg == $agreg) { 381 $test_agreg = 0; 382 if ($decal == 30) $decal = 0; 383 $decal ++; 384 $tab_moyenne[$decal] = $value; 385 // Inserer des jours vides si pas d'entrees 386 if ($jour_prec > 0) { 387 $ecart = floor(($key-$jour_prec)/((3600*24)*$agreg)-1); 388 for ($i=0; $i < $ecart; $i++){ 389 if ($decal == 30) $decal = 0; 390 $decal ++; 391 $tab_moyenne[$decal] = $value; 392 reset($tab_moyenne); 393 $moyenne = 0; 394 while (list(,$val_tab) = each($tab_moyenne)) 395 $moyenne += $val_tab; 396 $moyenne = $moyenne / count($tab_moyenne); 397 $moyenne = round($moyenne,2); // Pour affichage harmonieux 398 } 399 } 400 $total_loc = $total_loc + $value; 401 reset($tab_moyenne); 402 403 $moyenne = 0; 404 while (list(,$val_tab) = each($tab_moyenne)) 405 $moyenne += $val_tab; 406 $moyenne = $moyenne / count($tab_moyenne); 407 $moyenne = round($moyenne,2); // Pour affichage harmonieux 408 $jour_prec = $key; 409 $val_prec = $value; 410 } 411 } 412 } else { 413 414 echo "<table cellpadding='0' cellspacing='0' border='0'><tr>", 415 "<td ".http_style_background("fond-stats.gif").">"; 416 echo "<table cellpadding='0' cellspacing='0' border='0'><tr>"; 417 418 echo "<td style='background-color: black'>", http_img_rien(1,200), "</td>"; 419 420 $test_agreg = $decal = $jour_prec = $val_prec = $total_loc =0; 421 422 // Presentation graphique (rq: on n'affiche pas le jour courant) 423 foreach ($log as $key => $value) { 424 # quand on atteint aujourd'hui, stop 425 if ($key == $date_today) break; 426 427 $test_agreg ++; 428 429 if ($test_agreg == $agreg) { 430 431 $test_agreg = 0; 432 433 if ($decal == 30) $decal = 0; 434 $decal ++; 435 $tab_moyenne[$decal] = $value; 436 // Inserer des jours vides si pas d'entrees 437 if ($jour_prec > 0) { 438 $ecart = floor(($key-$jour_prec)/((3600*24)*$agreg)-1); 439 440 for ($i=0; $i < $ecart; $i++){ 441 if ($decal == 30) $decal = 0; 442 $decal ++; 443 $tab_moyenne[$decal] = $value; 444 445 $ce_jour=date("Y-m-d", $jour_prec+(3600*24*($i+1))); 446 $jour = nom_jour($ce_jour).' '.affdate_jourcourt($ce_jour); 447 448 reset($tab_moyenne); 449 $moyenne = 0; 450 while (list(,$val_tab) = each($tab_moyenne)) 451 $moyenne += $val_tab; 452 $moyenne = $moyenne / count($tab_moyenne); 453 454 $hauteur_moyenne = round(($moyenne) * $rapport) - 1; 455 echo "<td valign='bottom' width='$largeur'>"; 456 $difference = ($hauteur_moyenne) -1; 457 $moyenne = round($moyenne,2); // Pour affichage harmonieux 458 $tagtitle= attribut_html(supprimer_tags("$jour | " 459 ._T('info_visites')." | " 460 ._T('info_moyenne')." $moyenne")); 461 if ($difference > 0) { 462 echo http_img_rien($largeur,1, 'background-color:#333333;', $tagtitle); 463 echo http_img_rien($largeur, $hauteur_moyenne, '', $tagtitle); 464 } 465 echo 466 http_img_rien($largeur,1,'background-color:black;', $tagtitle); 467 echo "</td>"; 468 } 469 } 470 471 $ce_jour=date("Y-m-d", $key); 472 $jour = nom_jour($ce_jour).' '.affdate_jourcourt($ce_jour); 473 474 $total_loc = $total_loc + $value; 475 reset($tab_moyenne); 476 477 $moyenne = 0; 478 while (list(,$val_tab) = each($tab_moyenne)) 479 $moyenne += $val_tab; 480 $moyenne = $moyenne / count($tab_moyenne); 481 482 $hauteur_moyenne = round($moyenne * $rapport) - 1; 483 $hauteur = round($value * $rapport) - 1; 484 $moyenne = round($moyenne,2); // Pour affichage harmonieux 485 echo "<td valign='bottom' width='$largeur'>"; 486 487 $tagtitle= attribut_html(supprimer_tags("$jour | " 488 ._T('info_visites')." ".$value)); 489 490 if ($hauteur > 0){ 491 if ($hauteur_moyenne > $hauteur) { 492 $difference = ($hauteur_moyenne - $hauteur) -1; 493 echo http_img_rien($largeur, 1,'background-color:#333333;',$tagtitle); 494 echo http_img_rien($largeur, $difference, '', $tagtitle); 495 echo http_img_rien($largeur,1, "background-color:$couleur_foncee;", $tagtitle); 496 if (date("w",$key) == "0") // Dimanche en couleur foncee 497 echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle); 498 else 499 echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle); 500 } else if ($hauteur_moyenne < $hauteur) { 501 $difference = ($hauteur - $hauteur_moyenne) -1; 502 echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle); 503 if (date("w",$key) == "0") // Dimanche en couleur foncee 504 $couleur = $couleur_foncee; 505 else 506 $couleur = $couleur_claire; 507 echo http_img_rien($largeur, $difference, "background-color:$couleur;", $tagtitle); 508 echo http_img_rien($largeur,1,"background-color:#333333;", $tagtitle); 509 echo http_img_rien($largeur, $hauteur_moyenne, "background-color:$couleur;", $tagtitle); 510 } else { 511 echo http_img_rien($largeur, 1, "background-color:$couleur_foncee;", $tagtitle); 512 if (date("w",$key) == "0") // Dimanche en couleur foncee 513 echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle); 514 else 515 echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle); 516 } 517 } 518 echo http_img_rien($largeur, 1, 'background-color:black;', $tagtitle); 519 echo "</td>\n"; 520 521 $jour_prec = $key; 522 $val_prec = $value; 523 } 524 } 525 526 // Dernier jour 527 $hauteur = round($visites_today * $rapport) - 1; 528 $total_absolu = $total_absolu + $visites_today; 529 echo "<td valign='bottom' width='$largeur'>"; 530 // prevision de visites jusqu'a minuit 531 // basee sur la moyenne (site) ou popularite (article) 532 if (! $id_article) $val_popularite = $moyenne; 533 $prevision = (1 - (date("H")*60 + date("i"))/(24*60)) * $val_popularite; 534 $hauteurprevision = ceil($prevision * $rapport); 535 // Afficher la barre tout en haut 536 if ($hauteur+$hauteurprevision>0) 537 echo http_img_rien($largeur, 1, "background-color:$couleur_foncee;"); 538 // preparer le texte de survol (prevision) 539 $tagtitle= attribut_html(supprimer_tags(_T('info_aujourdhui')." $visites_today → ".(round($prevision,0)+$visites_today))); 540 // afficher la barre previsionnelle 541 if ($hauteurprevision>0) 542 echo http_img_rien($largeur, $hauteurprevision,'background-color:#eeeeee;', $tagtitle); 543 // afficher la barre deja realisee 544 if ($hauteur>0) 545 echo http_img_rien($largeur, $hauteur, 'background-color:#cccccc;', $tagtitle); 546 // et afficher la ligne de base 547 echo http_img_rien($largeur, 1, 'background-color:black;'); 548 echo "</td>"; 549 550 551 echo "<td style='background-color: black'>",http_img_rien(1, 1),"</td>"; 552 echo "</tr></table>"; 553 echo "</td>", 554 "<td ".http_style_background("fond-stats.gif")." valign='bottom'>", http_img_rien(3, 1, 'background-color:black;'),"</td>"; 555 echo "<td>", http_img_rien(5, 1),"</td>"; 556 echo "<td valign='top'><div style='font-size:small;' class='verdana1'>"; 557 echo "<table cellpadding='0' cellspacing='0' border='0'>"; 558 echo "<tr><td height='15' valign='top'>"; 559 echo "<span class='arial1 spip_x-small'><b>".round($maxgraph)."</b></span>"; 560 echo "</td></tr>"; 561 echo "<tr><td height='25' valign='middle' $style>"; 562 echo round(7*($maxgraph/8)); 563 echo "</td></tr>"; 564 echo "<tr><td height='25' valign='middle'>"; 565 echo "<span class='arial1 spip_x-small'>".round(3*($maxgraph/4))."</span>"; 566 echo "</td></tr>"; 567 echo "<tr><td height='25' valign='middle' $style>"; 568 echo round(5*($maxgraph/8)); 569 echo "</td></tr>"; 570 echo "<tr><td height='25' valign='middle'>"; 571 echo "<span class='arial1 spip_x-small'><b>".round($maxgraph/2)."</b></span>"; 572 echo "</td></tr>"; 573 echo "<tr><td height='25' valign='middle' $style>"; 574 echo round(3*($maxgraph/8)); 575 echo "</td></tr>"; 576 echo "<tr><td height='25' valign='middle'>"; 577 echo "<span class='arial1 spip_x-small'>".round($maxgraph/4)."</span>"; 578 echo "</td></tr>"; 579 echo "<tr><td height='25' valign='middle' $style>"; 580 echo round(1*($maxgraph/8)); 581 echo "</td></tr>"; 582 echo "<tr><td height='10' valign='bottom'>"; 583 echo "<span class='arial1 spip_x-small'><b>0</b></span>"; 584 echo "</td>"; 585 586 587 echo "</tr></table>"; 588 echo "</div></td>"; 589 echo "</tr></table>"; 590 591 echo "<div style='position: relative; height: 15px;'>"; 592 $gauche_prec = -50; 593 for ($jour = $date_debut; $jour <= $date_today; $jour = $jour + (24*3600)) { 594 $ce_jour = date("d", $jour); 595 596 if ($ce_jour == "1") { 597 $afficher = nom_mois(date("Y-m-d", $jour)); 598 if (date("m", $jour) == 1) $afficher = "<b>".annee(date("Y-m-d", $jour))."</b>"; 599 600 601 $gauche = ($jour - $date_debut) * $largeur / ((24*3600)*$agreg); 602 603 if ($gauche - $gauche_prec >= 40 OR date("m", $jour) == 1) { 604 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>"; 605 $gauche_prec = $gauche; 606 } 607 } 608 } 609 echo "</div>"; 610 } 611 //} 612 613 // cette ligne donne la moyenne depuis le debut 614 // (desactive au profit de la moeynne "glissante") 615 # $moyenne = round($total_absolu / ((date("U")-$date_premier)/(3600*24))); 616 617 echo "<span class='arial1 spip_x-small'>"._T('texte_statistiques_visites')."</span>"; 618 echo "<br /><table cellpadding='0' cellspacing='0' border='0' width='100%'><tr style='width:100%;'>"; 619 echo "<td valign='top' style='width: 33%; ' class='verdana1'>", _T('info_maximum')." ".$max, "<br />"._T('info_moyenne')." ".round($moyenne), "</td>"; 620 echo "<td valign='top' style='width: 33%; ' class='verdana1'>"; 621 echo '<a href="' . generer_url_ecrire("statistiques_referers","").'" title="'._T('titre_liens_entrants').'">'._T('info_aujourdhui').'</a> '.$visites_today; 622 if ($val_prec > 0) echo '<br /><a href="' . generer_url_ecrire("statistiques_referers","jour=veille").'" title="'._T('titre_liens_entrants').'">'._T('info_hier').'</a> '.$val_prec; 623 if ($id_article) echo "<br />"._T('info_popularite_5').' '.$val_popularite; 624 625 echo "</td>"; 626 echo "<td valign='top' style='width: 33%; ' class='verdana1'>"; 627 echo "<b>"._T('info_total')." ".$total_absolu."</b>"; 628 629 if ($id_article) { 630 if ($classement[$id_article] > 0) { 631 if ($classement[$id_article] == 1) 632 $ch = _T('info_classement_1', array('liste' => $liste)); 633 else 634 $ch = _T('info_classement_2', array('liste' => $liste)); 635 echo "<br />".$classement[$id_article].$ch; 636 } 637 } else { 638 echo "<span class='spip_x-small'><br />"._T('info_popularite_2')." ", ceil($GLOBALS['meta']['popularite_total']), "</span>"; 639 } 640 echo "</td></tr></table>"; 641 } 642 643 if (count($log) > 60) { 644 echo "<br />"; 645 echo "<span class='verdana1 spip_small'><b>"._T('info_visites_par_mois')."</b></span>"; 646 647 echo "<div align='left'>"; 648 ///////// Affichage par mois 649 $result=spip_query("SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(date),'%Y-%m') AS date_unix, SUM(visites) AS total_visites FROM $table WHERE $where AND date > DATE_SUB(NOW(),INTERVAL 2700 DAY) GROUP BY date_unix ORDER BY date"); 650 651 652 $i = 0; 653 while ($row = spip_fetch_array($result)) { 654 $date = $row['date_unix']; 655 $visites = $row['total_visites']; 656 $i++; 657 $entrees["$date"] = $visites; 658 } 659 660 if (count($entrees)>0){ 661 662 $max = max($entrees); 663 $maxgraph = maxgraph($max); 664 $rapport = 200/$maxgraph; 665 666 $largeur = floor(420 / (count($entrees))); 667 if ($largeur < 1) $largeur = 1; 668 if ($largeur > 50) $largeur = 50; 669 } 670 671 echo "<table cellpadding='0' cellspacing='0' border='0'><tr>", 672 "<td ".http_style_background("fond-stats.gif").">"; 673 echo "<table cellpadding='0' cellspacing='0' border='0'><tr>"; 674 echo "<td style='background-color: black'>", http_img_rien(1, 200),"</td>"; 675 676 // Presentation graphique 677 $decal = 0; 678 $tab_moyenne = ""; 679 680 while (list($key, $value) = each($entrees)) { 681 682 $mois = affdate_mois_annee($key); 683 684 if ($decal == 30) $decal = 0; 685 $decal ++; 686 $tab_moyenne[$decal] = $value; 687 688 $total_loc = $total_loc + $value; 689 reset($tab_moyenne); 690 691 $moyenne = 0; 692 while (list(,$val_tab) = each($tab_moyenne)) 693 $moyenne += $val_tab; 694 $moyenne = $moyenne / count($tab_moyenne); 695 696 $hauteur_moyenne = round($moyenne * $rapport) - 1; 697 $hauteur = round($value * $rapport) - 1; 698 echo "<td valign='bottom' width='$largeur'>"; 699 700 $tagtitle= attribut_html(supprimer_tags("$mois | " 701 ._T('info_visites')." ".$value)); 702 703 if ($hauteur > 0){ 704 if ($hauteur_moyenne > $hauteur) { 705 $difference = ($hauteur_moyenne - $hauteur) -1; 706 echo http_img_rien($largeur, 1, 'background-color:#333333;'); 707 echo http_img_rien($largeur, $difference, '', $tagtitle); 708 echo http_img_rien($largeur,1,"background-color:$couleur_foncee;"); 709 if (ereg("-01",$key)){ // janvier en couleur foncee 710 echo http_img_rien($largeur,$hauteur,"background-color:$couleur_foncee;", $tagtitle); 711 } 712 else { 713 echo http_img_rien($largeur,$hauteur,"background-color:$couleur_claire;", $tagtitle); 714 } 715 } 716 else if ($hauteur_moyenne < $hauteur) { 717 $difference = ($hauteur - $hauteur_moyenne) -1; 718 echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle); 719 if (ereg("-01",$key)){ // janvier en couleur foncee 720 $couleur = $couleur_foncee; 721 } 722 else { 723 $couleur = $couleur_claire; 724 } 725 echo http_img_rien($largeur,$difference, "background-color:$couleur;", $tagtitle); 726 echo http_img_rien($largeur,1,'background-color:#333333;',$tagtitle); 727 echo http_img_rien($largeur,$hauteur_moyenne,"background-color:$couleur;", $tagtitle); 728 } 729 else { 730 echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle); 731 if (ereg("-01",$key)){ // janvier en couleur foncee 732 echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle); 733 } 734 else { 735 echo http_img_rien($largeur,$hauteur, "background-color:$couleur_claire;", $tagtitle); 736 } 737 } 738 } 739 echo http_img_rien($largeur,1,'background-color:black;', $tagtitle); 740 echo "</td>\n"; 741 } 742 743 echo "<td style='background-color: black'>", http_img_rien(1, 1),"</td>"; 744 echo "</tr></table>"; 745 echo "</td>", 746 "<td ".http_style_background("fond-stats.gif")." valign='bottom'>", http_img_rien(3, 1, 'background-color:black;'),"</td>"; 747 echo "<td>", http_img_rien(5, 1),"</td>"; 748 echo "<td valign='top'><div style='font-size:small;' class='verdana1'>"; 749 echo "<table cellpadding='0' cellspacing='0' border='0'>"; 750 echo "<tr><td height='15' valign='top'>"; 751 echo "<span class='arial1 spip_x-small'><b>".round($maxgraph)."</b></span>"; 752 echo "</td></tr>"; 753 echo "<tr><td height='25' valign='middle' $style>"; 754 echo round(7*($maxgraph/8)); 755 echo "</td></tr>"; 756 echo "<tr><td height='25' valign='middle'>"; 757 echo "<span class='arial1 spip_x-small'>".round(3*($maxgraph/4))."</span>"; 758 echo "</td></tr>"; 759 echo "<tr><td height='25' valign='middle' $style>"; 760 echo round(5*($maxgraph/8)); 761 echo "</td></tr>"; 762 echo "<tr><td height='25' valign='middle'>"; 763 echo "<span class='arial1 spip_x-small'><b>".round($maxgraph/2)."</b></span>"; 764 echo "</td></tr>"; 765 echo "<tr><td height='25' valign='middle' $style>"; 766 echo round(3*($maxgraph/8)); 767 echo "</td></tr>"; 768 echo "<tr><td height='25' valign='middle'>"; 769 echo "<span class='arial1 spip_x-small'>".round($maxgraph/4)."</span>"; 770 echo "</td></tr>"; 771 echo "<tr><td height='25' valign='middle' $style>"; 772 echo round(1*($maxgraph/8)); 773 echo "</td></tr>"; 774 echo "<tr><td height='10' valign='bottom'>"; 775 echo "<span class='arial1 spip_x-small'><b>0</b></span>"; 776 echo "</td>"; 777 778 echo "</tr></table>"; 779 echo "</div></td></tr></table>"; 780 echo "</div>"; 781 } 782 783 ///// 784 785 fin_cadre_relief(); 786 787 788 // Le bouton pour passer de svg a htm 789 if ($GLOBALS['accepte_svg']) { 790 $lien = 'non'; $alter = 'HTML'; 791 } else { 792 $lien = 'oui'; $alter = 'SVG'; 793 } 794 echo "\n<div align='".$GLOBALS['spip_lang_right']."' style='font-size:x-small;' class='verdana1'> 795 <a href='". 796 parametre_url(self(), 'var_svg', $lien)."'>$alter</a> | <a href='". 797 parametre_url(self(), 'format', 'csv')."'>CSV</a>". 798 "</div>\n"; 799 800 } 801 802 803 804 // 805 // Affichage des referers 806 // 807 808 // nombre de referers a afficher 809 $limit = intval($limit); //secu 810 if ($limit == 0) 811 $limit = 100; 812 813 // afficher quels referers ? 814 $vis = "visites"; 815 if ($origine) { 816 $where = "visites_jour>0"; 817 $vis = "visites_jour"; 818 $table_ref = "spip_referers"; 819 } 820 821 822 $result = spip_query("SELECT referer, $vis AS vis FROM $table_ref WHERE $where ORDER BY vis DESC LIMIT $limit"); 823 824 825 echo "<br /><br /><br />"; 826 gros_titre(_T("onglet_origine_visites")); 827 828 echo "<div style='font-size:small;overflow:hidden;' class='verdana1'><br />"; 829 echo aff_referers ($result, $limit, generer_url_ecrire('statistiques_visites', ('limit=' . strval($limit+200)))); 830 echo "<br /></div>"; 831 832 echo fin_gauche(), fin_page(); 833 } 834 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Wed Nov 21 10:20:27 2007 | par Balluche grâce à PHPXref 0.7 |
|