Example #1
0
function action_snippet_exporte(){
	global $auteur_session;
	$arg = _request('arg');
	$args = explode(":",$arg);
	$hash = _request('hash');
	$id_auteur = $auteur_session['id_auteur'];
	$redirect = _request('redirect');
	if ($redirect==NULL) $redirect="";
	include_spip("inc/securiser_action");
	if (verifier_action_auteur("snippet_exporte-$arg",$hash,$id_auteur)==TRUE) {
		$table = $args[0];
		$id = $args[1];
		
		$f = snippets_fond_exporter($table, false);
			
		if ($f) {
			include_spip('public/assembler');
			$out = recuperer_fond($f,array('id'=>intval($id)));
			//$out = preg_replace(",\n\n[\s]*(?=\n),","",$out);
			
			$filename=str_replace(":","_",$arg);
			if (preg_match(",<titre>(.*)</titre>,Uims",$out,$regs))
				$filename = preg_replace(',[^-_\w]+,', '_', trim(translitteration(textebrut(typo($regs[1])))));
			$extension = "xml";
			
			Header("Content-Type: text/xml; charset=".$GLOBALS['meta']['charset']);
			Header("Content-Disposition: attachment; filename=$filename.$extension");
			Header("Content-Length: ".strlen($out));
			echo $out;
			exit();
		}
	}	
	redirige_par_entete(str_replace("&amp;","&",urldecode($redirect)));
}
Example #2
0
function message_oubli($email, $param)
{
	$r = formulaires_oubli_mail($email);
	if (is_array($r) AND $r[1]) {
		include_spip('inc/acces'); # pour creer_uniqid
		include_spip('inc/texte'); # pour corriger_typo
		$cookie = creer_uniqid();
		sql_updateq("spip_auteurs", array("cookie_oubli" => $cookie), "id_auteur=" . $r[1]['id_auteur']);

		$nom = textebrut(corriger_typo($GLOBALS['meta']["nom_site"]));
		$envoyer_mail = charger_fonction('envoyer_mail','inc');

		if ($envoyer_mail($email,
				  ("[$nom] " .  _T('pass_oubli_mot')),
				  _T('pass_mail_passcookie',
				     array('nom_site_spip' => $nom,
					   'adresse_site' => url_de_base(),
					   'sendcookie' => generer_url_public('spip_pass',
					   "$param=$cookie", true)))) )
		  return _T('pass_recevoir_mail');
		else
		  return  _T('pass_erreur_probleme_technique');
	}
	return  _T('pass_erreur_probleme_technique');
}
Example #3
0
function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff')
{
    include_spip('inc/texte');
    if ($type == "rubrique") {
        $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = {$id}");
        if ($row) {
            $titre = typo($row["titre"]);
            $descriptif = propre($row["descriptif"]);
        } else {
            $titre = _T('info_racine_site');
        }
    } else {
        $titre = '';
    }
    $res = '';
    if ($type == "rubrique" and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) {
        if ($GLOBALS['meta']['image_process'] != "non") {
            $chercher_logo = charger_fonction('chercher_logo', 'inc');
            if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
                list($fid, $dir, $nom, $format) = $res;
                include_spip('inc/filtres_images_mini');
                $res = image_reduire("<img src='{$fid}' alt='' />", 100, 48);
                if ($res) {
                    $res = "<div style='float: " . $GLOBALS['spip_lang_right'] . "; margin-" . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>{$res}</div>";
                }
            }
        }
    }
    $rac = spip_htmlentities($rac);
    # ce lien provoque la selection (directe) de la rubrique cliquee
    # et l'affichage de son titre dans le bandeau
    $titre = strtr(str_replace("'", "&#8217;", str_replace('"', "&#34;", textebrut($titre))), "\n\r", "  ");
    $js_func = $do . '_selection_titre';
    return "<div style='display: none;'>" . "<input type='text' id='" . $rac . "_sel' value='{$id}' />" . "<input type='text' id='" . $rac . "_sel2' value=\"" . entites_html($titre) . "\" />" . "</div>" . "<div class='informer' style='padding: 5px; border-top: 0px;'>" . (!$res ? '' : $res) . "<p><b>" . safehtml($titre) . "</b></p>" . (!$descriptif ? '' : "<div>" . safehtml($descriptif) . "</div>") . "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" . "<input type='submit' class='fondo' value='" . _T('bouton_choisir') . "'\nonclick=\"{$js_func}('{$titre}',{$id},'selection_rubrique','id_parent'); return false;\" />" . "</div>" . "</div>";
}
function recherche_avancee_google_like($string, $options = array())
{
    $resume = isset($options['resume']) ? $options['resume'] : ($options['resume'] != 'non' ? $string : '');
    $wrapper = isset($options['wrapper']) ? '<i class="rsusp">[...]</i>' : '';
    $taille = isset($options['taille']) ? $options['taille'] : 55;
    // Convertir en texte brut sans accent
    $string = textebrut($string);
    $string = translitteration($string);
    $rech = translitteration(_request('recherche'));
    // Supprimer les caracteres qui m...
    $badguy = array("^", "/", "\\", "\$", "@", "*");
    $rech = str_replace($badguy, "", $rech);
    // en avant
    $query = rtrim(str_replace("+", " ", $rech));
    $qt = explode(" ", $query);
    if ($wrapper) {
        $num = count($qt);
        // $cc = ceil(55 / $num);
        $cc = $taille;
        for ($i = 0; $i < $num; $i++) {
            $tab[$i] = preg_split("/\\b({$qt[$i]})/i", $string, 2, PREG_SPLIT_DELIM_CAPTURE);
            if (count($tab[$i]) > 1) {
                // Chaine avant
                $avant = substr($tab[$i][0], -$cc, $cc);
                $mots = split(" ", $avant, 2);
                if (count($mots) > 1) {
                    $avant = $mots[1];
                }
                // Chaine apres
                $apres = substr($tab[$i][2], 0, $cc);
                $apres = preg_replace('@(.+)\\s\\S+@s', '\\1', $apres);
                // Concatener
                if ($string_re == '') {
                    $string_re = $wrapper;
                }
                $string_re .= " {$avant}<span class='spip_surligne'>" . $tab[$i][1] . "</span>{$apres} {$wrapper}";
            }
        }
    } else {
        $pattern = array();
        $replace = array();
        foreach ($qt as $t) {
            $pattern[] = "/{$t}/";
            $replace[] = "<span class='spip_surligne'>" . $t . "</span>";
        }
        $string_re = preg_replace($pattern, $replace, $string);
    }
    // Si rien trouve : renvoyer les premiers mots en resume
    if ($resume != '' and $string_re == '') {
        $mots = split(" ", $string, 40);
        for ($i = 0; $i < count($mots) - 1; $i++) {
            $string_re .= $mots[$i] . " ";
            if (strlen($string_re) > 2 * $cc) {
                break;
            }
        }
        $string_re = $resume;
    }
    return $string_re;
}
Example #5
0
function init_entete($titre='', $id_rubrique=0, $minipres=false) {
	include_spip('inc/gadgets');

	if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"])))
		$nom_site_spip=  _T('info_mon_site_spip');

	// Pour corriger la position des sous-menus principaux 
	// (quand intitules sur 2 lignes)

	$js = repercuter_gadgets($id_rubrique);
	$head = "<title>["
		. $nom_site_spip
		. "] " . textebrut(typo($titre)) . "</title>\n"
		. "<meta http-equiv='Content-Type' content='text/html"
		. (($c = $GLOBALS['meta']['charset']) ?
			"; charset=$c" : '')
		. "' />\n"
		. envoi_link($nom_site_spip,$minipres, $js);

	return _DOCTYPE_ECRIRE
	. html_lang_attributes()
	. "<head>\n"
	. pipeline('header_prive', $head)
	. "</head>\n";
}
Example #6
0
function install_debut_html($titre = 'AUTO', $onLoad = '') {
	global $spip_lang_right,$spip_lang_left;
	
	utiliser_langue_visiteur();

	http_no_cache();

	if ($titre=='AUTO')
		$titre=_T('info_installation_systeme_publication');

	# le charset est en utf-8, pour recuperer le nom comme il faut
	# lors de l'installation
	if (!headers_sent())
		header('Content-Type: text/html; charset=utf-8');

	// au cas ou minipres() est appele avant spip_initialisation_suite()
	if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', '');
	return  _DOCTYPE_ECRIRE.
		html_lang_attributes().
		"<head>\n".
		"<title>".
		textebrut($titre).
		"</title>
		<link rel='stylesheet' href='".direction_css(find_in_path('minipres.css')).
		"' type='text/css' media='all' />\n" .
 // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
		http_script('',  "spip_barre.js") .
"</head>
<body".$onLoad." class='minipres'>
	<div id='minipres'>
	<h1>".
	  $titre .
	  "</h1>
	<div>\n";
}
/**
 * Envoi du DOCTYPE et du `<head><title>   </head>`
 *
 * @uses _DOCTYPE_ECRIRE
 * @uses textebrut()
 * @uses typo()
 * @uses html_lang_attributes()
 * @uses init_head()
 *
 * @param string $titre
 *     Titre de la page
 * @param integer $dummy
 *     Valeur non utilisée…
 * @param bool $minipres
 * @return string
 *     Entête du fichier HTML avec le DOCTYPE
 */
function init_entete($titre = '', $dummy = 0, $minipres = false)
{
    include_spip('inc/texte');
    if (!($nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"])))) {
        $nom_site_spip = _T('info_mon_site_spip');
    }
    $titre = "[" . $nom_site_spip . "]" . ($titre ? " " . textebrut(typo($titre)) : "");
    return _DOCTYPE_ECRIRE . html_lang_attributes() . "<head>\n" . init_head($titre, $dummy, $minipres) . "</head>\n";
}
Example #8
0
function sommaire_d_une_page(&$texte, &$nbh3, $page = 0, $num_pages = 0)
{
    static $index;
    if (!$index || $page === false) {
        $index = 0;
    }
    if ($page === false) {
        return;
    }
    // trouver quel <hx> est utilise
    $hierarchie = preg_match(',<h(\\d),', $GLOBALS['debut_intertitre'], $regs) ? $regs[1] : '3';
    @define('_sommaire_NB_CARACTERES', 30);
    $self = nettoyer_uri();
    //self();//$GLOBALS['REQUEST_URI'];
    // si on n'est pas en mode impression, on calcule l'image de retour au sommaire
    if (!defined('_CS_PRINT')) {
        $titre = _T('couteau:sommaire_titre');
        $haut = "<a title=\"{$titre}\" href=\"" . $self . "#sommaire\" class=\"sommaire_ancre\">&nbsp;</a>";
        // modif cld
    } else {
        $haut = '';
    }
    // traitement des intertitres <hx>
    preg_match_all(",(<h{$hierarchie}[^>]*)>(.*)</h{$hierarchie}>,Umsi", $texte, $regs);
    $nbh3 += count($regs[0]);
    $pos = 0;
    $sommaire = '';
    // calcul de la page
    $p = $page ? _T('couteau:sommaire_page', array('page' => $page)) : '';
    for ($i = 0; $i < count($regs[0]); $i++, $index++) {
        $ancre = " id=\"sommaire_{$index}\">";
        // modif cld
        if (($pos2 = strpos($texte, $regs[0][$i], $pos)) !== false) {
            $titre = preg_replace(',^<p[^>]*>(.*)</p>$,Umsi', '\\1', trim($regs[2][$i]));
            // ancre 'haut', sauf si les blocs depliables utilisent h3...
            $texte = substr($texte, 0, $pos2) . $regs[1][$i] . $ancre . (strpos($regs[0][$i], 'blocs_titre') === false ? $haut : '') . $titre . substr($texte, $pos2 + strlen($regs[1][$i]) + 1 + strlen($regs[2][$i]));
            $pos = $pos2 + strlen($ancre) + strlen($regs[0][$i]);
            // tout le texte, sans les notes
            $brut = preg_replace(',\\[<a href=["\']#nb.*?</a>\\],', '', echappe_retour($regs[2][$i], 'CS'));
            // pas de glossaire
            if (function_exists('cs_retire_glossaire')) {
                $brut = cs_retire_glossaire($brut);
            }
            // texte brut
            $brut = preg_replace(',[\\n\\r]+,', ' ', textebrut($brut));
            $lien = cs_propre(couper($brut, _sommaire_NB_CARACTERES));
            $lien = preg_replace('/(&nbsp;|\\s)*[!?,;.:]+$/', '', $lien);
            // eviter une ponctuation a la fin
            $titre = attribut_html(couper($brut, 100));
            // si la decoupe en page est active...
            $artpage = function_exists('decoupe_url') && (strlen(_request('artpage')) || $page > 1) ? decoupe_url($self, $page, $num_pages) : $self;
            $sommaire .= "<dd><a {$st} title=\"{$titre}\" href=\"{$artpage}#sommaire_{$index}\">{$lien}</a>{$p}</dd>";
            // modif cld
        }
    }
    return $sommaire;
}
Example #9
0
/**
 * Ajout automatique du title dans les pages du privé en squelette
 * 
 * Appellé dans le pipeline affichage_final_prive
 *
 * @param string $texte
 * @return string
 */
function affichage_final_prive_title_auto($texte)
{
    if (strpos($texte, '<title>') === false and (preg_match(",<h1[^>]*>(.+)</h1>,Uims", $texte, $match) or preg_match(",<h[23][^>]*>(.+)</h[23]>,Uims", $texte, $match)) and $match = textebrut(trim($match[1])) and ($p = strpos($texte, '<head>')) !== FALSE) {
        if (!($nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"])))) {
            $nom_site_spip = _T('info_mon_site_spip');
        }
        $titre = "<title>[" . $nom_site_spip . "] " . $match . "</title>";
        $texte = substr_replace($texte, $titre, $p + 6, 0);
    }
    return $texte;
}
Example #10
0
function sommaire_nettoyer_titre($t) {
	// pas de notes
	$brut = preg_replace(',\[<a href=["\']#nb.*?</a>\],','', echappe_retour($t,'CS'));
	// pas de glossaire
	if(function_exists('cs_retire_glossaire')) $brut = cs_retire_glossaire($brut);
	// texte brut
	$brut2 = trim(preg_replace(',[\n\r]+,',' ',textebrut($brut)));
	// cas des intertitres en image_typo
	if(!strlen($brut2)) $brut2 = trim(extraire_attribut($brut, 'alt'));
	return $brut2;
}
Example #11
0
function inc_formater_auteur_dist($id_auteur, $row=NULL) {

  global $connect_id_auteur, $connect_statut;

	$id_auteur = intval($id_auteur);

	if ($row===NULL)
	  $row = sql_fetsel("*, (en_ligne<DATE_SUB(NOW(),INTERVAL 15 DAY)) AS parti", "spip_auteurs", "id_auteur=$id_auteur");

	$vals = array();
	$statut = $row['statut'];
	$href = generer_url_ecrire("auteurs","statut=$statut");
	$vals[] = "<a href='$href'>" . bonhomme_statut($row) . '</a>';

	if (($id_auteur == $connect_id_auteur) OR $row['parti'])
		$vals[]= '&nbsp;';
	else	$vals[]= formater_auteur_mail($row, $id_auteur);

	if (!$nom = typo($row['nom']))
		$nom = "<span style='color: red'>" . _T('texte_vide') . '</span>';

	$vals[] = "<a href='"
	. generer_url_ecrire('auteur_infos', "id_auteur=$id_auteur")
	. "'"
	. (!$row['bio'] ? '' : (" title=\"" . attribut_html(couper(textebrut($row["bio"]), 200)) ."\""))
	. ">$nom</a>";

	$url = traiter_lien_explicite($row["url_site"]);

	$vals[] =  !$url ? "&nbsp;"
	  :  "<a href='$url'>".couper(sinon(typo($row['nom_site']), $row["url_site"]),30)."</a>";

	$contributions = array();
	if (autoriser('modifier', 'auteur', $id_auteur, $row)) {
		$in = sql_in('statut', 
			($connect_statut == "0minirezo"
			? array('prepa', 'prop', 'publie', 'refuse')
			: array('prop', 'publie')));
		if ($cpt = sql_countsel("spip_auteurs_articles AS L LEFT JOIN spip_articles AS A ON A.id_article=L.id_article", "L.id_auteur=$id_auteur AND $in"))
			$contributions[] = ($cpt>1?$cpt.' '._T('info_article_2'):_T('info_1_article'));
	} else {
		if ($cpt = sql_countsel("spip_forum AS F", "F.id_auteur=$id_auteur"))
			$contributions[] = ($cpt>1?$cpt.' '._T('public:messages_forum'):('1 ' . _T('public:message')));
	}

	$contributions = pipeline('compter_contributions_auteur',array('args'=>array('id_auteur'=>$id_auteur,'row'=>$row),'data'=>$contributions));

	$vals[] =  count($contributions)?implode('<br />',$contributions):"&nbsp;";

	return $vals;
}
Example #12
0
function inc_exporter_csv_dist($titre, $resource, $delim=',', $entetes = null,$envoyer = true){

	$filename = preg_replace(',[^-_\w]+,', '_', translitteration(textebrut(typo($titre))));
	
	if ($delim == 'TAB') $delim = "\t";
	if (!in_array($delim,array(',',';',"\t")))
		$delim = ",";

	$charset = $GLOBALS['meta']['charset'];
	$importer_charset = null;
	if ($delim == ',')
		$extension = 'csv';
	else {
		$extension = 'xls';
		# Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut
		$importer_charset = $charset = 'iso-8859-1';
	}
	$filename = "$filename.$extension";

	if ($entetes AND is_array($entetes) AND count($entetes))
		$output = exporter_csv_ligne($entetes,$delim,$importer_charset);

	// on passe par un fichier temporaire qui permet de ne pas saturer la memoire
	// avec les gros exports
	$fichier = sous_repertoire(_DIR_CACHE,"export") . $filename;
	$fp = fopen($fichier, 'w');
	$length = fwrite($fp, $output);

	while ($row=is_array($resource)?array_shift($resource):sql_fetch($resource)){
		$output = exporter_csv_ligne($row,$delim,$importer_charset);
		$length += fwrite($fp, $output);
	}
	fclose($fp);

	if ($envoyer) {
		Header("Content-Type: text/comma-separated-values; charset=$charset");
		Header("Content-Disposition: attachment; filename=$filename");
		//non supporte
		//Header("Content-Type: text/plain; charset=$charset");
		Header("Content-Length: $length");
		ob_clean();
    flush();
    readfile($fichier);
	}

	return $fichier;
}
function BOUCLE_art_agendahtml_78503d8cb0bd66f2d97f4b9c0f7d329a(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_art_agenda';
        $command['from'] = array('articles' => 'spip_articles', 'L1' => 'spip_mots_liens', 'L2' => 'spip_mots');
        $command['type'] = array();
        $command['groupby'] = array("articles.id_article");
        $command['select'] = array("articles.date_redac", "articles.id_article", "articles.texte", "articles.descriptif", "articles.chapo", "articles.titre", "articles.lang");
        $command['orderby'] = array('articles.date_redac');
        $command['join'] = array('L1' => array('articles', 'id_objet', 'id_article', 'L1.objet=' . sql_quote('article')), 'L2' => array('L1', 'id_mot'));
        $command['limit'] = '0,5';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), array('=', 'L2.titre', "'Agenda'"), array('<', 'TIMESTAMPDIFF(HOUR,articles.date_redac,NOW())/24', "1"), array('=', 'articles.lang', sql_quote($GLOBALS['spip_lang'], '', 'varchar(10) NOT NULL DEFAULT \'\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-menu-agenda.html', 'html_78503d8cb0bd66f2d97f4b9c0f7d329a', '_art_agenda', 4, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
				<li>' . (($t1 = strval(affdate(normaliser_date($Pile[$SP]['date_redac'])))) !== '' ? '<span>' . $t1 . (' ' . (($t2 = strval(heures(normaliser_date($Pile[$SP]['date_redac'])) != '0' ? (($t3 = strval(heures(normaliser_date($Pile[$SP]['date_redac'])))) !== '' ? $t3 . ':' : '') . minutes(normaliser_date($Pile[$SP]['date_redac'])) : '')) !== '' ? '- ' . $t2 : '') . '</span>') : '') . '
					<a class="lien' . interdire_scripts(@$Pile[0]['exposer']) . ' article" href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist($Pile[$SP]['descriptif'], strlen($Pile[$SP]['descriptif']) ? '' : $Pile[$SP]['chapo'] . "\n\n" . $Pile[$SP]['texte'], 500, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>

				</li>
		';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_art_agenda @ squelettes/inc/inc-menu-agenda.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_breves_rubriqueshtml_11157eacea3e766769d2031f1e2eed04(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'breves';
        $command['id'] = '_breves_rubriques';
        $command['from'] = array('breves' => 'spip_breves');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("breves.date_heure", "breves.date_heure AS date", "breves.id_breve", "breves.texte", "breves.titre", "breves.lang");
        $command['orderby'] = array('breves.date_heure DESC');
        $command['join'] = array();
        $command['limit'] = '0,10';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('breves.statut', 'publie,prop', 'publie', ''), array('=', 'breves.id_rubrique', sql_quote(@$Pile[0]['id_rubrique'], '', 'bigint(21) NOT NULL DEFAULT \'0\'')), array('=', 'breves.lang', sql_quote($GLOBALS['spip_lang'], '', 'varchar(10) NOT NULL DEFAULT \'\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-breves.html', 'html_11157eacea3e766769d2031f1e2eed04', '_breves_rubriques', 2, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
          	<li>' . (($t1 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? '<span>' . $t1 . '</span>' : '') . '
              <a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_breve'], 'breve', '', '', true))) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist('', $Pile[$SP]['texte'], 300, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>
          	</li>
            ';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_breves_rubriques @ squelettes/inc/inc-breves.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function socialtags_choix()
{
    include_spip('socialtags_fonctions');
    global $couleur_fonce;
    $cfg = is_array($cfg = lire_config('socialtags/tags')) ? $cfg : array();
    $retour = array();
    foreach (socialtags_liste() as $service) {
        $t = $service['titre'];
        $u = $service['url'];
        $a = $service['lesauteurs'];
        $d = isset($service['descriptif']) ? $service['descriptif'] : '';
        $category = count($service['tags']) ? textebrut(reset($service['tags'])) : '99';
        $image = 'data:image/png;base64,' . base64_encode(file_get_contents(find_in_path('images/' . $a . '.png')));
        //$image = find_in_path('images/'.$a.'.png');
        $checked = in_array($a, $cfg) ? ' checked="checked"' : '';
        $retour[$category] .= "<div class='choix'>\n\t\t\t\t<input type='checkbox' id='choix_{$a}' name='tags[]' value='{$a}'{$checked} />\n\t\t\t\t<label for='choix_{$a}'>\n\t\t\t\t\t<img src=\"{$image}\" title=\"" . texte_script($t) . "\" alt=\"\" style=\"max-width:16px; height:auto;\" />\n\t\t\t\t\t" . ($checked ? "<strong>{$t}</strong>" : $t) . ($d ? "&nbsp;<span style='color:{$couleur_fonce};font-size:90%'>{$d}</span>" : "") . "\n\t\t\t\t</label>\n\t\t\t</div>";
    }
    ksort($retour);
    return implode("<hr />", $retour);
}
Example #16
0
/**
 * http://doc.spip.org/@install_debut_html
 *
 * @param string $titre
 * @param string $onLoad
 * @param bool $all_inline
 *   inliner les css et js dans la page (limiter le nombre de hits)
 * @return string
 */
function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false)
{
    global $spip_lang_right, $spip_lang_left;
    utiliser_langue_visiteur();
    http_no_cache();
    if ($titre == 'AUTO') {
        $titre = _T('info_installation_systeme_publication');
    }
    # le charset est en utf-8, pour recuperer le nom comme il faut
    # lors de l'installation
    if (!headers_sent()) {
        header('Content-Type: text/html; charset=utf-8');
    }
    $css = "";
    $files = array('reset.css', 'clear.css', 'minipres.css');
    if ($all_inline) {
        // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
        foreach ($files as $name) {
            $file = direction_css(find_in_theme($name));
            if (function_exists("compacte")) {
                $file = compacte($file);
            } else {
                $file = url_absolue_css($file);
            }
            // precaution
            lire_fichier($file, $c);
            $css .= $c;
        }
        $css = "<style type='text/css'>" . $css . "</style>";
    } else {
        foreach ($files as $name) {
            $file = direction_css(find_in_theme($name));
            $css .= "<link rel='stylesheet' href='{$file}' type='text/css' />\n";
        }
    }
    // au cas ou minipres() est appele avant spip_initialisation_suite()
    if (!defined('_DOCTYPE_ECRIRE')) {
        define('_DOCTYPE_ECRIRE', '');
    }
    return _DOCTYPE_ECRIRE . html_lang_attributes() . "<head>\n" . "<title>" . textebrut($titre) . "</title>\n" . "<meta name='viewport' content='width=device-width' />\n" . $css . "</head>\n<body" . $onLoad . " class='minipres'>\n\t<div id='minipres'>\n\t<h1>" . $titre . "</h1>\n\t<div>\n";
}
Example #17
0
function init_entete($titre='', $id_rubrique=0) {
	include_spip('inc/gadgets');

	if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"])))
		$nom_site_spip=  _T('info_mon_site_spip');

	$head = "<title>["
		. $nom_site_spip
		. "] " . textebrut(typo($titre)) . "</title>\n"
		. "<meta http-equiv='Content-Type' content='text/html"
		. (($c = $GLOBALS['meta']['charset']) ?
			"; charset=$c" : '')
		. "' />\n"
		. envoi_link($nom_site_spip);

	// anciennement verifForm
	$head .= '
	<script type="text/javascript"><!--
	$(document).ready(function(){
		verifForm();
		$("#page")
		.mouseover(function(){
			changestyle("garder-recherche");
		});
	'
	.
	repercuter_gadgets($id_rubrique)
	.'
	});
	// --></script>
	';

	return _DOCTYPE_ECRIRE
	. html_lang_attributes()
	. "<head>\n"
	. pipeline('header_prive', $head)
	. "</head>\n";
}
function bookmarks_extract_links($contenu)
{
    $out = array();
    $contenu = str_ireplace("<DT>", "<dt>", $contenu);
    $contenu = explode("<dt>", $contenu);
    $h3 = array_shift($contenu);
    $h3 = extraire_balise($h3, "h3");
    $out['titre'] = strip_tags($h3);
    foreach ($contenu as $item) {
        $link = array();
        if ($a = extraire_balise($item, 'a')) {
            $link['url'] = extraire_attribut($a, 'href');
            $link['titre'] = strip_tags($a);
            $link['date'] = extraire_attribut($a, "add_date");
            $link['descriptif'] = "";
            if ($p = stripos($item, "<dd>")) {
                $link['descriptif'] = textebrut(substr($item, $p));
            }
            $out['links'][] = $link;
        }
    }
    return $out;
}
Example #19
0
function inc_selectionner_dist($sel, $idom = "", $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff')
{
    if ($recur) {
        $recur = mini_hier($sel);
    } else {
        $sel = 0;
    }
    if ($aff_racine) {
        $info = generer_url_ecrire('informer', "type=rubrique&rac={$idom}&do={$do}&id=");
        $idom3 = $idom . "_selection";
        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '{$idom3}', '{$info}', event);return false;";
        $ondbClick = strtr(str_replace("'", "&#8217;", str_replace('"', "&#34;", textebrut(_T('info_racine_site')))), "\n\r", "  ");
        $js_func = $do . '_selection_titre';
        $ondbClick = "{$js_func}('{$ondbClick}',0,'selection_rubrique','id_parent');";
        $aff_racine = "<div class='petite-racine item'>" . "<a href='#'" . "onclick=\"" . $onClick . "\"\nondbclick=\"" . $ondbClick . $onClick . "\">" . _T("info_racine_site") . "</a></div>";
    }
    $url_init = generer_url_ecrire('plonger', "rac={$idom}&exclus={$exclus}&id=0&col=1&do={$do}");
    $plonger = charger_fonction('plonger', 'inc');
    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
    // url completee par la fonction JS onkeypress_rechercher
    $url = generer_url_ecrire('rechercher', "exclus={$exclus}&rac={$idom}&do={$do}&type=");
    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
}
Example #20
0
function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {

	if ($recur) $recur = mini_hier($sel); else $sel = 0;

	if ($aff_racine) {
		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
		$idom3 = $idom . "_selection";

		$onClick = " aff_selection(0, '$idom3', '$info', event);";

		$ondbClick = strtr(str_replace("'", "&#8217;",
				str_replace('"', "&#34;",
					textebrut(_T('info_racine_site')))),
				"\n\r", "  ");

		$js_func = $do . '_selection_titre';
		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";

		$aff_racine = "<div class='arial11 petite-racine'\nonclick=\""
		. $onClick
		. "\"\nondbclick=\""
		. $ondbClick
		. $onClick
		. "\">\n<div class='highlight off'>"
		. _T("info_racine_site")
		. "</div></div>";
	} else $onClick = '';

	$url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");

	$plonger = charger_fonction('plonger', 'inc');
	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);

	// url completee par la fonction JS onkeypress_rechercher
	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
}
Example #21
0
function action_exporter()
{
    //global $auteur_session;
    $arg = _request('arg');
    $args = explode(":", $arg);
    $hash = _request('hash');
    //$id_auteur = $auteur_session['id_auteur'];
    $redirect = _request('redirect');
    if ($redirect == NULL) {
        $redirect = "";
    }
    //include_spip("inc/securiser_action");
    //if (verifier_action_auteur("snippet_exporte-$arg",$hash,$id_auteur)==TRUE) {
    $table = array_shift($args);
    $id = $args;
    $f = snippets_fond_exporter($table, false);
    spip_log('f ' . $f, 'export');
    if ($f) {
        include_spip('public/assembler');
        $out = recuperer_fond($f, array('id' => $id));
        //$out = preg_replace(",\n\n[\s]*(?=\n),","",$out);
        // $filename=str_replace(":","_",$arg);
        $today = date(Ymd);
        $filename = $table . '_export_' . $today;
        if (preg_match(",<titre>(.*)</titre>,Uims", $out, $regs)) {
            $filename = preg_replace(',[^-_\\w]+,', '_', trim(translitteration(textebrut(typo($regs[1])))));
        }
        $extension = "csv";
        Header("Content-Type: text/csv; charset=" . $GLOBALS['meta']['charset']);
        Header("Content-Disposition: attachment; filename={$filename}.{$extension}");
        Header("Content-Length: " . strlen($out));
        echo $out;
        exit;
        //	}
    }
    redirige_par_entete(str_replace("&amp;", "&", urldecode($redirect)));
}
Example #22
0
function onglets_callback($matches) {
	// cas des onglets imbriques
	if (strpos($matches[2], '<onglets')!==false)
		$matches[2] = preg_replace_callback(_onglets_REGEXPR, 'onglets_callback', $matches[2]);
	// nettoyage apres les separateurs
	$matches[2] = preg_replace(','.preg_quote(_decoupe_SEPARATEUR,',').'\s+,', _decoupe_SEPARATEUR, $matches[2]);
	// au cas ou on ne veuille pas d'onglets, on remplace les '++++' par un filet et on entoure d'une classe.
	if (defined('_CS_PRINT')) {
		@define(_decoupe_FILET, '<p style="border-bottom:1px dashed #666; padding:0; margin:1em 20%; font-size:4pt;" >&nbsp; &nbsp;</p>');
		$t = preg_split(',(\n\n|\r\n\r\n|\r\r),', $matches[2], 2);
		$texte = preg_replace(','.preg_quote(_decoupe_SEPARATEUR, ',').'(.*?)(\n\n|\r\n\r\n|\r\r),ms', _decoupe_FILET."<h4>$1</h4>\n\n", $t[1]);
		// on sait jamais...
		str_replace(_decoupe_SEPARATEUR, _decoupe_FILET, $texte);
		return '<div class="onglets_print"><h4>' . textebrut(echappe_retour($t[0],'CS')) . "</h4>\n\n$texte\n\n</div>";
	}
	$onglets = $contenus = array();
	$pages = explode(_decoupe_SEPARATEUR, $matches[2]);
	foreach ($pages as $p) {
		$t = preg_split(',(\n\n|\r\n\r\n|\r\r),', $p, 2);
		$t = array(trim(textebrut(nettoyer_raccourcis_typo(echappe_retour($t[0],'CS')))), cs_safebalises($t[1]));
		if(strlen($t[0].$t[1])) $contenus[] = _onglets_CONTENU.$t[0]._onglets_CONTENU2."<div>\n\n".$t[1]."\n\n</div></div>";
	}
	return _onglets_DEBUT.join('', $contenus).'</div>'._onglets_FIN;
}
Example #23
0
function tags2dcsubject($tags)
{
    $subjects = '';
    foreach (extraire_balises($tags, 'a') as $e) {
        if (extraire_attribut($e, rel) == 'tag') {
            $subjects .= '<dc:subject>' . texte_backend(textebrut($e)) . '</dc:subject>' . "\n";
        }
    }
    return $subjects;
}
function BOUCLE_auteur_principalhtml_ce97d1249b67fffb20134bd49b8a9e29(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'auteurs';
        $command['id'] = '_auteur_principal';
        $command['from'] = array('auteurs' => 'spip_auteurs');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("auteurs.id_auteur", "auteurs.lang", "auteurs.nom", "auteurs.bio", "auteurs.url_site", "auteurs.nom_site", "auteurs.email");
        $command['orderby'] = array();
        $command['join'] = array();
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('auteurs.statut', '!5poubelle', '!5poubelle', ''), array('=', 'auteurs.id_auteur', sql_quote(@$Pile[0]['id_auteur'], '', 'bigint(21) NOT NULL AUTO_INCREMENT')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/auteur.html', 'html_ce97d1249b67fffb20134bd49b8a9e29', '_auteur_principal', 1, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            $t0 .= '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" lang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" dir="' . lang_dir($Pile[$SP]['lang'], 'ltr', 'rtl') . '">
<head>
	<title>' . interdire_scripts(textebrut(typo(supprimer_numero($Pile[$SP]['nom']), "TYPO", $connect, $Pile[0]))) . ' - [' . interdire_scripts(textebrut(typo($GLOBALS['meta']['nom_site'], "TYPO", $connect, $Pile[0]))) . ']</title>
	' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-meta') . ', array(\'id_auteur\' => ' . argumenter_squelette($Pile[$SP]['id_auteur']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',7,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
	<link rel="alternate" type="application/rss+xml" title="' . interdire_scripts(textebrut(typo(supprimer_numero($Pile[$SP]['nom']), "TYPO", $connect, $Pile[0]))) . '" href="' . interdire_scripts(parametre_url(generer_url_public('backend', ''), 'id_auteur', $Pile[$SP]['id_auteur'])) . '" />
	' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('styles') . ', array(\'id_auteur\' => ' . argumenter_squelette($Pile[$SP]['id_auteur']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',9,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
</head>
<body dir="' . lang_dir($Pile[$SP]['lang'], 'ltr', 'rtl') . '" class="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . ' auteur aut' . $Pile[$SP]['id_auteur'] . '">
<div id="page" class="auteur">

<!-- *****************************************************************
	Bandeau, titre du site et menu langue
	Header and main menu (top and right) 
    ************************************************************* -->
	
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-bandeau') . ', array(\'id_auteur\' => ' . argumenter_squelette($Pile[$SP]['id_auteur']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',19,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

<!-- *****************************************************************
	Contenu principal (centre)
	Main content (center) 
    ************************************************************* -->
	<div id="bloc-contenu">
		<div class="cartouche">
		' . (($t1 = strval(filtrer('image_graver', filtrer('image_reduire', !is_array($l = quete_logo('id_auteur', 'ON', $Pile[$SP]['id_auteur'], '', 0)) ? '' : "<img class=\"spip_logo spip_logos\" alt=\"\" src=\"{$l['0']}\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src='{$l['1']}'\" onmouseout=\"this.src='{$l['0']}'\"" : "") . ' />', '120', '0')))) !== '' ? '<span style="float:right;">' . $t1 . '</span>' : '') . '
			<h1 class="">' . interdire_scripts(typo(supprimer_numero($Pile[$SP]['nom']), "TYPO", $connect, $Pile[0])) . '</h1>
			<div class="texte">
				' . (($t1 = strval(interdire_scripts(propre($Pile[$SP]['bio'], $connect, $Pile[0])))) !== '' ? '<div  class="bio">' . $t1 . '</div>' : '') . '
				' . (($t1 = strval(calculer_url($Pile[$SP]['url_site'], '', 'url', $connect))) !== '' ? '<b>' . interdire_scripts(typo(supprimer_numero(calculer_url($Pile[$SP]['url_site'], $Pile[$SP]['nom_site'], 'titre', $connect, false)), "TYPO", $connect, $Pile[0])) . ' : <a href="' . $t1 . ('">' . calculer_url($Pile[$SP]['url_site'], '', 'url', $connect) . '</a></b><br />') : '') . '
				' . (($t1 = strval(interdire_scripts(calculer_notes()))) !== '' ? $t1 . '<br />' : '') . '
				<br />
				' . (($t1 = strval(executer_balise_dynamique('FORMULAIRE_ECRIRE_AUTEUR', array($Pile[$SP]['id_auteur'], @$Pile[0]['id_article'], $Pile[$SP]['email']), array('squelettes/auteur.html', 'html_ce97d1249b67fffb20134bd49b8a9e29', '_auteur_principal', 27, $GLOBALS['spip_lang'])))) !== '' ? '<h2 id="message">' . _T('public|spip|ecrire:info_envoyer_message_prive') . '</h2>' . $t1 : '') . '
			</div><!-- texte -->
		</div><!-- cartouche -->
		<!-- Articles de l\'auteur -->
		<h2>' . _T('public|spip|ecrire:articles_auteur') . '</h2>
		' . (($t1 = BOUCLE_articleshtml_ce97d1249b67fffb20134bd49b8a9e29($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t1 : '
		') . '
	</div><!-- bloc-contenu -->

<!-- *****************************************************************
	Menus contextuels (droite)
	Contextual menus (right) 
    ************************************************************* -->
	<div id="encart">
	' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-annonces') . ', array(\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',53,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

		' . (($t1 = BOUCLE_auteurshtml_ce97d1249b67fffb20134bd49b8a9e29($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? '
		<!-- Tous les auteurs -->
			<div class="menu">
				<ul class="titre">
					<li><b>' . _T('public|spip|ecrire:icone_tous_auteur') . '</b>
						' . $t1 . '
					</li>
				</ul>
			</div><!-- menu -->
		' : '') . '
	</div><!-- encart -->
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-menu') . ', array(\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',72,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-bas') . ', array(\'id_auteur\' => ' . argumenter_squelette($Pile[$SP]['id_auteur']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/auteur.html\',\'html_ce97d1249b67fffb20134bd49b8a9e29\',\'\',73,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
</div><!-- page -->

</body>
</html>
';
        }
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_auteur_principal @ squelettes/auteur.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
/**
 * Construitre l'email personalise de notification d'un forum
 *
 * @param array $t
 * @param string $email
 * @param array $contexte
 * @return string
 */
function inc_email_notification_forum_dist($t, $email, $contexte = array())
{
    static $contextes_store = array();
    if (!isset($contextes_store[$t['id_forum']])) {
        $url = '';
        $id_forum = $t['id_forum'];
        if ($t['statut'] == 'prive') {
            if ($t['id_objet']) {
                $url = generer_url_entite($t['id_objet'], $t['objet'], '', 'forum' . $id_forum, false);
            }
        } else {
            if ($t['statut'] == 'privrac') {
                $url = generer_url_ecrire('forum') . '#forum' . $id_forum;
            } else {
                if ($t['statut'] == 'privadm') {
                    $url = generer_url_ecrire('forum', 'quoi=admin') . '#forum' . $id_forum;
                } else {
                    if ($t['statut'] == 'publie') {
                        $url = generer_url_entite($id_forum, 'forum');
                    } else {
                        $url = generer_url_ecrire('controler_forum', "debut_id_forum=" . $id_forum);
                    }
                }
            }
        }
        if (!$url) {
            spip_log("forum {$id_forum} sans referent", 'notifications');
            $url = './';
        }
        if ($t['id_objet']) {
            include_spip('inc/filtres');
            $t['titre_source'] = generer_info_entite($t['id_objet'], $t['objet'], 'titre');
        }
        $t['url'] = $url;
        // detecter les url des liens du forum
        // pour la moderation (permet de reperer les SPAMS avec des liens caches)
        // il faut appliquer le traitement de raccourci car sinon on rate des liens sous forme [->..] utilises par les spammeurs !
        include_spip("public/interfaces");
        $table_objet = "forum";
        $links = array();
        foreach ($t as $champ => $v) {
            $champ = strtoupper($champ);
            $traitement = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : null;
            if (is_array($traitement) and (isset($traitement[$table_objet]) or isset($traitement[0]))) {
                $traitement = $traitement[isset($traitement[$table_objet]) ? $table_objet : 0];
                $traitement = str_replace('%s', "'" . texte_script($v) . "'", $traitement);
                eval("\$v = {$traitement};");
            }
            $links = $links + extraire_balises($v, 'a');
        }
        $links = extraire_attribut($links, 'href');
        $links = implode("\n", $links);
        $t['liens'] = $links;
        $contextes_store[$t['id_forum']] = $t;
    }
    $fond = "notifications/forum_poste";
    if (isset($contexte['fond'])) {
        $fond = $contexte['fond'];
        unset($contexte['fond']);
    }
    $t = array_merge($contextes_store[$t['id_forum']], $contexte);
    // Rechercher eventuellement la langue du destinataire
    if (null !== ($l = sql_getfetsel('lang', 'spip_auteurs', "email=" . sql_quote($email)))) {
        $l = lang_select($l);
    }
    $parauteur = strlen($t['auteur']) <= 2 ? '' : " " . _T('forum_par_auteur', array('auteur' => $t['auteur'])) . ($t['email_auteur'] ? ' <' . $t['email_auteur'] . '>' : '');
    $titre = textebrut(typo($t['titre_source']));
    if ($titre) {
        $forum_poste_par = _T($t['objet'] == 'article' ? 'forum:forum_poste_par' : 'forum:forum_poste_par_generique', array('parauteur' => $parauteur, 'titre' => $titre, 'objet' => $t['objet']));
    } else {
        $forum_poste_par = _T('forum:forum_poste_par_court', array('parauteur' => $parauteur));
    }
    $t['par_auteur'] = $forum_poste_par;
    $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
    // pour nettoyer_titre_email
    $corps = recuperer_fond($fond, $t);
    if ($l) {
        lang_select();
    }
    return $corps;
}
Example #26
0
function proposer_item($ids, $titles, $rac, $type, $do)
{
    if (!$ids) {
        return "<br /><br /><div style='padding: 5px; color: red;'><b>" . spip_htmlentities($type) . "</b> :  " . _T('avis_aucun_resultat') . "</div>";
    }
    $ret = '';
    $info = generer_url_ecrire('informer', "type=rubrique&rac={$rac}&id=");
    $onClick = "aff_selection(this.firstChild.title,'{$rac}" . "_selection','{$info}', event)";
    $ondbClick = "{$do}(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');";
    foreach ($ids as $id => $bof) {
        $titre = strtr(str_replace("'", "&#8217;", str_replace('"', "&#34;", textebrut($titles[$id]["titre"]))), "\n\r", "  ");
        $ret .= "<div class='highlight off'\nonclick=\"changerhighlight(this); " . $onClick . "\"\nondblclick=\"" . $ondbClick . $onClick . " \"><div" . $titles[$id]["atts"] . " title='{$id}'>&nbsp; " . $titre . "</div></div>";
    }
    return $ret;
}
function BOUCLE_rubrique_principalhtml_0caead67327defaf94febb642f511490(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'rubriques';
        $command['id'] = '_rubrique_principal';
        $command['from'] = array('rubriques' => 'spip_rubriques');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("rubriques.id_rubrique", "rubriques.lang", "rubriques.titre", "rubriques.id_secteur", "rubriques.texte", "rubriques.descriptif");
        $command['orderby'] = array();
        $command['join'] = array();
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('rubriques.statut', '!', 'publie', ''), array('=', 'rubriques.id_rubrique', sql_quote(@$Pile[0]['id_rubrique'], '', 'bigint(21) NOT NULL AUTO_INCREMENT')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/rubrique.html', 'html_0caead67327defaf94febb642f511490', '_rubrique_principal', 1, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], 'oui', $Pile[$SP]['titre']);
            $t0 .= '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" lang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" dir="' . lang_dir($Pile[$SP]['lang'], 'ltr', 'rtl') . '">
<head>
	<title>[' . interdire_scripts(textebrut(typo($GLOBALS['meta']['nom_site'], "TYPO", $connect, $Pile[0]))) . '] : ' . interdire_scripts(entites_html(textebrut(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))))) . '</title>
	' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-meta') . ', array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',7,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
	<link rel="alternate" type="application/rss+xml" title="' . _T('public|spip|ecrire:syndiquer_rubrique') . ' : ' . interdire_scripts(entites_html(textebrut(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))))) . '" href="' . interdire_scripts(parametre_url(generer_url_public('backend', ''), 'id_rubrique', $Pile[$SP]['id_rubrique'])) . '" />

	' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('styles') . ', array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',10,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
</head>
<body dir="' . lang_dir($Pile[$SP]['lang'], 'ltr', 'rtl') . '" class="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . ' rubrique sect' . $Pile[$SP]['id_secteur'] . ' ' . BOUCLE_rubriques_bodyhtml_0caead67327defaf94febb642f511490($Cache, $Pile, $doublons, $Numrows, $SP) . ' rub' . $Pile[$SP]['id_rubrique'] . '">
<div id="page" class="rubrique rub' . $Pile[$SP]['id_rubrique'] . '">

<!-- *****************************************************************
	Bandeau, titre du site et menu langue
	Header and main menu (top and right) 
    ************************************************************* -->
	
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-bandeau') . ', array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',20,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

<!-- *****************************************************************
	Contenu principal (centre)
	Main content (center) 
    ************************************************************* -->
	<div id="bloc-contenu">
		<h5>
		<a href="' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '" title="' . _T('public|spip|ecrire:accueil_site') . ' : ' . interdire_scripts(typo($GLOBALS['meta']['nom_site'], "TYPO", $connect, $Pile[0])) . '">' . _T('public|spip|ecrire:accueil_site') . '</a>
    ' . (($t1 = BOUCLE_rubriques_cheminhtml_0caead67327defaf94febb642f511490($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? '
    ' . $t1 . '
	' : '') . '
		' . (($t1 = strval(interdire_scripts(couper(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])), '60')))) !== '' ? '<b class=\'separateur\'>&gt;</b> ' . $t1 : '') . '
		</h5>
		<div class="ligne-debut"></div><!-- ligne-debut -->
    	' . (($t1 = strval(filtrer('image_graver', filtrer('image_reduire', !is_array($l = quete_logo('id_rubrique', 'ON', $Pile[$SP]['id_rubrique'], quete_parent($Pile[$SP]['id_rubrique']), 0)) ? '' : "<img class=\"spip_logo spip_logos\" alt=\"\" src=\"{$l['0']}\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src='{$l['1']}'\" onmouseout=\"this.src='{$l['0']}'\"" : "") . ' />', '120', '0')))) !== '' ? '<div class="logo-liste-art">
    		' . $t1 . '
    	</div>' : '') . '
    <h1 class="titre-article">' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</h1>
	' . (($t1 = strval(interdire_scripts(($a = filtrer('image_graver', filtrer('image_reduire', propre($Pile[$SP]['texte'], $connect, $Pile[0]), '560', '0')) or is_string($a) and strlen($a)) ? $a : interdire_scripts(propre($Pile[$SP]['descriptif'], $connect, $Pile[0]))))) !== '' ? '<div class="chapo ' . interdire_scripts($Pile[$SP]['texte'] ? '' : '') . '" id="description">
        ' . $t1 . ('
        ' . (($t2 = strval(interdire_scripts(calculer_notes()))) !== '' ? '<div class="notes" style="padding: 0 1.5em;">' . $t2 . '</div>' : '') . '
	</div><!-- chapo -->') : '') . '
	

		' . recuperer_fond('inc/inc-rub-documents', array_merge($Pile[0], array('id_rubrique' => $Pile[$SP]['id_rubrique'])), array('compil' => array('squelettes/rubrique.html', 'html_0caead67327defaf94febb642f511490', '_rubrique_principal', 43, $GLOBALS['spip_lang'])), _request('connect')) . '
	


		' . (($t1 = BOUCLE_type_miniplanhtml_0caead67327defaf94febb642f511490($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t1 . '
		' : '


		' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-rub-articles') . ', array_merge(' . var_export($Pile[0], 1) . ',array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'id_secteur\' => ' . argumenter_squelette($Pile[$SP]['id_secteur']) . ',
	\'self\' => ' . argumenter_squelette(self()) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . ')), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',63,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
		
		') . '
		
		<br class="nettoyeur" />
	</div><!-- bloc-contenu -->
	
<!-- *****************************************************************
	Menus contextuels (droite)
	Contextual menus (right) 
    ************************************************************* -->
  <div id="encart">  

' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-annonces') . ', array_merge(' . var_export($Pile[0], 1) . ',array(\'self\' => ' . argumenter_squelette(self()) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . ')), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',76,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-breves') . ', array_merge(' . var_export($Pile[0], 1) . ',array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'self\' => ' . argumenter_squelette(self()) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . ')), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',78,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-syndic') . ', array_merge(' . var_export($Pile[0], 1) . ',array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'self\' => ' . argumenter_squelette(self()) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . ')), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',80,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
	
  </div><!-- encart -->

<!-- *****************************************************************
	Navigation principale et rubriques (haut et/ou gauche)
	Main and Sections Navigation (top and/orleft) 
    ************************************************************* -->
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-menu') . ', array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',88,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>
<!-- *****************************************************************
	Pied de page - Footer
    ************************************************************* -->
' . '<' . '?php echo recuperer_fond( ' . argumenter_squelette('inc/inc-bas') . ', array(\'id_rubrique\' => ' . argumenter_squelette($Pile[$SP]['id_rubrique']) . ',
	\'id_secteur\' => ' . argumenter_squelette($Pile[$SP]['id_secteur']) . ',
	\'lang\' => ' . argumenter_squelette($GLOBALS["spip_lang"]) . '), array("compil"=>array(\'squelettes/rubrique.html\',\'html_0caead67327defaf94febb642f511490\',\'\',92,$GLOBALS[\'spip_lang\'])), _request("connect"));
?' . '>

</div><!-- page -->
</body>
</html>
';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_rubrique_principal @ squelettes/rubrique.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
Example #28
0
/**
 * Generer le contexte pour le formulaire de requete de paiement
 * il faut avoir un id_transaction et un transaction_hash coherents
 * pour se premunir d'une tentative d'appel exterieur
 *
 * @param int $id_transaction
 * @param string $transaction_hash
 * @param array $config
 *   array cartes
 * @param string $action
 *   REGISTER : enregsitrement simple et on recupere un numero d'abonne/identifiant
 *   REGISTER_UPDATE : mise a jour des coordonnes liees au numero d'abonne
 *   REGISTER_PAY : payer et enregistrer
 *   REGISTER_SUBSCRIBE : abonner et enregistrer
 *   PAYMENT : avec un identifiant optionnel qui evite de resaisir les numeros de CB
 *   SUBSCRIBE : abonner avec un identifiant qui evite de resaisir les numeros de CB
 * @param array $options
 *   string $abo_uid : utile pour les actions REGISTER_UPDATE, PAYMENT, SUBSCRIBE
 *   int $delay : nb jours avant effet du paiement ponctuel (vads_capture_delay)
 *   int $delay_subscribe : nb jours avant effet de l'abonnement (vads_sub_effect_date)
 * @return array
 */
function presta_systempay_call_request_dist($id_transaction, $transaction_hash, $config = array(), $action = "PAYMENT", $options = array())
{
    $mode = $config['presta'];
    if (isset($config['mode_test']) and $config['mode_test']) {
        $mode .= "_test";
    }
    $cartes = array('CB', 'VISA', 'MASTERCARD', 'E-CARTEBLEUE');
    if (isset($config['cartes']) and $config['cartes']) {
        $cartes = $config['cartes'];
    }
    $c = $config;
    $c['type'] = strpos($action, "SUBSCRIBE") !== false ? 'abo' : 'acte';
    $cartes_possibles = systempay_available_cards($c);
    $options = array_merge(array('abo_uid' => '', 'delay' => 0, 'delay_subscribe' => 0), $options);
    $abo_uid = $options['abo_uid'];
    if (!in_array($action, array('REGISTER', 'REGISTER_UPDATE', 'REGISTER_PAY', 'REGISTER_SUBSCRIBE', 'REGISTER_PAY_SUBSCRIBE', 'PAYMENT', 'SUBSCRIBE'))) {
        spip_log("Action {$action} inconnue", $mode . _LOG_ERREUR);
        return false;
    }
    if (in_array($action, array('REGISTER_UPDATE', 'SUBSCRIBE')) and !$abo_uid) {
        spip_log("Action {$action} : abo_uid manquant pour generer le formulaire", $mode . _LOG_ERREUR);
        return false;
    }
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($transaction_hash)))) {
        return array();
    }
    if (!$row['id_auteur'] and isset($GLOBALS['visiteur_session']['id_auteur']) and $GLOBALS['visiteur_session']['id_auteur']) {
        sql_updateq("spip_transactions", array("id_auteur" => intval($row['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'])), "id_transaction=" . intval($id_transaction));
    }
    include_spip('inc/filtres');
    $parm = array();
    $parm['vads_site_id'] = $config['SITE_ID'];
    $parm['vads_ctx_mode'] = $config['mode_test'] ? "TEST" : "PRODUCTION";
    $parm['vads_version'] = _SYSTEMPAY_VERSION;
    $parm['vads_trans_id'] = bank_transaction_id($row);
    $parm['vads_order_id'] = $row['id_transaction'];
    // il ne faut pas utiliser la date de la transaction qui peut dater de plusieurs heures/jour
    // mais la date de generation du formulaire de paiement, car il y a une verif de coherence chez payzen
    // la demande doit arriver entre -30min et +2h30 par rapport a cette date
    $parm['vads_trans_date'] = gmdate("YmdHis");
    $parm['vads_page_action'] = $action;
    if ($abo_uid) {
        $parm['vads_identifier'] = $abo_uid;
    }
    $parm['vads_action_mode'] = "INTERACTIVE";
    $parm['vads_payment_config'] = "SINGLE";
    //$parm['vads_capture_delay'] = 0;
    //$parm['vads_validation_mode'] = 0;
    // passage en centimes d'euros : round en raison des approximations de calcul de PHP
    $parm['vads_currency'] = 978;
    $parm['vads_amount'] = intval(round(100 * $row['montant'], 0));
    $parm['vads_language'] = $GLOBALS['spip_lang'];
    // recuperer l'email
    $parm['vads_cust_email'] = bank_porteur_email($row);
    // si il y a du SEPA, il faut si possible nom et prenom
    if (in_array('SDD', $cartes) and isset($cartes_possibles['SDD'])) {
        $parm['vads_cust_first_name'] = bank_porteur_prenom($row);
        $parm['vads_cust_last_name'] = bank_porteur_nom($row);
    }
    // nom et url de la boutique
    $parm['vads_shop_url'] = $GLOBALS['meta']['adresse_site'];
    $parm['vads_shop_name'] = textebrut($GLOBALS['meta']['nom_site']);
    // Urls de retour
    $parm['vads_return_mode'] = "GET";
    // POST pour privacy et ne pas loger par Apache, mais GET pour ne pas avoir un message d'avertissement au retour utilisateur
    $parm['vads_url_return'] = bank_url_api_retour($config, "response");
    $parm['vads_url_cancel'] = bank_url_api_retour($config, "cancel");
    $url_check = bank_url_api_retour($config, "autoresponse");
    if (strpos($url_check, "localhost") === false) {
        $parm['vads_url_check'] = bank_url_api_retour($config, "autoresponse");
    }
    $now = time();
    // c'est un abonnement
    if (in_array($action, array('REGISTER_PAY_SUBSCRIBE', 'REGISTER_SUBSCRIBE', 'SUBSCRIBE'))) {
        // on decrit l'echeance
        if ($decrire_echeance = charger_fonction("decrire_echeance", "abos", true) and $echeance = $decrire_echeance($id_transaction)) {
            if ($echeance['montant'] > 0) {
                // on commence maintenant
                $date_effet = $now;
                if (isset($echeance['date_start']) and $echeance['date_start'] and strtotime($echeance['date_start']) > $now) {
                    $date_effet = strtotime($echeance['date_start']);
                }
                if (isset($options['delay_subscribe']) and $options['delay_subscribe']) {
                    $date_effet = strtotime("+" . $options['delay_subscribe'] . " DAY", $date_effet);
                }
                $parm['vads_sub_effect_date'] = gmdate("Ymd", $date_effet);
                $nb = 0;
                $nb_init = 0;
                if (isset($echeance['count'])) {
                    $nb = intval($echeance['count']);
                }
                if (isset($echeance['count_init'])) {
                    $nb_init = intval($echeance['count_init']);
                }
                // dans le cas Payzen $nb est le nombre total d'echeances, en incluant les echeances initiales
                if ($nb and $nb_init) {
                    $nb += $nb_init;
                }
                $freq = "MONTHLY";
                if (isset($echeance['freq']) and $echeance['freq'] == 'yearly') {
                    $freq = "YEARLY";
                }
                // si on fait le premier paiement maintenant, il ne faut pas le compter dans l'abonnement
                if ($action === "REGISTER_PAY_SUBSCRIBE") {
                    // on decale l'effet a +1mois ou +1an
                    $parm['vads_sub_effect_date'] = gmdate("Ymd", strtotime("+1 " . substr($freq, 0, -2), $date_effet));
                    // on le decompte du nombre d'echeance
                    if ($nb_init > 0) {
                        $nb_init--;
                    }
                    if ($nb > 0) {
                        $nb--;
                    }
                }
                // montant de l'echeance
                $parm['vads_sub_amount'] = intval(round(100 * $echeance['montant'], 0));
                // meme devise que le paiement initial
                $parm['vads_sub_currency'] = $parm['vads_currency'];
                // regle de recurrence
                $rule = "RRULE:";
                $rule .= "FREQ={$freq};";
                if ($freq == "MONTHLY") {
                    $monthday = intval(substr($parm['vads_sub_effect_date'], -2));
                    switch ($monthday) {
                        case 31:
                            $rule .= "BYMONTHDAY=28,29,30,31;BYSETPOS=-1;";
                            break;
                        case 30:
                            $rule .= "BYMONTHDAY=28,29,30;BYSETPOS=-1;";
                            break;
                        case 29:
                            $rule .= "BYMONTHDAY=28,29;BYSETPOS=-1;";
                            break;
                        default:
                            $rule .= "BYMONTHDAY={$monthday};";
                            break;
                    }
                }
                if ($nb > 0) {
                    $rule .= "COUNT={$nb};";
                }
                $parm['vads_sub_desc'] = $rule;
                if ($nb_init > 0) {
                    $parm['vads_sub_init_amount_number'] = $nb_init;
                    $parm['vads_sub_init_amount'] = $parm['vads_amount'];
                    if (isset($echeance['montant_init']) and ($m = intval(round(100 * $echeance['montant_init'], 0))) > 0) {
                        $parm['vads_sub_init_amount'] = $m;
                    }
                }
            }
        }
    }
    if (in_array($action, array('REGISTER_PAY', 'REGISTER_PAY_SUBSCRIBE', 'PAYMENT'))) {
        if ($options['delay']) {
            $parm['vads_capture_delay'] = $options['delay'];
        }
    }
    // s'annoncer fierement : SPIP + bank vx
    $parm['vads_contrib'] = bank_annonce_version_plugin();
    #$parm['vads_redirect_success_timeout'] = 1;
    #$parm['vads_redirect_success_message'] = "OK";
    #$parm['vads_redirect_error_timeout'] = 1;
    #$parm['vads_redirect_error_message'] = "Echec";
    // cas particulier de la carte SDD :
    // si on fait un REGISTER_SUBSCRIBE ou un SUBSCRIBE il faut un delai minimum de 13j sur le subscribe
    // pas de probleme avec le REGISTER_PAY_SUBSCRIBE car le subscribe est decale d'une echeance dans ce cas
    if (isset($cartes_possibles['SDD']) and in_array('SDD', $cartes) and (in_array($action, array('REGISTER_SUBSCRIBE', 'SUBSCRIBE')) and intval($options['delay_subscribe']) < 13)) {
        $action_sdd = $action;
        $config_sdd = $config;
        $config_sdd['cartes'] = array('SDD');
        $options_sdd = $options;
        $options_sdd['delay_subscribe'] = max($options_sdd['delay_subscribe'], 13);
        // minimum 13 jours pour un SEPA
        $contexte = presta_systempay_call_request_dist($id_transaction, $transaction_hash, $config_sdd, $action_sdd, $options_sdd);
        unset($cartes_possibles['SDD']);
    } else {
        $contexte = array('hidden' => array(), 'action' => systempay_url_serveur($config), 'backurl' => url_absolue(self()), 'id_transaction' => $id_transaction, 'transaction_hash' => $transaction_hash);
    }
    foreach ($cartes as $carte) {
        if (isset($cartes_possibles[$carte])) {
            $parm['vads_payment_cards'] = $carte;
            $contexte['hidden'][$carte] = systempay_form_hidden($config, $parm);
            $contexte['logo'][$carte] = $cartes_possibles[$carte];
        }
    }
    return $contexte;
}
Example #29
0
function signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url, $msg, $lang, &$statut)
{
    include_spip('inc/texte');
    include_spip('inc/filtres');
    // Si on est deja connecte et que notre mail a ete valide d'une maniere
    // ou d'une autre, on entre directement la signature dans la base, sans
    // envoyer d'email. Sinon email de verification
    if (isset($GLOBALS['visiteur_session']['statut']) and $GLOBALS['visiteur_session']['session_email'] == $GLOBALS['visiteur_session']['email'] and strlen($GLOBALS['visiteur_session']['email']) or isset($GLOBALS['visiteur_session']['email_confirme']) and $GLOBALS['visiteur_session']['session_email'] == $GLOBALS['visiteur_session']['email_confirme'] and strlen($GLOBALS['visiteur_session']['session_email'])) {
        // Si on est en ajax on demande a reposter sans ajax, car il faut
        // recharger toute la page pour afficher la signature
        refuser_traiter_formulaire_ajax();
        $statut = 'publie';
        // invalider le cache !
        include_spip('inc/invalideur');
        suivre_invalideur("id='article/{$id_article}'");
        // message de reussite
        return _T('petitions:form_pet_signature_validee');
    }
    //
    // Cas normal : envoi d'une demande de confirmation
    //
    $row = sql_fetsel('titre,lang', 'spip_articles', "id_article=" . intval($id_article));
    $lang = lang_select($row['lang']);
    $titre = textebrut(typo($row['titre']));
    if ($lang) {
        lang_select();
    }
    if (!strlen($statut)) {
        $statut = signature_test_pass();
    }
    if ($lang != $GLOBALS['meta']['langue_site']) {
        $url_page = parametre_url($url_page, "lang", $lang, '&');
    }
    $url_page = parametre_url($url_page, 'var_confirm', $statut, '&') . "#sp{$id_article}";
    $r = _T('petitions:form_pet_mail_confirmation', array('titre' => $titre, 'nom_email' => $nom, 'nom_site' => $site, 'url_site' => $url, 'url' => $url_page, 'message' => $msg));
    $titre = _T('petitions:form_pet_confirmation') . " " . $titre;
    $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
    if ($envoyer_mail($mail, $titre, $r)) {
        return _T('petitions:form_pet_envoi_mail_confirmation', array('email' => $mail));
    }
    return false;
    # erreur d'envoi de l'email
}
Example #30
0
/**
 * Sélecteur de rubrique pour l'espace privé, en mode AJAX
 *
 * @note
 *   `$restreint` indique qu'il faut limiter les rubriques affichées
 *   aux rubriques éditables par l'admin restreint... or, ca ne marche pas.
 *   Pour la version HTML c'est bon (cf. ci-dessus), mais pour l'ajax...
 *   je laisse ça aux spécialistes de l'ajax & des admins restreints
 * 
 *   Toutefois c'est juste un pb d'interface, car question securite
 *   la vérification est faite à l'arrivée des données (Fil)
 *
 * @uses construire_selecteur()
 * @see exec_selectionner_dist() Pour l'obtention du contenu AJAX ensuite
 * 
 * @param int $id_rubrique
 *     Identifiant de rubrique courante (0 si NEW)
 * @param string $type
 *     Type de l'objet à placer.
 * @param bool $restreint
 *     True pour indiquer qu'il faut limiter les rubriques affichées
 *     aux rubriques éditables par l'admin restreint. Ne fonctionne actuellement pas ici.
 * @param int $idem
 *     En mode rubrique, identifiant de soi-même
 * @param string $do
 *     Type d'action
 * @return string
 *     Code HTML du sélecteur
 */
function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do)
{
    if ($id_rubrique) {
        $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
    } else {
        if ($type == 'auteur') {
            $titre = '&nbsp;';
        } else {
            $titre = _T('info_racine_site');
        }
    }
    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
    $url = generer_url_ecrire('selectionner', "id={$id_rubrique}&type={$type}&do={$do}" . (!$idem ? '' : "&exclus={$idem}") . ($restreint ? "" : "&racine=oui") . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
}