| 4 | 
           david | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           /***************************************************************************\
  | 
        
        
            | 
            | 
           4 | 
            *  SPIP, Systeme de publication pour l'internet                           *
  | 
        
        
            | 
            | 
           5 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           6 | 
            *  Copyright (c) 2001-2005                                                *
  | 
        
        
            | 
            | 
           7 | 
            *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  | 
        
        
            | 
            | 
           8 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           9 | 
            *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  | 
        
        
            | 
            | 
           10 | 
            *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  | 
        
        
            | 
            | 
           11 | 
           \***************************************************************************/
  | 
        
        
            | 
            | 
           12 | 
              | 
        
        
            | 
            | 
           13 | 
           /*
  | 
        
        
            | 
            | 
           14 | 
              | 
        
        
            | 
            | 
           15 | 
           - Comment utiliser ce jeu d'URLs ?
  | 
        
        
            | 
            | 
           16 | 
              | 
        
        
            | 
            | 
           17 | 
           Recopiez le fichier "htaccess.txt" du repertoire de base du site SPIP sous
  | 
        
        
            | 
            | 
           18 | 
           le sous le nom ".htaccess" (attention a ne pas ecraser d'autres reglages
  | 
        
        
            | 
            | 
           19 | 
           que vous pourriez avoir mis dans ce fichier) ; si votre site est en
  | 
        
        
            | 
            | 
           20 | 
           "sous-repertoire", vous devrez aussi editer la ligne "RewriteBase" ce fichier.
  | 
        
        
            | 
            | 
           21 | 
           Les URLs definies seront alors redirigees vers les fichiers de SPIP.
  | 
        
        
            | 
            | 
           22 | 
              | 
        
        
            | 
            | 
           23 | 
           Definissez ensuite dans ecrire/mes_options.php3 :
  | 
        
        
            | 
            | 
           24 | 
           	type_urls = 'html';
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           SPIP calculera alors ses liens sous la forme "article123.html".
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           Note : si le fichier htaccess.txt se revele trop "puissant", car trop
  | 
        
        
            | 
            | 
           30 | 
           generique, et conduit a des problemes (en lien par exemple avec d'autres
  | 
        
        
            | 
            | 
           31 | 
           applications installees dans votre repertoire, a cote de SPIP), vous
  | 
        
        
            | 
            | 
           32 | 
           pouvez l'editer pour ne conserver que la partie concernant les URLS 'html'.
  | 
        
        
            | 
            | 
           33 | 
              | 
        
        
            | 
            | 
           34 | 
           */
  | 
        
        
            | 
            | 
           35 | 
              | 
        
        
            | 
            | 
           36 | 
           // executer une seule fois
  | 
        
        
            | 
            | 
           37 | 
           if (defined("_INC_URLS2")) return;
  | 
        
        
            | 
            | 
           38 | 
           define("_INC_URLS2", "1");
  | 
        
        
            | 
            | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
           function generer_url_article($id_article) {
  | 
        
        
            | 
            | 
           41 | 
           	return "article$id_article.html";
  | 
        
        
            | 
            | 
           42 | 
           }
  | 
        
        
            | 
            | 
           43 | 
              | 
        
        
            | 
            | 
           44 | 
           function generer_url_rubrique($id_rubrique) {
  | 
        
        
            | 
            | 
           45 | 
           	return "rubrique$id_rubrique.html";
  | 
        
        
            | 
            | 
           46 | 
           }
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
           function generer_url_breve($id_breve) {
  | 
        
        
            | 
            | 
           49 | 
           	return "breve$id_breve.html";
  | 
        
        
            | 
            | 
           50 | 
           }
  | 
        
        
            | 
            | 
           51 | 
              | 
        
        
            | 
            | 
           52 | 
           function generer_url_mot($id_mot) {
  | 
        
        
            | 
            | 
           53 | 
           	return "mot$id_mot.html";
  | 
        
        
            | 
            | 
           54 | 
           }
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
           function generer_url_site($id_syndic) {
  | 
        
        
            | 
            | 
           57 | 
           	return "site$id_syndic.html";
  | 
        
        
            | 
            | 
           58 | 
           }
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
           function generer_url_auteur($id_auteur) {
  | 
        
        
            | 
            | 
           61 | 
           	return "auteur$id_auteur.html";
  | 
        
        
            | 
            | 
           62 | 
           }
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           function generer_url_document($id_document) {
  | 
        
        
            | 
            | 
           65 | 
           	if (intval($id_document) <= 0)
  | 
        
        
            | 
            | 
           66 | 
           		return '';
  | 
        
        
            | 
            | 
           67 | 
           	if ((lire_meta("creer_htaccess")) == 'oui')
  | 
        
        
            | 
            | 
           68 | 
           		return "spip_acces_doc.php3?id_document=$id_document";
  | 
        
        
            | 
            | 
           69 | 
           	if ($row = @spip_fetch_array(spip_query("SELECT fichier FROM spip_documents WHERE id_document = $id_document")))
  | 
        
        
            | 
            | 
           70 | 
           		return ($row['fichier']);
  | 
        
        
            | 
            | 
           71 | 
           	return '';
  | 
        
        
            | 
            | 
           72 | 
           }
  | 
        
        
            | 
            | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
           function recuperer_parametres_url($fond, $url) {
  | 
        
        
            | 
            | 
           75 | 
           	global $contexte;
  | 
        
        
            | 
            | 
           76 | 
              | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
           	/*
  | 
        
        
            | 
            | 
           79 | 
           	 * Le bloc qui suit sert a faciliter les transitions depuis
  | 
        
        
            | 
            | 
           80 | 
           	 * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html'
  | 
        
        
            | 
            | 
           81 | 
           	 * Il est inutile de le recopier si vous personnalisez vos URLs
  | 
        
        
            | 
            | 
           82 | 
           	 * et votre .htaccess
  | 
        
        
            | 
            | 
           83 | 
           	 */
  | 
        
        
            | 
            | 
           84 | 
           	// Si on est revenu en mode html, mais c'est une ancienne url_propre
  | 
        
        
            | 
            | 
           85 | 
           	// on ne redirige pas, on assume le nouveau contexte (si possible)
  | 
        
        
            | 
            | 
           86 | 
           	if ($url_propre = $GLOBALS['_SERVER']['REDIRECT_url_propre']
  | 
        
        
            | 
            | 
           87 | 
           	OR $url_propre = $GLOBALS['HTTP_ENV_VARS']['url_propre']
  | 
        
        
            | 
            | 
           88 | 
           	AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) {
  | 
        
        
            | 
            | 
           89 | 
           		$url_propre = preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/',
  | 
        
        
            | 
            | 
           90 | 
           			'$1', $url_propre);
  | 
        
        
            | 
            | 
           91 | 
           		if ($r = spip_query("SELECT ".id_table_objet($fond)." AS id
  | 
        
        
            | 
            | 
           92 | 
           		FROM spip_".table_objet($fond)."
  | 
        
        
            | 
            | 
           93 | 
           		WHERE url_propre = '".addslashes($url_propre)."'")
  | 
        
        
            | 
            | 
           94 | 
           		AND $t = spip_fetch_array($r))
  | 
        
        
            | 
            | 
           95 | 
           			$contexte[id_table_objet($fond)] = $t['id'];
  | 
        
        
            | 
            | 
           96 | 
           	}
  | 
        
        
            | 
            | 
           97 | 
           	/* Fin du bloc compatibilite url-propres */
  | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
              | 
        
        
            | 
            | 
           100 | 
           	return;
  | 
        
        
            | 
            | 
           101 | 
           }
  | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
           //
  | 
        
        
            | 
            | 
           105 | 
           // URLs des forums
  | 
        
        
            | 
            | 
           106 | 
           //
  | 
        
        
            | 
            | 
           107 | 
              | 
        
        
            | 
            | 
           108 | 
           function generer_url_forum($id_forum, $show_thread=false) {
  | 
        
        
            | 
            | 
           109 | 
           	include_ecrire('inc_forum.php3');
  | 
        
        
            | 
            | 
           110 | 
           	return generer_url_forum_dist($id_forum, $show_thread);
  | 
        
        
            | 
            | 
           111 | 
           }
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
           ?>
  |