Browse Source

permettre de passer le contexte et le referer en argument de public/stats (appel depuis un JS via une action)

svn/root/tags/plugins/statistiques/0.5.6 v0.5.6
cedric@yterium.com 8 years ago
parent
commit
5e87eaa7b9
  1. 2
      paquet.xml
  2. 27
      public/stats.php

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="stats"
categorie="statistique"
version="0.5.5"
version="0.5.6"
etat="stable"
compatibilite="[3.0.0;3.1.*]"
logo="prive/themes/spip/images/statistique-32.png"

27
public/stats.php

@ -13,21 +13,26 @@
if (!defined("_ECRIRE_INC_VERSION")) return;
// http://doc.spip.org/@public_stats_dist
function public_stats_dist() {
// $_SERVER["HTTP_REFERER"] ne fonctionne pas partout
if (isset($_SERVER['HTTP_REFERER'])) $referer = $_SERVER['HTTP_REFERER'];
else if (isset($GLOBALS["HTTP_SERVER_VARS"]["HTTP_REFERER"])) $referer = $GLOBALS["HTTP_SERVER_VARS"]["HTTP_REFERER"];
function public_stats_dist($contexte = null, $referer = null) {
if (is_array($contexte)){
$contexte = $GLOBALS['contexte'];
}
if (is_null($referer)){
// $_SERVER["HTTP_REFERER"] ne fonctionne pas partout
if (isset($_SERVER['HTTP_REFERER'])) $referer = $_SERVER['HTTP_REFERER'];
else if (isset($GLOBALS["HTTP_SERVER_VARS"]["HTTP_REFERER"])) $referer = $GLOBALS["HTTP_SERVER_VARS"]["HTTP_REFERER"];
}
// Rejet des robots (qui sont pourtant des humains comme les autres)
if (_IS_BOT OR (isset($referer) AND strpbrk($referer, '<>"\''))) return;
// Ne pas tenir compte des tentatives de spam des forums
if ($_SERVER['REQUEST_METHOD'] !== 'GET'
OR (isset($_GET['page']) AND $_GET['page'] == 'forum'))
OR (isset($contexte['page']) AND $contexte['page'] == 'forum'))
return;
// rejet des pages 404
if (isset($GLOBALS['page']['status'])
erme if (isset($GLOBALS['page']['status'])
AND $GLOBALS['page']['status'] == 404)
return;
@ -67,17 +72,17 @@ function public_stats_dist() {
if (count($content) < 200) {
// Identification de l'element
if (isset($GLOBALS['contexte']['id_article']))
if (isset($contexte['id_article']))
$log_type = "article";
else if (isset($GLOBALS['contexte']['id_breve']))
else if (isset($contexte['id_breve']))
$log_type = "breve";
else if (isset($GLOBALS['contexte']['id_rubrique']))
else if (isset($contexte['id_rubrique']))
$log_type = "rubrique";
else
$log_type = "";
if ($log_type)
$log_type .= "\t" . intval($GLOBALS['contexte']["id_$log_type"]);
$log_type .= "\t" . intval($contexte["id_$log_type"]);
else $log_type = "autre\t0";
$log_type .= "\t" . trim($log_referer);

Loading…
Cancel
Save