Browse Source

retour des referers, en squelette

il s'avere que l'affichage des referers est completement delirant dans la version stable, en masquant une partie aleatoire.
on retrouve ici ses referers, qui ont toujours ete en base :)
spip-3.0
cedric@yterium.com 12 years ago
parent
commit
add3319444
  1. 2
      .gitattributes
  2. 6
      inc/referenceurs.php
  3. 115
      inc/stats_referers_to_array.php
  4. 57
      prive/squelettes/contenu/stats_referers.html
  5. 9
      prive/squelettes/contenu/stats_referers_fonctions.php
  6. 1
      prive/squelettes/top/stats_referers.html
  7. 7
      prive/style_prive_plugin_stats.html

2
.gitattributes vendored

@ -13,6 +13,7 @@ genie/popularites.php -text
genie/visites.php -text
inc/referenceurs.php -text
inc/statistiques.php -text
inc/stats_referers_to_array.php -text
inc/stats_visites_to_array.php -text
javascript/excanvas.js -text
javascript/jquery.flot.js -text
@ -21,6 +22,7 @@ javascript/jquery.tflot.js -text
prive/bouton/statistiques.html -text
prive/images/statistiques-48.png -text
prive/squelettes/contenu/stats_referers.html -text
prive/squelettes/contenu/stats_referers_fonctions.php -text
prive/squelettes/contenu/stats_visites.html -text
prive/squelettes/inclure/admin_effacer_stats.html -text
prive/squelettes/inclure/stats-visites-data.html -text

6
inc/referenceurs.php

@ -155,7 +155,10 @@ function stats_show_keywords($kw_referer, $kw_referer_host){
$query = isset($url['query']) ? $url['query'] : "";
$host = strtolower($url['host']);
$path = $url['path'];
} else $query = $host = $path = '';
$scheme = $url['scheme'];
}
else
$scheme = $query = $host = $path = '';
// Cette fonction affecte directement les variables selon la query-string !
parse_str($query);
@ -208,6 +211,7 @@ function stats_show_keywords($kw_referer, $kw_referer_host){
}
$buffer["host"] = $host;
$buffer["scheme"] = $scheme;
if (!isset($buffer["hostname"]) OR !$buffer["hostname"])
$buffer["hostname"] = $host;

115
inc/stats_referers_to_array.php

@ -0,0 +1,115 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2011 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined('_ECRIRE_INC_VERSION')) return;
include_spip('inc/statistiques');
// moyenne glissante sur 30 jours
define('MOYENNE_GLISSANTE_JOUR', 30);
// moyenne glissante sur 12 mois
define('MOYENNE_GLISSANTE_MOIS', 12);
include_spip('inc/referenceurs');
function inc_stats_referers_to_array_dist($limit, $id_article, $options = array()) {
$now = time();
$table = "spip_referers";
$where = array();
$serveur = '';
if ($id_article) {
$table = "spip_referers_articles";
$where[] = "id_article=".intval($id_article);
}
$where = implode(" AND ",$where);
$limit = $limit?"0,".intval($limit):'';
$nbvisites = $lescriteres = array();
$result = sql_select("referer_md5, referer, visites AS vis", $table, $where, '', "maj DESC", $limit,'',$serveur);
$referers = array();
$trivisites = array(); // pour le tri
while ($row = sql_fetch($result,$serveur)) {
$referer = interdire_scripts($row['referer']);
$buff = stats_show_keywords($referer, $referer);
if ($buff["host"]) {
$refhost = $buff["hostname"];
$visites = $row['vis'];
$host = $buff["scheme"]."://".$buff["host"];
$referers[$refhost]['referer_md5'] = $row['referer_md5'];
if (!isset($referers[$refhost]['liens'][$referer]))
$referers[$refhost]['liens'][$referer] = 0;
if (!isset($referers[$refhost]['hosts'][$host]))
$referers[$refhost]['hosts'][$host] = 0;
if (!isset($referers[$refhost]['visites']))
$referers[$refhost]['visites'] = 0;
if (!isset($referers[$refhost]['visites_racine']))
$referers[$refhost]['visites_racine'] = 0;
if (!isset($referers[$refhost]['referers']))
$referers[$refhost]['referers'] = array();
$referers[$refhost]['hosts'][$host]++;
$referers[$refhost]['liens'][$referer]++ ;
$referers[$refhost]['visites'] += $visites;
$trivisites[$refhost] = $referers[$refhost]['visites'];
$tmp = "";
$set = array(
'referer'=>$referer,
'visites'=>$visites,
'referes'=>$id_article?'':referes($row['referer_md5'])
);
if (isset($buff["keywords"])
AND $c = $buff["keywords"]) {
if (!isset($referers[$refhost]['keywords'][$c])) {
$referers[$refhost]['keywords'][$c] = true;
$set['keywords'] = $c;
}
}
else {
$tmp = $buff["path"];
if ($buff["query"])
$tmp .= "?".$buff['query'];
if (strlen($tmp))
$set['path'] = "/$tmp";
}
if (isset($set['path']) OR isset($set['keywords']))
$referers[$refhost]['referers'][] = $set;
else
$referers[$refhost]['visites_racine'] += $visites;
}
}
// trier les liens pour trouver le principal
foreach($referers as $k=>$r){
arsort($referers[$k]['liens']);
$referers[$k]['liens'] = array_keys($referers[$k]['liens']);
arsort($referers[$k]['hosts']);
$referers[$k]['hosts'] = array_keys($referers[$k]['hosts']);
$referers[$k]['url'] = reset($referers[$k]['hosts']);
}
if (count($trivisites)){
array_multisort($trivisites, SORT_DESC,$referers);
}
return $referers;
}
?>

57
prive/squelettes/contenu/stats_referers.html

@ -1,26 +1,33 @@
<?php
$referenceurs = charger_fonction('referenceurs', 'inc');
$res = $referenceurs('#ENV{id_article,''}', "visites", '[(#ENV{id_article,''}|?{spip_referers,spip_referers_articles})]', array(), '', '#ENV{limit,100}');
<B_statsr>
<h1><:onglet_origine_visites:> (#TOTAL_BOUCLE [(#TOTAL_BOUCLE|singulier_ou_pluriel{info_site,info_sites})])</h1>
<ul class="liste-items referers">
<BOUCLE_statsr(DATA){source stats_referers,#ENV{limit,100},#ENV{id_article}}>
<li class="item referer" onclick="$(this).find('.referer-detail').toggle('fast');">
<h3>
<span class="visites">[[(#VALEUR{visites}) ](#VALEUR{visites}|singulier_ou_pluriel{info_visite,info_visites}|trim{:}|trim)]</span>
[(#CLE|=={(email)}|oui)
#CLE
][(#CLE|=={(email)}|non)
<a href="[(#VALEUR{url})]">[(#CLE)][<span class="miniature"><img src='(#CLE|vigneter_referer)' width="120" height="90" /></span>]</a>[(#VALEUR{visites_racine}|oui)\(#VALEUR{visites_racine}\)]</h3>
]
if ($res) {
// Le lien pour en afficher "plus"
$args = ($id_article?"id_article=$id_article&" : '') . "limit=" . strval($limit+200);
$n = count($res);
$plus = generer_url_ecrire('statistiques_visites', $args);
if ($plus) {
$plus = "<div style='text-align:right;'><b><a href='$plus'>+++</a></b></div>";
}
$titre = _T("onglet_origine_visites")
. " ($n "
. ($n == 1 ? _T('info_site') : _T('info_sites'))
. ")";
echo gros_titre($titre,'', false);
echo "<div style='overflow:hidden;' class='verdana1 spip_small'><br />";
echo "<ul class='referers'><li>";
echo join("</li><li>\n",$res);
echo "</li></ul>";
echo $plus;
echo "<br /></div>";
}
?>
</h3>
<B_sous>
<div class="referer-detail none-js">
<ul>
<BOUCLE_sous(POUR){tableau #VALEUR{referers}}>
<li><a href="#VALEUR{referer}">[(#VALEUR{keywords}|?{[&laquo;&nbsp;(#VALEUR{keywords})&nbsp;&raquo;],[(#VALEUR{path})]})]</a>
[(#VALEUR{visites}|>{1}|oui)\(#VALEUR{visites}\)]
[(#VALEUR{referes})]
</li>
</BOUCLE_sous>
</ul>
</div>
</B_sous>
</li>
</BOUCLE_statsr>
</ul>
</B_statsr>
<h1><:onglet_origine_visites:></h1>
<//B_statsr>
<p class="action plus"><a href="[(#SELF|parametre_url{limit,#ENV{limit,100}|plus{200}})]" class="ajax">+++</a></p>

9
prive/squelettes/contenu/stats_referers_fonctions.php

@ -0,0 +1,9 @@
<?php
function vigneter_referer($url){
if (!strlen($GLOBALS['source_vignettes']) OR $GLOBALS['meta']["activer_captures_referers"]=='non')
return '';
return $GLOBALS['source_vignettes'].rawurlencode(preg_replace(";^[a-z]{3,6}://;","",$url));
}

1
prive/squelettes/top/stats_referers.html

@ -1 +1,2 @@
<?php $GLOBALS['pleine_largeur']=true; ?>
[(#VAL{statistiques}|barre_onglets{stats_referers})]

7
prive/style_prive_plugin_stats.html

@ -86,5 +86,12 @@ table#visites tr.c_recap th {background-color:#[(#GET{foncee}|couleur_foncer)];c
padding: 2px;
background-color: #fee;
}
.stats_referers .liste-items.referers li.referer {padding-left:300px;}
.stats_referers .liste-items.referers li.referer span.visites {float:left;text-align:right;width:140px;margin-left:-150px;}
.stats_referers .liste-items.referers li.referer .miniature {margin-left:-295px;float:left;max-width:140px;}
.stats_referers .liste-items.referers li.referer ul {margin-left:15px;padding-left:0;}
.stats_referers .liste-items.referers li.referer ul li {margin-left:0px;padding-left:0;}
.stats_referers .action.plus {text-align:right;font-size:1.5em;font-weight:bold;}
[(#REM) </style>]

Loading…
Cancel
Save