Update of /home/spip-cvs/spip/ecrire
In directory alan:/tmp/cvs-serv23515/ecrire
Modified Files:
inc_tidy.php inc_version.php3
Log Message:
un petit cache pour tidy, qui expire souvent
pourt l'instant ça s'active avec "xhtml_page=1", mais c'est transitoire 
Index: inc_tidy.php
RCS file: /home/spip-cvs/spip/ecrire/inc_tidy.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- inc_tidy.php 5 Apr 2005 12:44:05 -0000 1.16
+++ inc_tidy.php 5 Apr 2005 13:52:39 -0000 1.17
@@ -82,23 +82,39 @@
else if ($charset == "utf-8") $enc_char = "utf8";
else return echappe_retour($buffer, $les_echap, "xhtml");
- $nomfich = _DIR_CACHE."bidouille".rand();
- $f = fopen($nomfich, 'wb');
- fputs($f, $buffer);
- fclose($f);
-
- exec("$tidy_command --tidy-mark false --char-encoding $enc_char --quote-nbsp false --show-body-only false --indent true --wrap false --output-xhtml true --add-xml-decl false -m $nomfich");
-
- $tidy = join(file($nomfich),"");
- @unlink($nomfich);
-
- $tidy = echappe_retour($tidy, $les_echap, "xhtml");
- $tidy = ereg_replace ("\<\?xml([^\>]*)\>", "", $tidy);
- //$tidy = ereg_replace ("\/\*\<\!\[CDATA\[\*\/\n*", "", $tidy);
- //$tidy = ereg_replace ("\/\*\]\]>\*\/", "", $tidy);
-
- return $tidy;
+ $cache = _DIR_CACHE.creer_repertoire(_DIR_CACHE,'tidy');
+ $nomfich = $cache.'tidy'.md5($buffer);
+ if (!file_exists($nomfich)) {
+ $tmp = "$nomfich.".@getmypid().".tmp";
+ ecrire_fichier($tmp, $buffer);
+
+ $c = "$tidy_command --tidy-mark false --char-encoding $enc_char --quote-nbsp false --show-body-only false --indent true --wrap false --output-xhtml true --add-xml-decl false -m $tmp"; #." 2>$nomfich.err";
+ spip_log ($c);
+ exec("$tidy_command --tidy-mark false --char-encoding $enc_char --quote-nbsp false --show-body-only false --indent true --wrap false --output-xhtml true --add-xml-decl false -m $tmp");
+ rename($tmp,$nomfich);
+ }
+
+ if (lire_fichier($nomfich, $tidy)
+ AND strlen(trim($tidy)) > 0) {
+ // purger le petit cache toutes les 5 minutes
+ spip_touch($nomfich); # rester vivant
+ if (spip_touch($cache.'purger_tidy', 300, true)) {
+ if ($h = @opendir($cache)) {
+ while (($f = readdir($h)) !== false) {
+ if (substr($f, 0, 4) == 'tidy'
+ AND time() - filemtime("$cache$f") > 300) {
+ @unlink("$cache$f");
+ }
+ }
+ }
+ }
+
+ $tidy = echappe_retour($tidy, $les_echap, "xhtml");
+ $tidy = ereg_replace ("\<\?xml([^\>]*)\>", "", $tidy);
+ return $tidy;
+ } else
+ return $buffer; # echec de tidy
}
else if (version_tidy() == "1") {
include_ecrire("inc_texte.php3");
Index: inc_version.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_version.php3,v
retrieving revision 1.474
retrieving revision 1.475
diff -u -d -r1.474 -r1.475
--- inc_version.php3 2 Apr 2005 19:50:53 -0000 1.474
+++ inc_version.php3 5 Apr 2005 13:52:39 -0000 1.475
@@ -251,6 +251,11 @@
// voir http://gallery.menalto.com/modules.php?op=modload&name=GalleryFAQ&file=index&myfaq=yes&id_cat=2#43
$pnmscale_command = 'pnmscale';
+// tidy en ligne de commande (si on ne l'a pas en module php,
+// ou si le module php ne marche pas)
+// $tidy_command = '/bin/tidy' ou '/usr/local/bin/tidy', ou simplement 'tidy'
+$tidy_command = '';
+
// faut-il passer les connexions MySQL en mode debug ?
$mysql_debug = false;