[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 // Ce fichier ne sera execute qu'une fois 20 if (defined("_ECRIRE_INC_META")) 21 return; 22 23 define("_ECRIRE_INC_META", "1"); 24 require_once(dirname(__FILE__). "/include/bd/inc_meta_factory.php"); 25 26 function lire_metas () { 27 global $meta, $meta_maj; 28 29 if (isset($GLOBALS['db_ok'])) { 30 if (!$GLOBALS['db_ok']) { 31 return false; 32 } 33 } 34 35 $meta = ''; 36 $meta_maj = ''; 37 $metaMetier = &recuperer_instance_meta(); 38 $allMetas = &$metaMetier->getAllMetas(); 39 40 if (PEAR::isError($allMetas)) { 41 die($allMetas->getMessage()); 42 } 43 44 while (list(, $maMeta) = each($allMetas)) { 45 $nom = $maMeta->getNom(); 46 $meta[$nom] = $maMeta->getValeur(); 47 $meta_maj[$nom] = $maMeta->getMaj(); 48 } 49 } 50 51 function ecrire_meta ($nom, $valeur) { 52 $valeur = addslashes($valeur); 53 $metaMetier = &recuperer_instance_meta(); 54 $writeOK = $metaMetier->writeMeta($nom, $valeur); 55 56 if (PEAR::isError($writeOK)) { 57 die($writeOK->getMessage()); 58 } 59 } 60 61 function effacer_meta ($nom) { 62 $metaMetier = &recuperer_instance_meta(); 63 $deleteOK = $metaMetier->delete($nom); 64 65 if (PEAR::isError($deleteOK)) { 66 die($deleteOK->getMessage()); 67 } 68 } 69 70 // 71 // Mettre a jour le fichier cache des metas 72 // Ne pas oublier d'appeler cette fonction apres ecrire_meta() et effacer_meta() ! 73 // 74 75 function ecrire_metas () { 76 global $meta, $meta_maj, $flag_ecrire; 77 lire_metas(); 78 $s = '<' . '?php 79 80 if (defined("_ECRIRE_INC_META_CACHE")) return; 81 define("_ECRIRE_INC_META_CACHE", "1"); 82 83 function lire_meta($nom) { 84 global $meta; 85 return $meta[$nom]; 86 } 87 88 function lire_meta_maj($nom) { 89 global $meta_maj; 90 return $meta_maj[$nom]; 91 } 92 '; 93 94 if ($meta) { 95 reset($meta); 96 97 while (list($key, $val) = each($meta)) { 98 $key = addslashes($key); 99 $val = ereg_replace("([\\\\'])", "\\\\1", $val); 100 $s .= "\$GLOBALS['meta']['$key'] = '$val';\n"; 101 } 102 $s .= "\n"; 103 } 104 105 if ($meta_maj) { 106 reset($meta_maj); 107 108 while (list($key, $val) = each($meta_maj)) { 109 $key = addslashes($key); 110 $s .= "\$GLOBALS['meta_maj']['$key'] = '$val';\n"; 111 } 112 $s .= "\n"; 113 } 114 115 $s .= '?' . '>'; 116 117 // pouvoir appeler ce fichier de n'importe ou 118 $fichier_meta_cache = dirname(__FILE__). '/data/inc_meta_cache.php'; 119 $f = @fopen($fichier_meta_cache . '.' .@getmypid(), "wb"); 120 121 if ($f) { 122 @fputs($f, $s); 123 @fclose($f); 124 @unlink($fichier_meta_cache); 125 @rename($fichier_meta_cache . '.' .@getmypid(), $fichier_meta_cache); 126 } 127 else { 128 global $connect_statut; 129 require_once(dirname(__FILE__). "/include/authorization/inc_authorization_factory.php"); 130 $authorization = &recuperer_instance_authorization('verifierDroitEcritureRepEcrire', $GLOBALS['connect_id_auteur']); 131 if ($authorization->isAuthorizedAction()) 132 echo "<h4 font color='red'>" . _T('texte_inc_meta_1'). " " 133 ."<a href='../spip_test_dirs.php'>" . _T('texte_inc_meta_2'). "</a> " 134 . _T('texte_inc_meta_3'). " </h4>\n"; 135 } 136 } 137 138 lire_metas(); 139 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |