Skip to content
Extraits de code Groupes Projets
Valider 23de6253 rédigé par esj's avatar esj
Parcourir les fichiers

poursuite de l'abstraction de IMG (et CACHE)

parent 73f5a3a3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -384,16 +384,16 @@ function reduire_image_logo($img, $taille = 120, $taille_y=0) {
if (ereg("^" . _DIR_IMG, $logo))
$img = substr($logo,strlen(_DIR_IMG));
else { $img = $logo; $logo = _DIR_IMG . $logo;}
spip_log("$img, $logo" . file_exists($logo));
if (@file_exists($logo) AND
eregi("^(.*)\.(jpg|gif|png)$", $img, $regs)) {
include_local('inc-cache.php3');
include_local('inc-public-global.php3');
$nom = $regs[1];
$format = $regs[2];
$suffixe = '-'.$taille.'x'.$taille_y;
$cache_folder= _DIR_IMG . creer_repertoire(_DIR_IMG, 'cache'.$suffixe);
$preview = creer_vignette($logo, $taille, $taille_y, $format, $cache_folder.$nom.$suffixe);
spip_log($preview['fichier'] . $cache_folder);
if ($preview) {
$vignette = $preview['fichier'];
$width = $preview['width'];
......
......@@ -622,7 +622,6 @@ function calcul_balise_logo ($p) {
"''") .
", $code_lien, '$flag_fichier')";
}
spip_log($p->nom_champ . $type_objet . "'$flag_fichier'" . $p->code);
$p->statut = 'php';
return $p;
}
......
......@@ -61,7 +61,7 @@ function generer_nom_fichier_cache($contexte='', $fond='') {
$gzip = $flag_gz && $compresser_cache ? '.gz' : '';
return $subdir.$subdir2.$fichier_cache.$gzip;
return 'CACHE/' . $subdir.$subdir2.$fichier_cache.$gzip;
}
......@@ -97,36 +97,6 @@ function utiliser_cache(&$chemin_cache, $delais) {
}
//
// Retourne $subdir/ si le sous-repertoire peut etre cree, '' sinon
//
function creer_repertoire($base, $subdir) {
if (@file_exists("$base/.plat")) return '';
$path = $base.'/'.$subdir;
if (@file_exists($path)) return "$subdir/";
@mkdir($path, 0777);
@chmod($path, 0777);
$ok = false;
if ($f = @fopen("$path/.test", "w")) {
@fputs($f, '<'.'?php $ok = true; ?'.'>');
@fclose($f);
include("$path/.test");
}
if (!$ok) {
$f = @fopen("$base/.plat", "w");
if ($f)
fclose($f);
else {
@header("Location: spip_test_dirs.php3");
exit;
}
}
return ($ok? "$subdir/" : '');
}
// Obsolete ? Utilisee pour vider le cache depuis l'espace prive
// (ou juste les squelettes si un changement de config le necessite)
function purger_repertoire($dir, $age='ignore', $regexp = '') {
......
......@@ -124,7 +124,7 @@ function afficher_page_globale ($fond, $delais, &$use_cache) {
}
// Calculer le chemin putatif du cache
$chemin_cache = 'CACHE/'.generer_nom_fichier_cache('', $fond);
$chemin_cache = generer_nom_fichier_cache('', $fond);
// Faut-il effacer des pages invalidees ?
if (lire_meta('invalider')) {
......@@ -249,7 +249,7 @@ function inclure_page($fond, $delais_inclus, $contexte_inclus, $cache_incluant='
$contexte_inclus['fond'] = $fond;
$chemin_cache = 'CACHE/'.generer_nom_fichier_cache($contexte_inclus, $fond);
$chemin_cache = generer_nom_fichier_cache($contexte_inclus, $fond);
// Peut-on utiliser un fichier cache ?
determiner_cache($delais_inclus, $use_cache, $chemin_cache);
......@@ -292,7 +292,7 @@ function admin_page($cached, $texte) {
function calcule_fichier_logo($on) {
$r= ereg_replace("^" . _DIR_IMG, "", $on);
spip_log("calculer_fihchier_logo $on $r");
# spip_log("calculer_fihchier_logo $on $r");
return $r;
}
......@@ -314,10 +314,42 @@ function taches_de_fond() {
// Si MySQL est out, laisser souffler
if (!@file_exists('ecrire/data/mysql_out')
OR (time() - @filemtime('ecrire/data/mysql_out') > 300)) {
# spip_log("cron");
include_ecrire('inc_cron.php3');
spip_cron();
}
}
}
//
// Retourne $subdir/ si le sous-repertoire peut etre cree, '' sinon
//
function creer_repertoire($base, $subdir) {
if (@file_exists("$base/.plat")) return '';
$path = $base.'/'.$subdir;
if (@file_exists($path)) return "$subdir/";
@mkdir($path, 0777);
@chmod($path, 0777);
$ok = false;
if ($f = @fopen("$path/.test", "w")) {
@fputs($f, '<'.'?php $ok = true; ?'.'>');
@fclose($f);
include("$path/.test");
}
if (!$ok) {
$f = @fopen("$base/.plat", "w");
if ($f)
fclose($f);
else {
@header("Location: spip_test_dirs.php3");
exit;
}
}
return ($ok? "$subdir/" : '');
}
?>
<?php
include ("ecrire/inc_version.php3");
include_local("inc-public-global.php3");
include_ecrire("inc_filtres.php3");
include_ecrire("inc_charsets.php3");
include_ecrire("inc_meta.php3");
include_ecrire("inc_admin.php3");
include_local("inc-cache.php3");
global $flag_ecrire;
define('_DIR_IMG', ($flag_ecrire ? "../" : "")."IMG/");
function creer_repertoire_documents($nom) {
# est-il bien raisonnable d'accepter de creer si creer_rep retourne '' ?
......@@ -77,7 +74,7 @@ if ($test_vignette) {
$loc =_DIR_IMG . "test_$test_vignette";
if ($preview = creer_vignette(_DIR_IMG . 'test_image.jpg',
$taille_preview, $taille_preview, 'jpg', $loc, $test_vignette, true))
@header("Location: $m." . $preview['format']);
@header("Location: $loc." . $preview['format']);
}
exit;
}
......@@ -665,7 +662,6 @@ if ($vignette) {
if ($regs) {
$source = $regs[0];
$format = $regs[3];
include_local('inc-cache.php3');
$destination = creer_repertoire_documents('vignettes').$regs[2].'-s'; // adresse new style
if (lire_meta("creer_preview") == 'oui') {
......@@ -685,8 +681,7 @@ if ($vignette) {
}
@header("Location: $fichier_vignette");
exit;
}
} else {
//
......@@ -695,23 +690,26 @@ if ($vignette) {
#var_dump($GLOBALS);
if ($HTTP_POST_VARS) $vars = $HTTP_POST_VARS;
else $vars = $HTTP_GET_VARS;
$redirect_url = "ecrire/" . $vars["redirect"];
$link = new Link($redirect_url);
reset($vars);
while (list ($key, $val) = each ($vars)) {
if (!ereg("^(redirect|image.*|hash.*|ajout.*|doc.*|transformer.*|modifier_.*|ok|type|forcer_.*|var_rot|action_zip)$", $key)) {
$link->addVar($key, $val);
}
}
if ($id_document)
$link->addVar('id_document',$id_document);
if ($type == 'rubrique')
$link->delVar('id_article');
header ("Location: ".$link->getUrl());
if ($HTTP_POST_VARS) $vars = $HTTP_POST_VARS;
else $vars = $HTTP_GET_VARS;
$redirect_url = "ecrire/" . $vars["redirect"];
$link = new Link($redirect_url);
reset($vars);
while (list ($key, $val) = each ($vars)) {
if (!ereg("^(redirect|image.*|hash.*|ajout.*|doc.*|transformer.*|modifier_.*|ok|type|forcer_.*|var_rot|action_zip)$", $key)) {
$link->addVar($key, $val);
}
}
if ($id_document)
$link->addVar('id_document',$id_document);
if ($type == 'rubrique')
$link->delVar('id_article');
header("Location: ".$link->getUrl());
}
exit;
# etudier les acces concurrents avant de lancer a
# header("Connection: close");
# taches_de_fond();
?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter