diff --git a/.gitattributes b/.gitattributes index b98edc1..94e20d7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,7 +5,6 @@ base/stats_upgrade.php -text /engines-list.txt -text exec/base_delete_stats.php -text exec/statistiques_lang.php -text -exec/statistiques_referers.php -text exec/statistiques_repartition.php -text formulaires/configurer_compteur.html -text formulaires/configurer_compteur.php -text @@ -20,7 +19,6 @@ javascript/jquery.flot.js -text javascript/jquery.tflot.js -text /plugin.xml -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 @@ -31,8 +29,23 @@ prive/squelettes/top/stats_referers.html -text prive/squelettes/top/stats_visites.html -text prive/stats/visites.html -text prive/style_prive_plugin_stats.html -text +prive/themes/spip/images/chartpie-16.png -text +prive/themes/spip/images/chartpie-24.png -text +prive/themes/spip/images/chartpie-32.png -text +prive/themes/spip/images/licence.txt -text +prive/themes/spip/images/referers-16.png -text +prive/themes/spip/images/referers-24.png -text +prive/themes/spip/images/referers-32.png -text prive/themes/spip/images/statistique-16.png -text prive/themes/spip/images/statistique-24.png -text +prive/themes/spip/images/statistique-32.png -text +prive/themes/spip/images/statistiques-48.png -text +prive/themes/spip/images/zoomin-16.png -text +prive/themes/spip/images/zoomin-24.png -text +prive/themes/spip/images/zoomin-32.png -text +prive/themes/spip/images/zoomout-16.png -text +prive/themes/spip/images/zoomout-24.png -text +prive/themes/spip/images/zoomout-32.png -text prive/transmettre/statistiques.html -text public/stats.php -text /stats_autoriser.php -text diff --git a/exec/statistiques_referers.php b/exec/statistiques_referers.php deleted file mode 100644 index d2756dc..0000000 --- a/exec/statistiques_referers.php +++ /dev/null @@ -1,75 +0,0 @@ -'veille') $jour='jour'; - - $referenceurs = charger_fonction('referenceurs', 'inc'); - $res = $referenceurs (0, "SUM(visites_$jour)", 'spip_referers', "visites_$jour>0", "referer", $limit); - - $n = count($res); - $args = "jour=$jour&limit=" . strval($limit+200); - $plus = generer_url_ecrire('statistiques_referers', $args); - - if ($plus) { - $plus = "
+++
"; - } - - $titre = _T('titre_liens_entrants') - . " ($n " - . ($n <= 1 ? _T('info_site') : _T('info_sites')) - . ")"; - - $commencer_page = charger_fonction('commencer_page', 'inc'); - - echo $commencer_page(_T('titre_page_statistiques_referers'), "statistiques_visites", "referers"); - - echo gros_titre($titre,'', false); - echo debut_gauche('', true); - echo debut_boite_info(true); - echo "

"; - echo _T('info_gauche_statistiques_referers'); - echo "

"; - echo fin_boite_info(true); - echo debut_droite('', true); - echo barre_onglets("stat_referers", $jour . '_referers'); // attention a pas avoir le meme id d'onglet... - - if ($res) { - echo "
"; - echo ""; - echo $plus; - } - echo "

"; - - echo fin_gauche(), fin_page(); - } -} - -?> diff --git a/inc/referenceurs.php b/inc/referenceurs.php index 0420440..053ef60 100644 --- a/inc/referenceurs.php +++ b/inc/referenceurs.php @@ -12,115 +12,15 @@ if (!defined("_ECRIRE_INC_VERSION")) return; -// -// Afficher les referers d'un article (ou du site) -// - -// http://doc.spip.org/@inc_referenceurs_dist -function inc_referenceurs_dist($id_article, $select, $table, $where, $groupby, $limit, $serveur = ''){ - - $nbvisites = $lescriteres = array(); - - $result = sql_select("referer_md5, referer, $select AS vis", $table, $where, $groupby, "maj DESC", $limit, '', $serveur); - while ($row = sql_fetch($result, $serveur)){ - $referer = interdire_scripts($row['referer']); - $buff = stats_show_keywords($referer, $referer); - - if ($buff["host"]){ - $numero = $buff["hostname"]; - $visites = $row['vis']; - $referermd5 = $row['referer_md5']; - $lesreferermd5[$numero] = $referermd5; - $lesliens[$numero] = $referer; - $lesurls[$numero] = $buff["host"]; - if (!isset($nbvisites[$numero])) - $nbvisites[$numero] = $visites; - else - $nbvisites[$numero] += $visites; - if (!isset($lesreferers[$numero])) - $lesreferers[$numero] = array(); - if (!isset($lesliensracine[$numero])) - $lesliensracine[$numero] = 0; - - if (isset($buff["keywords"]) - AND $c = $buff["keywords"]){ - if (!isset($lescriteres[$numero][$c])){ - $lescriteres[$numero][$c] = true; - $tmp = " « $c »"; - } else $tmp = ""; - } else { - $tmp = $buff["path"]; - if ($buff["query"]) - $tmp .= "?".$buff['query']; - if (strlen($tmp)>18) - $tmp = "/".substr($tmp, 0, 15)."..."; - else if (strlen($tmp)>0) - $tmp = "/$tmp"; - } - if ($tmp){ - $lesreferers[$numero][] = "".quote_amp(urldecode($tmp))."".(($visites>1) ? " ($visites)" : "").($id_article ? '' : referes($referermd5)); - } else $lesliensracine[$numero] += $visites; - } - } - - if (!count($nbvisites)) return array(); - arsort($nbvisites); - return referers_group($nbvisites, $id_article, $lesliensracine, $lesreferermd5, $lesreferers, $lesurls); -} - -function referers_group($nbvisites, $id_article, $lesliensracine, $lesreferermd5, $lesreferers, $lesurls){ - global $spip_lang_right, $source_vignettes; - $vign = ((strlen($source_vignettes)>0) && - $GLOBALS['meta']["activer_captures_referers"]!='non'); - $aff = array(); - foreach ($nbvisites as $numero => $visites){ - if (!$numero) next; - $referermd5 = $lesreferermd5[$numero]; - $bouton = $ret = ""; - - if ($vign) - $ret = "\n"; - - if ($visites>5) $bouton .= "$visites "._T('info_visites')." "; - else if ($visites>1) $bouton .= "$visites "._T('info_visites')." "; - else $bouton .= "$visites "._T('info_visite')." "; - - if ($numero=="(email)"){ - $ret .= $bouton."".$numero.""; - } - else { - $n = count($lesreferers[$numero]); - if (($n>1) || ($n>0 && substr(supprimer_tags($lesreferers[$numero][0]), 0, 1)!='/')){ - $rac = $lesliensracine[$numero]; - $bouton .= "".$numero."" - .(!$rac ? '' : (" (".$rac.")")); - $ret .= bouton_block_depliable($bouton, false) - .debut_block_depliable(false) - ."\n" - .fin_block(); - } else { - $ret .= $bouton; - $lien = $n ? $lesreferers[$numero][0] : ''; - if (preg_match(",^(]+>)([^ ]*)( \([0-9]+\))?,i", $lien, $regs)){ - $lien = quote_amp($regs[1]).$numero.$regs[2]; - if (!strpos($lien, '')) $lien .= ''; - } else - $lien = "".$numero.""; - $ret .= "".quote_amp($lien)."" - .($id_article ? '' : referes($referermd5)); - } - } - $aff[] = $ret; - } - return $aff; -} - -// Les deux fonctions suivantes sont adaptees du code des "Visiteurs", -// par Jean-Paul Dezelus (http://www.phpinfo.net/applis/visiteurs/) - -// http://doc.spip.org/@stats_load_engines +/** + * Recuperer la liste des moteurs de recherche depuis un fichier txt + * Adaptees du code des "Visiteurs", + * par Jean-Paul Dezelus (http://www.phpinfo.net/applis/visiteurs/) + * + * http://doc.spip.org/@stats_load_engines + * + * @return array + */ function stats_load_engines(){ $arr_engines = Array(); lire_fichier(find_in_path('engines-list.txt'), $moteurs); @@ -137,8 +37,18 @@ function stats_load_engines(){ return $arr_engines; } -// http://doc.spip.org/@stats_show_keywords -function stats_show_keywords($kw_referer, $kw_referer_host){ +/** + * Retrouver les mots cles de recherche dans une url de referer + * + * Adaptees du code des "Visiteurs", + * par Jean-Paul Dezelus (http://www.phpinfo.net/applis/visiteurs/) + * + * http://doc.spip.org/@stats_show_keywords + * + * @param string $kw_referer + * @return array + */ +function stats_show_keywords($kw_referer){ static $arr_engines = ''; static $url_site; @@ -231,11 +141,14 @@ function stats_show_keywords($kw_referer, $kw_referer_host){ } - -// -// Recherche des articles pointes par le referer -// -// http://doc.spip.org/@referes +/** + * Recherche des articles pointes par le referer + * http://doc.spip.org/@referes + * + * @param $referermd5 + * @param string $serveur + * @return string + */ function referes($referermd5, $serveur = ''){ $retarts = sql_allfetsel('J2.id_article, J2.titre', 'spip_referers_articles AS J1 LEFT JOIN spip_articles AS J2 ON J1.id_article = J2.id_article', "(referer_md5='$referermd5' AND J1.maj>=DATE_SUB(".sql_quote(date('Y-m-d H:i:s')).", INTERVAL 2 DAY))", '', "titre", '', '', $serveur); @@ -246,9 +159,9 @@ function referes($referermd5, $serveur = ''){ } if (count($retarts)>1) - return '
→ '.join(',
→ ', $retarts); + return '→ '.join(',
→ ', $retarts); if (count($retarts)==1) - return '
→ '.array_shift($retarts); + return '→ '.array_shift($retarts); return ''; } diff --git a/inc/stats_referers_to_array.php b/inc/stats_referers_to_array.php index 265dcf4..807a57d 100644 --- a/inc/stats_referers_to_array.php +++ b/inc/stats_referers_to_array.php @@ -20,13 +20,19 @@ define('MOYENNE_GLISSANTE_JOUR', 30); define('MOYENNE_GLISSANTE_MOIS', 12); include_spip('inc/referenceurs'); -function inc_stats_referers_to_array_dist($limit, $id_article, $options = array()) { - $now = time(); +function inc_stats_referers_to_array_dist($limit, $jour, $id_article, $options = array()) { + $visites = 'visites'; $table = "spip_referers"; $where = array(); $serveur = ''; + if (in_array($jour,array('jour','veille'))){ + $visites .= "_$jour"; + $where[] = "$visites>0"; + } + //$res = $referenceurs (0, "SUM(visites_$jour)", 'spip_referers', "visites_$jour>0", "referer", $limit); + if ($id_article) { $table = "spip_referers_articles"; $where[] = "id_article=".intval($id_article); @@ -35,8 +41,7 @@ function inc_stats_referers_to_array_dist($limit, $id_article, $options = array( $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); + $result = sql_select("referer_md5, referer, $visites AS vis", $table, $where, '', "maj DESC", $limit,'',$serveur); $referers = array(); $trivisites = array(); // pour le tri diff --git a/plugin.xml b/plugin.xml index bba26f6..4834644 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,8 +1,8 @@ Statistiques - prive/themes/spip/images/statistique-24.png + prive/themes/spip/images/statistique-32.png Collectif SPIP - 0.1.4 + 0.3.0 0.1.0 dev @@ -57,42 +57,25 @@ stats_visites - null + images/statistique-24.png icone_statistiques_visites stats_visites - null + images/referers-24.png titre_liens_entrants stats_referers - null + images/chartpie-24.png icone_repartition_visites statistiques_repartition - null + images/langue-24.png onglet_repartition_lang statistiques_lang - - images/referer-16.png - titre_liens_entrants - statistiques_referers - - - null - date_aujourdhui - statistiques_referers - - - null - date_hier - statistiques_referers - jour=veille - - diff --git a/prive/squelettes/contenu/stats_referers.html b/prive/squelettes/contenu/stats_referers.html index 149e72d..b5fbbba 100644 --- a/prive/squelettes/contenu/stats_referers.html +++ b/prive/squelettes/contenu/stats_referers.html @@ -1,7 +1,25 @@ + +#BOITE_OUVRIR{'','note'} + [(#CHEMIN_IMAGE{fermer-16.png}|balise_img|inserer_attribut{alt,<:tout_voir:>})] + <:titre_liens_entrants:> <:info_pour:> +

#TITRE

+ <:titre_page_statistiques_visites:> +#BOITE_FERMER + + +
+ +

<:onglet_origine_visites:> (#TOTAL_BOUCLE [(#TOTAL_BOUCLE|singulier_ou_pluriel{info_site,info_sites})])

+ [

(#ENV{jour,''}|=={jour}|oui)<:date_aujourdhui|ucfirst:>

] + [

(#ENV{jour,''}|=={veille}|oui)<:date_hier|ucfirst:>

] @@ -29,5 +47,7 @@

<:onglet_origine_visites:>

+ [

(#ENV{jour,''}|=={jour}|oui)<:date_aujourdhui|ucfirst:>

] + [

(#ENV{jour,''}|=={veille}|oui)<:date_hier|ucfirst:>

] -

+++

\ No newline at end of file +

+++

diff --git a/prive/squelettes/inclure/stats-visites-data.html b/prive/squelettes/inclure/stats-visites-data.html index 0edfce5..d8a752b 100644 --- a/prive/squelettes/inclure/stats-visites-data.html +++ b/prive/squelettes/inclure/stats-visites-data.html @@ -1,9 +1,10 @@ [(#BOITE_OUVRIR{[(#CHEMIN_IMAGE{statistique-24.png}|balise_img{'',cadre-icone})]

<:titre_evolution_visite:>

,'simple stats'})] - + #BOITE_OUVRIR{'','note'} [(#CHEMIN_IMAGE{fermer-16.png}|balise_img|inserer_attribut{alt,<:tout_voir:>})] <:titre_page_statistiques_visites:> <:info_pour:>

#TITRE

+ <:titre_liens_entrants:> #BOITE_FERMER #SET{c,#VAL{article}|classement_populaires} @@ -13,12 +14,12 @@ #SET{args,#ARRAY{id_article,#ID_ARTICLE,duree,#DUREE}} CSV - - [(#ENV{duree,90}) <:info_jours:>] + | + [(#ENV{duree,90}) <:info_jours:>] | [(#CHEMIN_IMAGE{loupe-moins.gif}|balise_img{<:info_zoom:> -})] + class="ajax">[(#CHEMIN_IMAGE{zoomout-24.png}|balise_img{<:info_zoom:> -})] [(#CHEMIN_IMAGE{loupe-plus.gif}|balise_img{<:info_zoom:> +})] + class="ajax">[(#CHEMIN_IMAGE{zoomin-24.png}|balise_img{<:info_zoom:> +})]

#SET{max,0} #SET{moy,0} diff --git a/prive/themes/spip/images/chartpie-16.png b/prive/themes/spip/images/chartpie-16.png new file mode 100755 index 0000000..2f74995 Binary files /dev/null and b/prive/themes/spip/images/chartpie-16.png differ diff --git a/prive/themes/spip/images/chartpie-24.png b/prive/themes/spip/images/chartpie-24.png new file mode 100644 index 0000000..de7d6b2 Binary files /dev/null and b/prive/themes/spip/images/chartpie-24.png differ diff --git a/prive/themes/spip/images/chartpie-32.png b/prive/themes/spip/images/chartpie-32.png new file mode 100755 index 0000000..6d14c72 Binary files /dev/null and b/prive/themes/spip/images/chartpie-32.png differ diff --git a/prive/themes/spip/images/licence.txt b/prive/themes/spip/images/licence.txt new file mode 100644 index 0000000..be38b01 --- /dev/null +++ b/prive/themes/spip/images/licence.txt @@ -0,0 +1,2 @@ +Icones sous license: Creative Commons (Attribution 3.0 United States) +credits : http://www.fatcow.com/free-icons \ No newline at end of file diff --git a/prive/themes/spip/images/referers-16.png b/prive/themes/spip/images/referers-16.png new file mode 100755 index 0000000..6dfec70 Binary files /dev/null and b/prive/themes/spip/images/referers-16.png differ diff --git a/prive/themes/spip/images/referers-24.png b/prive/themes/spip/images/referers-24.png new file mode 100644 index 0000000..f43c5ac Binary files /dev/null and b/prive/themes/spip/images/referers-24.png differ diff --git a/prive/themes/spip/images/referers-32.png b/prive/themes/spip/images/referers-32.png new file mode 100755 index 0000000..4832b50 Binary files /dev/null and b/prive/themes/spip/images/referers-32.png differ diff --git a/prive/themes/spip/images/statistique-16.png b/prive/themes/spip/images/statistique-16.png index 1bb91d3..59c4544 100644 Binary files a/prive/themes/spip/images/statistique-16.png and b/prive/themes/spip/images/statistique-16.png differ diff --git a/prive/themes/spip/images/statistique-24.png b/prive/themes/spip/images/statistique-24.png index 47e554d..7ce085b 100644 Binary files a/prive/themes/spip/images/statistique-24.png and b/prive/themes/spip/images/statistique-24.png differ diff --git a/prive/themes/spip/images/statistique-32.png b/prive/themes/spip/images/statistique-32.png new file mode 100644 index 0000000..a66163a Binary files /dev/null and b/prive/themes/spip/images/statistique-32.png differ diff --git a/prive/images/statistiques-48.png b/prive/themes/spip/images/statistiques-48.png similarity index 100% rename from prive/images/statistiques-48.png rename to prive/themes/spip/images/statistiques-48.png diff --git a/prive/themes/spip/images/zoomin-16.png b/prive/themes/spip/images/zoomin-16.png new file mode 100755 index 0000000..01a4df5 Binary files /dev/null and b/prive/themes/spip/images/zoomin-16.png differ diff --git a/prive/themes/spip/images/zoomin-24.png b/prive/themes/spip/images/zoomin-24.png new file mode 100644 index 0000000..041d4c7 Binary files /dev/null and b/prive/themes/spip/images/zoomin-24.png differ diff --git a/prive/themes/spip/images/zoomin-32.png b/prive/themes/spip/images/zoomin-32.png new file mode 100755 index 0000000..18e4383 Binary files /dev/null and b/prive/themes/spip/images/zoomin-32.png differ diff --git a/prive/themes/spip/images/zoomout-16.png b/prive/themes/spip/images/zoomout-16.png new file mode 100755 index 0000000..3d096c1 Binary files /dev/null and b/prive/themes/spip/images/zoomout-16.png differ diff --git a/prive/themes/spip/images/zoomout-24.png b/prive/themes/spip/images/zoomout-24.png new file mode 100644 index 0000000..9e8b82f Binary files /dev/null and b/prive/themes/spip/images/zoomout-24.png differ diff --git a/prive/themes/spip/images/zoomout-32.png b/prive/themes/spip/images/zoomout-32.png new file mode 100755 index 0000000..2bdc37a Binary files /dev/null and b/prive/themes/spip/images/zoomout-32.png differ