Browse Source

Quelques améliorations de l’analyseur :

- Le composed-by de mediaspip est pris en compte
- Le terme recherché 'spip' (si on n’a pas trouvé de version)  dans le contenu des pages devient plus précis (spip_in, spip_out, spip_logo) afin d’éviter de faux positifs
- Lorsqu’on n’a rien trouvé, c’est probablement que ce n’est plus un SPIP, et pas uniquement un vieux SPIP.
svn/root
marcimat@rezo.net 2 years ago
parent
commit
fdd16f5609
  1. 38
      inc/univers_analyser.php
  2. 2
      plugin.xml

38
inc/univers_analyser.php

@ -139,7 +139,12 @@ function univers_analyser($url, $debug = false) {
}
// check if the header says "Hey, i'm made with SPIP"
if (preg_match($regexp = ',Composed-By: (.*)( @ www.spip.net)( ?\+ ?(.*))?$,m', $header, $r)) {
$regexp_plugin_spip = ',Composed-By: (?:.*)\+ (?<plugins>spip\((?<spip>[^)]+)\)(.*)?)$,m';
$regexp_generique = ',Composed-By: (?<spip>.*)( @ www.spip.net)( ?\+ ?(?<plugins>.*))?$,m';
if (
preg_match($regexp_plugin_spip, $header, $r)
or preg_match($regexp_generique, $header, $r)
) {
// essayer de choper local/config.txt si il est la car plus complet si le header semble coupe
if (substr($header, -1)!==')') {
$url_config = suivre_lien($url, 'local/config.txt');
@ -149,16 +154,21 @@ function univers_analyser($url, $debug = false) {
$url_config = suivre_lien($url, "sites/$url_mutu/local/config.txt");
$config = univers_recuperer_lapage($url_config);
}
if ($config and preg_match($regexp, $config[1], $rc)) {
$r = $rc;
if ($config) {
if (
preg_match($regexp_plugin_spip, $config[1], $rc)
or preg_match($regexp_generique, $config[1], $rc)
) {
$r = $rc;
}
}
}
$res['spip'] = trim(preg_replace(',^[^0-9]*,', '', $r[1]));
$res['spip'] = trim(preg_replace(',^[^0-9]*,', '', $r['spip']));
if (!$res['spip']) {
$res['spip'] = '?';
}
$res['plugins'] = array();
if ($p = array_filter(explode(',', $r[4]))) {
if ($p = array_filter(explode(',', $r['plugins']))) {
foreach ($p as $plugin) {
$plugin = trim($plugin);
$res['plugins'][preg_replace(',[(].*,', '', $plugin)] = $plugin;
@ -166,16 +176,16 @@ function univers_analyser($url, $debug = false) {
}
}
// else, find another clue
// if 'spip' is in the html, there are some chance that it is a SPIP site
// if 'spip_' is in the html, there are some chance that it is a SPIP site
if (!isset($res['spip'])) {
if (preg_match(',spip,i', $page)) {
$res['spip'] = '';
if (preg_match(',spip_(in|out|logo),i', $page)) {
$res['spip'] = '?';
}
}
// if maybe but not sure, try to get the login page
// it should have some information that says "SPIP"
if (isset($res['spip']) and (!$res['spip'] or $res['spip']=='?')) {
if (isset($res['spip']) and $res['spip'] === '?') {
// recuperer la page de login
$login = preg_replace(',spip[.]php.*$,', '', $url).'ecrire/';
if ($login = univers_recuperer_lapage($login)) {
@ -191,7 +201,7 @@ function univers_analyser($url, $debug = false) {
// if we did'nt found login page, or there whas no information
// try to get the htaccess.txt delivered with SPIP,
// it has some extra informations
if (isset($res['spip']) and (!$res['spip'] or $res['spip']=='?')) {
if (isset($res['spip']) and $res['spip'] === '?') {
// tenter de recup le htaccess.txt qui contient un numero de version
$ht = preg_replace(',spip[.]php.*$,', '', $url).'htaccess.txt';
if ($ht = univers_recuperer_lapage($ht)) {
@ -201,10 +211,10 @@ function univers_analyser($url, $debug = false) {
}
}
// if we did'nt found a confirmation and there was only 'spip' in the html
// maybe it's an old spip site, but whe mark it apart as it is suspect
if (!$res['spip']) {
$res['spip'] = '<1.8?';
// if we didn't found a confirmation and there was only 'spip' in the html
// maybe it's an old spip site, but it’s no more a SPIP now.
if ($res['spip'] === '?') {
unset($res['spip']);
}
}

2
plugin.xml

@ -3,7 +3,7 @@
<auteur>&#169; 2010 C&eacute;dric MORIN</auteur>
<licence>GPL</licence>
<etat>test</etat>
<version>0.2.31</version>
<version>0.2.32</version>
<version_base>0.1.10</version_base>
<categorie>statistique</categorie>
<install>base/univers.php</install>

Loading…
Cancel
Save