extranet/application/controllers/FichierController.php

441 lines
16 KiB
PHP
Raw Normal View History

<?php
class FichierController extends Zend_Controller_Action
{
2011-09-05 13:40:49 +00:00
2011-05-10 08:19:24 +00:00
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function indexAction()
{
$request = $this->getRequest();
print_r($request->getParams());
exit;
}
2011-05-11 13:38:14 +00:00
/**
* Gestion du chargement des logos
*/
public function logoAction()
{
2011-05-10 08:19:24 +00:00
$file = $this->getRequest()->getParam('fichier');
$explode = explode('.', $file);
switch ($explode[1]) {
case 'png' : $content_type = 'image/png'; break;
case 'gif' : $content_type = 'image/gif'; break;
case 'jpeg':
case 'jpg' : $content_type = 'image/jpeg'; break;
}
$configuration = Zend_Registry::get('configuration');
$path = realpath($configuration->path->data).'/'.$configuration->path->logos;
2011-05-10 08:19:24 +00:00
if ( file_exists($path.'/'.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.'/'.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.'/'.$file)));
header('Content-Disposition: filename="' . basename($path.'/'.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.'/'.$file);
} else {
echo 'Impossible de charger le logo.';
}
exit;
}
2011-05-11 13:38:14 +00:00
/**
* Gestion du chargement des images du cache
*/
public function imgcacheAction()
{
$content_type = 'image/png';
$path = APPLICATION_PATH.'/../cache/pages/imgcache/';
$file = $this->getRequest()->getParam('fichier');
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
}
2011-05-11 13:38:14 +00:00
/**
* Gestion du chargement des fichiers des marques
*/
2011-05-02 13:38:52 +00:00
public function marqueAction()
{
$configuration = Zend_Registry::get('configuration');
$directory = realpath($configuration->path->data).'/'.$configuration->path->marques;
2011-05-02 13:38:52 +00:00
$file = $this->getRequest()->getParam('fichier');
//On affiche le fichier en vérifiant qu'il existe
if(file_exists($directory.'/'.$file) && filesize($directory.'/'.$file)>0) {
//On affiche le fichier
header("Pragma: public");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: must-revalidate");
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=\"$file\"");
print file_get_contents($directory.'/'.$file);
}else{
2011-05-18 09:59:57 +00:00
echo "Erreur lors de l'affichage du fichier.";
2011-05-02 13:38:52 +00:00
}
}
2011-05-11 13:38:14 +00:00
/**
* Gestion des fichiers Actes et Bilans
*/
public function pdfAction()
{
2011-05-18 09:59:57 +00:00
$file = $this->getRequest()->getParam('fichier');
$configuration = Zend_Registry::get('configuration');
//bilan
2012-11-03 09:29:47 +00:00
if (preg_match('/^bilan-[0-9]{9}-(consolides|sociaux)-([0-9]{8})/', $file, $matches)) {
$directory = realpath($configuration->path->data).
'/'.'greffes/bilans/'.$matches[1].'/'.substr($matches[2],0,4);
}
//acte
else {
$directory = realpath($configuration->path->data).'/'.$configuration->path->pdf;
}
2011-05-18 09:59:57 +00:00
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
2011-05-18 13:38:55 +00:00
}
/**
* Gestion des fichiers Actes et Bilans
*/
public function pdfassociationAction()
{
$configuration = Zend_Registry::get('configuration');
$directory = realpath($configuration->path->data).'/association';
$file = $this->getRequest()->getParam('fichier');
2012-02-17 10:43:43 +00:00
$type = $this->getRequest()->getParam('type');
$output_file = $directory.'/'.$type.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
}
2011-09-05 13:40:49 +00:00
/**
* Gestion des liasses au formats excel
*/
2011-05-20 15:39:05 +00:00
public function liasseAction()
2011-05-18 13:38:55 +00:00
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/vnd.ms-excel';
$path = APPLICATION_PATH.'/../cache/liasse/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
2011-05-11 13:38:14 +00:00
}
2011-09-05 13:40:49 +00:00
/**
* Gestion des log de consommation
*/
2011-05-20 15:39:05 +00:00
public function consommationAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$path = APPLICATION_PATH.'/../cache/consommation/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
}
2011-09-05 13:40:49 +00:00
/**
* Export du portefeuille au format CSV
*/
2011-05-20 15:39:05 +00:00
public function portefeuilleAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$path = APPLICATION_PATH.'/../cache/surveillance/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
}
2011-09-05 13:40:49 +00:00
/**
* Export de la liste des surveillances au format CSV
*/
2011-05-20 15:39:05 +00:00
public function surveillanceAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$path = APPLICATION_PATH.'/../cache/surveillance/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
}
2011-09-05 13:40:49 +00:00
/**
* Gestion des fichiers bilan saisie par les clients
*/
2011-07-12 15:13:03 +00:00
public function bilanclientAction()
{
$configuration = Zend_Registry::get('configuration');
2012-01-25 09:27:21 +00:00
$directory = realpath($configuration->path->data).'/bilanclient';
2011-07-12 15:13:03 +00:00
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$explode = explode('.', $output_file);
switch ($explode[1]) {
case 'pdf' : $content_type = 'application/pdf'; break;
case 'tiff' : $content_type = 'image/tiff'; break;
}
2011-07-12 15:13:03 +00:00
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
}
2011-09-05 13:40:49 +00:00
/**
* Gestion des kbis
*/
2011-08-09 08:20:40 +00:00
public function kbisAction()
{
$directory = realpath(APPLICATION_PATH . '/../cache/kbis/');
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
2011-08-09 08:20:40 +00:00
}
2011-09-05 13:40:49 +00:00
/**
* Gestion des rapports personnalisés
*/
2011-09-02 09:44:09 +00:00
public function customrapportAction()
{
$directory = realpath(APPLICATION_PATH . '/../cache/pages/');
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
/**
* Gestion bodacc au format PDF
*/
public function bodaccAction()
{
$configuration = Zend_Registry::get('configuration');
$directory = realpath($configuration->path->data).'/bodacc';
$file = $this->getRequest()->getParam('fichier');
//Construire le chemin du dossier
preg_match('/BODACC_(A|B|C)_([0-9]{4})_(.*)\.pdf/', $file, $matches);
$directory.= '/'.$matches[1].'/'.$matches[2];
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
/**
* Gestion des fichiers PDF des nouveautés
*/
public function newAction()
{
$configuration = Zend_Registry::get('configuration');
$directory = realpath($configuration->path->data).'/nouveautes';
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
2012-08-17 14:52:03 +00:00
/**
* Bodacc history file
*/
public function histopdfAction()
{
$directory = APPLICATION_PATH.'/../cache/histopdf';
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
2012-08-17 14:52:03 +00:00
/**
* Bilan pdf file
*/
public function bilanAction()
{
$directory = APPLICATION_PATH.'/../cache/bilan';
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
/**
* Internal files for groupes
*/
public function groupesAction()
{
$configuration = Zend_Registry::get('configuration');
$directory = realpath($configuration->path->data).'/groupes';
$file = $this->getRequest()->getParam('fichier');
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Impossible de charger le fichier.";
}
}
}