Changeset 112585 in spip-zone
- Timestamp:
- Dec 1, 2018, 1:44:10 PM (2 years ago)
- Location:
- _dev_/univers_spip
- Files:
-
- 1 added
- 5 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
_dev_/univers_spip
-
Property
svn:ignore
set to
phpcs.xml
.php_cs.cache
-
Property
svn:ignore
set to
-
_dev_/univers_spip/base/univers.php
r107430 r112585 8 8 9 9 10 if (!defined("_ECRIRE_INC_VERSION")) return; 10 if (!defined('_ECRIRE_INC_VERSION')) { 11 return; 12 } 11 13 12 function univers_declarer_tables_interfaces($interface) {14 function univers_declarer_tables_interfaces($interface) { 13 15 // 'spip_' dans l'index de $tables_principales 14 16 $interface['table_des_tables']['websites']='websites'; … … 17 19 } 18 20 19 function univers_declarer_tables_principales($tables_principales){ 21 function univers_declarer_tables_principales($tables_principales) { 22 $spip_websites = array( 23 'id_website' => 'bigint(21) NOT NULL', 24 'url' => "varchar(255) default '' NOT NULL", 25 'titre' => "text DEFAULT '' NOT NULL", 26 'descriptif' => "text DEFAULT '' NOT NULL", 27 'ip' => "varchar(255) default '' NOT NULL", 28 'spip' => "varchar(255) default '' NOT NULL", 29 'server' => "varchar(255) default '' NOT NULL", 30 'php' => "varchar(255) default '' NOT NULL", 31 'gzip' => "varchar(3) default '' NOT NULL", 32 'length' => 'bigint(21) NOT NULL', 33 'size' => 'bigint(21) NOT NULL', 34 'plugins' => 'bigint(21) default NULL', 35 'pays' => "char(3) default '' NOT NULL", 20 36 21 $spip_websites = array( 22 "id_website" => "bigint(21) NOT NULL", 23 "url" => "varchar(255) default '' NOT NULL", 24 "titre" => "text DEFAULT '' NOT NULL", 25 "descriptif" => "text DEFAULT '' NOT NULL", 26 "ip" => "varchar(255) default '' NOT NULL", 27 "spip" => "varchar(255) default '' NOT NULL", 28 "server" => "varchar(255) default '' NOT NULL", 29 "php" => "varchar(255) default '' NOT NULL", 30 "gzip" => "varchar(3) default '' NOT NULL", 31 "length" => "bigint(21) NOT NULL", 32 "size" => "bigint(21) NOT NULL", 33 "plugins" => "bigint(21) default NULL", 34 "pays" => "char(3) default '' NOT NULL", 37 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", 38 'statut' => "varchar(10) default 'prop' NOT NULL", 35 39 36 "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", 37 "statut" => "varchar(10) default 'prop' NOT NULL", 38 39 "retry" => "int(5) default 0 NOT NULL", 40 "status" => "varchar(10) default '' NOT NULL", 40 'retry' => 'int(5) default 0 NOT NULL', 41 'status' => "varchar(10) default '' NOT NULL", 41 42 ); 42 43 43 44 $spip_websites_key = array( 44 "PRIMARY KEY" => "id_website",45 'PRIMARY KEY' => 'id_website', 45 46 ); 46 47 … … 53 54 54 55 55 function univers_declarer_tables_auxiliaires($tables_auxiliaires) {56 function univers_declarer_tables_auxiliaires($tables_auxiliaires) { 56 57 $spip_websites_plugins = array( 57 "id_website" => "bigint(21) NOT NULL",58 "plugin"=> "varchar(64) default '' NOT NULL",59 "version"=> "varchar(255) default '' NOT NULL",58 'id_website' => 'bigint(21) NOT NULL', 59 'plugin' => "varchar(64) default '' NOT NULL", 60 'version' => "varchar(255) default '' NOT NULL", 60 61 ); 61 62 62 63 $spip_websites_plugins_key = array( 63 "PRIMARY KEY" => "id_website, plugin",64 'PRIMARY KEY' => 'id_website, plugin', 64 65 ); 65 66 … … 71 72 } 72 73 73 function univers_upgrade($nom_meta_base_version, $version_cible){74 function univers_upgrade($nom_meta_base_version, $version_cible) { 74 75 $current_version = 0.0; 75 if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]))76 || (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)) {76 if ((!isset($GLOBALS['meta'][$nom_meta_base_version])) 77 || (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)) { 77 78 include_spip('base/abstract_sql'); 78 if (version_compare($current_version, "0.1.2",'<')){79 echo "Creation des tables";79 if (version_compare($current_version, '0.1.2', '<')) { 80 echo 'Creation des tables'; 80 81 include_spip('base/serial'); 81 82 include_spip('base/auxiliaires'); 82 83 include_spip('base/create'); 83 84 creer_base(); 84 ecrire_meta($nom_meta_base_version, $current_version=$version_cible,'non');85 ecrire_meta($nom_meta_base_version, $current_version = $version_cible, 'non'); 85 86 } 86 if (version_compare($current_version, "0.1.4",'<')){87 if (version_compare($current_version, '0.1.4', '<')) { 87 88 include_spip('inc/univers'); 88 $res = sql_select('referer','spip_referers',"referer LIKE '%spip.php%' AND referer NOT LIKE 'https://contrib.spip.net%' AND referer NOT LIKE '%localhost%'"); 89 echo "Import depuis les referer %spip.php% : ".sql_count($res)." <br />"; 90 while ($row = sql_fetch($res)) 89 $res = sql_select( 90 'referer', 91 'spip_referers', 92 "referer LIKE '%spip.php%' AND referer NOT LIKE 'https://contrib.spip.net%'". 93 " AND referer NOT LIKE '%localhost%'" 94 ); 95 echo 'Import depuis les referer %spip.php% : '.sql_count($res).' <br />'; 96 while ($row = sql_fetch($res)) { 91 97 univers_proposer_site($row['referer']); 92 ecrire_meta($nom_meta_base_version,$current_version="0.1.4",'non'); 98 } 99 ecrire_meta($nom_meta_base_version, $current_version = '0.1.4', 'non'); 93 100 } 94 if (version_compare($current_version,"0.1.5",'<')){ 95 $res = sql_select('referer','spip_referers',"referer LIKE '%/ecrire/%' AND referer NOT LIKE 'https://contrib.spip.net%' AND referer NOT LIKE '%localhost%'"); 96 echo "Import depuis les referer %/ecrire/% : ".sql_count($res)." <br />"; 97 while ($row = sql_fetch($res)) 98 univers_proposer_site(preg_replace(',/ecrire/.*$,Uims','/spip.php',$row['referer'])); 99 ecrire_meta($nom_meta_base_version,$current_version="0.1.5",'non'); 101 if (version_compare($current_version, '0.1.5', '<')) { 102 $res = sql_select( 103 'referer', 104 'spip_referers', 105 "referer LIKE '%/ecrire/%' AND referer NOT LIKE 'https://contrib.spip.net%'". 106 " AND referer NOT LIKE '%localhost%'" 107 ); 108 echo 'Import depuis les referer %/ecrire/% : '.sql_count($res).' <br />'; 109 while ($row = sql_fetch($res)) { 110 univers_proposer_site(preg_replace(',/ecrire/.*$,Uims', '/spip.php', $row['referer'])); 111 } 112 ecrire_meta($nom_meta_base_version, $current_version = '0.1.5', 'non'); 100 113 } 101 if (version_compare($current_version, "0.1.8",'<')){114 if (version_compare($current_version, '0.1.8', '<')) { 102 115 include_spip('base/serial'); 103 116 include_spip('base/auxiliaires'); 104 117 include_spip('base/create'); 105 118 maj_tables(array('spip_websites','spip_websites_plugins')); 106 sql_updateq("spip_websites", array('plugins'=>0),"statut='publie'"); 107 $res = sql_select("id_website, count(plugin) AS nb", "spip_websites_plugins", "", "id_website"); 108 while($row = sql_fetch($res)) 109 sql_updateq("spip_websites", array('plugins'=>$row['nb']),'id_website='.intval($row['id_website'])); 110 ecrire_meta($nom_meta_base_version,$current_version="0.1.8",'non'); 119 sql_updateq('spip_websites', array('plugins'=>0), "statut='publie'"); 120 $res = sql_select('id_website, count(plugin) AS nb', 'spip_websites_plugins', '', 'id_website'); 121 while ($row = sql_fetch($res)) { 122 sql_updateq('spip_websites', array('plugins'=>$row['nb']), 'id_website='.intval($row['id_website'])); 123 } 124 ecrire_meta($nom_meta_base_version, $current_version = '0.1.8', 'non'); 111 125 } 112 if (version_compare($current_version, "0.1.9",'<')){126 if (version_compare($current_version, '0.1.9', '<')) { 113 127 include_spip('base/serial'); 114 128 include_spip('base/auxiliaires'); … … 117 131 maj_tables(array('spip_websites','spip_websites_plugins')); 118 132 include_spip('inc/univers_analyser'); 119 $c = sql_countsel( "spip_websites", "pays='' AND IP<>''");133 $c = sql_countsel('spip_websites', "pays='' AND IP<>''"); 120 134 echo "MAJ 0.1.9 : $c pays a renseigner<br />"; 121 $res = sql_select("id_website, ip","spip_websites", "pays='' AND IP<>''"); 122 while($row = sql_fetch($res)) { 123 sql_updateq("spip_websites", 124 array('pays'=>univers_geoip($row['ip'])),'id_website='.intval($row['id_website'])); 135 $res = sql_select('id_website, ip', 'spip_websites', "pays='' AND IP<>''"); 136 while ($row = sql_fetch($res)) { 137 sql_updateq( 138 'spip_websites', 139 array('pays'=>univers_geoip($row['ip'])), 140 'id_website='.intval($row['id_website']) 141 ); 125 142 } 126 ecrire_meta($nom_meta_base_version, $current_version="0.1.9",'non');143 ecrire_meta($nom_meta_base_version, $current_version = '0.1.9', 'non'); 127 144 } 128 145 } … … 131 148 function univers_vider_tables($nom_meta_base_version) { 132 149 effacer_meta($nom_meta_base_version); 133 sql_drop_table( "spip_websites_plugins");134 sql_drop_table( "spip_websites");150 sql_drop_table('spip_websites_plugins'); 151 sql_drop_table('spip_websites'); 135 152 } -
_dev_/univers_spip/exec/universparse.php
r107430 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 9 function exec_universparse_dist() { 10 $url = ''; 11 include_spip('inc/univers_analyser'); 9 12 10 function exec_universparse_dist(){11 #$encore = univers_google_parse_one_step(true);12 #univers_feed_watch(true);13 14 #univers_boss_explore();15 16 $url = "";17 18 #include_spip('inc/univers');19 #var_dump(univers_twitter_extraire_feed_urls("http://search.twitter.com/search.atom?q=spip.php"));20 21 include_spip('inc/univers_analyser');22 13 if ($id = _request('id')) { 23 $res = sql_select("*", "spip_websites", "id_website=".intval($id)/*." AND statut='prop'"*/, "", "id_website","0,1"); 14 $res = sql_select( 15 '*', 16 'spip_websites', 17 'id_website='.intval($id), 18 '', 19 'id_website', 20 '0,1' 21 ); 24 22 while ($row = sql_fetch($res)) { 25 23 univers_analyser_un($row, true); 26 24 } 27 } 28 elseif($url = _request('url')){ 25 } elseif ($url = _request('url')) { 29 26 var_dump($url); 30 27 var_dump(univers_analyser($url, true)); 31 28 } 32 29 } 33 -
_dev_/univers_spip/genie/univers_check.php
r47084 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 … … 10 10 include_spip('inc/univers_analyser'); 11 11 12 $il_y_a_une_heure = date('Y-m-d H:i:s', time()-3600);12 $il_y_a_une_heure = date('Y-m-d H:i:s', time()-3600); 13 13 // 2 sites en attente de validation 14 $res = sql_select("*", "spip_websites", "statut='prop' AND (retry=0 OR date<".sql_quote($il_y_a_une_heure).")", "", "date,retry","0,2"); 14 $res = sql_select( 15 '*', 16 'spip_websites', 17 "statut='prop' AND (retry=0 OR date<".sql_quote($il_y_a_une_heure).')', 18 '', 19 'date,retry', 20 '0,2' 21 ); 15 22 while ($row = sql_fetch($res)) { 16 23 univers_analyser_un($row); 17 24 } 18 25 19 $il_y_a_quatre_heure = date('Y-m-d H:i:s', time()-4*3600);26 $il_y_a_quatre_heure = date('Y-m-d H:i:s', time()-4*3600); 20 27 // revisiter 5 sites deja vu, en commencant par les plus anciens 21 $res = sql_select("*", "spip_websites", "statut='publie' AND (retry=0 OR date<".sql_quote($il_y_a_quatre_heure).")", "", "date,retry","0,5"); 28 $res = sql_select( 29 '*', 30 'spip_websites', 31 "statut='publie' AND (retry=0 OR date<".sql_quote($il_y_a_quatre_heure).')', 32 '', 33 'date,retry', 34 '0,5' 35 ); 22 36 while ($row = sql_fetch($res)) { 23 37 univers_analyser_un($row); … … 25 39 26 40 // revisiter un site publie, en retry de plus de 4 heures 27 $res = sql_select("*", "spip_websites", "statut='publie' AND (retry>0 AND date<".sql_quote($il_y_a_quatre_heure).")", "", "date,retry","0,1"); 41 $res = sql_select( 42 '*', 43 'spip_websites', 44 "statut='publie' AND (retry>0 AND date<".sql_quote($il_y_a_quatre_heure).')', 45 '', 46 'date,retry', 47 '0,1' 48 ); 28 49 while ($row = sql_fetch($res)) { 29 50 univers_analyser_un($row); … … 31 52 32 53 // passer a la poubelle les sites proposes sans DNS et essayes au moins 5 fois 33 sql_updateq( "spip_websites",array('statut'=>'poub'),"statut='prop' AND status='no-dns' AND retry>=5");54 sql_updateq('spip_websites', array('statut'=>'poub'), "statut='prop' AND status='no-dns' AND retry>=5"); 34 55 35 56 // passer a la poubelle les sites morts et essayes au moins 10 fois 36 57 // soit un propose pas vu vivant dans les 10 dernieres heures 37 58 // soit un publie (donc vu vivant un jour) pas vu vivant dans les 40 dernieres heures 38 sql_updateq("spip_websites",array('statut'=>'poub'),"statut IN ('prop','publie') AND status='dead' AND retry>=10"); 59 sql_updateq( 60 'spip_websites', 61 array('statut'=>'poub'), 62 "statut IN ('prop','publie') AND status='dead' AND retry>=10" 63 ); 39 64 40 65 return 0; 41 66 } 42 43 44 ?> -
_dev_/univers_spip/genie/univers_feed.php
r107430 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 … … 10 10 include_spip('inc/univers'); 11 11 univers_feed_watch(); 12 12 13 return 0; 13 14 } 14 -
_dev_/univers_spip/genie/univers_referers.php
r107430 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 9 9 function genie_univers_referers_dist($t) { 10 10 include_spip('inc/univers'); 11 univers_rechercher_referers(date("Y-m-d",time()-24*3600)); 11 univers_rechercher_referers(date('Y-m-d', time()-24*3600)); 12 12 13 return 0; 13 14 } 14 -
_dev_/univers_spip/genie/univers_statsv.php
r112576 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 … … 11 11 12 12 $versions = array( 13 "3.3",14 "3.2",15 "3.1",16 "3.0",17 "2.1",18 "2.0",19 "1.9.3",20 "1.9.2",21 "1.9.1",13 '3.3', 14 '3.2', 15 '3.1', 16 '3.0', 17 '2.1', 18 '2.0', 19 '1.9.3', 20 '1.9.2', 21 '1.9.1', 22 22 ); 23 23 24 $stats = array( "date"=> date('Y-m-d H:i:s'));24 $stats = array('date' => date('Y-m-d H:i:s')); 25 25 26 foreach ($versions as $version) {27 $n = sql_countsel( "spip_websites","statut='publie' AND spip LIKE ".sql_quote("$version%"));26 foreach ($versions as $version) { 27 $n = sql_countsel('spip_websites', "statut='publie' AND spip LIKE ".sql_quote("$version%")); 28 28 $stats[$version] = $n; 29 29 } … … 32 32 $stats = json_encode($stats); 33 33 34 $filename = _DIR_VAR.(defined('_UNIVERS_STATSV_FILE')?_UNIVERS_STATSV_FILE: "histostats.json.txt");35 ecrire_fichier($filename, "$stats\n",false,false);34 $filename = _DIR_VAR.(defined('_UNIVERS_STATSV_FILE')?_UNIVERS_STATSV_FILE:'histostats.json.txt'); 35 ecrire_fichier($filename, "$stats\n", false, false); 36 36 37 37 return 0; 38 38 } 39 40 41 ?> -
_dev_/univers_spip/inc/univers.php
r107430 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 9 include_spip('inc/filtres'); 9 10 include_spip('inc/distant'); 10 11 include_spip('inc/meta'); 11 12 12 13 function univers_proposer_site($url, $desc=""){ 13 function univers_proposer_site($url, $desc = '') { 14 14 $parts = parse_url($url); 15 15 // pas d'IP fixe ! 16 if (preg_match( ";^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}$;",$parts['host']))16 if (preg_match(';^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}$;', $parts['host'])) { 17 17 return false; 18 } 18 19 // pas de fausse url venant de feedburner ou google ! 19 20 // on pourrait faire mieux en suivant la redirection pour 20 21 // attraper le vrai nom du site 21 if (preg_match( ",(feeds\.feedburner\.com|feedproxy\.google\.com),i",$parts['host']))22 if (preg_match(',(feeds\.feedburner\.com|feedproxy\.google\.com),i', $parts['host'])) { 22 23 return false; 24 } 23 25 24 26 #if (is_utf8($parts['host'])) … … 26 28 27 29 #$parts['path'] = preg_replace(",(IMG|local)/cache.+spip[.]php,","spip.php",$parts['path']); 28 $base = $parts['scheme'] . "://". $parts['host'] . $parts['path'];30 $base = $parts['scheme'] . '://' . $parts['host'] . $parts['path']; 29 31 $base = univers_nettoyer_url($base); 30 $base = preg_replace(",(spip[.]php3?).*$,i",'\\1',$base); 31 $base_short = preg_replace(",spip[.]php.*$,i",'',$base); 32 33 if ($id_website = sql_getfetsel('id_website', "spip_websites", "url=".sql_quote($base)) 34 OR 35 ($base_short!==$base AND $id_website = sql_getfetsel('id_website', "spip_websites", "url=".sql_quote($base_short)))) 36 return $id_website; 37 38 $id_website = sql_insertq("spip_websites", array('url'=>$base,'descriptif'=>$desc,'date'=>date('Y-m-d H:i:s'))); 32 $base = preg_replace(',(spip[.]php3?).*$,i', '\\1', $base); 33 $base_short = preg_replace(',spip[.]php.*$,i', '', $base); 34 35 if ($id_website = sql_getfetsel('id_website', 'spip_websites', 'url='.sql_quote($base)) or 36 ($base_short!==$base and 37 $id_website = sql_getfetsel('id_website', 'spip_websites', 'url='.sql_quote($base_short)) 38 ) 39 ) { 40 return $id_website; 41 } 42 43 $id_website = sql_insertq('spip_websites', array('url'=>$base,'descriptif'=>$desc,'date'=>date('Y-m-d H:i:s'))); 39 44 40 45 // relire et verifier 41 $url = sql_getfetsel( "url","spip_websites","id_website=".intval($id_website));46 $url = sql_getfetsel('url', 'spip_websites', 'id_website='.intval($id_website)); 42 47 if ($url !== $base) { 43 48 // il y a eu un caractere exotique dans l'url, on la vire 44 sql_delete('spip_websites', "id_website=".intval($id_website));49 sql_delete('spip_websites', 'id_website='.intval($id_website)); 45 50 return false; 46 51 } … … 50 55 51 56 // reparer les urls mal formees 52 function univers_nettoyer_url($url) {53 $url = preg_replace( ",(IMG|local)/cache.+spip[.]php,","spip.php",$url);54 $url = preg_replace( ",(index|spip)[.]php/.+,i","spip.php",$url);55 $url = preg_replace( ",(index|spip|forum|article)[.]php3/.+,i","",$url);56 $url = preg_replace( ",/(plugins|ecrire|IMG|local|squelettes)/.+[.]php,i","",$url);57 function univers_nettoyer_url($url) { 58 $url = preg_replace(',(IMG|local)/cache.+spip[.]php,', 'spip.php', $url); 59 $url = preg_replace(',(index|spip)[.]php/.+,i', 'spip.php', $url); 60 $url = preg_replace(',(index|spip|forum|article)[.]php3/.+,i', '', $url); 61 $url = preg_replace(',/(plugins|ecrire|IMG|local|squelettes)/.+[.]php,i', '', $url); 57 62 58 63 return $url; 59 64 } 60 65 61 function univers_nettoyer_urls() {66 function univers_nettoyer_urls() { 62 67 // urls mal formees 63 $res = sql_select("id_website,url", "spip_websites", 64 "url REGEXP '(index|spip)[.]php/.+'" 68 $res = sql_select( 69 'id_website,url', 70 'spip_websites', 71 "url REGEXP '(index|spip)[.]php/.+'" 65 72 ." OR url REGEXP '/(plugins|ecrire|IMG|local|squelettes)/.+[.]php$'" 66 67 while ($row = sql_fetch($res)) {73 ); 74 while ($row = sql_fetch($res)) { 68 75 $url = univers_nettoyer_url($row['url']); 69 if ($url!=$row['url']) {70 spip_log( "nettoyage ".$row['id_website'].":".$row['url']." => $url",'universclean');71 sql_updateq( "spip_websites", array('url'=>$url),"id_website=".intval($row['id_website']));76 if ($url!=$row['url']) { 77 spip_log('nettoyage '.$row['id_website'].':'.$row['url']." => $url", 'universclean'); 78 sql_updateq('spip_websites', array('url'=>$url), 'id_website='.intval($row['id_website'])); 72 79 } 73 80 } 74 81 75 82 // urls refusees (feed google/feedburner) 76 sql_delete('spip_websites', 'url LIKE'.sql_quote('http://feeds.feedburner.com%'));77 sql_delete('spip_websites', 'url LIKE'.sql_quote('http://feedproxy.google.com%'));83 sql_delete('spip_websites', 'url LIKE'.sql_quote('http://feeds.feedburner.com%')); 84 sql_delete('spip_websites', 'url LIKE'.sql_quote('http://feedproxy.google.com%')); 78 85 79 86 // nettoyage des liens morts (suite a delete ci-dessus) 80 $res = sql_select('P.id_website','spip_websites_plugins AS P LEFT JOIN spip_websites AS W ON P.id_website = W.id_website','W.id_website IS NULL'); 81 while ($row = sql_fetch($res)){ 82 sql_delete('spip_websites_plugins','id_website='.intval($row['id_website'])); 83 } 84 } 85 86 function univers_rechercher_referers($date){ 87 $res = sql_select('referer','spip_referers',"date=".sql_quote($date)." AND referer LIKE '%spip.php%' AND referer NOT LIKE 'https://contrib.spip.net%' AND referer NOT LIKE '%localhost%'"); 88 spip_log("Import depuis les referer du $date : %spip.php% , ".sql_count($res),"universreferers"); 89 while ($row = sql_fetch($res)) { 90 spip_log("Import referer : ".$row['referer'],"universreferers"); 87 $res = sql_select( 88 'P.id_website', 89 'spip_websites_plugins AS P LEFT JOIN spip_websites AS W ON P.id_website = W.id_website', 90 'W.id_website IS NULL' 91 ); 92 while ($row = sql_fetch($res)) { 93 sql_delete('spip_websites_plugins', 'id_website='.intval($row['id_website'])); 94 } 95 } 96 97 function univers_rechercher_referers($date) { 98 $res = sql_select( 99 'referer', 100 'spip_referers', 101 'date='. 102 sql_quote($date). 103 " AND referer LIKE '%spip.php%' AND referer NOT LIKE 'https://contrib.spip.net%'". 104 " AND referer NOT LIKE '%localhost%'" 105 ); 106 spip_log("Import depuis les referer du $date : %spip.php% , ".sql_count($res), 'universreferers'); 107 while ($row = sql_fetch($res)) { 108 spip_log('Import referer : '.$row['referer'], 'universreferers'); 91 109 univers_proposer_site($row['referer']); 92 110 } 93 111 94 $res = sql_select('referer','spip_referers',"date=".sql_quote($date)." AND referer LIKE '%/ecrire/%' AND referer NOT LIKE 'https://contrib.spip.net%' AND referer NOT LIKE '%localhost%'"); 95 spip_log("Import depuis les referer du $date : %/ecrire/% , ".sql_count($res),"universreferers"); 96 while ($row = sql_fetch($res)) { 97 spip_log("Import referer : ".$row['referer'],"universreferers"); 98 univers_proposer_site(preg_replace(',/ecrire/.*$,Uims','/spip.php',$row['referer'])); 99 } 100 } 101 102 # 21 dec 2012 : fin du monde , plus de yahoo boss 103 /* 104 function univers_boss_request($query, $args=array()){ 105 $apiid = "vKArhavV34HzXT9wvczrzUX58tMbO_TDOyDZqoi6o243vTtNPSZXW0GOYuuP4NxqUA--"; 106 $uri = "http://boss.yahooapis.com/ysearch/web/v1/$query?appid=$apiid"; 107 $params = array_merge(array( 108 'format' => 'xml', 109 'start' => 0, 110 'count' => 50, 111 'lang' => 'fr', 112 'region' => 'fr', 113 'style' => 'raw', 114 ),$args); 115 116 foreach($params as $k=>$v) 117 $uri = parametre_url($uri, $k, $v,'&'); 118 include_spip('inc/distant'); 119 $res = recuperer_page($uri); 120 return $res; 121 } 122 123 function univers_boss_explore($echo=false){ 124 $explore = array( 125 0=>array('"spip.php"',array()), 126 1=>array('"spip.php?page=backend"',array()), 127 2=>array('"spip.php?page=plan"',array()), 128 3=>array('"spip.php?page=sommaire"',array()), 129 4=>array("Si votre message se réfère à un article publié sur le Web, ou à une page fournissant plus d'informations, vous pouvez indiquer ci-après le titre de la page et son adresse",array()) 130 ); 131 132 $regions = array( 133 array('ar','es'), 134 array('at','de'), 135 array('au','en'), 136 array('br','pt'), 137 array('ca','en'), 138 array('ca','fr'), 139 array('ct','ca'), 140 array('cl','es'), 141 array('co','es'), 142 array('cz','cs'), 143 array('dk','da'), 144 array('fi','fi'), 145 array('fr','fr'), 146 array('de','de'), 147 array('hk','tzh'), 148 array('hu','hu'), 149 array('id','en'), 150 array('id','id'), 151 array('in','en'), 152 array('il','he'), 153 array('it','it'), 154 array('jp','jp'), 155 array('kr','kr'), 156 array('my','en'), 157 array('my','ms'), 158 array('mx','es'), 159 array('nl','nl'), 160 array('nz','en'), 161 array('no','no'), 162 array('pe','es'), 163 array('ph','tl'), 164 array('ph','en'), 165 array('ro','ro'), 166 array('ru','ru'), 167 array('sg','en'), 168 array('es','es'), 169 array('se','sv'), 170 array('ch','fr'), 171 array('ch','de'), 172 array('ch','it'), 173 array('th','th'), 174 array('tw','tzh'), 175 array('tr','tr'), 176 array('uk','en'), 177 array('us','en'), 178 array('us','es'), 179 array('ve','es'), 180 array('vn','vi'), 181 ); 182 183 $start = rand(0,19)*50; 184 $region = $regions[rand(0,count($regions)-1)]; 185 $ex = $explore[rand(0,3)]; 186 spip_log("BOSS $ex[0]/$start/".implode(',',$region),'univers'); 187 $res = univers_boss_request($ex[0],array_merge($ex[1],array('start'=>$start,'region'=>$region[0],'lang'=>$region[1]))); 188 189 $links = extraire_balises($res,'url'); 190 foreach($links as $link) 191 if (preg_match(",<url>(.*)</url>,Uims", $link,$reg) 192 AND preg_match(",http://[^?\"'#;:]*(spip|forum|article)[.]php3?,Uims", $reg[1])) 193 $urls[] = trim($reg[1]); 194 195 $urls = array_unique($urls); 196 foreach($urls as $url){ 197 spip_log("$url",'univers'); 198 univers_proposer_site($url); 199 } 200 } 201 */ 202 203 function univers_rechercher_sites_spip($req,$start=0,$max=10,$step=10,$var='start'){ 112 $res = sql_select( 113 'referer', 114 'spip_referers', 115 'date='. 116 sql_quote($date). 117 " AND referer LIKE '%/ecrire/%' AND referer NOT LIKE 'https://contrib.spip.net%'". 118 " AND referer NOT LIKE '%localhost%'" 119 ); 120 spip_log("Import depuis les referer du $date : %/ecrire/% , ".sql_count($res), 'universreferers'); 121 while ($row = sql_fetch($res)) { 122 spip_log('Import referer : '.$row['referer'], 'universreferers'); 123 univers_proposer_site(preg_replace(',/ecrire/.*$,Uims', '/spip.php', $row['referer'])); 124 } 125 } 126 127 function univers_rechercher_sites_spip($req, $start = 0, $max = 10, $step = 10, $var = 'start') { 204 128 $urls = array(); 205 while ($start<$max) {129 while ($start<$max) { 206 130 $url = parametre_url($req, $var, $start, '&'); 207 131 $page = recuperer_page($url); 208 $h3 = extraire_balises($page, 'h3');209 foreach ($h3 as $h){210 $a = extraire_balise($h, 'a');211 $href = extraire_attribut($a, "href");212 if (preg_match( ";^([a-z]{3,5})://;i",$href)213 AND strpos($href,'inurl:')===FALSE214 AND strpos($href,'google')===FALSE215 AND strpos($href,'spip.php')!==FALSE){216 $href = preg_replace( ",spip[.]php?.*$,i", "spip.php", $href);132 $h3 = extraire_balises($page, 'h3'); 133 foreach ($h3 as $h) { 134 $a = extraire_balise($h, 'a'); 135 $href = extraire_attribut($a, 'href'); 136 if (preg_match(';^([a-z]{3,5})://;i', $href) 137 and strpos($href, 'inurl:')===false 138 and strpos($href, 'google')===false 139 and strpos($href, 'spip.php')!==false) { 140 $href = preg_replace(',spip[.]php?.*$,i', 'spip.php', $href); 217 141 $urls[$href] = textebrut($a); 218 142 } 219 143 } 220 144 $start+=$step; 221 #sleep(1);222 145 } 223 146 return $urls; 224 147 } 225 148 226 227 function univers_twitter_extraire_feed_urls($url, $enlarge=true){ 149 function univers_twitter_extraire_feed_urls($url, $enlarge = true) { 228 150 $long = array(); 229 151 $urls = array(); 230 152 $page = recuperer_page($url); 231 $page = str_replace( "<b>","",$page);232 $page = str_replace( "</b>","",$page);233 234 $titles = extraire_balises($page, "title");235 $page = preg_replace( ",</?title>,ims","\n",implode($titles));153 $page = str_replace('<b>', '', $page); 154 $page = str_replace('</b>', '', $page); 155 156 $titles = extraire_balises($page, 'title'); 157 $page = preg_replace(',</?title>,ims', "\n", implode($titles)); 236 158 237 159 preg_match_all(",https?://[^?\"'#;:\s]*,ims", $page, $regs, PREG_SET_ORDER); 238 $urls = array_map('reset', $regs);239 foreach ($urls as $k=>$url) {240 if (!preg_match(",https?://[^?\"'#;:]*spip[.]php3?,Uims", $url)) {160 $urls = array_map('reset', $regs); 161 foreach ($urls as $k => $url) { 162 if (!preg_match(",https?://[^?\"'#;:]*spip[.]php3?,Uims", $url)) { 241 163 // essayer de l'elargir 242 if (!isset($long[$url])){ 243 #var_dump($url); 244 $long[$url] = recuperer_lapage($url,false,'GET',100000); 164 if (!isset($long[$url])) { 165 $long[$url] = recuperer_lapage($url, false, 'GET', 100000); 245 166 $long[$url] = (is_string($long[$url])?$long[$url]:false); 246 167 } 247 if ($long[$url]){ 248 #var_dump("$url > ".$long[$url]); 168 if ($long[$url]) { 249 169 $urls[$k] = $url = $long[$url]; 250 170 } 251 171 } 252 if (!preg_match(",https?://[^?\"'#;:]*spip[.]php3?,Uims", $url)) {172 if (!preg_match(",https?://[^?\"'#;:]*spip[.]php3?,Uims", $url)) { 253 173 unset($urls[$k]); 254 174 } … … 258 178 return $urls; 259 179 } 260 function univers_googlenews_extraire_feed_urls($url){ 261 return univers_identica_extraire_feed_urls($url, false); 262 } 263 function univers_identica_extraire_feed_urls($url){ 180 181 function univers_spipnet_extraire_feed_urls($url) { 264 182 $urls = array(); 265 183 $page = recuperer_page($url); 266 $page = str_replace("<b>","",$page); 267 $page = str_replace("</b>","",$page); 268 preg_match_all(",http://[^?\"'#;:]*spip[.]php3?,Uims", $page, $regs, PREG_SET_ORDER); 269 $urls = array_map('reset',$regs); 184 $links = extraire_balises($page, 'link'); 185 foreach ($links as $link) { 186 if (preg_match(',<link>(.*)</link>,Uims', $link, $reg)) { 187 $urls[] = trim($reg[1]); 188 } 189 } 270 190 $urls = array_unique($urls); 191 271 192 return $urls; 272 193 } 273 194 274 function univers_spipnet_extraire_feed_urls($url){ 275 $urls = array(); 276 $page = recuperer_page($url); 277 $links = extraire_balises($page,'link'); 278 foreach($links as $link) 279 if (preg_match(",<link>(.*)</link>,Uims", $link,$reg)) 280 $urls[] = trim($reg[1]); 281 $urls = array_unique($urls); 282 283 return $urls; 284 } 285 function univers_delisarka_extraire_feed_urls($url){ 286 return univers_spipnet_extraire_feed_urls($url); 287 } 288 289 function univers_feed_watch($echo=false){ 195 function univers_feed_watch($echo = false) { 290 196 $explore = array( 291 //MORT 'twitter'=>"http://search.twitter.com/search.atom?q=spip.php",292 197 'twitter' => 'https://blog.spip.net/?page=backend-twitter-spip', 293 'spipnet'=>"https://www.spip.net/?page=backend-sites-sous-spip&id_article=884", 294 //MORT 'googlenews'=>"http://news.google.fr/news?pz=1&cf=all&ned=fr&hl=fr&q=%22spip.php%22&cf=all&output=rss", 295 //MORT 'delisarka'=>'http://feeds.delicious.com/v2/rss/sarkaspip?count=10', 296 //MORT 'identica'=>"http://identi.ca/search/notice/rss?q=spip.php", 297 ); 298 198 'spipnet'=>'https://www.spip.net/?page=backend-sites-sous-spip&id_article=884', 199 ); 299 200 300 201 $feed = 0; 301 if (isset($GLOBALS['meta']['univers_feedwatch'])) 202 if (isset($GLOBALS['meta']['univers_feedwatch'])) { 302 203 $feed = $GLOBALS['meta']['univers_feedwatch']; 204 } 303 205 304 206 305 207 $i = 0; 306 while ($i++<$feed) 307 list($type,$url) = each($explore); 308 309 list($type,$url) = each($explore); 310 if (function_exists($f="univers_$type"."_extraire_feed_urls")) { 311 spip_log($s="Analyse Feed $url",'univers'); 312 if ($echo) 208 while ($i++<$feed) { 209 list($type, $url) = each($explore); 210 } 211 212 list($type, $url) = each($explore); 213 if (function_exists($f = "univers_$type".'_extraire_feed_urls')) { 214 spip_log($s = "Analyse Feed $url", 'univers'); 215 if ($echo) { 313 216 echo "$s<br />"; 217 } 314 218 $liste = $f($url); 315 219 316 foreach ($liste as $url){317 spip_log($s ="$url",'univers');318 if ($echo) 220 foreach ($liste as $url) { 221 spip_log($s = "$url", 'univers'); 222 if ($echo) { 319 223 echo "$s<br />"; 224 } 320 225 univers_proposer_site($url); 321 226 } … … 323 228 324 229 $feed++; 325 if ($feed>=count($explore)) 230 if ($feed>=count($explore)) { 326 231 $feed = 0; 232 } 327 233 ecrire_meta('univers_feedwatch', $feed); 328 234 // un coup de netoyage sur les urls mal formees 329 235 univers_nettoyer_urls(); 330 236 } 331 332 ?> -
_dev_/univers_spip/inc/univers_analyser.php
r111472 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 9 9 // User agent used to load the page 10 @define('_INC_DISTANT_USER_AGENT', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fr; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9'); 11 @define('_INC_DISTANT_VERSION_HTTP', "HTTP/1.0"); 10 @define( 11 '_INC_DISTANT_USER_AGENT', 12 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fr; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9' 13 ); 14 @define('_INC_DISTANT_VERSION_HTTP', 'HTTP/1.0'); 15 16 if (!defined('_ECRIRE_INC_VERSION')) { 17 return; 18 } 12 19 13 20 include_spip('inc/filtres'); … … 15 22 include_spip('inc/meta'); 16 23 17 if (!defined("_ECRIRE_INC_VERSION")) return;18 19 24 /** 20 25 * Get the complete page. … … 28 33 * 29 34 */ 30 function univers_recuperer_lapage($url, $cookie="") {31 $ref = $GLOBALS['meta'][ "adresse_site"];35 function univers_recuperer_lapage($url, $cookie = '') { 36 $ref = $GLOBALS['meta']['adresse_site']; 32 37 // let's say we're coming from google, after all... 33 $GLOBALS['meta']["adresse_site"] = "http://www.google.fr"; 34 $datas = "" 35 # ."Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" 36 # ."Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n" 37 # ."Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" 38 # ."Keep-Alive: 300\r\n" 39 # ."Connection: keep-alive\r\n" 38 $GLOBALS['meta']['adresse_site'] = 'http://www.google.fr'; 39 $datas = '' 40 40 ."Cookie: $cookie\r\n" 41 # ."If-Modified-Since: Sat, 08 May 2010 20:49:37 GMT\r\n"42 # ."Cache-Control: max-age=0\r\n"43 41 ."\r\n" 44 42 ; … … 46 44 $site = $url; 47 45 $max_redir = 10; 48 while ($site AND is_string($site) AND$max_redir--) {46 while ($site and is_string($site) and $max_redir--) { 49 47 $url = $site; 50 $site = recuperer_lapage($url, false,'GET',1048576,$datas);51 } 52 53 $GLOBALS['meta'][ "adresse_site"] = $ref;54 if (!$site) 48 $site = recuperer_lapage($url, false, 'GET', 1048576, $datas); 49 } 50 51 $GLOBALS['meta']['adresse_site'] = $ref; 52 if (!$site) { 55 53 return $site; 56 if (is_string($site) AND !$max_redir) 54 } 55 if (is_string($site) and !$max_redir) { 57 56 return false; 57 } 58 58 list($header, $page) = $site; 59 59 60 60 // if a cookie set, accept it an retry with it 61 if (preg_match( ",Set-Cookie: (.*)(;.*)?$,Uims",$header,$r)) {61 if (preg_match(',Set-Cookie: (.*)(;.*)?$,Uims', $header, $r)) { 62 62 //ne pas relancer si le cookie est déjà présent 63 if (strpos($cookie, $r[1])===FALSE) {64 $cookie .= $r[1] . ";";65 spip_log("Cookie : $cookie on repart pour un tour ", "univers_check");63 if (strpos($cookie, $r[1])===false) { 64 $cookie .= $r[1] . ';'; 65 spip_log("Cookie : $cookie on repart pour un tour ", 'univers_check'); 66 66 return univers_recuperer_lapage($url, $cookie); 67 67 } … … 86 86 if (is_callable('shell_exec') && false === stripos(ini_get('disable_functions'), 'shell_exec')) { 87 87 $query = `nslookup -timeout=$timeout -retry=1 $host`; 88 if (preg_match('/\nAddress: (.*)\n/', $query, $matches)) {88 if (preg_match('/\nAddress: (.*)\n/', $query, $matches)) { 89 89 return trim($matches[1]); 90 90 } … … 101 101 * @return boolean 102 102 */ 103 function univers_analyser($url, $debug =false) {103 function univers_analyser($url, $debug = false) { 104 104 $res = array(); 105 105 106 spip_log("analyse version : $url ", "univers_check");106 spip_log("analyse version : $url ", 'univers_check'); 107 107 $path = parse_url($url); 108 108 $ip = univers_getaddrbyhost($path['host']); 109 if (!$ip OR $ip==$path['host'])109 if (!$ip or $ip==$path['host']) { 110 110 return false; // pas d'ip, pas de site, rien a faire 111 } 111 112 112 113 $res['ip'] = $ip; … … 120 121 121 122 list($header, $page) = $site; 122 if ($debug) var_dump($header); 123 if ($debug) { 124 var_dump($header); 125 } 123 126 124 127 // get some generic informations (server, php, gzip, length) … … 139 142 if (preg_match($regexp = ',Composed-By: (.*)( @ www.spip.net)( ?\+ ?(.*))?$,m', $header, $r)) { 140 143 // essayer de choper local/config.txt si il est la car plus complet si le header semble coupe 141 if (substr($header, -1)!==")"){142 $url_config = suivre_lien($url, "local/config.txt");144 if (substr($header, -1)!==')') { 145 $url_config = suivre_lien($url, 'local/config.txt'); 143 146 $config = univers_recuperer_lapage($url_config); 144 147 if (!$config) { 145 148 $url_mutu = str_replace('ww2.', '', str_replace('www.', '', $path['host'])); 146 $url_config = suivre_lien($url, "sites/$url_mutu/local/config.txt");149 $url_config = suivre_lien($url, "sites/$url_mutu/local/config.txt"); 147 150 $config = univers_recuperer_lapage($url_config); 148 151 } 149 if ($config AND preg_match($regexp, $config[1], $rc))152 if ($config and preg_match($regexp, $config[1], $rc)) { 150 153 $r = $rc; 151 } 152 $res['spip'] = trim(preg_replace(',^[^0-9]*,','',$r[1])); 153 if (!$res['spip']) 154 } 155 } 156 $res['spip'] = trim(preg_replace(',^[^0-9]*,', '', $r[1])); 157 if (!$res['spip']) { 154 158 $res['spip'] = '?'; 159 } 155 160 $res['plugins'] = array(); 156 161 if ($p = array_filter(explode(',', $r[4]))) { 157 162 foreach ($p as $plugin) { 158 163 $plugin = trim($plugin); 159 $res['plugins'][preg_replace(',[(].*,', '', $plugin)] = $plugin;164 $res['plugins'][preg_replace(',[(].*,', '', $plugin)] = $plugin; 160 165 } 161 166 } … … 163 168 // else, find another clue 164 169 // if 'spip' is in the html, there are some chance that it is a SPIP site 165 if (!isset($res['spip'])) 166 if (preg_match(',spip,i', $page)) 170 if (!isset($res['spip'])) { 171 if (preg_match(',spip,i', $page)) { 167 172 $res['spip'] = ''; 173 } 174 } 168 175 169 176 // if maybe but not sure, try to get the login page 170 177 // it should have some information that says "SPIP" 171 if (isset($res['spip']) AND (!$res['spip'] OR $res['spip']=='?')){178 if (isset($res['spip']) and (!$res['spip'] or $res['spip']=='?')) { 172 179 // recuperer la page de login 173 $login = preg_replace( ",spip[.]php.*$,","",$url)."ecrire/";174 if ($login = univers_recuperer_lapage($login)) {180 $login = preg_replace(',spip[.]php.*$,', '', $url).'ecrire/'; 181 if ($login = univers_recuperer_lapage($login)) { 175 182 list(, $login) = $login; 176 if (preg_match(',<meta name=[\'"]generator["\'][^>]*>,Uims',$login,$r)177 AND$v = extraire_attribut($r[0], 'content')178 AND preg_match(",SPIP ([^\[]+),",$v,$r))183 if (preg_match(',<meta name=[\'"]generator["\'][^>]*>,Uims', $login, $r) 184 and $v = extraire_attribut($r[0], 'content') 185 and preg_match(',SPIP ([^\[]+),', $v, $r)) { 179 186 $res['spip'] = trim($r[1]); 187 } 180 188 } 181 189 } … … 184 192 // try to get the htaccess.txt delivered with SPIP, 185 193 // it has some extra informations 186 if (isset($res['spip']) AND (!$res['spip'] OR $res['spip']=='?')){194 if (isset($res['spip']) and (!$res['spip'] or $res['spip']=='?')) { 187 195 // tenter de recup le htaccess.txt qui contient un numero de version 188 $ht = preg_replace( ",spip[.]php.*$,","",$url)."htaccess.txt";196 $ht = preg_replace(',spip[.]php.*$,', '', $url).'htaccess.txt'; 189 197 if ($ht = univers_recuperer_lapage($ht)) { 190 198 list(, $htpage) = $ht; 191 if (preg_match( ",SPIP v\s*([0-9.]+),",$htpage,$r))199 if (preg_match(',SPIP v\s*([0-9.]+),', $htpage, $r)) { 192 200 $res['spip'] = $r[1]; 201 } 193 202 } 194 203 195 204 // if we did'nt found a confirmation and there was only 'spip' in the html 196 205 // maybe it's an old spip site, but whe mark it apart as it is suspect 197 if (!$res['spip']) 206 if (!$res['spip']) { 198 207 $res['spip'] = '<1.8?'; 208 } 199 209 } 200 210 201 211 // if it is a 404, that was a bad adress 202 if (count($res)==1 AND preg_match(',404 ,', $header)){212 if (count($res)==1 and preg_match(',404 ,', $header)) { 203 213 $res['response'] = '404'; 204 } 205 else { 214 } else { 206 215 // else record the page size and so on 207 216 $res['size'] = strlen($page); 208 217 $res['response'] = true; 209 if (preg_match(',<title>(.*)</title>,Uims', $page, $r))218 if (preg_match(',<title>(.*)</title>,Uims', $page, $r)) { 210 219 $res['title'] = $r[1]; 211 if (preg_match(',<meta name=[\'"]description["\'][^>]*>,Uims',$page,$r)) 220 } 221 if (preg_match(',<meta name=[\'"]description["\'][^>]*>,Uims', $page, $r)) { 212 222 $res['description'] = extraire_attribut($r[0], 'content'); 223 } 213 224 } 214 225 return $res; 215 216 226 } 217 227 … … 222 232 * @param bool $debug 223 233 */ 224 function univers_analyser_un($row,$debug = false){ 225 if ($debug) var_dump($row); 234 function univers_analyser_un($row, $debug = false) { 235 if ($debug) { 236 var_dump($row); 237 } 226 238 $id = $row['id_website']; 227 239 $url = $row['url']; … … 229 241 // incrementer le retry et la date avant tout pour ne pas tourner en rond 230 242 // sur ce site si il timeout 231 sql_updateq("spip_websites", array('retry'=>$row['retry']+1,'date'=>date('Y-m-d H:i:s'),'status'=>'timeout?'), "id_website=".intval($id)); 243 sql_updateq( 244 'spip_websites', 245 array('retry'=>$row['retry']+1,'date'=>date('Y-m-d H:i:s'),'status'=>'timeout?'), 246 'id_website='.intval($id) 247 ); 232 248 233 249 $res = univers_analyser($url, $debug); 234 if ($debug) var_dump($res); 250 if ($debug) { 251 var_dump($res); 252 } 235 253 236 254 $set = array(); … … 238 256 $set['retry'] = ++$row['retry']; 239 257 $set['status'] = 'no-dns'; 240 } 241 elseif ($res['response']===false OR $res['response']==='404'){ 258 } elseif ($res['response']===false or $res['response']==='404') { 242 259 $set['ip'] = $res['ip']; 243 260 $set['retry'] = ++$row['retry']; 244 261 $set['status'] = ($res['response']?$res['response']:'dead'); 245 } 246 elseif ($res['response']===true) { 262 } elseif ($res['response']===true) { 247 263 $set['ip'] = $res['ip']; 248 264 $set['server'] = !empty($res['server'])?$res['server']:''; … … 252 268 $set['size'] = !empty($res['size'])?$res['size']:0; 253 269 254 if (isset($res['spip'])) {270 if (isset($res['spip'])) { 255 271 $set['pays'] = univers_geoip($set['ip']); 256 272 … … 258 274 $set['spip'] = $res['spip']; 259 275 $set['statut'] = 'publie'; 260 if ($res['title']) 276 if ($res['title']) { 261 277 $set['titre'] = $res['title']; 262 if ($res['description']) 278 } 279 if ($res['description']) { 263 280 $set['descriptif'] = $res['description']; 281 } 264 282 $set['plugins'] = count($res['plugins']); 265 283 // mettre a jour les plugins 266 sql_delete('spip_websites_plugins', "id_website=".intval($id));267 268 foreach ($res['plugins'] as $p=>$v) {284 sql_delete('spip_websites_plugins', 'id_website='.intval($id)); 285 if (is_array($res['plugins'])) { 286 foreach ($res['plugins'] as $p => $v) { 269 287 sql_insertq('spip_websites_plugins', array('id_website'=>$id,'plugin'=>$p,'version'=>$v)); 270 288 } 271 289 } 272 290 273 if ($debug) var_dump(univers_geoip($set['ip'])); 274 } 275 else { 291 if ($debug) { 292 var_dump(univers_geoip($set['ip'])); 293 } 294 } else { 276 295 // c'en est pas un ! 277 296 $set['statut'] = 'refuse'; … … 279 298 $set['status'] = ''; 280 299 $set['retry'] = 0; 281 } 282 else { 300 } else { 283 301 // ??? 284 302 $set['retry'] = ++$row['retry']; … … 287 305 288 306 $set['date'] = date('Y-m-d H:i:s'); 289 if ($debug) var_dump($set); 290 sql_updateq("spip_websites", $set, "id_website=".intval($id)); 291 } 292 307 if ($debug) { 308 var_dump($set); 309 } 310 sql_updateq('spip_websites', $set, 'id_website='.intval($id)); 311 } 293 312 294 313 /** … … 299 318 * @return string 300 319 */ 301 function univers_geoip($ip =null){320 function univers_geoip($ip = null) { 302 321 static $gi = null; 303 if (is_null($ip)) {304 include_spip( "geoip/geoip");322 if (is_null($ip)) { 323 include_spip('geoip/geoip'); 305 324 geoip_close($gi); 306 325 return; 307 326 } 308 if (is_null($gi)) {309 include_spip( "geoip/geoip");310 $gi = geoip_open(find_in_path( "geoip/GeoIP.dat"),GEOIP_STANDARD);311 } 312 313 return geoip_country_code_by_addr($gi, $ip);314 } 327 if (is_null($gi)) { 328 include_spip('geoip/geoip'); 329 $gi = geoip_open(find_in_path('geoip/GeoIP.dat'), GEOIP_STANDARD); 330 } 331 332 return geoip_country_code_by_addr($gi, $ip); 333 } -
_dev_/univers_spip/stats-tout.html
r112576 r112585 87 87 </B_plugins> 88 88 89 <!--90 <B_pluginsv>91 <h3>Plugins, versionnés</h3>92 <table>93 <thead>94 <tr><th>Version de plugin</th><th>Nombre de sites</th></tr>95 </thead>96 <tbody>97 <BOUCLE_pluginsv(websites_plugins){fusion version}{!par compte_version}{compte version}>98 <tr><td>#VERSION</td><td>#COMPTE{version}</td></tr>99 </BOUCLE_pluginsv>100 </tbody>101 </table>102 </B_pluginsv>103 -->104 105 89 <B_pays> 106 90 <h3>Pays</h3> -
_dev_/univers_spip/stats-v.html
r112576 r112585 49 49 </B_plugins> 50 50 51 <!--52 <B_pluginsv>53 <h3>Plugins, versionnés</h3>54 <table>55 <thead>56 <tr><th>Version de plugin</th><th>Nombre de sites</th></tr>57 </thead>58 <tbody>59 <BOUCLE_pluginsv(websites_plugins websites){websites.spip like #GET{likev}}{fusion version}{!par compte_version}{compte version}>60 <tr><td>#VERSION</td><td>#COMPTE{version}</td></tr>61 </BOUCLE_pluginsv>62 </tbody>63 </table>64 </B_pluginsv>65 -->66 67 51 <B_pays> 68 52 <h3>Pays</h3> -
_dev_/univers_spip/univers_pipelines.php
r107430 r112585 1 1 <?php 2 /* 2 3 /** 3 4 * Plugin Univers SPIP 4 5 * (c) 2010 Cedric 5 6 * Distribue sous licence GPL 6 *7 7 */ 8 8 9 function univers_taches_generales_cron($taches_generales){ 9 /** 10 * Taches periodiques de verification des sites en SPIP. 11 * 12 * @param array $taches_generales Les taches generales 13 * 14 * @return array Les nouvelles taches generales 15 */ 16 function univers_taches_generales_cron(array $taches_generales) { 10 17 $taches_generales['univers_feed'] = 240; 11 #$taches_generales['univers_google'] = 77;12 18 $taches_generales['univers_referers'] = 12*3600; 13 19 $taches_generales['univers_statsv'] = 3*24*3600; 20 $taches_generales['univers_check'] = 97; 14 21 15 # 21 dec 2012 : fin du monde , plus de yahoo boss16 #$taches_generales['univers_boss'] = 173;17 18 $taches_generales['univers_check'] = 97;19 #$taches_generales['univers_check_1'] = 41;20 #$taches_generales['univers_check_2'] = 37;21 #$taches_generales['univers_check_3'] = 31;22 22 return $taches_generales; 23 23 }
Note: See TracChangeset
for help on using the changeset viewer.