diff --git a/.gitattributes b/.gitattributes index 148efe3d59cec96e0b3f70888cae4c6e34844e54..9843bd8a75d2cae067a5ac0953723160f748cfef 100644 --- a/.gitattributes +++ b/.gitattributes @@ -280,6 +280,7 @@ ecrire/inc_configuration.php -text ecrire/inc_controle_forum.php -text ecrire/inc_controle_petition.php -text ecrire/inc_cookie.php -text +ecrire/inc_distant.php -text ecrire/inc_forum_admin.php -text ecrire/inc_headers.php -text ecrire/inc_install.php -text @@ -294,6 +295,7 @@ ecrire/inc_minipres.php -text ecrire/inc_naviguer.php -text ecrire/inc_popularites.php3 -text ecrire/inc_sites_edit.php -text +ecrire/inc_sites_tous.php -text ecrire/inc_spip_cal.php -text ecrire/inc_spip_image.php -text ecrire/inc_statistiques_repartition.php -text diff --git a/ecrire/inc_accueil.php b/ecrire/inc_accueil.php index 648bc815f5c421c9676be616a46fada078bea4ba..dd0e9431d4f635148218e3aae98201366ef2bbb9 100644 --- a/ecrire/inc_accueil.php +++ b/ecrire/inc_accueil.php @@ -47,7 +47,7 @@ afficher_breves(afficher_plus('breves.php3')._T('info_breves_valider'), "SELECT // Les sites references a valider // if (afficher_plus('sites_tous.php3').$GLOBALS['meta']['activer_syndic'] != 'non') { - include_ecrire("inc_sites.php3"); + include_ecrire("inc_sites_tous.php"); afficher_sites(afficher_plus('sites_tous.php3')._T('info_site_valider'), "SELECT * FROM spip_syndic WHERE statut='prop' ORDER BY nom_site"); } @@ -55,7 +55,7 @@ if (afficher_plus('sites_tous.php3').$GLOBALS['meta']['activer_syndic'] != 'non' // Les sites a probleme // if ($GLOBALS['meta']['activer_syndic'] != 'non' AND $connect_statut == '0minirezo' AND $connect_toutes_rubriques) { - include_ecrire("inc_sites.php3"); + include_ecrire("inc_sites_tous.php"); afficher_sites(afficher_plus('sites_tous.php3')._T('avis_sites_syndiques_probleme'), "SELECT * FROM spip_syndic WHERE (syndication='off' OR syndication='sus') AND statut='publie' ORDER BY nom_site"); } diff --git a/ecrire/inc_aide_index.php b/ecrire/inc_aide_index.php index 5a46d9299bdaeef3238d9d0bc0749b4cd72c1f08..bc062731f0b7b8eb308c9ffb36743db379bb19c9 100644 --- a/ecrire/inc_aide_index.php +++ b/ecrire/inc_aide_index.php @@ -72,7 +72,7 @@ function fichier_aide($lang_aide = '') { // en cache ? if (!@file_exists($fichier_aide = _DIR_CACHE . "aide-$lang_aide-aide.html")) { if ($help_server) { - include_ecrire('inc_sites.php3'); + include_ecrire('inc_distant.php'); if (ecrire_fichier(_DIR_CACHE . 'aide-test', "test") AND ($contenu = recuperer_page("$help_server/$lang_aide-aide.html"))) ecrire_fichier ($fichier_aide, $contenu); @@ -240,7 +240,7 @@ function help_img($regs) { } else if (@file_exists($img = '../AIDE/aide-'.$cache)) { readfile($img); } else if ($help_server) { - include_ecrire('inc_sites.php3'); + include_ecrire('inc_distant.php'); if (ecrire_fichier(_DIR_CACHE . 'aide-test', "test") AND ($contenu = recuperer_page("$help_server/$rep/$lang/$file"))) { diff --git a/ecrire/inc_config-fonctions.php b/ecrire/inc_config-fonctions.php index bf7cdf917c0140d7e364c6fa653de929abc96976..70d36d553473f42a30acc6a4fbd882f1cca520d8 100644 --- a/ecrire/inc_config-fonctions.php +++ b/ecrire/inc_config-fonctions.php @@ -407,7 +407,7 @@ function proxy_config() // Masquer un eventuel password authentifiant if ($http_proxy = $GLOBALS['meta']["http_proxy"]) { - include_ecrire ("inc_sites.php3"); + include_ecrire ("inc_distant.php3"); $http_proxy=entites_html(no_password_proxy_url($http_proxy)); } diff --git a/ecrire/inc_config.php3 b/ecrire/inc_config.php3 index 12ee80b4ebb267bab9f1f33cc24ebedfef919001..88109aa8472a1bbda65615968ff6e09384f6e9fe 100644 --- a/ecrire/inc_config.php3 +++ b/ecrire/inc_config.php3 @@ -11,9 +11,7 @@ \***************************************************************************/ -// if (!defined("_ECRIRE_INC_VERSION")) return; - include_ecrire ("inc_meta.php3"); // @@ -176,7 +174,7 @@ function appliquer_modifs_config() { echo _T('info_adresse_non_indiquee'); exit; } else { - include_ecrire("inc_sites.php3"); + include_ecrire('inc_distant.php'); $page = recuperer_page($test_proxy, true); if ($page) echo "<pre>".entites_html($page)."</pre>"; @@ -307,4 +305,43 @@ function appliquer_modifs_config() { } } + +// Ne pas afficher la partie 'password' du proxy +function no_password_proxy_url($http_proxy) { + if ($p = @parse_url($http_proxy) + AND $p['pass']) { + $p['pass'] = '****'; + $http_proxy = glue_url($p); + } + return $http_proxy; +} + + +// Function glue_url : le pendant de parse_url +function glue_url ($url){ + if (!is_array($url)){ + return false; + } + // scheme + $uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : ''; + // user & pass + if (!empty($url['user'])){ + $uri .= $url['user'].':'.$url['pass'].'@'; + } + // host + $uri .= $url['host']; + // port + $port = (!empty($url['port'])) ? ':'.$url['port'] : ''; + $uri .= $port; + // path + $uri .= $url['path']; +// fragment or query + if (isset($url['fragment'])){ + $uri .= '#'.$url['fragment']; + } elseif (isset($url['query'])){ + $uri .= '?'.$url['query']; + } + return $uri; +} + ?> diff --git a/ecrire/inc_distant.php b/ecrire/inc_distant.php new file mode 100644 index 0000000000000000000000000000000000000000..4cc03c007eae5ed31b8c4aa4ad08a21c03e17acb --- /dev/null +++ b/ecrire/inc_distant.php @@ -0,0 +1,313 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2005 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +// +// Cree au besoin la copie locale d'un fichier distant +// mode = 'test' - ne faire que tester +// mode = 'auto' - charger au besoin +// mode = 'force' - charger toujours (mettre a jour) +// +function copie_locale($source, $mode='auto') { + include_ecrire('inc_getdocument.php3'); + + // Si copie_locale() est appele depuis l'espace prive + if (!_DIR_RESTREINT + AND strpos('../'.$source, _DIR_IMG) === 0) + return '../'.$source; + + $local = fichier_copie_locale($source); + + if ($source != $local) { + if (($mode=='auto' AND !@file_exists($local)) + OR $mode=='force') { + $contenu = recuperer_page($source); + if ($contenu) { + ecrire_fichier($local, $contenu); + + // signaler au moteur de recherche qu'il peut reindexer ce doc + $a = spip_query("SELECT id_document FROM spip_documents + WHERE fichier='".addslashes($source)."'"); + list($id_document) = spip_fetch_array($a); + if ($id_document) { + include_ecrire('inc_index.php3'); + marquer_indexer('document', $id_document); + } + } + else + return false; + } + } + + return $local; +} + +// +// Recupere une page sur le net +// et au besoin l'encode dans le charset local +// +// options : get_headers si on veut recuperer les entetes +// taille_max : arreter le contenu au-dela (0 = seulement les entetes) +// Par defaut taille_max = 1Mo. +function recuperer_page($url, $munge_charset=false, $get_headers=false, $taille_max = 1048576) { + + // Accepter les URLs au format feed:// ou qui ont oublie le http:// + $url = preg_replace(',^feed://,i', 'http://', $url); + if (!preg_match(',^[a-z]+://,i', $url)) $url = 'http://'.$url; + + if ($taille_max == 0) + $get = 'HEAD'; + else + $get = 'GET'; + + + for ($i=0;$i<10;$i++) { // dix tentatives maximum en cas d'entetes 301... + list($f, $fopen) = init_http($get, $url); + + // si on a utilise fopen() - passer a la suite + if ($fopen) { + spip_log('connexion via fopen'); + break; + } else { + // Fin des entetes envoyees par SPIP + fputs($f,"\r\n"); + + // Reponse du serveur distant + $s = trim(fgets($f, 16384)); + if (ereg('^HTTP/[0-9]+\.[0-9]+ ([0-9]+)', $s, $r)) { + $status = $r[1]; + } + else return; + + // Entetes HTTP de la page + $headers = ''; + while ($s = trim(fgets($f, 16384))) { + $headers .= $s."\n"; + if (eregi('^Location: (.*)', $s, $r)) { + include_ecrire('inc_filtres.php3'); + $location = suivre_lien($url, $r[1]); + spip_log("Location: $location"); + } + if (preg_match(",^Content-Encoding: .*gzip,i", $s)) + $gz = true; + } + if ($status >= 300 AND $status < 400 AND $location) + $url = $location; + else if ($status != 200) + return; + else + break; # ici on est content + fclose($f); + $f = false; + } + } + + // Contenu de la page + if (!$f) { + spip_log("ECHEC chargement $url"); + return false; + } + + $result = ''; + while (!feof($f) AND strlen($result)<$taille_max) + $result .= fread($f, 16384); + fclose($f); + + // Decompresser le flux + if ($gz) + $result = gzinflate(substr($result,10)); + + // Faut-il l'importer dans notre charset local ? + if ($munge_charset) { + include_ecrire('inc_charsets.php3'); + $result = transcoder_page ($result, $headers); + } + + return ($get_headers ? $headers."\n" : '').$result; +} + + +// Si on doit conserver une copie locale des fichiers distants, autant que ca +// soit a un endroit canonique -- si ca peut etre bijectif c'est encore mieux, +// mais la tout de suite je ne trouve pas l'idee, etant donne les limitations +// des filesystems +function nom_fichier_copie_locale($source, $extension) { + $dir = _DIR_IMG. creer_repertoire(_DIR_IMG, 'distant'); # IMG/distant/ + $dir2 = $dir . creer_repertoire($dir, $extension); # IMG/distant/pdf/ + return $dir2 . substr(basename($source).'-'.md5($source),0,12). + substr(md5($source),0,4).'.'.$extension; +} + +// +// Donne le nom de la copie locale de la source +// +function fichier_copie_locale($source) { + // Si c'est une image de IMG/ pas de souci + if (preg_match(',^'._DIR_IMG.',', $source)) + return $source; + + // Si l'extension n'est pas precisee, aller la chercher dans la table + // des documents -- si la source n'est pas dans la table des documents, + // on ne fait rien + if ($t = spip_fetch_array(spip_query("SELECT * FROM spip_documents + WHERE fichier='".addslashes($source)."' AND distant='oui'"))) + list($extension) = spip_fetch_array(spip_query("SELECT extension + FROM spip_types_documents WHERE id_type=".$t['id_type'])); + + if ($extension) + return nom_fichier_copie_locale($source, $extension); +} + + +// Recuperer les infos d'un document distant, sans trop le telecharger +function recuperer_infos_distantes($source, $max=0) { + + $a = array(); + + // On va directement charger le debut des images et des fichiers html, + // de maniere a attrapper le maximum d'infos (titre, taille, etc). Si + // ca echoue l'utilisateur devra les entrer... + if ($headers = recuperer_page($source, false, true, $max)) { + list($headers, $a['body']) = split("\n\n", $headers, 2); + if (preg_match(",\nContent-Type: *([^[:space:];]*),i", + "\n$headers", $regs) + AND $mime_type = addslashes(trim($regs[1])) + AND $s = spip_query("SELECT id_type,extension FROM spip_types_documents + WHERE mime_type='$mime_type'") + AND $t = spip_fetch_array($s)) { + spip_log("mime-type $mime_type ok"); + $a['id_type'] = $t['id_type']; + $a['extension'] = $t['extension']; + } else { + # par defaut on retombe sur '.bin' si c'est autorise + spip_log("mime-type $mime_type inconnu"); + $t = spip_fetch_array(spip_query( + "SELECT id_type,extension FROM spip_types_documents + WHERE extension='bin'")); + if (!$t) return false; + $a['id_type'] = $t['id_type']; + $a['extension'] = $t['extension']; + } + + if (preg_match(",\nContent-Length: *([^[:space:]]*),i", + "\n$headers", $regs)) + $a['taille'] = intval($regs[1]); + } + + // Echec avec HEAD, on tente avec GET + if (!$a AND !$max) { + spip_log("tente $source"); + $a = recuperer_infos_distantes($source, 1024*1024); + } + + // S'il s'agit d'une image pas trop grosse ou d'un fichier html, on va aller + // recharger le document en GET et recuperer des donnees supplementaires... + if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)) { + if ($max == 0 + AND $a['taille'] < 1024*1024 + AND ereg(",".$a['extension'].",", + ','.$GLOBALS['meta']['formats_graphiques'].',')){ + $a = recuperer_infos_distantes($source, 1024*1024); + } + else if ($a['body']) { + $a['fichier'] = nom_fichier_copie_locale($source, $a['extension']); + ecrire_fichier($a['fichier'], $a['body']); + $size_image = @getimagesize($a['fichier']); + $a['largeur'] = intval($size_image[0]); + $a['hauteur'] = intval($size_image[1]); + $a['type_image'] = true; + } + } + + if ($mime_type == 'text/html') { + $page = recuperer_page($source, true, false, 1024*1024); + if(preg_match(',<title>(.*?)</title>,ims', $page, $regs)) + $a['titre'] = corriger_caracteres(trim($regs[1])); + if (!$a['taille']) $a['taille'] = strlen($page); # a peu pres + } + + return $a; +} + + +// +// Demarre une transaction HTTP (s'arrete a la fin des entetes) +// retourne un descripteur de fichier +// +function init_http($get, $url, $refuse_gz=false) { + $http_proxy = $GLOBALS['meta']["http_proxy"]; + if (!eregi("^http://", $http_proxy)) + $http_proxy = ''; + else + $via_proxy = " (proxy $http_proxy)"; + + spip_log("http $get $url$via_proxy"); + + $t = @parse_url($url); + $host = $t['host']; + if ($t['scheme'] == 'http') { + $scheme = 'http'; $scheme_fsock=''; + } else { + $scheme = $t['scheme']; $scheme_fsock=$scheme.'://'; + } + if (!($port = $t['port'])) $port = 80; + $query = $t['query']; + if (!($path = $t['path'])) $path = "/"; + + if ($http_proxy) { + $t2 = @parse_url($http_proxy); + $proxy_host = $t2['host']; + $proxy_user = $t2['user']; + $proxy_pass = $t2['pass']; + if (!($proxy_port = $t2['port'])) $proxy_port = 80; + $f = @fsockopen($proxy_host, $proxy_port); + } else + $f = @fsockopen($scheme_fsock.$host, $port); + + if ($f) { + if ($http_proxy) + fputs($f, "$get $scheme://$host" . (($port != 80) ? ":$port" : "") . $path . ($query ? "?$query" : "") . " HTTP/1.0\r\n"); + else + fputs($f, "$get $path" . ($query ? "?$query" : "") . " HTTP/1.0\r\n"); + + fputs($f, "Host: $host\r\n"); + fputs($f, "User-Agent: SPIP-".$GLOBALS['spip_version_affichee']." (http://www.spip.net/)\r\n"); + + // Proxy authentifiant + if ($proxy_user) { + fputs($f, "Proxy-Authorization: Basic " + . base64_encode($proxy_user . ":" . $proxy_pass) . "\r\n"); + } + // Referer = c'est nous ! + if ($referer = $GLOBALS['meta']["adresse_site"]) + fputs($f, "Referer: $referer/\r\n"); + + // On sait lire du gzip + if ($GLOBALS['flag_gz'] AND !$refuse_gz) + fputs($f, "Accept-Encoding: gzip\r\n"); + + } + // fallback : fopen + else if (!$GLOBALS['tester_proxy']) { + $f = @fopen($url, "rb"); + $fopen = true; + } + // echec total + else { + $f = false; + } + + return array($f, $fopen); +} + +?> diff --git a/ecrire/inc_documents.php3 b/ecrire/inc_documents.php3 index 57b0e69ce6b0f157d746cb056904f25803e3dd35..a9fd0d0bbb973bfde6cc9f34fff10dc340bb03fe 100644 --- a/ecrire/inc_documents.php3 +++ b/ecrire/inc_documents.php3 @@ -85,6 +85,7 @@ function document_et_vignette($document, $url, $portfolio=false) { } } else if (strstr($GLOBALS['meta']['formats_graphiques'], $extension) AND $GLOBALS['meta']['creer_preview'] == 'oui') { + include_ecrire('inc_distant.php'); include_ecrire('inc_logos.php3'); #var_dump($document); $local = copie_locale($document['fichier']); diff --git a/ecrire/inc_filtres.php3 b/ecrire/inc_filtres.php3 index a0a0aa15948f2c464d98bd42ae58ba23d0b7c5de..3e603c9954cab987f97ea1e67265f8484b467afb 100644 --- a/ecrire/inc_filtres.php3 +++ b/ecrire/inc_filtres.php3 @@ -11,10 +11,8 @@ \***************************************************************************/ -// if (!defined("_ECRIRE_INC_VERSION")) return; - // Echappement des entites HTML avec correction des entites "brutes" // (generees par les butineurs lorsqu'on rentre des caracteres n'appartenant // pas au charset de la page [iso-8859-1 par defaut]) @@ -1414,50 +1412,6 @@ function couleur_eclaircir_si_foncee ($couleur) { } - - -// -// Cree au besoin la copie locale d'un fichier distant -// mode = 'test' - ne faire que tester -// mode = 'auto' - charger au besoin -// mode = 'force' - charger toujours (mettre a jour) -// -function copie_locale($source, $mode='auto') { - include_ecrire('inc_getdocument.php3'); - - // Si copie_locale() est appele depuis l'espace prive - if (!_DIR_RESTREINT - AND strpos('../'.$source, _DIR_IMG) === 0) - return '../'.$source; - - $local = fichier_copie_locale($source); - - if ($source != $local) { - if (($mode=='auto' AND !@file_exists($local)) - OR $mode=='force') { - include_ecrire('inc_sites.php3'); - $contenu = recuperer_page($source); - if ($contenu) { - ecrire_fichier($local, $contenu); - - // signaler au moteur de recherche qu'il peut reindexer ce doc - $a = spip_query("SELECT id_document FROM spip_documents - WHERE fichier='".addslashes($source)."'"); - list($id_document) = spip_fetch_array($a); - if ($id_document) { - include_ecrire('inc_index.php3'); - marquer_indexer('document', $id_document); - } - } - else - return false; - } - } - - return $local; -} - - // // Recuperation de donnees dans le champ extra // Ce filtre n'a de sens qu'avec la balise #EXTRA diff --git a/ecrire/inc_getdocument.php3 b/ecrire/inc_getdocument.php3 index e40d17e7b0a1153bc12e454f0740cd93517f905a..1bf27598a061c552cf81e5b178e0f41599e68bfc 100644 --- a/ecrire/inc_getdocument.php3 +++ b/ecrire/inc_getdocument.php3 @@ -185,110 +185,6 @@ function verifier_compactes($zip) { } } -// Si on doit conserver une copie locale des fichiers distants, autant que ca -// soit a un endroit canonique -- si ca peut etre bijectif c'est encore mieux, -// mais la tout de suite je ne trouve pas l'idee, etant donne les limitations -// des filesystems -function nom_fichier_copie_locale($source, $extension) { - $dir = _DIR_IMG. creer_repertoire(_DIR_IMG, 'distant'); # IMG/distant/ - $dir2 = $dir . creer_repertoire($dir, $extension); # IMG/distant/pdf/ - return $dir2 . substr(basename($source).'-'.md5($source),0,12). - substr(md5($source),0,4).'.'.$extension; -} - -// -// Donne le nom de la copie locale de la source -// -function fichier_copie_locale($source) { - // Si c'est une image de IMG/ pas de souci - if (preg_match(',^'._DIR_IMG.',', $source)) - return $source; - - // Si l'extension n'est pas precisee, aller la chercher dans la table - // des documents -- si la source n'est pas dans la table des documents, - // on ne fait rien - if ($t = spip_fetch_array(spip_query("SELECT * FROM spip_documents - WHERE fichier='".addslashes($source)."' AND distant='oui'"))) - list($extension) = spip_fetch_array(spip_query("SELECT extension - FROM spip_types_documents WHERE id_type=".$t['id_type'])); - - if ($extension) - return nom_fichier_copie_locale($source, $extension); -} - - -// Recuperer les infos d'un document distant, sans trop le telecharger -function recuperer_infos_distantes($source, $max=0) { - include_ecrire('inc_sites.php3'); - - $a = array(); - - // On va directement charger le debut des images et des fichiers html, - // de maniere a attrapper le maximum d'infos (titre, taille, etc). Si - // ca echoue l'utilisateur devra les entrer... - if ($headers = recuperer_page($source, false, true, $max)) { - list($headers, $a['body']) = split("\n\n", $headers, 2); - if (preg_match(",\nContent-Type: *([^[:space:];]*),i", - "\n$headers", $regs) - AND $mime_type = addslashes(trim($regs[1])) - AND $s = spip_query("SELECT id_type,extension FROM spip_types_documents - WHERE mime_type='$mime_type'") - AND $t = spip_fetch_array($s)) { - spip_log("mime-type $mime_type ok"); - $a['id_type'] = $t['id_type']; - $a['extension'] = $t['extension']; - } else { - # par defaut on retombe sur '.bin' si c'est autorise - spip_log("mime-type $mime_type inconnu"); - $t = spip_fetch_array(spip_query( - "SELECT id_type,extension FROM spip_types_documents - WHERE extension='bin'")); - if (!$t) return false; - $a['id_type'] = $t['id_type']; - $a['extension'] = $t['extension']; - } - - if (preg_match(",\nContent-Length: *([^[:space:]]*),i", - "\n$headers", $regs)) - $a['taille'] = intval($regs[1]); - } - - // Echec avec HEAD, on tente avec GET - if (!$a AND !$max) { - spip_log("tente $source"); - $a = recuperer_infos_distantes($source, 1024*1024); - } - - // S'il s'agit d'une image pas trop grosse ou d'un fichier html, on va aller - // recharger le document en GET et recuperer des donnees supplementaires... - if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)) { - if ($max == 0 - AND $a['taille'] < 1024*1024 - AND ereg(",".$a['extension'].",", - ','.$GLOBALS['meta']['formats_graphiques'].',')){ - $a = recuperer_infos_distantes($source, 1024*1024); - } - else if ($a['body']) { - $a['fichier'] = nom_fichier_copie_locale($source, $a['extension']); - ecrire_fichier($a['fichier'], $a['body']); - $size_image = @getimagesize($a['fichier']); - $a['largeur'] = intval($size_image[0]); - $a['hauteur'] = intval($size_image[1]); - $a['type_image'] = true; - } - } - - if ($mime_type == 'text/html') { - $page = recuperer_page($source, true, false, 1024*1024); - if(preg_match(',<title>(.*?)</title>,ims', $page, $regs)) - $a['titre'] = corriger_caracteres(trim($regs[1])); - if (!$a['taille']) $a['taille'] = strlen($page); # a peu pres - } - - return $a; -} - - // // Ajouter un document (au format $_FILES) // @@ -310,6 +206,7 @@ function ajouter_un_document ($source, $nom_envoye, $type_lien, $id_lien, $mode, // content-type est connu, et si possible recuperer la taille, voire plus. spip_log ("ajout du document $nom_envoye ($mode $type_lien $id_lien $id_document)"); if ($mode == 'distant') { + include_ecrire('inc_distant.php'); if ($a = recuperer_infos_distantes($source)) { # fichier local pour creer la vignette (!!), # on retablira la valeur de l'url a la fin diff --git a/ecrire/inc_index.php3 b/ecrire/inc_index.php3 index 96d30d98670130705280a97889952cdd268d6c20..6061322ab73c8008b51150499a0ec77bcf051048 100644 --- a/ecrire/inc_index.php3 +++ b/ecrire/inc_index.php3 @@ -133,6 +133,7 @@ function indexer_contenu_document ($row) { if (function_exists($lire = $extracteur[$extension])) { // Voir si on a deja une copie du doc distant // Note: si copie_locale() charge le doc, elle demande une reindexation + include_ecrire('inc_distant.php'); if (!$fichier = copie_locale($row['fichier'], 'test')) { spip_log("pas de copie locale de '$fichier'"); return; @@ -305,7 +306,7 @@ function indexer_objet($type, $id_objet, $forcer_reset = true) { } // Aller chercher la page d'accueil if ($GLOBALS['meta']["visiter_sites"] == "oui") { - include_ecrire ("inc_sites.php3"); + include_ecrire('inc_distant.php'); spip_log ("indexation contenu syndic ".$row['url_site']); indexer_chaine(supprimer_tags( recuperer_page($row['url_site'], true, false, 50000) diff --git a/ecrire/inc_logos.php3 b/ecrire/inc_logos.php3 index 88a113960f1e62c6d9cbdcc401f77c2e30e3551c..fd60b8c3bc0e55a8d49b4a559354b525276f4476 100644 --- a/ecrire/inc_logos.php3 +++ b/ecrire/inc_logos.php3 @@ -451,6 +451,7 @@ function reduire_image_logo($img, $taille = -1, $taille_y = -1) { if (!$logo) return ''; // Si c'est une image distante, la recuperer (si possible) + include_ecrire('inc_distant.php'); if (!$local = copie_locale($logo)) { spip_log("pas de version locale de $logo"); return $img; diff --git a/ecrire/inc_math.php3 b/ecrire/inc_math.php3 index d825077f025b7544a4a91f70e10f2a090c668d72..a97db57066268a9ae2472fc422d5a9344760bdfb 100644 --- a/ecrire/inc_math.php3 +++ b/ecrire/inc_math.php3 @@ -43,7 +43,7 @@ function image_math($tex) { // Aller chercher l'image sur le serveur if ($server) { spip_log($url = $server.'?'.urlencode($tex)); - include_ecrire('inc_sites.php3'); + include_ecrire('inc_distant.php3'); if ($image = recuperer_page($url)) { if ($f = @fopen($fichier, 'w')) { @fwrite($f, $image); diff --git a/ecrire/inc_naviguer.php b/ecrire/inc_naviguer.php index 84542d9b27448f8f61e5a0c30c3f910445bc821a..ab56ca1a5edb6025661299a16a49c35de8dd43db 100644 --- a/ecrire/inc_naviguer.php +++ b/ecrire/inc_naviguer.php @@ -325,7 +325,7 @@ if ($relief) { // Les sites references a valider // if ($GLOBALS['meta']['activer_syndic'] != 'non') { - include_ecrire("inc_sites.php3"); + include_ecrire("inc_sites_tous.php"); afficher_sites(_T('info_site_valider'), "SELECT * FROM spip_syndic WHERE id_rubrique='$id_rubrique' AND statut='prop' ORDER BY nom_site"); } @@ -333,7 +333,7 @@ if ($relief) { // Les sites a probleme // if ($GLOBALS['meta']['activer_syndic'] != 'non' AND $connect_statut == '0minirezo' AND $connect_toutes_rubriques) { - include_ecrire("inc_sites.php3"); + include_ecrire("inc_sites_tous.php"); afficher_sites(_T('avis_sites_syndiques_probleme'), "SELECT * FROM spip_syndic WHERE id_rubrique='$id_rubrique' AND (syndication='off' OR syndication='sus') AND statut='publie' ORDER BY nom_site"); } @@ -385,7 +385,7 @@ if ($relief) { //// Les sites references if ($GLOBALS['meta']["activer_sites"] == 'oui') { - include_ecrire("inc_sites.php3"); + include_ecrire("inc_sites_tous.php"); afficher_sites(_T('titre_sites_references_rubrique'), "SELECT * FROM spip_syndic WHERE id_rubrique='$id_rubrique' AND statut!='refuse' AND statut != 'prop' AND syndication NOT IN ('off','sus') ORDER BY nom_site"); $proposer_sites=$GLOBALS['meta']["proposer_sites"]; diff --git a/ecrire/inc_rubriques.php3 b/ecrire/inc_rubriques.php3 index 6e4321b4f2050d147a85cf11ddc37b310aba52e7..0b2bf875667192a15486ae14b1d74b4c9b70a215 100644 --- a/ecrire/inc_rubriques.php3 +++ b/ecrire/inc_rubriques.php3 @@ -136,10 +136,11 @@ function propager_les_secteurs() FROM spip_articles AS fille, spip_rubriques AS maman WHERE fille.id_rubrique = maman.id_rubrique AND fille.id_secteur <> maman.id_secteur"); - while ($row = spip_fetch_array($r)) + while ($row = spip_fetch_array($r)) { +# spip_log("change " . $row['id'] . " secteur " . $row['secteur']); spip_query("UPDATE spip_articles SET id_secteur=".$row['secteur']." WHERE id_article=".$row['id']); - + } // reparer les sites $r = spip_query("SELECT fille.id_syndic AS id, maman.id_secteur AS secteur FROM spip_syndic AS fille, spip_rubriques AS maman diff --git a/ecrire/inc_sites.php3 b/ecrire/inc_sites.php3 index 0fb4502e462db02bfd6914546a6b0d7cdf9684a6..9580a35981b9a7e07167162f6fcb4ac0beecfa59 100644 --- a/ecrire/inc_sites.php3 +++ b/ecrire/inc_sites.php3 @@ -12,6 +12,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return; +include_ecrire ("inc_sites_tous.php"); // Moderation manuelle des liens if (!_DIR_RESTREINT AND $GLOBALS['connect_statut'] == '0minirezo') { @@ -23,197 +24,6 @@ if (!_DIR_RESTREINT AND $GLOBALS['connect_statut'] == '0minirezo') { WHERE id_syndic_article='$ajouter_lien'"); } -// Function glue_url : le pendant de parse_url (cf doc spip.net/parse_url) -function glue_url ($url){ - if (!is_array($url)){ - return false; - } - // scheme - $uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : ''; - // user & pass - if (!empty($url['user'])){ - $uri .= $url['user'].':'.$url['pass'].'@'; - } - // host - $uri .= $url['host']; - // port - $port = (!empty($url['port'])) ? ':'.$url['port'] : ''; - $uri .= $port; - // path - $uri .= $url['path']; -// fragment or query - if (isset($url['fragment'])){ - $uri .= '#'.$url['fragment']; - } elseif (isset($url['query'])){ - $uri .= '?'.$url['query']; - } - return $uri; -} - -// Ne pas afficher la partie 'password' du proxy -function no_password_proxy_url($http_proxy) { - if ($p = @parse_url($http_proxy) - AND $p['pass']) { - $p['pass'] = '****'; - $http_proxy = glue_url($p); - } - return $http_proxy; -} - -// -// Demarre une transaction HTTP (s'arrete a la fin des entetes) -// retourne un descripteur de fichier -// -function init_http($get, $url, $refuse_gz=false) { - $http_proxy = $GLOBALS['meta']["http_proxy"]; - if (!eregi("^http://", $http_proxy)) - $http_proxy = ''; - else - $via_proxy = " (proxy $http_proxy)"; - - spip_log("http $get $url$via_proxy"); - - $t = @parse_url($url); - $host = $t['host']; - if ($t['scheme'] == 'http') { - $scheme = 'http'; $scheme_fsock=''; - } else { - $scheme = $t['scheme']; $scheme_fsock=$scheme.'://'; - } - if (!($port = $t['port'])) $port = 80; - $query = $t['query']; - if (!($path = $t['path'])) $path = "/"; - - if ($http_proxy) { - $t2 = @parse_url($http_proxy); - $proxy_host = $t2['host']; - $proxy_user = $t2['user']; - $proxy_pass = $t2['pass']; - if (!($proxy_port = $t2['port'])) $proxy_port = 80; - $f = @fsockopen($proxy_host, $proxy_port); - } else - $f = @fsockopen($scheme_fsock.$host, $port); - - if ($f) { - if ($http_proxy) - fputs($f, "$get $scheme://$host" . (($port != 80) ? ":$port" : "") . $path . ($query ? "?$query" : "") . " HTTP/1.0\r\n"); - else - fputs($f, "$get $path" . ($query ? "?$query" : "") . " HTTP/1.0\r\n"); - - fputs($f, "Host: $host\r\n"); - fputs($f, "User-Agent: SPIP-".$GLOBALS['spip_version_affichee']." (http://www.spip.net/)\r\n"); - - // Proxy authentifiant - if ($proxy_user) { - fputs($f, "Proxy-Authorization: Basic " - . base64_encode($proxy_user . ":" . $proxy_pass) . "\r\n"); - } - // Referer = c'est nous ! - if ($referer = $GLOBALS['meta']["adresse_site"]) - fputs($f, "Referer: $referer/\r\n"); - - // On sait lire du gzip - if ($GLOBALS['flag_gz'] AND !$refuse_gz) - fputs($f, "Accept-Encoding: gzip\r\n"); - - } - // fallback : fopen - else if (!$GLOBALS['tester_proxy']) { - $f = @fopen($url, "rb"); - $fopen = true; - } - // echec total - else { - $f = false; - } - - return array($f, $fopen); -} - -// -// Recupere une page sur le net -// et au besoin l'encode dans le charset local -// -// options : get_headers si on veut recuperer les entetes -// taille_max : arreter le contenu au-dela (0 = seulement les entetes) -// Par defaut taille_max = 1Mo. -function recuperer_page($url, $munge_charset=false, $get_headers=false, $taille_max = 1048576) { - - // Accepter les URLs au format feed:// ou qui ont oublie le http:// - $url = preg_replace(',^feed://,i', 'http://', $url); - if (!preg_match(',^[a-z]+://,i', $url)) $url = 'http://'.$url; - - if ($taille_max == 0) - $get = 'HEAD'; - else - $get = 'GET'; - - - for ($i=0;$i<10;$i++) { // dix tentatives maximum en cas d'entetes 301... - list($f, $fopen) = init_http($get, $url); - - // si on a utilise fopen() - passer a la suite - if ($fopen) { - spip_log('connexion via fopen'); - break; - } else { - // Fin des entetes envoyees par SPIP - fputs($f,"\r\n"); - - // Reponse du serveur distant - $s = trim(fgets($f, 16384)); - if (ereg('^HTTP/[0-9]+\.[0-9]+ ([0-9]+)', $s, $r)) { - $status = $r[1]; - } - else return; - - // Entetes HTTP de la page - $headers = ''; - while ($s = trim(fgets($f, 16384))) { - $headers .= $s."\n"; - if (eregi('^Location: (.*)', $s, $r)) { - include_ecrire('inc_filtres.php3'); - $location = suivre_lien($url, $r[1]); - spip_log("Location: $location"); - } - if (preg_match(",^Content-Encoding: .*gzip,i", $s)) - $gz = true; - } - if ($status >= 300 AND $status < 400 AND $location) - $url = $location; - else if ($status != 200) - return; - else - break; # ici on est content - fclose($f); - $f = false; - } - } - - // Contenu de la page - if (!$f) { - spip_log("ECHEC chargement $url"); - return false; - } - - $result = ''; - while (!feof($f) AND strlen($result)<$taille_max) - $result .= fread($f, 16384); - fclose($f); - - // Decompresser le flux - if ($gz) - $result = gzinflate(substr($result,10)); - - // Faut-il l'importer dans notre charset local ? - if ($munge_charset) { - include_ecrire('inc_charsets.php3'); - $result = transcoder_page ($result, $headers); - } - - return ($get_headers ? $headers."\n" : '').$result; -} - // helas strtotime ne reconnait pas le format W3C // http://www.w3.org/TR/NOTE-datetime function my_strtotime($la_date) { @@ -238,6 +48,7 @@ function my_strtotime($la_date) { function analyser_site($url) { include_ecrire("inc_filtres.php3"); # pour filtrer_entites() + include_ecrire("inc_distant.php"); // Accepter les URLs au format feed:// ou qui ont oublie le http:// $url = preg_replace(',^feed://,i', 'http://', $url); @@ -286,6 +97,7 @@ function analyser_site($url) { $result['descriptif'] = filtrer_entites(supprimer_tags($regs[3])); // Cherchons quand meme un backend + include_ecrire('inc_distant.php'); include_ecrire('feedfinder.php'); $feeds = get_feed_from_url($url, $texte); if (count($feeds>1)) { @@ -351,7 +163,6 @@ function ajouter_tags($matches, $item) { // et une chaine en cas d'erreur function analyser_backend($rss, $url_syndic='') { include_ecrire("inc_texte.php3"); # pour couper() - include_ecrire("inc_filtres.php3"); $les_auteurs_du_site = ""; @@ -616,7 +427,6 @@ function inserer_article_syndique ($data, $now_id_syndic, $statut, $url_site, $u // function syndic_a_jour($now_id_syndic, $statut = 'off') { include_ecrire("inc_texte.php3"); - include_ecrire("inc_filtres.php3"); $query = "SELECT * FROM spip_syndic WHERE id_syndic='$now_id_syndic'"; $result = spip_query($query); @@ -641,6 +451,7 @@ function syndic_a_jour($now_id_syndic, $statut = 'off') { date_syndic=NOW() WHERE id_syndic='$now_id_syndic'"); // Aller chercher les donnees du RSS et les analyser + include_ecrire("inc_distant.php"); $rss = recuperer_page($url_syndic, true); if (!$rss) $articles = _T('avis_echec_syndication_02'); @@ -702,302 +513,6 @@ function syndic_a_jour($now_id_syndic, $statut = 'off') { } -function afficher_sites($titre_table, $requete) { - global $couleur_claire, $spip_lang_left, $spip_lang_right; - global $connect_id_auteur; - - $tranches = afficher_tranches_requete($requete, 3); - - if ($tranches) { -// debut_cadre_relief("site-24.gif"); - if ($titre_table) echo "<div style='height: 12px;'></div>"; - echo "<div class='liste'>"; - bandeau_titre_boite2($titre_table, "site-24.gif", $couleur_claire, "black"); - echo "<table width='100%' cellpadding='2' cellspacing='0' border='0'>"; - - echo $tranches; - - $result = spip_query($requete); - $num_rows = spip_num_rows($result); - - $ifond = 0; - $premier = true; - - $compteur_liste = 0; - while ($row = spip_fetch_array($result)) { - $vals = ''; - $id_syndic=$row["id_syndic"]; - $id_rubrique=$row["id_rubrique"]; - $nom_site=sinon(typo($row["nom_site"]), _T('info_sans_titre')); - $url_site=$row["url_site"]; - $url_syndic=$row["url_syndic"]; - $description=propre($row["description"]); - $syndication=$row["syndication"]; - $statut=$row["statut"]; - $date=$row["date"]; - $moderation=$row['moderation']; - - $tous_id[] = $id_syndic; - - //echo "<tr bgcolor='$couleur'>"; - - //echo "<td class='arial2'>"; - $link = new Link("sites.php3?id_syndic=$id_syndic"); - switch ($statut) { - case 'publie': - if (acces_restreint_rubrique($id_rubrique)) - $puce = 'puce-verte-anim.gif'; - else - $puce='puce-verte-breve.gif'; - $title = _T('info_site_reference'); - break; - case 'prop': - if (acces_restreint_rubrique($id_rubrique)) - $puce = 'puce-orange-anim.gif'; - else - $puce='puce-orange-breve.gif'; - $title = _T('info_site_attente'); - break; - case 'refuse': - if (acces_restreint_rubrique($id_rubrique)) - $puce = 'puce-poubelle-anim.gif'; - else - $puce='puce-poubelle-breve.gif'; - $title = _T('info_site_refuse'); - break; - } - if ($syndication == 'off' OR $syndication == 'sus') { - $puce = 'puce-orange-anim.gif'; - $title = _T('info_panne_site_syndique'); - } - - $s = "<a href=\"".$link->getUrl()."\" title=\"$title\">"; - - if ($spip_display != 1 AND $spip_display != 4 AND $GLOBALS['meta']['image_process'] != "non") { - include_ecrire("inc_logos.php3"); - $logo = decrire_logo("siteon$id_syndic"); - if ($logo) { - $s.= "<div style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'>" - . reduire_image_logo(_DIR_IMG.$logo[0], 26, 20) - . "</div>\n"; - } - } - - - $s .= http_img_pack($puce, $statut, "width='7' height='7' border='0'") ." "; - - $s .= typo($nom_site); - - $s .= "</a> <font size='1'>[<a href='$url_site'>"._T('lien_visite_site')."</a>]</font>"; - $vals[] = $s; - - //echo "</td>"; - - $s = ""; - //echo "<td class='arial1' align='right'> "; - if ($syndication == 'off' OR $syndication == 'sus') { - $s .= "<font color='red'>"._T('info_probleme_grave')." </font>"; - } - if ($syndication == "oui" or $syndication == "off" OR $syndication == 'sus'){ - $s .= "<font color='red'>"._T('info_syndication')."</font>"; - } - $vals[] = $s; - //echo "</td>"; - //echo "<td class='arial1'>"; - $s = ""; - if ($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") { - $result_art = spip_query("SELECT COUNT(*) FROM spip_syndic_articles WHERE id_syndic='$id_syndic'"); - list($total_art) = spip_fetch_array($result_art); - $s .= " $total_art "._T('info_syndication_articles'); - } else { - $s .= " "; - } - $vals[] = $s; - //echo "</td>"; - //echo "</tr></n>"; - $table[] = $vals; - } - spip_free_result($result); - - $largeurs = array('','',''); - $styles = array('arial11', 'arial1', 'arial1'); - afficher_liste($largeurs, $table, $styles); - echo "</table>"; - //fin_cadre_relief(); - echo "</div>\n"; - } - return $tous_id; -} - - -function afficher_syndic_articles($titre_table, $requete, $afficher_site = false) { - global $connect_statut; - global $REQUEST_URI; - global $debut_liste_sites; - global $flag_editable; - - static $n_liste_sites; - global $spip_lang_rtl, $spip_lang_right; - - $adresse_page = substr($REQUEST_URI, strpos($REQUEST_URI, "/ecrire")+8, strlen($REQUEST_URI)); - $adresse_page = ereg_replace("\&?debut\_liste\_sites\[$n_liste_sites\]\=[0-9]+","",$adresse_page); - $adresse_page = ereg_replace("\&?(ajouter\_lien|supprimer_lien)\=[0-9]+","",$adresse_page); - - if (ereg("\?",$adresse_page)) $lien_url = "&"; - else $lien_url = "?"; - - $lien_url .= "debut_liste_sites[".$n_liste_sites."]=".$debut_liste_sites[$n_liste_sites]."&"; - - $cols = 2; - if ($connect_statut == '0minirezo') $cols ++; - if ($afficher_site) $cols ++; - - $tranches = afficher_tranches_requete($requete, $cols); - - if (strlen($tranches)) { - - if ($titre_table) echo "<div style='height: 12px;'></div>"; - echo "<div class='liste'>"; - //debut_cadre_relief("rubrique-24.gif"); - - if ($titre_table) { - bandeau_titre_boite2($titre_table, "site-24.gif", "#999999", "white"); - } - echo "<table width=100% cellpadding=3 cellspacing=0 border=0 background=''>"; - - echo $tranches; - - $result = spip_query($requete); - - $table = ''; - while ($row = spip_fetch_array($result)) { - $vals = ''; - - $id_syndic_article=$row["id_syndic_article"]; - $id_syndic=$row["id_syndic"]; - $titre=safehtml($row["titre"]); - $url=$row["url"]; - $date=$row["date"]; - $lesauteurs=typo($row["lesauteurs"]); - $statut=$row["statut"]; - $descriptif=safehtml($row["descriptif"]); - - - if ($statut=='publie') { - if (acces_restreint_rubrique($id_rubrique)) - $puce = 'puce-verte-anim.gif'; - else - $puce='puce-verte.gif'; - } - else if ($statut == "refuse") { - $puce = 'puce-poubelle.gif'; - } - - else if ($statut == "dispo") { // moderation : a valider - $puce = 'puce-rouge.gif'; - } - - else if ($statut == "off") { // feed d'un site en mode "miroir" - $puce = 'puce-rouge-anim.gif'; - } - - $s = http_img_pack($puce, $statut, "width='7' height='7' border='0'"); - $vals[] = $s; - - $s = "<a href='$url'>$titre</a>"; - - $date = affdate_court($date); - if (strlen($lesauteurs) > 0) $date = $lesauteurs.', '.$date; - $s.= " ($date)"; - - // Tags : d'un cote les enclosures, de l'autre les liens - if($e = afficher_enclosures($row['tags'])) - $s .= ' '.$e; - - // descriptif - if (strlen($descriptif) > 0) - $s .= "<div class='arial1'>".safehtml($descriptif)."</div>"; - - // tags - if ($tags = afficher_tags($row['tags'])) - $s .= "<div style='float:$spip_lang_right;'> <em>" - . $tags . '</em></div>'; - - // source - if (strlen($row['url_source'])) - $s .= "<div style='float:$spip_lang_right;'>" - . propre("[".$row['source']."->".$row['url_source']."]") - . "</div>"; - else if (strlen($row['source'])) - $s .= "<div style='float:$spip_lang_right;'>" - . typo($row['source']) - . "</div>"; - - $vals[] = $s; - - // $my_sites cache les resultats des requetes sur les sites - if (!$my_sites[$id_syndic]) - $my_sites[$id_syndic] = spip_fetch_array(spip_query( - "SELECT * FROM spip_syndic WHERE id_syndic=$id_syndic")); - - if ($afficher_site) { - $aff = $my_sites[$id_syndic]['nom_site']; - if ($my_sites[$id_syndic]['moderation'] == 'oui') - $s = "<i>$aff</i>"; - else - $s = $aff; - - $s = "<a href='sites.php3?id_syndic=$id_syndic'>$aff</a>"; - - $vals[] = $s; - } - - - if ($connect_statut == '0minirezo'){ - if ($statut == "publie"){ - $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&supprimer_lien=$id_syndic_article'><font color='black'>"._T('info_bloquer_lien')."</font></a>]"; - - } - else if ($statut == "refuse"){ - $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>"._T('info_retablir_lien')."</a>]"; - } - else if ($statut == "off" - AND $my_sites[$id_syndic]['miroir'] == 'oui') { - $s = '('._T('syndic_lien_obsolete').')'; - } - else /* 'dispo' ou 'off' (dans le cas ancien site 'miroir') */ - { - $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>"._T('info_valider_lien')."</a>]"; - } - $vals[] = $s; - } - - $table[] = $vals; - } - spip_free_result($result); - - - if ($afficher_site) { - $largeurs = array(7, '', '100'); - $styles = array('','arial11', 'arial1'); - } else { - $largeurs = array(7, ''); - $styles = array('','arial11'); - } - if ($connect_statut == '0minirezo') { - $largeurs[] = '80'; - $styles[] = 'arial1'; - } - - afficher_liste($largeurs, $table, $styles); - - echo "</TABLE>"; - //fin_cadre_relief(); - echo "</div>"; - } - return $tous_id; -} - // // Effectuer la syndication d'un unique site, retourne 0 si aucun a faire. diff --git a/ecrire/inc_sites_tous.php b/ecrire/inc_sites_tous.php new file mode 100644 index 0000000000000000000000000000000000000000..b409c4658ce032471287ed1f19a7c07fad89ec57 --- /dev/null +++ b/ecrire/inc_sites_tous.php @@ -0,0 +1,351 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2005 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +include_ecrire("inc_presentation.php3"); + +function sites_tous() +{ + global $connect_statut, $supp_syndic, $options, $clean_link; + +if ($connect_statut == '0minirezo' AND $supp_syndic) { + $query="DELETE FROM spip_syndic WHERE id_syndic=".intval($supp_syndic); + $result=spip_query($query); +} + +debut_page(_T('titre_page_sites_tous'),"documents","sites"); +debut_gauche(); +debut_droite(); + +afficher_sites(_T('titre_sites_tous'), "SELECT * FROM spip_syndic WHERE syndication='non' AND statut='publie' ORDER BY nom_site"); + +afficher_sites(_T('titre_sites_syndiques'), "SELECT * FROM spip_syndic WHERE (syndication='oui' OR syndication='sus') AND statut='publie' ORDER BY nom_site"); + +afficher_sites(_T('titre_sites_proposes'), "SELECT * FROM spip_syndic WHERE statut='prop' ORDER BY nom_site"); + +if ($connect_statut == '0minirezo' OR $GLOBALS['meta']["proposer_sites"] > 0) { + echo "<div align='right'>"; + $link = new Link('sites_edit.php3'); + $link->addVar('target', 'sites.php3'); + $link->addVar('redirect', $clean_link->getUrl()); + icone(_T('icone_referencer_nouveau_site'), $link->getUrl(), "site-24.gif", "creer.gif"); + echo "</div>"; +} + +afficher_sites(_T('avis_sites_probleme_syndication'), "SELECT * FROM spip_syndic WHERE syndication='off' AND statut='publie' ORDER BY nom_site"); + +if ($options == 'avancees' AND $connect_statut == '0minirezo') { + afficher_sites(_T('info_sites_refuses'), "SELECT * FROM spip_syndic WHERE statut='refuse' ORDER BY nom_site"); +} + +afficher_syndic_articles(_T('titre_dernier_article_syndique'), + "SELECT * FROM spip_syndic_articles ORDER BY date DESC LIMIT 50", 'afficher site'); + +fin_page(); +} + +function afficher_sites($titre_table, $requete) { + global $couleur_claire, $spip_lang_left, $spip_lang_right; + global $connect_id_auteur; + + $tranches = afficher_tranches_requete($requete, 3); + + if ($tranches) { +// debut_cadre_relief("site-24.gif"); + if ($titre_table) echo "<div style='height: 12px;'></div>"; + echo "<div class='liste'>"; + bandeau_titre_boite2($titre_table, "site-24.gif", $couleur_claire, "black"); + echo "<table width='100%' cellpadding='2' cellspacing='0' border='0'>"; + + echo $tranches; + + $result = spip_query($requete); + $num_rows = spip_num_rows($result); + + $ifond = 0; + $premier = true; + + $compteur_liste = 0; + while ($row = spip_fetch_array($result)) { + $vals = ''; + $id_syndic=$row["id_syndic"]; + $id_rubrique=$row["id_rubrique"]; + $nom_site=sinon(typo($row["nom_site"]), _T('info_sans_titre')); + $url_site=$row["url_site"]; + $url_syndic=$row["url_syndic"]; + $description=propre($row["description"]); + $syndication=$row["syndication"]; + $statut=$row["statut"]; + $date=$row["date"]; + $moderation=$row['moderation']; + + $tous_id[] = $id_syndic; + + //echo "<tr bgcolor='$couleur'>"; + + //echo "<td class='arial2'>"; + $link = new Link("sites.php3?id_syndic=$id_syndic"); + switch ($statut) { + case 'publie': + if (acces_restreint_rubrique($id_rubrique)) + $puce = 'puce-verte-anim.gif'; + else + $puce='puce-verte-breve.gif'; + $title = _T('info_site_reference'); + break; + case 'prop': + if (acces_restreint_rubrique($id_rubrique)) + $puce = 'puce-orange-anim.gif'; + else + $puce='puce-orange-breve.gif'; + $title = _T('info_site_attente'); + break; + case 'refuse': + if (acces_restreint_rubrique($id_rubrique)) + $puce = 'puce-poubelle-anim.gif'; + else + $puce='puce-poubelle-breve.gif'; + $title = _T('info_site_refuse'); + break; + } + if ($syndication == 'off' OR $syndication == 'sus') { + $puce = 'puce-orange-anim.gif'; + $title = _T('info_panne_site_syndique'); + } + + $s = "<a href=\"".$link->getUrl()."\" title=\"$title\">"; + + if ($spip_display != 1 AND $spip_display != 4 AND $GLOBALS['meta']['image_process'] != "non") { + include_ecrire("inc_logos.php3"); + $logo = decrire_logo("siteon$id_syndic"); + if ($logo) { + $s.= "<div style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'>" + . reduire_image_logo(_DIR_IMG.$logo[0], 26, 20) + . "</div>\n"; + } + } + + + $s .= http_img_pack($puce, $statut, "width='7' height='7' border='0'") ." "; + + $s .= typo($nom_site); + + $s .= "</a> <font size='1'>[<a href='$url_site'>"._T('lien_visite_site')."</a>]</font>"; + $vals[] = $s; + + //echo "</td>"; + + $s = ""; + //echo "<td class='arial1' align='right'> "; + if ($syndication == 'off' OR $syndication == 'sus') { + $s .= "<font color='red'>"._T('info_probleme_grave')." </font>"; + } + if ($syndication == "oui" or $syndication == "off" OR $syndication == 'sus'){ + $s .= "<font color='red'>"._T('info_syndication')."</font>"; + } + $vals[] = $s; + //echo "</td>"; + //echo "<td class='arial1'>"; + $s = ""; + if ($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") { + $result_art = spip_query("SELECT COUNT(*) FROM spip_syndic_articles WHERE id_syndic='$id_syndic'"); + list($total_art) = spip_fetch_array($result_art); + $s .= " $total_art "._T('info_syndication_articles'); + } else { + $s .= " "; + } + $vals[] = $s; + //echo "</td>"; + //echo "</tr></n>"; + $table[] = $vals; + } + spip_free_result($result); + + $largeurs = array('','',''); + $styles = array('arial11', 'arial1', 'arial1'); + afficher_liste($largeurs, $table, $styles); + echo "</table>"; + //fin_cadre_relief(); + echo "</div>\n"; + } + return $tous_id; +} + +function afficher_syndic_articles($titre_table, $requete, $afficher_site = false) { + global $connect_statut; + global $REQUEST_URI; + global $debut_liste_sites; + global $flag_editable; + + static $n_liste_sites; + global $spip_lang_rtl, $spip_lang_right; + + $adresse_page = substr($REQUEST_URI, strpos($REQUEST_URI, "/ecrire")+8, strlen($REQUEST_URI)); + $adresse_page = ereg_replace("\&?debut\_liste\_sites\[$n_liste_sites\]\=[0-9]+","",$adresse_page); + $adresse_page = ereg_replace("\&?(ajouter\_lien|supprimer_lien)\=[0-9]+","",$adresse_page); + + if (ereg("\?",$adresse_page)) $lien_url = "&"; + else $lien_url = "?"; + + $lien_url .= "debut_liste_sites[".$n_liste_sites."]=".$debut_liste_sites[$n_liste_sites]."&"; + + $cols = 2; + if ($connect_statut == '0minirezo') $cols ++; + if ($afficher_site) $cols ++; + + $tranches = afficher_tranches_requete($requete, $cols); + + if (strlen($tranches)) { + + if ($titre_table) echo "<div style='height: 12px;'></div>"; + echo "<div class='liste'>"; + //debut_cadre_relief("rubrique-24.gif"); + + if ($titre_table) { + bandeau_titre_boite2($titre_table, "site-24.gif", "#999999", "white"); + } + echo "<table width=100% cellpadding=3 cellspacing=0 border=0 background=''>"; + + echo $tranches; + + $result = spip_query($requete); + + $table = ''; + while ($row = spip_fetch_array($result)) { + $vals = ''; + + $id_syndic_article=$row["id_syndic_article"]; + $id_syndic=$row["id_syndic"]; + $titre=safehtml($row["titre"]); + $url=$row["url"]; + $date=$row["date"]; + $lesauteurs=typo($row["lesauteurs"]); + $statut=$row["statut"]; + $descriptif=safehtml($row["descriptif"]); + + + if ($statut=='publie') { + if (acces_restreint_rubrique($id_rubrique)) + $puce = 'puce-verte-anim.gif'; + else + $puce='puce-verte.gif'; + } + else if ($statut == "refuse") { + $puce = 'puce-poubelle.gif'; + } + + else if ($statut == "dispo") { // moderation : a valider + $puce = 'puce-rouge.gif'; + } + + else if ($statut == "off") { // feed d'un site en mode "miroir" + $puce = 'puce-rouge-anim.gif'; + } + + $s = http_img_pack($puce, $statut, "width='7' height='7' border='0'"); + $vals[] = $s; + + $s = "<a href='$url'>$titre</a>"; + + $date = affdate_court($date); + if (strlen($lesauteurs) > 0) $date = $lesauteurs.', '.$date; + $s.= " ($date)"; + + // Tags : d'un cote les enclosures, de l'autre les liens + if($e = afficher_enclosures($row['tags'])) + $s .= ' '.$e; + + // descriptif + if (strlen($descriptif) > 0) + $s .= "<div class='arial1'>".safehtml($descriptif)."</div>"; + + // tags + if ($tags = afficher_tags($row['tags'])) + $s .= "<div style='float:$spip_lang_right;'> <em>" + . $tags . '</em></div>'; + + // source + if (strlen($row['url_source'])) + $s .= "<div style='float:$spip_lang_right;'>" + . propre("[".$row['source']."->".$row['url_source']."]") + . "</div>"; + else if (strlen($row['source'])) + $s .= "<div style='float:$spip_lang_right;'>" + . typo($row['source']) + . "</div>"; + + $vals[] = $s; + + // $my_sites cache les resultats des requetes sur les sites + if (!$my_sites[$id_syndic]) + $my_sites[$id_syndic] = spip_fetch_array(spip_query( + "SELECT * FROM spip_syndic WHERE id_syndic=$id_syndic")); + + if ($afficher_site) { + $aff = $my_sites[$id_syndic]['nom_site']; + if ($my_sites[$id_syndic]['moderation'] == 'oui') + $s = "<i>$aff</i>"; + else + $s = $aff; + + $s = "<a href='sites.php3?id_syndic=$id_syndic'>$aff</a>"; + + $vals[] = $s; + } + + + if ($connect_statut == '0minirezo'){ + if ($statut == "publie"){ + $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&supprimer_lien=$id_syndic_article'><font color='black'>"._T('info_bloquer_lien')."</font></a>]"; + + } + else if ($statut == "refuse"){ + $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>"._T('info_retablir_lien')."</a>]"; + } + else if ($statut == "off" + AND $my_sites[$id_syndic]['miroir'] == 'oui') { + $s = '('._T('syndic_lien_obsolete').')'; + } + else /* 'dispo' ou 'off' (dans le cas ancien site 'miroir') */ + { + $s = "[<a href='".$adresse_page.$lien_url."id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>"._T('info_valider_lien')."</a>]"; + } + $vals[] = $s; + } + + $table[] = $vals; + } + spip_free_result($result); + + + if ($afficher_site) { + $largeurs = array(7, '', '100'); + $styles = array('','arial11', 'arial1'); + } else { + $largeurs = array(7, ''); + $styles = array('','arial11'); + } + if ($connect_statut == '0minirezo') { + $largeurs[] = '80'; + $styles[] = 'arial1'; + } + + afficher_liste($largeurs, $table, $styles); + + echo "</TABLE>"; + //fin_cadre_relief(); + echo "</div>"; + } + return $tous_id; +} +?> diff --git a/ecrire/lab_ortho.php b/ecrire/lab_ortho.php index e5ac168ce1d06a0da314d870b0a0a389d62ed324..b0e98d9d90afb842d06e911b7720b04fecd650e2 100644 --- a/ecrire/lab_ortho.php +++ b/ecrire/lab_ortho.php @@ -161,7 +161,7 @@ function choisir_miroirs_ortho($lang) { // Envoyer une requete a un serveur d'orthographe // function post_ortho($url, $texte, $lang) { - include_ecrire('inc_sites.php3'); + include_ecrire('inc_distant.php3'); list($f, $fopen) = init_http('POST', $url, true /* refuse gz */); if (!$f OR $fopen) { diff --git a/ecrire/mots_edit.php3 b/ecrire/mots_edit.php3 index 90e7c69347723038792bc2de28a0ebdccd08f9dd..c2e4f21d0a6ca347496416a47697bf5281465297 100644 --- a/ecrire/mots_edit.php3 +++ b/ecrire/mots_edit.php3 @@ -19,7 +19,6 @@ include_ecrire("inc_urls.php3"); include_ecrire("inc_rubriques.php3"); include_ecrire ("inc_mots.php3"); include_ecrire ("inc_logos.php3"); -include_ecrire ("inc_sites.php3"); include_ecrire ("inc_abstract_sql.php3"); @@ -202,6 +201,7 @@ if ($id_mot) { "SELECT breves.* FROM spip_breves AS breves, spip_mots_breves AS lien WHERE lien.id_mot='$id_mot' AND lien.id_breve=breves.id_breve ORDER BY breves.date_heure DESC"); + include_ecrire ("inc_sites_tous.php"); afficher_sites(_T('info_sites_lies_mot'), "SELECT syndic.* FROM spip_syndic AS syndic, spip_mots_syndic AS lien WHERE lien.id_mot='$id_mot' AND lien.id_syndic=syndic.id_syndic ORDER BY syndic.nom_site DESC"); diff --git a/ecrire/recherche.php3 b/ecrire/recherche.php3 index fedd9edd7505c58e67d6cc1719e477dfeff63bda..79531487c80a45e37d5ed4204d845b798a4aca53 100644 --- a/ecrire/recherche.php3 +++ b/ecrire/recherche.php3 @@ -18,7 +18,7 @@ include_ecrire("inc_texte.php3"); include_ecrire("inc_urls.php3"); include_ecrire("inc_rubriques.php3"); include_ecrire ("inc_mots.php3"); -include_ecrire ("inc_sites.php3"); +include_ecrire ("inc_sites_tous.php"); $recherche = addslashes(entites_html($recherche)); diff --git a/ecrire/sites_tous.php3 b/ecrire/sites_tous.php3 index fe79ed8d04306411752cd33d50575ad5e14e148e..2fe0d69a9d6849864202a92c72c7a464c539dffd 100644 --- a/ecrire/sites_tous.php3 +++ b/ecrire/sites_tous.php3 @@ -10,65 +10,7 @@ * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ - - include ("inc.php3"); -include_ecrire("inc_presentation.php3"); -include_ecrire("inc_texte.php3"); -include_ecrire("inc_urls.php3"); -include_ecrire("inc_rubriques.php3"); - -include_ecrire ("inc_sites.php3"); - -if ($connect_statut == '0minirezo' AND $supp_syndic) { - $query="DELETE FROM spip_syndic WHERE id_syndic=".intval($supp_syndic); - $result=spip_query($query); -} - - -debut_page(_T('titre_page_sites_tous'),"documents","sites"); -debut_gauche(); - - - -debut_droite(); - - - -$proposer_sites=$GLOBALS['meta']["proposer_sites"]; - - - - -afficher_sites(_T('titre_sites_tous'), "SELECT * FROM spip_syndic WHERE syndication='non' AND statut='publie' ORDER BY nom_site"); - - -afficher_sites(_T('titre_sites_syndiques'), "SELECT * FROM spip_syndic WHERE (syndication='oui' OR syndication='sus') AND statut='publie' ORDER BY nom_site"); - - -afficher_sites(_T('titre_sites_proposes'), "SELECT * FROM spip_syndic WHERE statut='prop' ORDER BY nom_site"); - -if ($connect_statut == '0minirezo' OR $proposer_sites > 0) { - echo "<div align='right'>"; - $link = new Link('sites_edit.php3'); - $link->addVar('target', 'sites.php3'); - $link->addVar('redirect', $clean_link->getUrl()); - icone(_T('icone_referencer_nouveau_site'), $link->getUrl(), "site-24.gif", "creer.gif"); - echo "</div>"; -} - - - -afficher_sites(_T('avis_sites_probleme_syndication'), "SELECT * FROM spip_syndic WHERE syndication='off' AND statut='publie' ORDER BY nom_site"); - -if ($options == 'avancees' AND $connect_statut == '0minirezo') { - afficher_sites(_T('info_sites_refuses'), "SELECT * FROM spip_syndic WHERE statut='refuse' ORDER BY nom_site"); -} - -afficher_syndic_articles(_T('titre_dernier_article_syndique'), - "SELECT * FROM spip_syndic_articles ORDER BY date DESC LIMIT 50", 'afficher site'); - -fin_page(); - +$var_f = include_fonction(basename($SCRIPT_NAME, _EXTENSION_PHP)); +$var_f(); ?> -