[ 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_BASE")) 21 return; 22 23 define("_ECRIRE_INC_BASE", "1"); 24 25 include_ecrire ("inc_acces.php"); 26 27 function remplir_type_documents () { 28 // Images reconnues par PHP 29 $query = "INSERT IGNORE spip_types_documents (id_type, extension, titre, inclus) VALUES " . "(1, 'jpg', 'JPEG', 'image'), " . "(2, 'png', 'PNG', 'image'), " . "(3, 'gif', 'GIF', 'image')"; 30 spip_query ($query); 31 32 // Autres images (peuvent utiliser le tag <img>) 33 $query = "INSERT IGNORE spip_types_documents (extension, titre, inclus) VALUES " . "('bmp', 'BMP', 'image'), " . "('psd', 'Photoshop', 'image'), " . "('tif', 'TIFF', 'image')"; 34 spip_query ($query); 35 36 // Multimedia (peuvent utiliser le tag <embed>) 37 $query = "INSERT IGNORE spip_types_documents (extension, titre, inclus) VALUES " . "('aiff', 'AIFF', 'embed'), " . "('asf', 'Windows Media', 'embed'), " . "('avi', 'Windows Media', 'embed'), " . "('mid', 'Midi', 'embed'), " . "('mng', 'MNG', 'embed'), " . "('mov', 'QuickTime', 'embed'), " . "('mp3', 'MP3', 'embed'), " . "('mpg', 'MPEG', 'embed'), " . "('ogg', 'Ogg', 'embed'), " . "('qt', 'QuickTime', 'embed'), " . "('ra', 'RealAudio', 'embed'), " . "('ram', 'RealAudio', 'embed'), " . "('rm', 'RealAudio', 'embed'), " . "('swf', 'Flash', 'embed'), " . "('wav', 'WAV', 'embed'), " . "('wmv', 'Windows Media', 'embed')"; 38 spip_query ($query); 39 40 // Documents varies 41 $query = "INSERT IGNORE spip_types_documents (extension, titre, inclus) VALUES " . "('ai', 'Adobe Illustrator', 'non'), " . "('bz2', 'BZip', 'non'), " . "('c', 'C source', 'non'), " . "('deb', 'Debian', 'non'), " . "('doc', 'Word', 'non'), " . "('djvu', 'DjVu', 'non'), " . "('dvi', 'LaTeX DVI', 'non'), " . "('eps', 'PostScript', 'non'), " . "('gz', 'GZ', 'non'), " . "('h', 'C header', 'non'), " . "('html', 'HTML', 'non'), " . "('pas', 'Pascal', 'non'), " . "('pdf', 'PDF', 'non'), " . "('ppt', 'PowerPoint', 'non'), " . "('ps', 'PostScript', 'non'), " . "('rpm', 'RedHat/Mandrake/SuSE', 'non'), " . "('rtf', 'RTF', 'non'), " . "('sdd', 'StarOffice', 'non'), " . "('sdw', 'StarOffice', 'non'), " . "('sit', 'Stuffit', 'non'), " . "('sxc', 'OpenOffice Calc', 'non'), " . "('sxi', 'OpenOffice Impress', 'non'), " . "('sxw', 'OpenOffice', 'non'), " . "('tex', 'LaTeX', 'non'), " . "('tgz', 'TGZ', 'non'), " . "('txt', 'texte', 'non'), " . "('xcf', 'GIMP multi-layer', 'non'), " . "('xls', 'Excel', 'non'), " . "('xml', 'XML', 'non'), " . "('zip', 'Zip', 'non')"; 42 spip_query ($query); 43 } 44 45 function stripslashes_base ($table, $champs) { 46 $modifs = ''; 47 reset ($champs); 48 49 while (list(, $champ) = each($champs)) { 50 $modifs[] = $champ . '=REPLACE(REPLACE(' . $champ . ',"\\\\\'", "\'"), \'\\\\"\', \'"\')'; 51 } 52 53 $query = "UPDATE $table SET " . join(',', $modifs); 54 spip_query ($query); 55 } 56 57 function maj_version ($version, $test = true) { 58 if ($test) { 59 $metaMetier = &recuperer_instance_meta(); 60 $loadOK = $metaMetier->load('version_installee'); 61 62 if (PEAR::isError($loadOK)) { 63 die ($loadOK->getMessage()); 64 } 65 66 $metaMetier->setValeur($version); 67 $updateOK = $metaMetier->update(); 68 if (PEAR::isError($updateOK)) { 69 die ($updateOK->getMessage()); 70 } 71 } 72 else { 73 include_ecrire ('inc_lang.php'); 74 echo _T('alerte_maj_impossible', array('version' => $version)); 75 exit; 76 } 77 } 78 79 function _private_maj_base ($version, &$bd_params, &$db) { 80 $phpBeforeFile = dirname(__FILE__). '/install/sql/' . $bd_params->getDbEngine(). '/maj/' . $version . '_before.php'; 81 $structFile = dirname(__FILE__). '/install/sql/' . $bd_params->getDbEngine(). '/maj/' . $version . '.sql'; 82 $dataFile = dirname(__FILE__). '/install/sql/' . $bd_params->getDbEngine(). '/maj/' . $version . '_data.sql'; 83 $phpAfterFile = dirname(__FILE__). '/install/sql/' . $bd_params->getDbEngine(). '/maj/' . $version . '_after.php'; 84 85 if (file_exists($phpBeforeFile)) { 86 include $phpBeforeFile; 87 } 88 89 if (file_exists($structFile)) { 90 $sqlScript = new SQLScript_spipagora($structFile, BLOCKMODE); 91 $result_ok = $sqlScript->executeScript($db); 92 unset ($sqlScript); 93 if (!$result_ok) { 94 echo "<B>" . _T('avis_operation_echec'). "</B> " . _T('texte_operation_echec'); 95 exit; 96 } 97 } 98 99 if (file_exists($dataFile)) { 100 $sqlScript = new SQLScript_spipagora($dataFile, LINEMODE); 101 $result_ok = $sqlScript->executeScript($db); 102 unset ($sqlScript); 103 if (!$result_ok) { 104 echo "<B>" . _T('avis_operation_echec'). "</B> " . _T('texte_operation_echec'); 105 exit; 106 } 107 } 108 109 if (file_exists($phpAfterFile)) { 110 include $phpAfterFile; 111 } 112 113 maj_version ($version); 114 } 115 116 function maj_base () { 117 118 require_once("DB.php"); 119 require_once (dirname(__FILE__). '/include/bd/parameters.php'); 120 121 //Inclusion de la classe permettant d'executer des requetes SQL depuis des fichiers 122 //SQL convenablement formattes 123 require_once (dirname(__FILE__). '/install/SQLScript/spipagora.php'); 124 125 global $agora_version; 126 global $bd_params; 127 128 $db = &DB::connect($bd_params->getDSN(), null); 129 130 $version_installee = 0.0; 131 $metaMetier = &recuperer_instance_meta(); 132 $loadOK = $metaMetier->load('version_installee'); 133 134 $version_installee = (double)$metaMetier->getValeur(); 135 136 if (!(double)$metaMetier->getValeur() || PEAR::isError($metaMetier)) { 137 include_ecrire ('inc_lang.php'); 138 echo _T('alerte_maj_impossible', array('version' => $version)); 139 return true; 140 } 141 142 //Maciek: dynamicaly determine which version we should update. 143 $verExecuted = 0.0; 144 145 foreach (glob(dirname(__FILE__). '/install/sql/' . $bd_params->getDbEngine(). '/maj/*.sql')as $filename) { 146 $filename = basename($filename); 147 $verToExecute = floatval(substr($filename, 0, 4)); 148 149 if ($verToExecute == 0) { 150 include_ecrire ('inc_lang.php'); 151 echo _T('alerte_maj_impossible', array('version' => $version)); 152 return true; 153 } 154 if ($verToExecute > $version_installee) { 155 if ($verToExecute != $verExecuted) { 156 _private_maj_base($verToExecute, $bd_params, $db); 157 $verExecuted = $verToExecute; 158 } 159 } 160 } 161 162 $metaMetier->load('version_installee'); 163 $version_installee = (double)$metaMetier->getValeur(); 164 165 if ($version_installee < $agora_version) 166 _private_maj_base($agora_version, $bd_params, $db); 167 168 //Maciek: we need to delete the spip_action cache too... 169 foreach (glob(dirname(__FILE__). '/data/auth_*.php')as $filename) { 170 unlink ($filename); 171 } 172 173 return true; 174 } 175 176 //Ajout elebescond 177 // Function glob pour les pauvres gens comme moi qui utilise php 4.2.2 178 if (!function_exists(glob)) { 179 function glob ($pattern) { 180 $path_parts = pathinfo($pattern); 181 $pattern = '^' . str_replace(array('*', '?'), array('(.+)', '(.)'), $path_parts['basename']. '$'); 182 $dir = opendir($path_parts['dirname']); 183 184 while ($file = readdir($dir)) { 185 if (ereg($pattern, $file)) 186 $result[] = "{$path_parts['dirname']}/$file"; 187 } 188 189 closedir ($dir); 190 191 // my changes here 192 if (isset($result)) 193 return $result; 194 195 return (array)null; 196 } 197 } 198 ?>
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 |