[ Index ] |
|
Code source de SPIP 1.8.3 |
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_charsets.php3"); 16 17 // Gestion d'expiration de ce jaja 18 $date = date("U"); 19 $expire = $date + 2 * 3600; 20 $headers_only = http_last_modified($expire); 21 22 $date = gmdate("D, d M Y H:i:s", $date); 23 $expire = gmdate("D, d M Y H:i:s", $expire); 24 @Header ("Content-Type: text/javascript"); 25 if ($headers_only) exit; 26 @Header ("Last-Modified: ".$date." GMT"); 27 @Header ("Expires: ".$expire." GMT"); 28 29 30 31 32 if ($connect_statut != '0minirezo') { 33 echo _T('avis_non_acces_page'); 34 fin_page(); 35 exit; 36 } 37 38 39 header("Content-type: image/svg+xml"); 40 echo "<?xml version=\"1.0\" standalone=\"no\"?>"; 41 42 ?> 43 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 44 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> 45 <svg width="450" height="310" x="0" y="0"> 46 47 48 <defs> 49 <linearGradient id="orange_red" x1="0%" y1="0%" x2="0%" y2="150%"> 50 <stop offset="0%" style="stop-color:rgb(255,255,0); stop-opacity:1"/> 51 <stop offset="100%" style="stop-color:rgb(255,0,0); stop-opacity:1"/> 52 </linearGradient> 53 </defs> 54 <?php 55 echo "<defs>\n"; 56 echo '<linearGradient id="claire" x1="0%" y1="0%" x2="0%" y2="100%">'; 57 echo '<stop offset="0%" style="stop-color:'.$couleur_claire.'; stop-opacity:0.3"/>'; 58 echo '<stop offset="100%" style="stop-color:'.$couleur_foncee.'; stop-opacity:1"/>'; 59 echo "</linearGradient>\n"; 60 echo "</defs>\n"; 61 62 echo "<style type='text/css'>\n"; 63 echo ".gris {fill: #aaaaaa; fill-opacity: 0.2;}\n"; 64 echo ".trait {stroke:black;stroke-width:1;}\n"; 65 echo "</style>\n"; 66 67 68 69 if (!$aff_jours) $aff_jours = 105; 70 if ($id_article) { 71 $table = "spip_visites_articles"; 72 $table_ref = "spip_referers_articles"; 73 $where = "id_article=$id_article"; 74 } else { 75 $table = "spip_visites"; 76 $table_ref = "spip_referers"; 77 $where = "1"; 78 } 79 80 // Recuperer premier jour 81 $query="SELECT UNIX_TIMESTAMP(date) AS date_unix FROM $table ". 82 "WHERE $where ORDER BY date LIMIT 0,1"; 83 $result = spip_query($query); 84 while ($row = spip_fetch_array($result)) { 85 $date_premier = $row['date_unix']; 86 } 87 88 // Recuperer toutes visites 89 $query="SELECT UNIX_TIMESTAMP(date) AS date_unix, visites FROM $table ". 90 "WHERE $where AND date > DATE_SUB(NOW(),INTERVAL $aff_jours DAY) ORDER BY date"; 91 $result=spip_query($query); 92 93 while ($row = spip_fetch_array($result)) { 94 $date = $row['date_unix']; 95 $visites = $row['visites']; 96 97 $log[$date] = $visites; 98 if ($i == 0) $date_debut = $date; 99 $i++; 100 } 101 102 103 104 if (count($log)>0) { 105 $max = max(max($log),$visites_today); 106 $date_today = time(); 107 $nb_jours = floor(($date_today-$date_debut)/(3600*24)); 108 109 $maxgraph = substr(ceil(substr($max,0,2) / 10)."000000000000", 0, strlen($max)); 110 111 if ($maxgraph < 10) $maxgraph = 10; 112 if (1.1 * $maxgraph < $max) $maxgraph.="0"; 113 if (0.8*$maxgraph > $max) $maxgraph = 0.8 * $maxgraph; 114 $rapport = 300 / $maxgraph; 115 116 if (count($log) < 420) $largeur = floor(420 / ($nb_jours+1)); 117 if ($largeur < 1) { 118 $largeur = 1; 119 $agreg = ceil(count($log) / 420); 120 } else { 121 $agreg = 1; 122 } 123 if ($largeur > 50) $largeur = 50; 124 125 $largeur_abs = 420 / $aff_jours; 126 127 if ($largeur_abs > 1) { 128 $inc = ceil($largeur_abs / 5); 129 $aff_jours_plus = 420 / ($largeur_abs - $inc); 130 $aff_jours_moins = 420 / ($largeur_abs + $inc); 131 } 132 133 if ($largeur_abs == 1) { 134 $aff_jours_plus = 840; 135 $aff_jour_moins = 210; 136 } 137 138 if ($largeur_abs < 1) { 139 $aff_jours_plus = 420 * ((1/$largeur_abs) + 1); 140 $aff_jours_moins = 420 * ((1/$largeur_abs) - 1); 141 } 142 143 144 echo "<line x1='0' y1='75' x2='".round($largeur*$nb_jours/$agreg)."' y2='75' style='stroke:#999999;stroke-width:1'/>\n"; 145 echo "<line x1='0' y1='150' x2='".round($largeur*$nb_jours/$agreg)."' y2='150' style='stroke:#999999;stroke-width:1'/>\n"; 146 echo "<line x1='0' y1='225' x2='".round($largeur*$nb_jours/$agreg)."' y2='225' style='stroke:#999999;stroke-width:1'/>\n"; 147 148 echo "<line x1='0' y1='37' x2='".round($largeur*$nb_jours/$agreg)."' y2='37' style='stroke:#eeeeee;stroke-width:1'/>\n"; 149 echo "<line x1='0' y1='112' x2='".round($largeur*$nb_jours/$agreg)."' y2='112' style='stroke:#eeeeee;stroke-width:1'/>\n"; 150 echo "<line x1='0' y1='187' x2='".round($largeur*$nb_jours/$agreg)."' y2='187' style='stroke:#eeeeee;stroke-width:1'/>\n"; 151 echo "<line x1='0' y1='262' x2='".round($largeur*$nb_jours/$agreg)."' y2='262' style='stroke:#eeeeee;stroke-width:1'/>\n"; 152 153 154 // Presentation graphique 155 while (list($key, $value) = each($log)) { 156 157 $test_agreg ++; 158 159 if ($test_agreg == $agreg) { 160 161 $test_agreg = 0; 162 $n++; 163 164 if ($decal == 30) $decal = 0; 165 $decal ++; 166 $tab_moyenne[$decal] = $value; 167 168 // Inserer des jours vides si pas d'entrees 169 if ($jour_prec > 0) { 170 $ecart = floor(($key-$jour_prec)/((3600*24)*$agreg)-1); 171 172 for ($i=0; $i < $ecart; $i++){ 173 if ($decal == 30) $decal = 0; 174 $decal ++; 175 $tab_moyenne[$decal] = $value; 176 177 $ce_jour=date("Y-m-d", $jour_prec+(3600*24*($i+1))); 178 $jour = nom_jour($ce_jour).' '.affdate_court($ce_jour); 179 180 reset($tab_moyenne); 181 $moyenne = 0; 182 while (list(,$val_tab) = each($tab_moyenne)) 183 $moyenne += $val_tab; 184 $moyenne = $moyenne / count($tab_moyenne); 185 186 // echo "<td valign='bottom' width=$largeur>"; 187 $difference = ($hauteur_moyenne) -1; 188 $moyenne = round($moyenne,2); // Pour affichage harmonieux 189 $hauteur_moyenne = round(($moyenne) * $rapport) - 1; 190 191 192 if ($hauteur_moyenne_prec > 0) { 193 echo "<polygon points = '".(($n-2)*$largeur+round($largeur/2)).",300 ".(($n-2)*$largeur+round($largeur/2)).",".(300-$hauteur_moyenne_prec)." ".(($n-1)*$largeur+round($largeur/2)).",".(300-$hauteur_moyenne)." ".(($n-1)*$largeur+round($largeur/2)).",300' class='gris' />\n"; 194 echo "<line x1='".(($n-2)*$largeur+round($largeur/2))."' y1='".(300-$hauteur_moyenne_prec)."' x2='".(($n-1)*$largeur+round($largeur/2))."' y2='".(300-$hauteur_moyenne)."' class='trait' />\n"; 195 } 196 197 $hauteur_moyenne_prec = $hauteur_moyenne; 198 199 200 if ($difference > 0) { 201 //echo "<img src='" . _DIR_IMG_PACK . "rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>"; 202 //echo "<img src='" . _DIR_IMG_PACK . "rien.gif' width=$largeur height=$hauteur_moyenne title=$tagtitle>"; 203 } 204 //echo "<img src='" . _DIR_IMG_PACK . "rien.gif' width=$largeur height=1 style='background-color:black;' title=$tagtitle>"; 205 //echo "</td>"; 206 $n++; 207 } 208 } 209 210 $ce_jour=date("Y-m-d", $key); 211 $jour = nom_jour($ce_jour).' '.affdate_court($ce_jour); 212 213 $total_loc = $total_loc + $value; 214 reset($tab_moyenne); 215 216 $moyenne = 0; 217 while (list(,$val_tab) = each($tab_moyenne)) 218 $moyenne += $val_tab; 219 $moyenne = $moyenne / count($tab_moyenne); 220 221 $hauteur_moyenne = round($moyenne * $rapport) - 1; 222 $hauteur = round($value * $rapport) - 1; 223 $moyenne = round($moyenne,2); // Pour affichage harmonieux 224 //echo "<td valign='bottom' width=$largeur>"; 225 226 // $tagtitle='"'.attribut_html(supprimer_tags("$jour | " 227 // ._T('info_visites')." ".$value)).'"'; 228 229 230 231 if (date("w",$key) == "0") // Dimanche en couleur foncee 232 $fill = $couleur_foncee; 233 else 234 $fill = "url(#claire)"; 235 236 237 238 echo "<rect x='".(($n-1)*$largeur)."' y='".(300-$hauteur)."' width='$largeur' height='$hauteur' style='fill:$fill'/>\n"; 239 echo "<rect x='".(($n-1)*$largeur)."' y='".(300-$hauteur)."' width='$largeur' height='1' style='fill:$couleur_foncee;'/>\n"; 240 241 if (date("d", $key) == "1") 242 echo "<line x1='".(($n-1)*$largeur)."' y1='".(300-$hauteur_moyenne)."' x2='".(($n-1)*$largeur)."' y2='300' class='trait'/>\n"; 243 244 245 if ($hauteur_moyenne_prec > 0) { 246 echo "<polygon points = '".(($n-2)*$largeur+round($largeur/2)).",300 ".(($n-2)*$largeur+round($largeur/2)).",".(300-$hauteur_moyenne_prec)." ".(($n-1)*$largeur+round($largeur/2)).",".(300-$hauteur_moyenne)." ".(($n-1)*$largeur+round($largeur/2)).",300' class='gris' />\n"; 247 echo "<line x1='".(($n-2)*$largeur+round($largeur/2))."' y1='".(300-$hauteur_moyenne_prec)."' x2='".(($n-1)*$largeur+round($largeur/2))."' y2='".(300-$hauteur_moyenne)."' class='trait' />\n"; 248 } else { 249 echo "<polygon points = '0,300 0,".(300-$hauteur_moyenne)." ".(($n-1)*$largeur+round($largeur/2)).",".(300-$hauteur_moyenne)." ".(($n-1)*$largeur+round($largeur/2)).",300' class='gris' />\n"; 250 echo "<line x1='0' y1='".(300-$hauteur_moyenne)."' x2='".(($n-1)*$largeur+round($largeur/2))."' y2='".(300-$hauteur_moyenne)."' class='trait' />\n"; 251 } 252 253 $hauteur_moyenne_prec = $hauteur_moyenne; 254 255 $jour_prec = $key; 256 $val_prec = $value; 257 } 258 } 259 260 261 echo "<rect x='0' y='0' width='".round($largeur*$nb_jours/$agreg)."' height='300' style='stroke-width: 1px; stroke: black; fill: blue; fill-opacity: 0; '/>\n"; 262 263 echo " <text x='".(round($largeur*$nb_jours/$agreg)+3)."' y='300' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 264 echo "0"; 265 echo "</text>\n"; 266 echo " <text x='".(round($largeur*$nb_jours/$agreg)+3)."' y='228' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 267 echo round($maxgraph/4); 268 echo "</text>\n"; 269 echo " <text x='".(round($largeur*$nb_jours/$agreg)+3)."' y='153' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 270 echo round($maxgraph/2); 271 echo "</text>\n"; 272 echo " <text x='".(round($largeur*$nb_jours/$agreg)+3)."' y='78' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 273 echo round(3*$maxgraph/4); 274 echo "</text>\n"; 275 echo " <text x='".(round($largeur*$nb_jours/$agreg)+3)."' y='8' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 276 echo round($maxgraph); 277 echo "</text>\n"; 278 279 $gauche_prec = -50; 280 for ($jour = $date_debut; $jour <= $date_today; $jour = $jour + (24*3600)) { 281 $ce_jour = date("d", $jour); 282 283 if ($ce_jour == "1") { 284 $afficher = nom_mois(date("Y-m-d", $jour)); 285 if (date("m", $jour) == 1) $afficher = "<b>".annee(date("Y-m-d", $jour))."</b>"; 286 287 288 $gauche = ($jour - $date_debut) * $largeur / ((24*3600)*$agreg); 289 290 if ($gauche - $gauche_prec >= 40 OR date("m", $jour) == 1) { 291 //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>"; 292 293 echo "<rect x='$gauche' y='300' width='1' height='10' style='fill: black;'/>\n"; 294 echo " <text x='".($gauche+3)."' y='308' font-family='Verdana, helvetica, sans-serif, sans' font-size='8' fill='black' >"; 295 echo filtrer_ical($afficher); 296 echo "</text>\n"; 297 298 299 $gauche_prec = $gauche; 300 301 302 303 } 304 } 305 } 306 307 308 } 309 310 311 312 ?> 313 314 315 </svg> 316 317 <?php 318 319 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Feb 22 22:27:47 2007 | par Balluche grâce à PHPXref 0.7 |