コード例 #1
0
function pdf_first_clean($texte){
	// Cette focntion est appelé après la fonction propre
	// $texte = ereg_replace("<p class[^>]*>", "<P>", $texte);
	//Translation des codes iso
	// PB avec l'utilisation de <code>
	$trans = get_html_translation_table(HTML_ENTITIES);
	$texte = preg_replace(',<!-- .* -->,msU', '', $texte); // supprimer les remarques HTML (du Couteau Suisse ?)
	$trans = array_flip($trans);
	$trans["<br />\n"] = "<BR>";        // Pour éviter que le \n ne se tranforme en espace dans les <DIV class=spip_code> (TT, tag SPIP : code)
	$trans['&#176;'] = "°";
	$trans["&#339;"] = "oe";
	$trans["&#8206;"] = "";
	$trans["&#8211;"] = "-";
	$trans["&#8216;"] = "'";
	$trans["&#8217;"] = "'";
	$trans["&#8220;"] = "\"";
	$trans["&#8221;"] = "\"";
	$trans["&#8230;"] = "...";
	$trans["&#8364;"] = "Euros";
	$trans["&ucirc;"] = "û";
	$trans['->'] = '-»';
	$trans['<-'] = '«-';
	$trans['&nbsp;'] = ' ';
	// certains titles font paniquer l'analyse
	$texte = preg_replace(',title=".*",msU', 'title=""', $texte);
	
	$texte = unicode2charset(charset2unicode($texte), 'iso-8859-1'); // repasser tout dans un charset acceptable par export PDF
	$texte = strtr($texte, $trans);

	return $texte;
}
コード例 #2
0
ファイル: afficher_liste.php プロジェクト: rhertzog/lcs
function plugins_afficher_liste_dist($url_page,$liste_plugins, $liste_plugins_actifs, $dir_plugins=_DIR_PLUGINS,$afficher_un = 'afficher_plugin'){
	$get_infos = charger_fonction('get_infos','plugins');
	$ligne_plug = charger_fonction($afficher_un,'plugins');
	$liste_plugins = array_flip($liste_plugins);
	foreach(array_keys($liste_plugins) as $chemin) {
		if ($info = $get_infos($chemin, false, $dir_plugins))
			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($info['nom']))))));
	}
	asort($liste_plugins);
	$exposed = urldecode(_request('plugin'));

	$block_par_lettre = false;//count($liste_plugins)>10;
	$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
	$res = '';
	$block = '';
	$initiale = '';
	$block_actif = false;
	foreach($liste_plugins as $plug => $nom){
		if (($i=substr($nom,0,1))!==$initiale){
			$res .= $block_par_lettre ? affiche_block_initiale($initiale,$block,$block_actif): $block;
			$initiale = $i;
			$block = '';
			$block_actif = false;
		}
		// le rep suivant
		$actif = @isset($fast_liste_plugins_actifs[$plug]);
		$block_actif = $block_actif | $actif;
		$expose = ($exposed AND ($exposed==$plug OR $exposed==$dir_plugins . $plug OR $exposed==substr($dir_plugins,strlen(_DIR_RACINE)) . $plug));
		$block .= $ligne_plug($url_page, $plug, $actif, $expose, "item", $dir_plugins)."\n";
	}
	$res .= $block_par_lettre ? affiche_block_initiale($initiale,$block,$block_actif): $block;
	$class = basename($dir_plugins);
	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
}
コード例 #3
0
ファイル: exporter_csv.php プロジェクト: rhertzog/lcs
/**
 * Exporter une ligne complete au format CSV, avec delimiteur fourni
 * @param array $ligne
 * @param string $delim
 * @return string
 */
function exporter_csv_ligne($ligne, $delim = ',', $importer_charset = null) {
	$output = join($delim, array_map('exporter_csv_champ', $ligne))."\r\n";
	if ($importer_charset){
		$output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset);
	}
	return $output;
}
コード例 #4
0
ファイル: fr.php プロジェクト: nursit/SPIP
function typographie_fr_dist($letexte)
{
    static $trans;
    // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ;
    // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
    if (!$trans) {
        $trans = array("'" => "&#8217;", "&nbsp;" => "~", "&raquo;" => "&#187;", "&laquo;" => "&#171;", "&rdquo;" => "&#8221;", "&ldquo;" => "&#8220;", "&deg;" => "&#176;");
        $chars = array(160 => '~', 187 => '&#187;', 171 => '&#171;', 148 => '&#8221;', 147 => '&#8220;', 176 => '&#176;');
        $chars_trans = array_keys($chars);
        $chars = array_values($chars);
        $chars_trans = implode(' ', array_map('chr', $chars_trans));
        $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
        $chars_trans = explode(" ", $chars_trans);
        foreach ($chars as $k => $r) {
            $trans[$chars_trans[$k]] = $r;
        }
    }
    $letexte = strtr($letexte, $trans);
    $cherche1 = array('/((?:^|[^\\#0-9a-zA-Z\\&])[\\#0-9a-zA-Z]*)\\;/S', '/&#187;| --?,|(?::| %)(?:\\W|$)/S', '/([^[<(!?.])([!?][!?\\.]*)/iS', '/&#171;|(?:M(?:M?\\.|mes?|r\\.?)|[MnN]&#176;) /S');
    $remplace1 = array('\\1~;', '~\\0', '\\1~\\2', '\\0~');
    $letexte = preg_replace($cherche1, $remplace1, $letexte);
    $letexte = preg_replace("/ *~+ */S", "~", $letexte);
    $cherche2 = array('/([^-\\n]|^)--([^-]|$)/S', ',(http|https|ftp|mailto)~((://[^"\'\\s\\[\\]\\}\\)<>]+)~([?]))?,S', '/~/');
    $remplace2 = array('\\1&mdash;\\2', '\\1\\3\\4', '&nbsp;');
    $letexte = preg_replace($cherche2, $remplace2, $letexte);
    return $letexte;
}
コード例 #5
0
ファイル: typo_exposants.php プロジェクト: rhertzog/lcs
function typo_exposants_fr($texte){
	static $typo = NULL;
	static $egrave; static $eaigu1; static $eaigu2; static $accents;
	if (is_null($typo)) {
		// en principe, pas besoin de : caractere_utf_8(232)
		$egrave = unicode2charset('&#232;').'|&#232;|&egrave;';
		$eaigu1 = unicode2charset('&#233;').'|&#233;|&eacute;';
		$eaigu2 = unicode2charset('&#201;').'|&#201;|&Eacute;';
		$accents = unicode2charset('&#224;&#225;&#226;&#228;&#229;&#230;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#242;&#243;&#244;&#246;&#249;&#250;&#251;&#252;');
		$typo = array( array(
			'/(?<=\bM)e?(lles?)\b/',		// Mlle(s), Mme(s) et erreurs Melle(s)
			'/(?<=\bM)(gr|mes?)\b/',	// Mme(s) et Mgr
			'/(?<=\b[DP])(r)(?=[\s\.-])/',	// Dr, Pr suivis d'un espace d'un point ou d'un tiret

			'/\bm²\b/', '/(?<=\bm)([23])\b/',	 // m2, m3, m²
			'/(?<=\b[Mm])([nd]s?)\b/',	// millions, milliards
			'/(?<=\bV)(ve)\b/', '/(?<=\bC)(ies?)\b/',	// Vve et Cie(s)
			"/(?<=\bS)(t(?:$eaigu1)s?)(?=\W)/", "/(?<=\W)(?:E|$eaigu2)ts\b/",	 // Societes(s), Etablissements

			'/(?<=\b[1I])i?(ers?)\b/',	// 1er(s), Erreurs 1ier(s), 1ier(s)
			"/(?<=\b[1I])i?(?:e|$egrave)(res?)\b/",	// Erreurs 1(i)ere(s) + accents
			'/(?<=\b1)(r?es?)\b/', // 1e(s), 1re(s)
			'/(?<=\b2)(nde?s?)\b/',	// 2nd(e)(s)

			"/(\b[0-9IVX]+)i?(?:e|$egrave)?me(s?)\b/", // Erreurs (i)(e)me(s) + accents
			'/\b([0-9IVX]+)(es?)\b/', // 2e(s), IIIe(s)... (les 1(e?r?s?) ont deja ete remplaces)
			"/(?<![;$accents])\b(\d+|r|v)o(?=(?:&nbsp;|[\s,;:!\/\?\.-]))/", // recto, verso, primo, secondo, etc.
			'/(?<=\bM)(e)(?= [A-Z])/', // Maitre (suivi d'un espace et d'une majuscule)
		), array(
			_TYPO_sup, _TYPO_sup,		// Mlle(s), Mme(s), Mgr
			_TYPO_sup,		// Dr, Pr, 

			'm<sup class="typo_exposants">2</sup>',	_TYPO_sup,	// m2, m3, m²
			_TYPO_sup, _TYPO_sup, _TYPO_sup,	// Vve, Mn(s), Md(s), Bd(s), Cie(s)
			_TYPO_sup, '&#201;<sup class="typo_exposants">ts</sup>',	// Sté(s), Ets

			_TYPO_sup, _TYPO_sup, _TYPO_sup, // 1er et Cie
			_TYPO_sup,	// 2nd(e)(s)

			'$1<sup class="typo_exposants">e$2</sup>', // Erreurs me, eme, ème, ième + pluriels
			_TYPO_sup2, // 2e(s), IIIe(s)...
			'$1<sup class="typo_exposants">o</sup>', // ro, vo, 1o, 2o, etc.
			_TYPO_sup,	// Me
		));

		if(defined('_CS_EXPO_BOFBOF')) {
			$typo[0] = array_merge($typo[0], array(
				'/(?<=\bS)(te?s?)(?=[\s\.-])/',  // St(e)(s) suivis d'un espace d'un point ou d'un tiret
				'/(?<=\bB)(x|se|ses)(?=[\s\.-])/',  // Bx, Bse(s) suivis d'un espace d'un point ou d'un tiret
				'/(?<=\b[Bb])(ds?)\b/',	 '/(?<=\b[Ff])(gs?)\b/', // boulevard(s) et faubourgs(s)
			));
			$typo[1] = array_merge($typo[1], array(
				_TYPO_sup, _TYPO_sup,	// St(e)(s), Bx, Bse(s)
				_TYPO_sup, _TYPO_sup,	// Bd(s) et Fg(s)
			));
		}
	}
	return preg_replace($typo[0], $typo[1], $texte);
}
コード例 #6
0
ファイル: glossaire_fonctions.php プロジェクト: rhertzog/lcs
function glossaire_accents_callback($matches) {
	$u = unicode2charset($matches[0]);	// charset
	$u2 = init_mb_string()?mb_strtoupper($u):strtoupper($u);	// charset majuscule
	$u3 = htmlentities($u2, ENT_QUOTES, $GLOBALS['meta']['charset']);	// html majuscule
	$u4 = html2unicode($u3); // unicode majuscule
	$a = array_unique(array($u, $u2, htmlentities($u, ENT_QUOTES, $GLOBALS['meta']['charset']), $u3, $matches[0], $u4));
//	$a = array_unique(array($u, htmlentities($u, ENT_QUOTES, $GLOBALS['meta']['charset']), $matches[0]));
	return '(?:'.join('|', $a).')';
}
コード例 #7
0
ファイル: mediabox_pipelines.php プロジェクト: genma/spip_ynh
function mediabox_insert_head_css($flux)
{
    $config = mediabox_config();
    if ($config['active'] == 'oui' and $f = find_in_path((test_espace_prive() ? "prive/" : "") . "colorbox/" . $config['skin'] . '/colorbox.css')) {
        $flux .= '<link rel="stylesheet" href="' . direction_css($f) . '" type="text/css" media="all" />';
        /**
         * Initialiser la config de la mediabox
         */
        $flux = '<script type="text/javascript">/* <![CDATA[ */
var box_settings = {tt_img:' . ($config['traiter_toutes_images'] == 'oui' ? 'true' : 'false') . ',sel_g:"' . $config['selecteur_galerie'] . '",sel_c:"' . $config['selecteur_commun'] . '",trans:"' . $config['transition'] . '",speed:"' . $config['speed'] . '",ssSpeed:"' . $config['slideshow_speed'] . '",maxW:"' . $config['maxWidth'] . '",maxH:"' . $config['maxHeight'] . '",minW:"' . $config['minWidth'] . '",minH:"' . $config['minHeight'] . '",opa:"' . $config['opacite'] . '",str_ssStart:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStart'))) . '",str_ssStop:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStop'))) . '",str_cur:"' . _T('mediabox:boxstr_current', array('current' => '{current}', 'total' => '{total}')) . '",str_prev:"' . _T('mediabox:boxstr_previous') . '",str_next:"' . _T('mediabox:boxstr_next') . '",str_close:"' . _T('mediabox:boxstr_close') . '",splash_url:"' . $config['splash_url'] . '"};
/* ]]> */</script>' . "\n" . $flux;
    }
    return $flux;
}
コード例 #8
0
ファイル: afficher_liste.php プロジェクト: genma/spip_ynh
/**
 * Afficher une liste de plugins dans l'interface
 * http://doc.spip.org/@affiche_liste_plugins
 *
 * @param string $url_page
 * @param array $liste_plugins
 * @param array $liste_plugins_checked
 * @param array $liste_plugins_actifs
 * @param string $dir_plugins
 * @param string $afficher_un
 * @return string
 */
function plugins_afficher_liste_dist($url_page, $liste_plugins, $liste_plugins_checked, $liste_plugins_actifs, $dir_plugins = _DIR_PLUGINS, $afficher_un = 'afficher_plugin')
{
    $get_infos = charger_fonction('get_infos', 'plugins');
    $ligne_plug = charger_fonction($afficher_un, 'plugins');
    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
    $all_infos = pipeline('filtrer_liste_plugins', array('args' => array('liste_plugins' => $liste_plugins, 'liste_plugins_checked' => $liste_plugins_checked, 'liste_plugins_actifs' => $liste_plugins_actifs, 'dir_plugins' => $dir_plugins), 'data' => $all_infos));
    $liste_plugins = array_flip($liste_plugins);
    foreach ($liste_plugins as $chemin => $v) {
        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
        if (isset($all_infos[$chemin])) {
            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
        } else {
            unset($liste_plugins[$chemin]);
        }
    }
    asort($liste_plugins);
    $exposed = urldecode(_request('plugin'));
    $block_par_lettre = false;
    //count($liste_plugins)>10;
    $fast_liste_plugins_actifs = array();
    $fast_liste_plugins_checked = array();
    if (is_array($liste_plugins_actifs)) {
        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
    }
    if (is_array($liste_plugins_checked)) {
        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
    }
    $res = '';
    $block = '';
    $initiale = '';
    $block_actif = false;
    foreach ($liste_plugins as $plug => $nom) {
        if (($i = substr($nom, 0, 1)) !== $initiale) {
            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
            $initiale = $i;
            $block = '';
            $block_actif = false;
        }
        // le rep suivant
        $actif = isset($fast_liste_plugins_actifs[$plug]);
        $checked = isset($fast_liste_plugins_checked[$plug]);
        $block_actif = $block_actif | $actif;
        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, strlen(_DIR_RACINE)) . $plug));
        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
    }
    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
    $class = basename($dir_plugins);
    return $res ? "<ul class='liste-items plugins {$class}'>{$res}</ul>" : "";
}
コード例 #9
0
function onelettrebis($chaine) {
    $chaine=sansle($chaine); 
    $chaine=filtrer_entites($chaine); // si il y a des fois des accents en dur qui trainent
    $chaine = unicode2charset(utf_8_to_unicode($chaine), 'iso-8859-1'); // on code en html ISO
    $a = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
    $b = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn";
    $chaine=strtr($chaine, $a, $b); // on retire les accents
    $chaine=strtoupper($chaine); // on passe en majuscules 
    /// si débute par le fameux Œ ou œ
    $pattern = "^(Œ|œ)";
    if (eregi($pattern,$chaine,$regs)) 
        $chaine='O';//$chaine= $regs[0]; //on va renvoyer la lettre O
    else 
        $chaine = $chaine{0}; 
    return $chaine ;
}
コード例 #10
0
function mediabox_insert_head_css($flux) {
	$config = mediabox_config();
	if ($config['active'] == 'oui' and $f = find_in_path((test_espace_prive() ? "prive/" : "") . "colorbox/" . $config['skin'] . '/colorbox.css')) {
		$flux .= '<link rel="stylesheet" href="' . direction_css($f) . '" type="text/css" media="all" />';
		/**
		 * Initialiser la config de la mediabox
		 */
		$configmediabox = '<script type="text/javascript">/* <![CDATA[ */
var box_settings = {tt_img:' . ($config['traiter_toutes_images'] == 'oui' ? 'true' : 'false')
			. ',sel_g:"' . $config['selecteur_galerie']
			. '",sel_c:"' . $config['selecteur_commun']
			. '",trans:"' . $config['transition']
			. '",speed:"' . $config['speed']
			. '",ssSpeed:"' . $config['slideshow_speed']
			. '",maxW:"' . $config['maxWidth']
			. '",maxH:"' . $config['maxHeight']
			. '",minW:"' . $config['minWidth']
			. '",minH:"' . $config['minHeight']
			. '",opa:"' . $config['opacite']
			. '",str_ssStart:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStart')))
			. '",str_ssStop:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStop')))
			. '",str_cur:"' . _T('mediabox:boxstr_current', array('current' => '{current}', 'total' => '{total}'))
			. '",str_prev:"' . _T('mediabox:boxstr_previous')
			. '",str_next:"' . _T('mediabox:boxstr_next')
			. '",str_close:"' . _T('mediabox:boxstr_close')
			. '",splash_url:"' . $config['splash_url']
			. '"};' . "\n";
		// Si c'est une image, on la chargera avec une redimentionnement automatique
		// Sinon, chargement dans une iframe
		$extension = pathinfo($config['splash_url'], PATHINFO_EXTENSION);
		if (match($extension, 'gif|png|jpg|jpeg')) {
			$configmediabox .= 'var box_settings_iframe = false;' . "\n";
		} else {
			$configmediabox .= 'var box_settings_splash_width = "' . $config['splash_width'] . '";
var box_settings_splash_height = "' . $config['splash_height'] . '";' . "\n";
			$configmediabox .= 'var box_settings_iframe = true;' . "\n";
		}
		$flux = $configmediabox . '/* ]]> */</script>' . "\n" . $flux;
	}

	return $flux;
}
コード例 #11
0
/**
 * Afficher de facon textuelle les dates de debut et fin en fonction des cas
 * - Le lundi 20 fevrier a 18h
 * - Le 20 fevrier de 18h a 20h
 * - Du 20 au 23 fevrier
 * - du 20 fevrier au 30 mars
 * - du 20 fevrier 2007 au 30 mars 2008
 * $horaire='oui' permet d'afficher l'horaire, toute autre valeur n'indique que le jour
 * $forme peut contenir abbr (afficher le nom des jours en abbrege) et ou hcal (generer une date au format hcal)
 * 
 * @param string $date_debut
 * @param string $date_fin
 * @param string $horaire
 * @param string $forme
 * @return string
 */
function agenda_affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '')
{
    $abbr = '';
    if (strpos($forme, 'abbr') !== false) {
        $abbr = 'abbr';
    }
    $affdate = "affdate_jourcourt";
    if (strpos($forme, 'annee') !== false) {
        $affdate = 'affdate';
    }
    $dtstart = $dtend = $dtabbr = "";
    if (strpos($forme, 'hcal') !== false) {
        $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
        $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
        $dtabbr = "</abbr>";
    }
    $date_debut = strtotime($date_debut);
    $date_fin = strtotime($date_fin);
    $d = date("Y-m-d", $date_debut);
    $f = date("Y-m-d", $date_fin);
    $h = $horaire == 'oui';
    $hd = date("H:i", $date_debut);
    $hf = date("H:i", $date_fin);
    $au = " " . strtolower(_T('agenda:evenement_date_au'));
    $du = _T('agenda:evenement_date_du') . " ";
    $s = "";
    if ($d == $f) {
        // meme jour
        $s = ucfirst(nom_jour($d, $abbr)) . " " . $affdate($d);
        if ($h) {
            $s .= " {$hd}";
        }
        $s = "{$dtstart}{$s}{$dtabbr}";
        if ($h and $hd != $hf) {
            $s .= "-{$dtend}{$hf}{$dtabbr}";
        }
    } else {
        if (date("Y-m", $date_debut) == date("Y-m", $date_fin)) {
            // meme annee et mois, jours differents
            if ($h) {
                $s = $du . $dtstart . affdate_jourcourt($d) . " {$hd}" . $dtabbr;
                $s .= $au . $dtend . $affdate($f);
                if ($hd != $hf) {
                    $s .= " {$hf}";
                }
                $s .= $dtabbr;
            } else {
                $s = $du . $dtstart . jour($d) . $dtabbr;
                $s .= $au . $dtend . $affdate($f) . $dtabbr;
            }
        } else {
            if (date("Y", $date_debut) == date("Y", $date_fin)) {
                // meme annee, mois et jours differents
                $s = $du . $dtstart . affdate_jourcourt($d);
                if ($h) {
                    $s .= " {$hd}";
                }
                $s .= $dtabbr . $au . $dtend . $affdate($f);
                if ($h) {
                    $s .= " {$hf}";
                }
                $s .= $dtabbr;
            } else {
                // tout different
                $s = $du . $dtstart . affdate($d);
                if ($h) {
                    $s .= " " . date("(H:i)", $date_debut);
                }
                $s .= $dtabbr . $au . $dtend . affdate($f);
                if ($h) {
                    $s .= " " . date("(H:i)", $date_fin);
                }
                $s .= $dtabbr;
            }
        }
    }
    return unicode2charset(charset2unicode($s, 'AUTO'));
}
コード例 #12
0
ファイル: lien.php プロジェクト: rhertzog/lcs
function traiter_raccourci_glossaire($texte)
{
	if (!preg_match_all(_RACCOURCI_GLOSSAIRE,
	$texte, $matches, PREG_SET_ORDER))
		return $texte;

	include_spip('inc/charsets');
	$lien = charger_fonction('lien', 'inc');

	foreach ($matches as $regs) {
	// Eviter les cas particulier genre "[?!?]"
	// et isoler le lexeme a gloser de ses accessoires
	// (#:url du glossaire, | bulle d'aide, {} hreflang)
	// Transformation en pseudo-raccourci pour passer dans inc_lien
		if (preg_match(_RACCOURCI_GLOSES, $regs[1], $r)) {
			preg_match('/^(.*?)(\d*)$/', $r[4], $m);
			$_n = intval($m[2]);
			$gloss = $m[1] ? ('#' . $m[1]) : '';
			$t = $r[1] . $r[2] . $r[5];
			list($t, $bulle, $hlang) = traiter_raccourci_lien_atts($t);
			if ($bulle===false) $bulle = $m[1];
			$t = unicode2charset(charset2unicode($t), 'utf-8');
			$ref = $lien("glose$_n$gloss", $t, 'spip_glossaire', $bulle, $hlang);
			$texte = str_replace($regs[0], $ref, $texte);
		}
	}
	return $texte;
}
コード例 #13
0
ファイル: barre_outils.php プロジェクト: rhertzog/lcs
	/**
	 * Cree la sortie json pour le javascript des parametres de la barre
	 * et la retourne
	 * 
	 * @return string : declaration json de la barre
	 */
	function creer_json(){
		$barre = $this;
		$type = $barre->nameSpace;
		$fonctions = $barre->functions;
		
		$barre->enlever_elements_non_affiches($this->markupSet);
		$barre->enlever_parametres_inutiles();
		
		$json = Barre_outils::json_export($barre);

		// on lance la transformation des &chose; en veritables caracteres
		// sinon markitup restitue &laquo; au lieu de « directement
		// lorsqu'on clique sur l'icone
		include_spip('inc/charsets');
		$json = unicode2charset(html2unicode($json));
		return "\n\nbarre_outils_$type = ".$json . "\n\n $fonctions";		
	}
コード例 #14
0
ファイル: texte_mini.php プロジェクト: loorenzooo/aslfc
function couper($texte, $taille = 50, $suite = '&nbsp;(...)')
{
    if (!($length = strlen($texte)) or $taille <= 0) {
        return '';
    }
    $offset = 400 + 2 * $taille;
    while ($offset < $length and strlen(preg_replace(",<[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
        $offset = 2 * $offset;
    }
    if ($offset < $length && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== NULL) {
        $p_tag_fermant = strpos($texte, '>', $offset);
        if ($p_tag_fermant && $p_tag_fermant < $p_tag_ouvrant) {
            $offset = $p_tag_fermant + 1;
        }
        // prolonger la coupe jusqu'au tag fermant suivant eventuel
    }
    $texte = substr($texte, 0, $offset);
    /* eviter de travailler sur 10ko pour extraire 150 caracteres */
    // on utilise les \r pour passer entre les gouttes
    $texte = str_replace("\r\n", "\n", $texte);
    $texte = str_replace("\r", "\n", $texte);
    // sauts de ligne et paragraphes
    $texte = preg_replace("/\n\n+/", "\r", $texte);
    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/", "\r", $texte);
    // supprimer les traits, lignes etc
    $texte = preg_replace("/(^|\r|\n)(-[-#\\*]*|_ )/", "\r", $texte);
    // supprimer les tags
    $texte = supprimer_tags($texte);
    $texte = trim(str_replace("\n", " ", $texte));
    $texte .= "\n";
    // marquer la fin
    // travailler en accents charset
    $texte = unicode2charset(html2unicode($texte, true));
    if (!function_exists('nettoyer_raccourcis_typo')) {
        include_spip('inc/lien');
    }
    $texte = nettoyer_raccourcis_typo($texte);
    // corriger la longueur de coupe
    // en fonction de la presence de caracteres utf
    if ($GLOBALS['meta']['charset'] == 'utf-8') {
        $long = charset2unicode($texte);
        $long = spip_substr($long, 0, max($taille, 1));
        $nbcharutf = preg_match_all('/(&#[0-9]{3,5};)/S', $long, $matches);
        $taille += $nbcharutf;
    }
    // couper au mot precedent
    $long = spip_substr($texte, 0, max($taille - 4, 1));
    $u = $GLOBALS['meta']['pcre_u'];
    $court = preg_replace("/([^\\s][\\s]+)[^\\s]*\n?\$/" . $u, "\\1", $long);
    $points = $suite;
    // trop court ? ne pas faire de (...)
    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
        $points = '';
        $long = spip_substr($texte, 0, $taille);
        $texte = preg_replace("/([^\\s][\\s]+)[^\\s]*\n?\$/" . $u, "\\1", $long);
        // encore trop court ? couper au caractere
        if (spip_strlen($texte) < 0.75 * $taille) {
            $texte = $long;
        }
    } else {
        $texte = $court;
    }
    if (strpos($texte, "\n")) {
        // la fin est encore la : c'est qu'on n'a pas de texte de suite
        $points = '';
    }
    // remettre les paragraphes
    $texte = preg_replace("/\r+/", "\n\n", $texte);
    // supprimer l'eventuelle entite finale mal coupee
    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
    return quote_amp(trim($texte)) . $points;
}
コード例 #15
0
ファイル: inc_text.php プロジェクト: nyimbi/legalcase
function typo_fr($letexte)
{
    global $flag_strtr2;
    static $trans;
    // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; 147 = ldquo; 148 = rdquo
    if (!$trans) {
        $trans = array("&nbsp;" => "~", "&raquo;" => "&#187;", "&laquo;" => "&#171;", "&rdquo;" => "&#148;", "&ldquo;" => "&#147;", "&deg;" => "&#176;");
        $chars = array(160 => '~', 187 => '&#187;', 171 => '&#171;', 148 => '&#148;', 147 => '&#147;', 176 => '&#176;');
        $charset = read_meta('charset');
        include_lcm('inc_charsets');
        while (list($c, $r) = each($chars)) {
            $c = unicode2charset(charset2unicode(chr($c), 'iso-8859-1', 'forcer'));
            $trans[$c] = $r;
        }
    }
    if ($flag_strtr2) {
        $letexte = strtr($letexte, $trans);
    } else {
        reset($trans);
        while (list($c, $r) = each($trans)) {
            $letexte = str_replace($c, $r, $letexte);
        }
    }
    $cherche1 = array('/((^|[^\\#0-9a-zA-Z\\&])[\\#0-9a-zA-Z]*)\\;/', '/&#187;| --?,|:([^0-9]|$)/', '/([^<!?])([!?])/', '/&#171;|(M(M?\\.|mes?|r\\.?)|[MnN]&#176;) /');
    $remplace1 = array('\\1~;', '~\\0', '\\1~\\2', '\\0~');
    $letexte = ereg_remplace($cherche1, $remplace1, $letexte);
    $letexte = preg_replace("/ *~+ */", "~", $letexte);
    $cherche2 = array('/([^-\\n]|^)--([^-]|$)/', '/(http|https|ftp|mailto)~:/', '/~/');
    $remplace2 = array('\\1&mdash;\\2', '\\1:', '&nbsp;');
    $letexte = ereg_remplace($cherche2, $remplace2, $letexte);
    return $letexte;
}
コード例 #16
0
ファイル: spiplistes_api.php プロジェクト: rhertzog/lcs
function spiplistes_envoyer_mail ($to, $subject, $message, $from = false, $headers = '', $format = 'texte') {
	
	static $opt_simuler_envoi;

	// si desabo, plus de format ! donc forcer a texte
	$format = ($format == 'html') ? $format : 'texte';
	
	$charset = $GLOBALS['meta']['spiplistes_charset_envoi'];
	if(!$opt_simuler_envoi) {
		$opt_simuler_envoi = spiplistes_pref_lire('opt_simuler_envoi');
	}
	if (!$from)
	{
		$from = spiplistes_email_from_default();
	}
	if(strpos($from, '<') === false) {
		$fromname = spiplistes_nom_site_texte();
		
		if ($charset != $GLOBALS['meta']['charset']){
			include_spip('inc/charsets');
			$fromname = unicode2charset(charset2unicode($fromname),$charset);
		}
	}
	// @TODO: voir email_reply_to ?
	$reply_to = 'no-reply'.preg_replace("|.*(@[a-z.]+)|i", "$1", email_valide($from));
	
	if($opt_simuler_envoi == 'oui') {
		spiplistes_log("!!! MAIL SIMULATION MODE !!!");
		$result = true;
	}
	else {
		include_once(_DIR_PLUGIN_SPIPLISTES.'inc/spiplistes_mail.inc.php');
		
		$email_a_envoyer = array();
		
		$return_path = spiplistes_return_path($from);
		
		if(is_array($message))
		{
			if($format=='html' && isset($message[$format])) {
				$email_a_envoyer['html'] = new phpMail($to, $subject, $message['html'], $message['texte'], $charset);
				$email_a_envoyer['html']->From = $from ; 
				if($fromname) $email_a_envoyer['html']->FromName = $fromname ; 
				$email_a_envoyer['html']->AddCustomHeader("Errors-To: ".$return_path); 
				$email_a_envoyer['html']->AddCustomHeader("Reply-To: ".$from); 
				$email_a_envoyer['html']->AddCustomHeader("Return-Path: ".$return_path); 	
				$email_a_envoyer['html']->SMTPKeepAlive = true;
				$email_a_envoyer['html']->Body = $message['html']->Body;
				$email_a_envoyer['html']->AltBody = $message['html']->AltBody;
			}
			$message = $message['texte']->Body;
		}
		//$message = spiplistes_html_entity_decode ($message, $charset);
		$message = spiplistes_translate_2_charset ($message, $charset, true);
		
		//$email_a_envoyer['texte'] = new phpMail($to, $subject, '', html_entity_decode($message), $charset);
		$email_a_envoyer['texte'] = new phpMail($to, $subject, '', $message, $charset);
		$email_a_envoyer['texte']->From = $from ;
		if($fromname) $email_a_envoyer['html']->FromName = $fromname ; 
		$email_a_envoyer['texte']->AddCustomHeader('Errors-To: '.$return_path); 
		$email_a_envoyer['texte']->AddCustomHeader('Reply-To: '.$reply_to); 
		$email_a_envoyer['texte']->AddCustomHeader('Return-Path: '.$return_path); 
		$email_a_envoyer['texte']->SMTPKeepAlive = true;
		
		$result = $email_a_envoyer[$format]->send();
		
		$msg = "email from $from to $to";
		spiplistes_log(!$result ? "error: $msg not sent" : "$msg sent");
	}
	return($result);
}
コード例 #17
0
function install_etape_3b_dist()
{
    $login = _request('login');
    $email = _request('email');
    $nom = _request('nom');
    $pass = _request('pass');
    $pass_verif = _request('pass_verif');
    $server_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : _request('server_db');
    if (!defined('_PASS_LONGUEUR_MINI')) {
        define('_PASS_LONGUEUR_MINI', 6);
    }
    if (!defined('_LOGIN_TROP_COURT')) {
        define('_LOGIN_TROP_COURT', 4);
    }
    if ($login) {
        $echec = $pass != $pass_verif ? _T('info_passes_identiques') : (strlen($pass) < _PASS_LONGUEUR_MINI ? _T('info_passe_trop_court_car_pluriel', array('nb' => _PASS_LONGUEUR_MINI)) : (strlen($login) < _LOGIN_TROP_COURT ? _T('info_login_trop_court') : ''));
        include_spip('inc/filtres');
        if (!$echec and $email and !email_valide($email)) {
            $echec = _T('form_email_non_valide');
        }
        if ($echec) {
            echo minipres('AUTO', info_progression_etape(3, 'etape_', 'install/', true) . "<div class='error'><h3>{$echec}</h3>\n" . "<p>" . _T('avis_connexion_echec_2') . "</p>" . "</div>");
            exit;
        }
    }
    if (@file_exists(_FILE_CHMOD_TMP)) {
        include _FILE_CHMOD_TMP;
    } else {
        redirige_url_ecrire('install');
    }
    if (!@file_exists(_FILE_CONNECT_TMP)) {
        redirige_url_ecrire('install');
    }
    # maintenant on connait le vrai charset du site s'il est deja configure
    # sinon par defaut lire_meta reglera _DEFAULT_CHARSET
    # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET)
    lire_metas();
    if ($login) {
        include_spip('inc/charsets');
        $nom = importer_charset($nom, _DEFAULT_CHARSET);
        $login = importer_charset($login, _DEFAULT_CHARSET);
        $email = importer_charset($email, _DEFAULT_CHARSET);
        # pour le passwd, bizarrement il faut le convertir comme s'il avait
        # ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js
        $pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1');
        include_spip('auth/sha256.inc');
        include_spip('inc/acces');
        $htpass = generer_htpass($pass);
        $alea_actuel = creer_uniqid();
        $alea_futur = creer_uniqid();
        $shapass = _nano_sha256($alea_actuel . $pass);
        // prelablement, creer le champ webmestre si il n'existe pas (install neuve
        // sur une vieille base
        $t = sql_showtable("spip_auteurs", true);
        if (!isset($t['field']['webmestre'])) {
            @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3)  DEFAULT 'non' NOT NULL");
        }
        $id_auteur = sql_getfetsel("id_auteur", "spip_auteurs", "login="******"nom" => $nom, 'email' => $email, 'login' => $login, 'pass' => $shapass, 'alea_actuel' => $alea_actuel, 'alea_futur' => $alea_futur, 'htpass' => $htpass, 'statut' => '0minirezo'), "id_auteur={$id_auteur}");
        } else {
            $id_auteur = sql_insertq('spip_auteurs', array('nom' => $nom, 'email' => $email, 'login' => $login, 'pass' => $shapass, 'htpass' => $htpass, 'alea_actuel' => $alea_actuel, 'alea_futur' => $alea_futur, 'statut' => '0minirezo'));
        }
        // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne
        @sql_updateq('spip_auteurs', array('webmestre' => 'oui'), "id_auteur={$id_auteur}");
        // inserer email comme email webmaster principal
        // (sauf s'il est vide: cas de la re-installation)
        if ($email) {
            ecrire_meta('email_webmaster', $email);
        }
        // Connecter directement celui qui vient de (re)donner son login
        // mais sans cookie d'admin ni connexion longue
        include_spip('inc/auth');
        if (!($auteur = auth_identifier_login($login, $pass)) or !auth_loger($auteur, true)) {
            spip_log("login automatique impossible {$auth_spip} {$session}" . count($row));
        }
    }
    // installer les metas
    $config = charger_fonction('config', 'inc');
    $config();
    // activer les plugins
    // leur installation ne peut pas se faire sur le meme hit, il faudra donc
    // poursuivre au hit suivant
    include_spip('inc/plugin');
    actualise_plugins_actifs();
    include_spip('inc/distant');
    redirige_par_entete(parametre_url(self(), 'etape', '4', '&'));
}
コード例 #18
0
function spiplistes_preparer_message ($objet, $patron, $contexte) {
	
	// si pas encore abonne' ou desabonne', pas de format ! donc forcer a texte
	$format = ($contexte['format'] == 'html') ? $contexte['format'] : ($contexte['format'] = 'texte');

	$contexte['patron'] = $patron;
	$path_patron = _SPIPLISTES_PATRONS_MESSAGES_DIR . $patron;
	
	list($message_html, $message_texte) = spiplistes_assembler_patron($path_patron, $contexte);

	$charset = $GLOBALS['meta']['spiplistes_charset_envoi'];
	
	if($charset != $GLOBALS['meta']['charset'])
	{
		include_spip('inc/charsets');
		if($format == 'html') {
			$message_html = unicode2charset(charset2unicode($message_html), $charset);
		}
		//$message_texte = unicode2charset(charset2unicode($message_texte), $charset);
		$message_texte = spiplistes_translate_2_charset ($message_texte, $charset);
	}
	$email_a_envoyer = array();
	$email_a_envoyer['texte'] = new phpMail('', $objet, '', $message_texte, $charset);
	if($format == 'html') {
		$email_a_envoyer['html'] = new phpMail('', $objet, $message_html, $message_texte, $charset);
		$email_a_envoyer['html']->Body = "<html>\n\n<body>\n\n" . $message_html	. "\n\n</body></html>";
		$email_a_envoyer['html']->AltBody = $message_texte;
	}
	$email_a_envoyer['texte']->Body = $message_texte ."\n\n";
	$email_a_envoyer[$format]->SetAddress($contexte['email'], $contexte['nom']);
	
	return($email_a_envoyer);
}
コード例 #19
0
ファイル: sax.php プロジェクト: rhertzog/lcs
function sax_bug($data)
{
	$r = analyser_doctype($data);

	if (!$r) {
		$data = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
		. preg_replace(_REGEXP_DOCTYPE, '', $data);
		$r =  analyser_doctype($data);
	}

	list($doctype, $topelement, $avail, $grammaire, $rotlvl, $len) = $r;

	include_spip('xml/analyser_dtd');
	$dtc = charger_dtd($grammaire, $avail, $rotlvl);

	// l'entete contient eventuellement < ? xml... ? >, le Doctype, 
	// et des commentaires autour d'eux
	$entete = ltrim(substr($data,0,$len));

	if ($dtc) {
		$trans = array();
		
		foreach($dtc->entites as $k => $v) {
			if (!strpos(" amp lt gt quot ", $k))
			    $trans["&$k;"] = $v;
		}
		$data = strtr(substr($data,$len), $trans);
	} else {
		$data = html2unicode(substr($data,$len), true);
	}
	return array($entete,unicode2charset($data), $dtc);
}
コード例 #20
0
ファイル: agenda_filtres.php プロジェクト: rhertzog/lcs
/**
 * Afficher de facon textuelle les dates de debut et fin en fonction des cas
 * - Le lundi 20 fevrier a 18h
 * - Le 20 fevrier de 18h a 20h
 * - Du 20 au 23 fevrier
 * - du 20 fevrier au 30 mars
 * - du 20 fevrier 2007 au 30 mars 2008
 * $horaire='oui' permet d'afficher l'horaire, toute autre valeur n'indique que le jour
 * $forme peut contenir abbr (afficher le nom des jours en abbrege) et ou hcal (generer une date au format hcal)
 * 
 * @param string $date_debut
 * @param string $date_fin
 * @param string $horaire
 * @param string $forme
 * @return string
 */
function agenda_affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme=''){
	static $trans_tbl=NULL;
	if ($trans_tbl==NULL){
		$trans_tbl = get_html_translation_table (HTML_ENTITIES);
		$trans_tbl = array_flip ($trans_tbl);
	}
	
	$abbr = '';
	if (strpos($forme,'abbr')!==false) $abbr = 'abbr';
	$affdate = "affdate_jourcourt";
	if (strpos($forme,'annee')!==false) $affdate = 'affdate';
	
	$dtstart = $dtend = $dtabbr = "";
	if (strpos($forme,'hcal')!==false) {
		$dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>";
		$dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>";
		$dtabbr = "</abbr>";
	}
	
	$date_debut = strtotime($date_debut);
	$date_fin = strtotime($date_fin);
	$d = date("Y-m-d", $date_debut);
	$f = date("Y-m-d", $date_fin);
	$h = $horaire=='oui';
	$hd = date("H:i",$date_debut);
	$hf = date("H:i",$date_fin);
	$au = " " . strtolower(_T('agenda:evenement_date_au'));
	$du = _T('agenda:evenement_date_du') . " ";
	$s = "";
	if ($d==$f)
	{ // meme jour
		$s = ucfirst(nom_jour($d,$abbr))." ".$affdate($d);
		if ($h)
			$s .= " $hd";
		$s = "$dtstart$s$dtabbr";
		if ($h AND $hd!=$hf) $s .= "-$dtend$hf$dtabbr";
	}
	else if ((date("Y-m",$date_debut))==date("Y-m",$date_fin))
	{ // meme annee et mois, jours differents
		if ($h){
			$s = $du . $dtstart . affdate_jourcourt($d) . " $hd" . $dtabbr;
			$s .= $au . $dtend . $affdate($f);
			if ($hd!=$hf) $s .= " $hf";
			$s .= $dtabbr;
		}
		else {
			$s = $du . $dtstart . jour($d) . $dtabbr;
			$s .= $au . $dtend . $affdate($f) . $dtabbr;
		}
	}
	else if ((date("Y",$date_debut))==date("Y",$date_fin))
	{ // meme annee, mois et jours differents
		$s = $du . $dtstart . affdate_jourcourt($d);
		if ($h) $s .= " $hd";
		$s .= $dtabbr . $au . $dtend . $affdate($f);
		if ($h) $s .= " $hf";
		$s .= $dtabbr;
	}
	else
	{ // tout different
		$s = $du . $dtstart . affdate($d);
		if ($h)
			$s .= " ".date("(H:i)",$date_debut);
		$s .= $dtabbr . $au . $dtend. affdate($f);
		if ($h)
			$s .= " ".date("(H:i)",$date_fin);
		$s .= $dtabbr;
	}
	return unicode2charset(charset2unicode(strtr($s,$trans_tbl),''));	
}
コード例 #21
0
/**
 * complete caracteres manquants dans HTML -> ISO
 * @return la chaine transcrite
 * @param $texte le texte a transcrire
 * @param $charset le charset souhaite'. Normalement 'iso-8859-1' (voir page de config)
 * @param $is_html flag. Pour ne pas transcrire completement la version html
 * @see http://fr.wikipedia.org/wiki/ISO_8859-1
 * @see http://www.w3.org/TR/html401/sgml/entities.html
 */
function spiplistes_translate_2_charset ($texte, $charset='AUTO', $is_html = false)
{
	$texte = charset2unicode($texte);
	
	$texte = unicode2charset($texte, $charset);
	
	if ($is_html) {
		$texte = spiplistes_html_entity_decode ($texte, $charset);
	}
	if($charset != 'utf-8') {
		$texte = spiplistes_iso2ascii ($texte, $is_html);		
	}
	return($texte);
}
コード例 #22
0
ファイル: inc_filters.php プロジェクト: nyimbi/legalcase
function filtrer_ical($texte)
{
    include_lcm('inc_charsets');
    $texte = html2unicode($texte);
    $texte = unicode2charset(charset2unicode($texte, read_meta('charset'), 1), 'utf-8');
    $texte = preg_replace("/\n/", " ", $texte);
    $texte = preg_replace("/,/", "\\,", $texte);
    return $texte;
}
コード例 #23
0
/**
 * Traitement de l'export des donnees auteurs.
 * 
 * @param  string $criteres de selection des auteurs
 * 
 * @return array $retour nbre auteurs exportes et message de confirmation d'action.
 */
function exec_adhauteurs_export()
{
    // Preparation affichage des choix type d'export
    $criteres_tot = _request('criteres');
    $criteres = explode('|', $criteres_tot, 7);
    // Preparation de l'export des criteres (mise en forme dans le fichier out)
    // -- saison --
    if (intval($criteres[2])) {
        $lib_criteres = sql_getfetsel('titre', 'spip_adhsaisons', array('id_saison=' . intval($criteres[2])));
        $export_crit[0] = array('Saison', $lib_criteres);
    } else {
        $export_crit[0] = array('Saison', 'active');
    }
    // -- technique --
    if (intval($criteres[3])) {
        $adhwhere = array("type = 'niveau_Technique'");
        $adhwhere = array_merge($adhwhere, array("id_mot = " . intval($criteres[3])));
        $lib_criteres = sql_getfetsel('titre', 'spip_mots', $adhwhere);
        $export_crit[1] = array('Techbase', $lib_criteres);
    } else {
        $export_crit[1] = array('Techbase', '<<Tous>>');
    }
    // -- encadrement --
    if (intval($criteres[4])) {
        $adhwhere = array("type='Niveau_Encadrement'");
        $adhwhere = array_merge($adhwhere, array("id_mot = " . intval($criteres[4])));
        $lib_criteres = sql_getfetsel('titre', 'spip_mots', $adhwhere);
        $export_crit[2] = array('Encadrant', $lib_criteres);
    } else {
        $export_crit[2] = array('Encadrant', '<<Tous>>');
    }
    // -- niveau --
    if (intval($criteres[5])) {
        $lib_criteres = sql_getfetsel('titre', 'spip_adhnivs', array('id_niveau =' . intval($criteres[5])));
        $export_crit[3] = array('Niveau', $criteres[6], $lib_criteres);
    } else {
        $export_crit[3] = array('Niveau', '<<Tous>>');
    }
    $export_crit[4] = array('Champ', $criteres[0], $criteres[1]);
    /*$debug1= "DEBUG adhclub JR : exec/adhauteurs_export - exec_adhauteurs_export - Pt05 - ";
    	adhclub_log("$debug1.", true);
    	adhclub_log("criteres tot= $criteres_tot.", true);
    	adhclub_log("criteres 0= $criteres[0].", true);
    	adhclub_log("criteres 1= $criteres[1].", true);
    	adhclub_log("criteres 2= $criteres[2].", true);
    	adhclub_log("criteres 3= $criteres[3].", true);
    	adhclub_log("criteres 4= $criteres[4].", true);
    	adhclub_log("criteres 5= $criteres[5].", true);
    	adhclub_log("criteres 6= $criteres[6].", true);
    	adhclub_log("criteres 7= $criteres[7].", true);
    	adhclub_log("FIN $debug1.", true);
    	*/
    $retour = _request('retour');
    $delim = _request('delim');
    if ($delim == 'TAB') {
        $delim = "\t";
    }
    if (!$retour) {
        $retour = generer_url_ecrire('adh_adherents');
    }
    $titre = _T("adhclub:exporter_user_nb", array('nb_auteurs' => $nb_auteurs));
    if (!$delim) {
        $icone = _DIR_PLUGIN_ADHCLUB . "img_pack/adh_export-24.png";
        //
        // Affichage de la page
        //
        $commencer_page = charger_fonction('commencer_page', 'inc');
        pipeline('exec_init', array('args' => $_GET, 'data' => ''));
        echo $commencer_page($titre, "adhclub");
        echo debut_gauche('', true);
        $raccourcis = recuperer_fond("prive/inclure/adh_menu_tous", $contexte);
        echo bloc_des_raccourcis($raccourcis);
        echo pipeline('affiche_gauche', array('args' => array('exec' => 'adhauteurs_export', 'sql_adh_auteurs' => $sql_adh_auteurs), 'data' => ''));
        echo creer_colonne_droite("", true);
        echo pipeline('affiche_droite', array('args' => array('exec' => 'adhauteurs_export', 'sql_adh_auteurs' => $sql_adh_auteurs), 'data' => ''));
        echo debut_droite("", true);
        $milieu = '';
        $milieu .= "<div class='entete-formulaire'>";
        // Icones retour
        if ($retour) {
            $milieu .= icone_verticale(_T('icone_retour'), $retour, $icone, "rien.gif", $GLOBALS['spip_lang_left']);
        }
        $milieu .= gros_titre($titre, '', false);
        $milieu .= "</div>";
        $milieu .= "<div class='formulaire_spip'>";
        $action = generer_url_ecrire("adhauteurs_export", "criteres={$criteres_tot}&retour={$retour}");
        $milieu .= "\n<form action='{$action}' method='post' class='formulaire_editer'><div>" . form_hidden($action);
        $milieu .= "<ul><li><label for='delim'>" . _T("adhclub:export_format") . "</label>";
        $milieu .= "<select name='delim' id='delim'>\n";
        $milieu .= "<option value=','>" . _T("adhclub:export_classique") . "</option>\n";
        $milieu .= "<option value=';'>" . _T("adhclub:export_excel") . "</option>\n";
        $milieu .= "<option value='TAB'>" . _T("adhclub:export_tabulation") . "</option>\n";
        $milieu .= "</select></li></ul>";
        $milieu .= "<p class='boutons'><input type='submit' class='submit' name='ok' value='" . _T('bouton_download') . "' /></p>\n";
        $milieu .= "</div></form>";
        $milieu .= "</div>";
        echo pipeline('affiche_milieu', array('args' => array('exec' => 'adhauteurs_export', 'criteres' => $criteres_tot, 'retour' => $retour), 'data' => $milieu));
        echo fin_gauche(), fin_page();
        exit;
    }
    // Debut de l'export des donnees
    // Recuperation de la requete des adherents suivant filtrage (array de la forme SELECT..)
    $sql_adh_auteurs = adh_recherche($criteres[0], $criteres[1], 'spip_auteurs', $criteres[2], $criteres[3], $criteres[4], $criteres[5], $criteres[6], true);
    if ($sql_adh_auteurs) {
        // JR 20/03/2013 - Definir les colonnes a extraire pour $adh_select
        $adhselect_l = array("au.id_auteur", "au.nom_famille", "au.prenom", "au.sexe", "au.naissance", "au.fonction as licence", "au.mobile", "au.telephone", "au.email", "au.certiflimite as date_certif", "au.certifaspirine as allergie_aspirine", "au.certifqualif as certif_restreint");
        $adhfrom_l = array("spip_auteurs au");
        $adhwhere_l = array("au.id_auteur IN(" . $sql_adh_auteurs . ")");
        // -- Si la saison est explicite,
        //    on recherche les données Cotisations et Assurances associees a chaque auteur
        if (intval($criteres[2])) {
            $adhselect_l = array_merge($adhselect_l, array("co_l.id_coti", "co_l.titre as cotisation", "co_l.mnt_cotis", "as_l.id_assur", "as_l.titre as assurance", "as_l.mnt_assur"));
            $adhfrom_l = array_merge($adhfrom_l, array("spip_adhcotis co_l", "spip_adhcotis_liens ca_l", "spip_adhassurs as_l", "spip_adhassurs_liens aa_l"));
            $adhwhere_l = array_merge($adhwhere_l, array("au.id_auteur=ca_l.id_objet", "ca_l.objet='auteur'", "ca_l.id_coti=co_l.id_coti", "co_l.id_saison=" . intval($criteres[2]), "co_l.complement='non'", "au.id_auteur=aa_l.id_objet", "aa_l.objet='auteur'", "aa_l.id_assur=as_l.id_assur", "as_l.id_saison=" . intval($criteres[2])));
        }
        /*$debug1= "DEBUG adhclub JR : exec/adhauteurs_export - Pt25 - ";
        		adhclub_log("$debug1.", true);
        		$debug2 = sql_get_select($adhselect_l, $adhfrom_l, sql_in('au.id_auteur', $sql_adh_auteurs));
        		adhclub_log("debug2=$debug2.", true);
        		adhclub_log("adhwhere_l=$adhwhere_l.", true);
        		$debug3 = sql_get_select($adhselect_l, $adhfrom_l, $adhwhere_l);
        		adhclub_log("debug3=$debug3.", true);
        		adhclub_log("FIN $debug1.", true);
        		*/
        if ($export_auteurs = sql_allfetsel($adhselect_l, $adhfrom_l, $adhwhere_l)) {
            foreach ($export_auteurs as $ligne) {
                $list_entete = array();
                $list_valeur = array();
                foreach ($ligne as $k => $v) {
                    /*$debug1= "DEBUG adhclub JR : exec/adhauteurs_export - Pt35 - ";
                    		adhclub_log("$debug1.", true);
                    		adhclub_log("k= $k , v= $v.", true);
                    		adhclub_log("FIN $debug1.", true);*/
                    $list_entete = array_merge($list_entete, array($k));
                    $list_valeur = array_merge($list_valeur, array($v));
                }
                // Ecriture de l'entete des colonnes.
                if ($nb_auteurs == 0) {
                    // JR-2013/08/01-Mise en forme des criteres en tete du fichier exporte.
                    // JR-25/03/2015-Utilisation des F(spip_bonux) existantes.
                    $output = exporter_csv_ligne(array('CRITERES'), $delim);
                    $output .= exporter_csv_ligne(array('-_-_-_-', '-_-_-_-_-_-_-_-_-_-_-_-'), $delim);
                    $output .= exporter_csv_ligne($export_crit[0], $delim);
                    $output .= exporter_csv_ligne($export_crit[1], $delim);
                    $output .= exporter_csv_ligne($export_crit[2], $delim);
                    $output .= exporter_csv_ligne($export_crit[3], $delim);
                    $output .= exporter_csv_ligne($export_crit[4], $delim);
                    $output .= exporter_csv_ligne(array('-_-_-_-', '-_-_-_-_-_-_-_-_-_-_-_-'), $delim);
                    // JR-20130801-Entetes de colonnes.
                    $output .= exporter_csv_ligne($list_entete, $delim);
                }
                // Ecriture des lignes de donnees.
                $output .= exporter_csv_ligne($list_valeur, $delim);
                ++$nb_auteurs;
            }
            $charset = $GLOBALS['meta']['charset'];
            $file_csv = "export_auteurs_" . date('Ymd_His');
            // @todo-JR-25/03/2015-Utilisation des F(spip_bonux) existantes. Attention remplissage criteres.
            //$filename = inc_exporter_csv($file_csv, ' ', $delim);
            $filename = preg_replace(',[^-_\\w]+,', '_', translitteration(textebrut(typo($file_csv))));
            // Excel ?
            if ($delim == ',') {
                $extension = 'csv';
            } else {
                // Extension 'csv' si delim = ';' (et pas forcément 'xls' !)
                if ($delim == ';') {
                    $extension = 'csv';
                } else {
                    $extension = 'xls';
                }
            }
            # Excel n'accepte pas l'utf-8 ni les entites html... on fait quoi?
            include_spip('inc/charsets');
            $output = unicode2charset(charset2unicode($output), 'iso-8859-1');
            $charset = 'iso-8859-1';
        }
        Header("Content-Type: text/comma-separated-values; charset={$charset}");
        Header("Content-Disposition: attachment; filename={$filename}.{$extension}");
        //Header("Content-Type: text/plain; charset=$charset");
        Header("Content-Length: " . strlen($output));
        echo $output;
        exit;
        //*/
    } else {
        include_spip('inc/minipres');
        echo minipres();
    }
}
コード例 #24
0
ファイル: charger_plugin.php プロジェクト: rhertzog/lcs
function afficher_liste_plugins_distants($liste){
	$res = "";
	if (!$liste) return "";
	
	$menu = array();
	$compte = 0;

	$afficher_plugin_distant = charger_fonction('afficher_plugin_distant','plugins');
	$url_page = self();
	foreach ($liste as $url => $info) {
		$titre = $info[0];
		$titre = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($titre))))));
		$menu[$titre] = $afficher_plugin_distant($url_page, $url, $info, _request('plugin')==$url);
	}
	ksort($menu);

	$res .=
		"<h3>"._T('plugins_compte',array('count' => count($menu)))."</h3>"
	  . '<p>'._T('plugin_info_automatique_select',array('rep'=>joli_repertoire(_DIR_PLUGINS_AUTO))).'</p>'
		. "<ul class='liste-items plugins distants'>".join("\n",$menu)."</ul>";

	return $res;
}
コード例 #25
0
/**
 * Importer un texte depuis un charset externe vers le charset du site
 *
 * Les caractères non resolus sont transformés en `&#123`;
 *
 * @param string $texte
 *     Texte unicode à importer
 * @param string $charset
 *     Charset d'origine du texte
 *     Par défaut (AUTO), le charset d'origine est celui du site.
 * @return string
 *     Texte transformé dans le charset site
 **/
function importer_charset($texte, $charset = 'AUTO')
{
    static $trans = array();
    // on traite le cas le plus frequent iso-8859-1 vers utf directement pour aller plus vite !
    if ($charset == 'iso-8859-1' && $GLOBALS['meta']['charset'] == 'utf-8') {
        $texte = corriger_caracteres_windows($texte, 'iso-8859-1', $GLOBALS['meta']['charset']);
        if (init_mb_string()) {
            if ($order = mb_detect_order() and mb_detect_order($charset)) {
                $s = mb_convert_encoding($texte, 'utf-8', $charset);
            }
            mb_detect_order($order);
            # remettre comme precedemment
            return $s;
        }
        // Sinon, peut-etre connaissons-nous ce charset ?
        if (!isset($trans[$charset])) {
            if ($cset = load_charset($charset) and is_array($GLOBALS['CHARSET'][$cset])) {
                foreach ($GLOBALS['CHARSET'][$cset] as $key => $val) {
                    $trans[$charset][chr($key)] = unicode2charset('&#' . $val . ';');
                }
            }
        }
        if (count($trans[$charset])) {
            return str_replace(array_keys($trans[$charset]), array_values($trans[$charset]), $texte);
        }
        return $texte;
    }
    return unicode2charset(charset2unicode($texte, $charset));
}
コード例 #26
0
ファイル: svp_outiller.php プロジェクト: genma/spip_ynh
/**
 * Transforme un texte écrit en entités HTML, dans le charset du site 
 *
 * @param string $texte
 *     Texte avec des entités HTML
 * @return string $texte
 *     Texte dans le charset du site
**/
function entite2charset($texte)
{
    if (!strlen($texte)) {
        return '';
    }
    include_spip('inc/charsets');
    return unicode2charset(html_entity_decode(preg_replace('/&([lg]t;)/S', '&amp;\\1', $texte), ENT_NOQUOTES, $GLOBALS['meta']['charset']));
}
コード例 #27
0
ファイル: filtres.php プロジェクト: loorenzooo/aslfc
function filtrer_ical($texte)
{
    #include_spip('inc/charsets');
    $texte = html2unicode($texte);
    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
    $texte = preg_replace("/\n/", " ", $texte);
    $texte = preg_replace("/,/", "\\,", $texte);
    return $texte;
}
コード例 #28
0
ファイル: test_couteau_suisse.php プロジェクト: rhertzog/lcs
function cs_les_tests() {
	global $icone, $metas_vars, $metas_outils;
	$icone = find_in_path('img/couteau-24.gif');

	test_outil($_SERVER, 'Echo de : $_SERVER[]');
	test_outil($_ENV, 'Echo de : $_ENV[]');
	global $HTTP_ENV_VARS;
	test_outil($HTTP_ENV_VARS, 'Echo de : $HTTP_ENV_VARS');
	$a = array('DOCUMENT_ROOT'=>getenv('DOCUMENT_ROOT'),
			'REQUEST_URI'=>getenv('REQUEST_URI'),
			'SCRIPT_NAME'=>getenv('SCRIPT_NAME'),
			'PHP_SELF'=>getenv('PHP_SELF'),
		);
	test_outil($a, 'Echo de : getenv()');

	// lecture des variables stockees en meta
	test_outil($metas_outils, 'Outils actifs : $metas_outils[]');
	test_outil($metas_vars, 'Contenu des variables : $metas_vars[]');

	// test de url_absolue()
	$relative_path = find_in_path('img/smileys');
	$realpath = str_replace("\\", "/", realpath($relative_path));
	$root = preg_replace(',/$,', '', $_SERVER['DOCUMENT_ROOT']);
	$test_result=substr($realpath, strlen($root));
	$dir = dirname(!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] :
			(!empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] :
			(!empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : str_replace('\\','/',__FILE__)
		)));
	$a = array('DOCUMENT_ROOT'=>$_SERVER['DOCUMENT_ROOT'],
			'REQUEST_URI'=>$_SERVER['REQUEST_URI'],
			'SCRIPT_NAME'=>$_SERVER['SCRIPT_NAME'],
			'PHP_SELF'=>$_SERVER['PHP_SELF'],
			'__FILE__'=>__FILE__,
			'$root'=>$root,
			"find_in_path('img/smileys')"=>find_in_path('img/smileys'),
			"str_replace('\\', '/', realpath('$relative_path'))"=>$realpath,
			"substr('$realpath', strlen('$root'))"=>cs_red($test_result),
			"return?"=>(strlen($root) && strpos($realpath, $root)===0)?'oui':'non',
			"url_absolue('$relative_path')"=>url_absolue($relative_path),
			'$dir'=>$dir,
			"cs_canonicalize('$dir'.'/'.'$relative_path')"=>cs_red(cs_canonicalize($dir.'/'.$relative_path)),
		);
	test_outil($a, 'Test sur : url_absolue()');

	// test de cs_canonicalize()
	$dir = $dir.'/'.$relative_path;
	$address = str_replace("//", "/", $dir);
	$address1 = $address2 = explode('/', $address);
	$keys = array_keys($address2, '..');
	foreach($keys as $keypos => $key) array_splice($address2, $key - ($keypos * 2 + 1), 2);
	$address3 = preg_replace(',([^.])\./,', '\1', implode('/', $address2));
	$a = array('$dir'=>$dir,
			'$address'=>$address,
			"explode('/', '$address')"=>$address1,
			'array_keys($dessus, "..")'=>$keys,
			'array_spliced()'=>$address2,
			'$resultat'=>cs_red($address3),
		);
	test_outil($a, 'Test sur : cs_canonicalize()');

	// charger mes_fonctions, utile pour les filtres ou certains outils
	include_spip('public/parametrer');

	// test de typo_exposants()
	include_spip('inc/charsets');
	$textes = array(
		"Pr Paul, Dr Jules, Prs Pierre &amp; Paul, Drs Pierre &amp; Paul. Surveiller : Pr&eacute;-St-Gervais ou Dr&eacute;",
		"Ste Lucie, St-Lucien, St.Patrick, St Patrick, st-jules (laisser?), Sts Pierre &amp; Paul, STe Lucie (laisser?)",
		"Bse Lucie, Bx-Lucien, Bx.Patrick, Bx Patrick, bx-jules (laisser?), Bses Jeanne &amp; Julie",
		"Ier, Iers, Iier, Iiers, Ire (laisser?), Ires (laisser?), I&#232;re, 1i&#232;re, 1&#232;res, 1i&#232;res",
		unicode2charset("Accents : I&#232;re, 1i&#232;re, 1&#232;res, 1i&#232;res - ro, vo, rro, 1o, 2o, 22o, Mgr J.XXIII"),
		unicode2charset("Ie II&#232;me IIIe IVe Ve VIe VIIe VIIIe IXe Xe XIe XVe XXe"),
		unicode2charset("Erreurs de typo : 2me, 3&#232;me, 4i&#232;me, 5mes, 6&#232;mes, 7i&#232;mes"),
		unicode2charset("Cas probl&#233;matique du L (50) : XLe XL&#232;me XLi&#232;me L&#232;me LIe"),
		"1er 1ers, 1eres, 2e 2es, IIIe IIIes, 2nd 22nd 21nd 2ndes. Vve Martin Cie Tartuffe, 3 Bd Voltaire.",
		"3 ou 4 m², 3 ou 4 m2 et 2 m3. 50 Mds ou 50 Mns ! Sté, St&eacute;s, Stés, Ste, Ets, Éts, Éts, &Eacute;ts, &#201;ts ...",
		"Mlle, Mlles, Mme, Mmes et erreurs Melle, Melles",
		"Me, Me martin, Me Martin, Mes M.&T., MMes M.&T.",
		'avant <a href="www.mon-1er-lien.com" title="Mon 1er titre">Mon 1er lien</a> et <img src="image.jpg" alt="logo 6e" title="Cliquez!">',
		'avant [Mon 1er lien->www.mon-1er-lien.com] apres le "test"!',
		'on est pass&eacute; du 7e au 15e rang, pas du 17e au 5e, des 7es aux 3emes !',
		'on est pass&eacute; du 7eme au 15&#232;me rang, pas du 17ieme au 5&egrave;me',
	);
	test_outil(cs_test_fun($textes, 'typo_exposants'), 'Test sur : typo_exposants() - Charset du site : '.$GLOBALS['meta']['charset']);

	// test de typo_guillemets()
	$textes = array(
		'avant <i class="style">le</i> "test"!',
		'avant <code class="code">toto</code>. apres le "test"!',
		'avant '.echappe_html('<script>toto</script>', 'TEST', true).'apres le "test"!',
		'avant '.echappe_html('<code class="code">toto</code>', 'TEST', true).'apres le "test"!',
		'avant <a href="www.monlien.com" title="Mon titre" target="_blank">Mon lien</a> apres le "test"!',
		'avant [Mon lien->www.monlien.com] apres le "test"!',
	);
	test_outil(cs_test_fun($textes, 'typo_guillemets'), 'Test sur : typo_guillemets()');

	// test des smileys
	$textes = array(
		"Doubles : :-(( :-)) :)) :'-)) :’-))",
		"Simples : :-> :-&gt; :-( :-D :-) |-) :'-) :’-) :'-D :’-D :'-( :’-( :-( :o) B-) ;-) :-p :-P' :-| :-/ :-o :-O",
		"les courts (reconnus s'il y a un espace avant) : :) :( ;) :| |) :/ :(",
	);
	test_outil(cs_test_fun($textes, 'cs_smileys_pre_typo'), 'Test sur : cs_smileys_pre_typo()');

	// test des filets
	$textes = array(
		"__degrade.png__\n__ornement.png__",
		"\n__6__\n__5__\n__4__\n__3__\n__2__\n__1__\n__0__\n",
	);
	if(function_exists('filets_sep'))
		test_outil(cs_test_fun($textes, create_function('$t','return propre(filets_sep($t));')), 'Test sur : filets_sep()');

	// test des liens orphelins
	$GLOBALS["liens_orphelins_etendu"]=true;
	$textes = array(
		"http://google.fr et <html>http://google.fr</html> et <code>http://google.fr</code> et <cite>http://google.fr</cite>",
		"Voici : http://google.fr. Voici :http://www.google.fr. Voici http://www.google.fr",
		"voici : https://mabanque.fr ou encore ftp://mabanque.fr!",
		"www.google.fr ou bien : www.google.fr",
		"http://*****:*****@www.commentcamarche.net:80/glossair/glossair.php3 et http://serveur:port/repertoire/fichier.html",
		"ftp://serveur/repertoire/fichier.qqchose, ou encore ftp.stockage.fr/tropdelaballe...",
		"file:///disque|/repertoire/fichier.qqchose et : file:///c|/tmp/fichier.txt",
		"mailto:nom@organisation.domaine et : mailto:Fabien.Gandon@sophia.inria.fr",
		"telnet://bbs.monsite.com/ et telnet://Nom:Password@serveur.ici:port",
		"telnet://*****:*****@gopa.insa.fr:23",
		"gopher://serveur.ici:port/repertoire/fichier#marqueur et gopher://gopher.monsite.com/",
		"newsrc://*****:*****@world.com, mailto:moi-moi@world.com, mailto:nom@provider.com?subject=renseignement",
		"moi+moi@kekpar.tm.fr, mailto:moi-moi@kekpar.tm.fr, mailto:nom@provider.com.tm.fr?subject=renseignement",
		'une image ? <img src="http://mailer.e-flux.com/mail_images/toto.jpg" alt="" />',
		'[<img src="http://mailer.e-flux.com/mail_images/toto.jpg" alt="" />->http://www.americas-society.org/] ',
	);
//	test_outil(cs_test_fun($textes, 'typo'), 'Test sur : echappements');
	test_outil(cs_test_fun($textes, 'liens_orphelins'), 'Test sur : liens_orphelins()');

	$textes = array(
		"mailto:nom@organisation.domaine et : mailto:Fabien.Gandon@sophia.inria.fr (on supprime ces liens)",
		"moi+moi@world.com, mailto:moi-moi@world.com, mailto:nom@provider.com?subject=renseignement",
		"pat@moi.com [->pat@moi.com] [pat->pat@moi.com]",
		"pat@moi.com.tm.fr [->pat@moi.com.tm.fr] [pat->pat@moi.com.tm.fr]",
		"<a href='mailto:moi@toto.com'>Moi</a> et : <a href='mailto:moi@toto.com'>moi@toto.com</a>",
		"<a href='mailto:moi@kekpar.tm.fr'>Moi</a> et : <a href='mailto:moi@kekpar.tm.fr'>moi@kekpar.tm.fr</a>",
		'[Navigation->/@mot.html] <a class="spip_out" href="/@mot.html">Navigation</a>',
	);
	test_outil(cs_test_fun($textes, 'mailcrypt'), 'Test sur : mailcrypt()');

/*
define('_COULEURS_FONDS', 1); define('_COULEURS_SET', 1);
define('_COULEURS_PERSO', "bas =#99CC11, haut= brown, test= bleu");
couleurs_installe();
print_r(couleurs_pre_typo("to[bas]to[/bas]to[haut]to[/haut]toto[test]to[/couleur]to\nto[bg bas]to[/bg]to[bg haut]to[/bg]toto[bg test]to[/bg test]to\n"));
print_r(couleurs_pre_typo("to[red]to[/red]to[bleu]to[/bleu]toto[rouge]to[/couleur]to\nto[bg red]to[/bg]to[bg bleu]to[/bg]toto[bg rouge]to[/bg rouge]to\n"));
*/
}
コード例 #29
0
ファイル: sax.php プロジェクト: nursit/SPIP
function sax_bug($data, $dtc, $charset = null)
{
    if (is_null($charset)) {
        $charset = $GLOBALS['meta']['charset'];
    }
    if ($dtc) {
        $trans = array();
        foreach ($dtc->entites as $k => $v) {
            if (!strpos(" amp lt gt quot ", $k)) {
                $trans["&{$k};"] = $v;
            }
        }
        $data = strtr($data, $trans);
    } else {
        $data = html2unicode($data, true);
    }
    return unicode2charset($data, $charset);
}
コード例 #30
0
ファイル: charsets.php プロジェクト: rhertzog/lcs
function importer_charset($texte, $charset = 'AUTO') {
	// on traite le cas le plus frequent iso-8859-1 vers utf directement pour aller plus vite !
	if (($charset == 'iso-8859-1') && ($GLOBALS['meta']['charset']=='utf-8') && function_exists('utf8_encode')){
		$texte = corriger_caracteres_windows($texte, 'iso-8859-1','unicode');
		$texte = utf8_encode($texte);
		return $texte;
	}
	return unicode2charset(charset2unicode($texte, $charset));
}