Samx Here
n1udSecurity


Server : Apache
System : Linux webd348.cluster026.gra.hosting.ovh.net 5.15.148-ovh-vps-grsec-zfs-classid #1 SMP Thu Feb 8 09:41:04 UTC 2024 x86_64
User : hednacluml ( 122243)
PHP Version : 8.3.9
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
Directory :  /home/hednacluml/univers/plugins/auto/article_pdf/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/hednacluml/univers/plugins/auto/article_pdf/rubrique_pdf.html
#CACHE{0}
<?php

	//au choix, selon le cas (voir les avantages et les inconv�niants de chaque selon le site):
    $path_pdf = sous_repertoire(_DIR_CACHE, "article_PDF"); // stockage dans le cache SPIP
	$path_pdf = sous_repertoire(_DIR_IMG, "article_PDF"); //stockage sous le dossier IMG

	// Mode release => $debug=0
	// Mode debug => $debug=1 (ne fonctionne pas sous Internet Explorer)=> ??? si, �a fonctionne !
	$debug=1;

	<BOUCLE_principale(RUBRIQUES){id_rubrique}>

	$conf_url_site = '[(#URL_RUBRIQUE|url_absolue|texte_script)]' ;
	$conf_nom_site = '[(#NOM_SITE_SPIP|pdf_first_clean|supprimer_tags|texte_script)]' ;

	// Recuperation et definition des differents elements

	$site='[(#NOM_SITE_SPIP|pdf_first_clean|supprimer_tags|texte_script)]';
	$rubrique='<BOUCLE_rubrique_mere(RUBRIQUES){id_enfant}>[(#TITRE|supprimer_numero|pdf_first_clean|supprimer_tags|texte_script)]</BOUCLE_rubrique_mere>[(#NOM_SITE_SPIP|pdf_first_clean|supprimer_tags|texte_script)]<//B_rubrique_mere>';
	$DateParution='[(#DATE_REDAC|affdate|pdf_first_clean|texte_script)]';
	$DateMiseEnLigne='[(#DATE|nom_jour|texte_script)] [(#DATE|affdate|pdf_first_clean|texte_script)]';

	/*$auteur='<BOUCLE_auteurs(AUTEURS){id_rubrique}{", "}>[(#NOM|pdf_first_clean|texte_script)]</BOUCLE_auteurs>';*/
	$motsclef=/*'<BOUCLE_keywords(MOTS){id_rubrique}{", "}>[(#TITRE|pdf_first_clean|supprimer_tags|texte_script)]</BOUCLE_keywords>'*/'';
	$yahoo='-<BOUCLE_yahoo(HIERARCHIE){id_rubrique}> [(#TITRE|supprimer_numero|pdf_first_clean|supprimer_tags|texte_script)] - </BOUCLE_yahoo>';

	$logo_site='[(#LOGO_SITE_SPIP|extraire_attribut{src}|texte_script)]';
	// attention � l'ordre des filtres SPIP
	[$logo_fichier='(#LOGO_RUBRIQUE|extraire_attribut{src}|texte_script|supprimer_param_logo)';]

//  [$logo_lien="(#URL_ARTICLE)";]

	[$surtitre='(#SURTITRE|pdf_first_clean|supprimer_tags|texte_script)';]
	[$titre='(#TITRE|supprimer_numero|pdf_first_clean|supprimer_tags|texte_script)';]
	[$soustitre='(#SOUSTITRE|pdf_first_clean|supprimer_tags|texte_script)';]
	[$chapo='(#CHAPO|pdf_first_clean|texte_script)';]
	[$descriptif='(#DESCRIPTIF|pdf_first_clean|texte_script)';]
	[$texte= '(#TEXTE|pdf_first_clean|texte_script)';]
	[$ps='(#PS|pdf_first_clean|texte_script)';]
	[$notes='(#NOTES|pdf_first_clean|texte_script)';]

	$copyright = '[(#VAL{articlepdf:copyright}|_T|pdf_first_clean|texte_script)][(#NOM_SITE_SPIP|pdf_first_clean|supprimer_tags|texte_script)][(#VAL{articlepdf:tous_droits_reserves}|_T|pdf_first_clean|texte_script)]';

	$id_rubrique = "#ID_RUBRIQUE";

	$titre_rubrique = translitteration(corriger_caracteres('[(#TITRE|supprimer_numero|pdf_first_clean|supprimer_tags|texte_script)]'));
	// Reprise du code de urls/propres.php (pourquoi c'est pas une fonction de l'API de SPIP ?)

	// on va convertir tous les caracteres de ponctuation et espaces
	// a l'exception de l'underscore (_), car on veut le conserver dans l'url
	$titre_rubrique = str_replace('_', chr(7), $titre_rubrique);
	$titre_rubrique = @preg_replace(',[[:punct:][:space:]]+,u', ' ', $titre_rubrique);
	$titre_rubrique = str_replace(chr(7), '_', $titre_rubrique);

	// S'il reste trop de caracteres non latins, les gerer comme wikipedia
	// avec rawurlencode :
	if (preg_match_all(",[^a-zA-Z0-9 _]+,", $titre_rubrique, $r, PREG_SET_ORDER)) {
		foreach ($r as $regs) {
			$titre_rubrique = substr_replace($titre_rubrique, rawurlencode($regs[0]),
				strpos($titre_rubrique, $regs[0]), strlen($regs[0]));
		}
	}

	// S'il reste trop peu, on retombe sur rubrique12
	if (strlen($titre_rubrique) == 0 ) {
		$titre_rubrique = "rubrique";
	}

	// Sinon couper les mots et les relier par des tirets
	else {
		$mots = preg_split(",[^a-zA-Z0-9_%]+,", $titre_rubrique);
		$titre_rubrique = '';
		foreach ($mots as $mot) {
			if (!strlen($mot)) continue;
			$titre_rubrique2 = $titre_rubrique.'-'.$mot;

			// Si on depasse _URLS_PROPRES_MAX caracteres, s'arreter
			// ne pas compter 3 caracteres pour %E9 mais un seul
			$long = preg_replace(',%.,', '', $titre_rubrique2);
			if (strlen($long) > _URLS_PROPRES_MAX) {
				break;
			}

			$titre_rubrique = $titre_rubrique2;
		}
		$titre_rubrique = substr($titre_rubrique, 1);

		// On enregistre en utf-8 dans la base
		$titre_rubrique = rawurldecode($titre_rubrique);

		if (strlen($titre_rubrique) == 0)
			$titre_rubrique = "rubrique";
	}

	$files_pdf = $titre_rubrique."_".$id_rubrique.".pdf";
	$file_out = $path_pdf . $files_pdf ;

	if (file_exists($file_out))
	{
		clearstatcache;
		$damo = date(YmdHi , strtotime("#DATE_MODIF")) ;
		$dage = date(YmdHi , filemtime($file_out)) ;
		if ($damo > $dage)
		{
			unlink($file_out);
		}
	}

	</BOUCLE_principale>
	header("Location: index.php");
	exit;
	<//B_principale>

	if ($debug == 1 && file_exists($file_out))
	{
		unlink($file_out);
	}

	if (!file_exists($file_out))
	{



		define('FPDF_FONTPATH',_DIR_FPDF_LIB.'font');
		include_spip(_DIR_FPDF_LIB.'fpdf');
		include_spip('pdf/lib_pdf_global');
		include_spip('pdf/lib_pdf_spip');

		//--------------------------------
		// Debut g�n�ration du PDF
		//--------------------------------
		$pdf->debug=$debug;
		$pdf=new PDF_SPIP();

		$pdf->SetCompression(false);
		$pdf->SetDisplayMode('fullpage', 'single');

		// haut, gauche,  bas, droite
		$pdf->SetAllMargins(12,15,12,10);

		$pdf->SetTitle($titre);
		$pdf->SetCreator($site);
		$pdf->SetCopyright($copyright);
		$pdf->SetSubject($rubrique);
		$pdf->SetKeywords($motsclef);

		$pdf->Build($file_out);

	}

		// Vous voulez afficher un pdf
		header("Content-type: application/pdf");
	if ($debug==1)
	{
		// Affiche le PDF directement dans l'onglet de Firefox
		// Ne fonctionne pas sous IE 6 SP2 : le pdf n'est pas reconnu (pris pour un fichier texte)
		header("location: ". url_de_base() . $file_out);
	}
	else
	{
		// Il sera nomm� $files_pdf
		// ATTENTION : pour "filename", mettre un nom de fichier court (<nom>.<extension>)
		// sinon IE 6 SP2 ne reconna�tra pas le type de fichier
		// Semble poser probl�me sous IE6 SP1
		// Ah,  Microsoft, je vous jure !
		header('Content-Disposition: attachment; filename=' . $files_pdf);

		// Le source du PDF original.pdf
		readfile($file_out);
	}

	exit;
?>

SAMX