3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
18 * Calculer la taille du cache ou du cache image pour l'afficher en ajax sur la page d'admin de SPIP
20 * @param string|null $arg
22 function action_calculer_taille_cache_dist($arg=null){
24 $securiser_action = charger_fonction('securiser_action', 'inc');
25 $arg = $securiser_action();
27 include_spip('inc/filtres');
30 $taille = calculer_taille_dossier(_DIR_VAR
);
31 $res = _T('ecrire:taille_cache_image',
33 'dir' => joli_repertoire(_DIR_VAR
),
34 'taille' => "<b>".(taille_en_octets($taille) > 0 ?
taille_en_octets($taille) : "0 octet")."</b>"
39 include_spip('inc/invalideur');
41 calculer_taille_dossier(_DIR_CACHE_XML
)
42 +
calculer_taille_dossier(_DIR_CACHE
.'skel/')
43 +
calculer_taille_dossier(_DIR_CACHE
.'wheels/')
44 +
calculer_taille_dossier(_DIR_CACHE
.'contextes/')
46 $taille +
= intval(taille_du_cache());
48 $res = _T('taille_cache_vide');
50 elseif ($taille<=1024*1024){
51 $res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024)));
54 $res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille)));
65 * Calculer la taille d'un dossier, sous dossiers inclus
67 * http://doc.spip.org/@calculer_taille_dossier
72 function calculer_taille_dossier ($dir) {
73 $handle = @opendir
($dir);
74 if (!$handle) return 0;
76 while (($fichier = @readdir
($handle)) !== false) {
77 // Eviter ".", "..", ".htaccess", etc.
78 if ($fichier[0] == '.') continue;
79 if (is_file($d = "$dir/$fichier")) {
80 $taille +
= filesize($d);
83 $taille +
= calculer_taille_dossier($d);