Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
e8238334
Valider
e8238334
rédigé
11 years ago
par
mattab
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Refactor VisitExcluded
parent
597f505e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
core/Tracker/VisitExcluded.php
+51
-40
51 ajouts, 40 suppressions
core/Tracker/VisitExcluded.php
avec
51 ajouts
et
40 suppressions
core/Tracker/VisitExcluded.php
+
51
−
40
Voir le fichier @
e8238334
...
...
@@ -35,38 +35,7 @@ class Piwik_Tracker_VisitExcluded
{
$excluded
=
false
;
/*
* Live/Bing/MSN bot and Googlebot are evolving to detect cloaked websites.
* As a result, these sophisticated bots exhibit characteristics of
* browsers (cookies enabled, executing JavaScript, etc).
*/
$allowBots
=
Piwik_Common
::
getRequestVar
(
'bots'
,
false
)
!=
false
;
if
(
!
$allowBots
&&
(
strpos
(
$this
->
userAgent
,
'Googlebot'
)
!==
false
// Googlebot
||
strpos
(
$this
->
userAgent
,
'Google Web Preview'
)
!==
false
// Google Instant
||
strpos
(
$this
->
userAgent
,
'bingbot'
)
!==
false
// Bingbot
||
strpos
(
$this
->
userAgent
,
'YottaaMonitor'
)
!==
false
// Yottaa
||
Piwik_IP
::
isIpInRange
(
$this
->
ip
,
array
(
// Live/Bing/MSN
'64.4.0.0/18'
,
'65.52.0.0/14'
,
'157.54.0.0/15'
,
'157.56.0.0/14'
,
'157.60.0.0/16'
,
'207.46.0.0/16'
,
'207.68.128.0/18'
,
'207.68.192.0/20'
,
'131.253.26.0/20'
,
'131.253.24.0/20'
,
// Yahoo
'72.30.198.0/20'
,
'72.30.196.0/20'
,
'98.137.207.0/20'
,
// Chinese bot hammering websites
'1.202.218.8'
)))
)
{
if
(
$this
->
isNonHumanBot
())
{
printDebug
(
'Search bot detected, visit excluded'
);
$excluded
=
true
;
}
...
...
@@ -104,7 +73,7 @@ class Piwik_Tracker_VisitExcluded
// Checking for excluded IPs
if
(
!
$excluded
)
{
$excluded
=
$this
->
isVisitorIpExcluded
(
$this
->
ip
);
$excluded
=
$this
->
isVisitorIpExcluded
();
if
(
$excluded
)
{
printDebug
(
"IP excluded."
);
}
...
...
@@ -119,11 +88,7 @@ class Piwik_Tracker_VisitExcluded
}
if
(
!
$excluded
)
{
if
((
isset
(
$_SERVER
[
"HTTP_X_PURPOSE"
])
&&
in_array
(
$_SERVER
[
"HTTP_X_PURPOSE"
],
array
(
"preview"
,
"instant"
)))
||
(
isset
(
$_SERVER
[
'HTTP_X_MOZ'
])
&&
$_SERVER
[
'HTTP_X_MOZ'
]
==
"prefetch"
)
)
{
if
(
$this
->
isPrefetchDetected
())
{
$excluded
=
true
;
printDebug
(
"Prefetch request detected, not a real visit so we Ignore this visit/pageview"
);
}
...
...
@@ -137,6 +102,53 @@ class Piwik_Tracker_VisitExcluded
return
false
;
}
protected
function
isPrefetchDetected
()
{
return
(
isset
(
$_SERVER
[
"HTTP_X_PURPOSE"
])
&&
in_array
(
$_SERVER
[
"HTTP_X_PURPOSE"
],
array
(
"preview"
,
"instant"
)))
||
(
isset
(
$_SERVER
[
'HTTP_X_MOZ'
])
&&
$_SERVER
[
'HTTP_X_MOZ'
]
==
"prefetch"
);
}
/*
* Live/Bing/MSN bot and Googlebot are evolving to detect cloaked websites.
* As a result, these sophisticated bots exhibit characteristics of
* browsers (cookies enabled, executing JavaScript, etc).
*/
protected
function
isNonHumanBot
()
{
$allowBots
=
Piwik_Common
::
getRequestVar
(
'bots'
,
false
)
!=
false
;
return
!
$allowBots
&&
(
strpos
(
$this
->
userAgent
,
'Googlebot'
)
!==
false
// Googlebot
||
strpos
(
$this
->
userAgent
,
'Google Web Preview'
)
!==
false
// Google Instant
||
strpos
(
$this
->
userAgent
,
'bingbot'
)
!==
false
// Bingbot
||
strpos
(
$this
->
userAgent
,
'YottaaMonitor'
)
!==
false
// Yottaa
||
Piwik_IP
::
isIpInRange
(
$this
->
ip
,
$this
->
getBotIpRanges
()));
}
protected
function
getBotIpRanges
()
{
return
array
(
// Live/Bing/MSN
'64.4.0.0/18'
,
'65.52.0.0/14'
,
'157.54.0.0/15'
,
'157.56.0.0/14'
,
'157.60.0.0/16'
,
'207.46.0.0/16'
,
'207.68.128.0/18'
,
'207.68.192.0/20'
,
'131.253.26.0/20'
,
'131.253.24.0/20'
,
// Yahoo
'72.30.198.0/20'
,
'72.30.196.0/20'
,
'98.137.207.0/20'
,
// Chinese bot hammering websites
'1.202.218.8'
);
}
/**
* Looks for the ignore cookie that users can set in the Piwik admin screen.
* @return bool
...
...
@@ -190,5 +202,4 @@ class Piwik_Tracker_VisitExcluded
}
return
false
;
}
}
\ No newline at end of file
}
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter