Example #1
0
 /**
  * Envoie une miniature à la taille indiquée au client HTTP
  * @return void
  */
 public function serveThumbnail($width = self::TAILLE_MINIATURE)
 {
     if (!$this->image) {
         throw new \LogicException('Il n\'est pas possible de fournir une miniature pour un fichier qui n\'est pas une image.');
     }
     $width = self::_findThumbSize($width);
     $cache_id = 'fichiers.' . $this->id_contenu . '.thumb.' . (int) $width;
     $path = Static_Cache::getPath($cache_id);
     // La miniature n'existe pas dans le cache statique, on la crée
     if (!Static_Cache::exists($cache_id)) {
         $source = $this->getFilePathFromCache();
         \KD2\Image::resize($source, $path, $width);
     }
     return $this->_serve($path, $this->type);
 }
Example #2
0
<?php

namespace Garradin;

require_once __DIR__ . '/include/init.php';
// Exécution des tâches automatiques
if ($config->get('frequence_sauvegardes') && $config->get('nombre_sauvegardes')) {
    $s = new Sauvegarde();
    $s->auto();
}
// Exécution des rappels automatiques
$rappels = new Rappels();
if ($rappels->countAll()) {
    $rappels->sendPending();
}
// Nettoyage du cache statique
Static_Cache::clean();
Example #3
0
    $categories = new Compta\Categories();
    $pie = new \KD2\SVGPie(400, 250);
    if ($graph == 'recettes') {
        $data = $stats->repartitionRecettes();
        $categories = $categories->getList(Compta\Categories::RECETTES);
        $pie->setTitle('Répartition des recettes');
    } else {
        $data = $stats->repartitionDepenses();
        $categories = $categories->getList(Compta\Categories::DEPENSES);
        $pie->setTitle('Répartition des dépenses');
    }
    $others = 0;
    $colors = ['#c71', '#941', '#fa4', '#fd9', '#ffc', '#cc9'];
    $max = count($colors);
    $i = 0;
    foreach ($data as $row) {
        if ($i++ >= $max) {
            $others += $row['somme'];
        } else {
            $cat = $categories[$row['id_categorie']];
            $pie->add(new \KD2\SVGPie_Data($row['somme'], substr($cat['intitule'], 0, 50), $colors[$i - 1]));
        }
    }
    if ($others > 0) {
        $pie->add(new \KD2\SVGPie_Data($others, 'Autres', '#ccc'));
    }
    Static_Cache::store('pie_' . $graph, $pie->output());
}
header('Content-Type: image/svg+xml');
Static_Cache::display('pie_' . $graph);
Example #4
0
 /**
  * Liste des plugins officiels depuis le repository signé
  * @return array Liste des plugins
  */
 public static function listOfficial()
 {
     // La liste est stockée en cache une heure pour ne pas tuer le serveur distant
     if (Static_Cache::expired('plugins_list', 3600 * 24)) {
         $url = parse_url(PLUGINS_URL);
         $context_options = ['ssl' => ['verify_peer' => TRUE, 'cafile' => ROOT . '/include/data/cacert.pem', 'verify_depth' => 5, 'CN_match' => $url['host'], 'SNI_enabled' => true, 'SNI_server_name' => $url['host'], 'disable_compression' => true]];
         $context = stream_context_create($context_options);
         try {
             $result = file_get_contents(PLUGINS_URL, NULL, $context);
         } catch (\Exception $e) {
             throw new UserException('Le téléchargement de la liste des plugins a échoué : ' . $e->getMessage());
         }
         Static_Cache::store('plugins_list', $result);
     } else {
         $result = Static_Cache::get('plugins_list');
     }
     $list = json_decode($result, true);
     return $list;
 }
Example #5
0
        $r->title = 'Caisse';
        $data[] = $r;
        foreach ($banques->getList() as $banque) {
            $r = new \KD2\SVGPlot_Data($stats->soldeCompte($banque['id']));
            $r->title = $banque['libelle'];
            $data[] = $r;
        }
        $plot->setTitle('Solde des comptes et caisses');
    }
    if (!empty($data)) {
        $labels = [];
        foreach ($data[0]->get() as $k => $v) {
            $labels[] = Utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) . '-01'));
        }
        $plot->setLabels($labels);
        $i = 0;
        $colors = ['#c71', '#941', '#fa4', '#fd9', '#ffc', '#cc9'];
        foreach ($data as $line) {
            $line->color = $colors[$i++];
            $line->width = 2;
            $plot->add($line);
            if ($i >= count($colors)) {
                $i = 0;
            }
        }
    }
    Static_Cache::store('graph_' . $graph, $plot->output());
}
header('Content-Type: image/svg+xml');
Static_Cache::display('graph_' . $graph);