1 | <?php |
---|
2 | |
---|
3 | function _fichier_microcache($id, $fond) { |
---|
4 | $fond = str_replace("/", "-", $fond); |
---|
5 | |
---|
6 | if (!is_numeric($id)) $id = md5($id); |
---|
7 | $cle = "$id-microcache"; |
---|
8 | $dossier_microcache = sous_repertoire(_DIR_LOCAL, "microcache"); |
---|
9 | $dossier_microcache = sous_repertoire($dossier_microcache, $fond); |
---|
10 | $microcache = sous_repertoire($dossier_microcache, (substr($id,-3))).$cle; |
---|
11 | |
---|
12 | return $microcache; |
---|
13 | } |
---|
14 | |
---|
15 | function _supprimer_microcache($id, $fond) { |
---|
16 | // echo "<li>$id - $fond</li>"; |
---|
17 | $microcache = _fichier_microcache($id, $fond); |
---|
18 | if (file_exists($microcache)) unlink($microcache); |
---|
19 | } |
---|
20 | |
---|
21 | function _esi_microcache($id, $fond) { |
---|
22 | $microcache = _fichier_microcache($id, $fond); |
---|
23 | |
---|
24 | if ($calcul |
---|
25 | OR in_array($_GET['var_mode'], array('recalcul', 'debug')) |
---|
26 | OR !@file_exists($microcache) |
---|
27 | OR filemtime($microcache) < time() - 60*60*24*7) { |
---|
28 | $contenu = recuperer_fond($fond, array('id'=>$id)); |
---|
29 | ecrire_fichier($microcache, $contenu); |
---|
30 | } |
---|
31 | |
---|
32 | return "<esi:include src=\"/$microcache\" />"; |
---|
33 | } |
---|
34 | |
---|
35 | function _microcache($id, $fond, $calcul=false) { |
---|
36 | $microcache = _fichier_microcache($id, $fond); |
---|
37 | |
---|
38 | if ($calcul |
---|
39 | OR in_array($_GET['var_mode'], array('recalcul', 'debug')) |
---|
40 | OR !@file_exists($microcache) |
---|
41 | OR filemtime($microcache) < time() - 60*60*24*7) { |
---|
42 | $contenu = recuperer_fond($fond, array('id'=>$id)); |
---|
43 | if ($_GET['var_mode'] != 'inclure') |
---|
44 | ecrire_fichier($microcache, $contenu); |
---|
45 | } else { |
---|
46 | lire_fichier($microcache, $contenu); |
---|
47 | } |
---|
48 | |
---|
49 | return $contenu; |
---|
50 | } |
---|
51 | |
---|
52 | ?> |
---|