webservice/application/controllers/FichierController.php

262 lines
11 KiB
PHP
Raw Normal View History

2013-11-05 12:18:30 +01:00
<?php
class FichierController extends Zend_Controller_Action
{
2016-10-24 10:09:21 +02:00
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
2016-11-29 15:10:11 +01:00
protected $conn;
2016-10-24 10:09:21 +02:00
public function init()
2016-11-29 15:10:11 +01:00
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$this->conn = Zend_Registry::get('doctrine');
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function bodaccAction()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
2016-10-24 10:09:21 +02:00
$c = Zend_Registry::get('config');
2016-11-29 15:10:11 +01:00
$directory = $c->profil->path->shared.'/datafile/bodacc/histo';
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
$q = $this->getRequest()->getParam('q');
$filename = base64_decode($q);
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
$file = $directory.'/'.$filename;
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
if (file_exists($file) && filesize($file) > 0) {
2016-11-29 15:10:11 +01:00
//Log de la requete
$data = array(
'login' => $auth->getIdentity()->username,
'idClient' => $auth->getIdentity()->idClient,
'page' => 'histobodacc',
'siren' => '',
'nic' => '',
'params' => $file,
'test' => 0,
'raisonSociale' => '',
'cp' => '',
'ville' => '',
'ipClient' => $_SERVER['REMOTE_ADDR'],
);
$this->conn->insert('sdv1.logs', $data);
2016-11-29 15:10:11 +01:00
$content_type = 'application/pdf';
// --- Envoi du fichier sur la sortie standard
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
echo "Erreur lors de l'affichage du fichier.";
}
} else {
echo "Authentification échoué.";
}
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function logsAction()
{
$content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'.$filename;
2016-01-25 17:24:49 +01:00
// --- Envoi du fichier sur la sortie standard
2016-11-29 15:10:11 +01:00
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function csvAction()
{
$content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'. $filename;
2016-01-25 17:24:49 +01:00
// --- Envoi du fichier sur la sortie standard
2016-11-29 15:10:11 +01:00
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function kbisAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = realpath($c->profil->path->shared).'/datafile/kbis/'.$filename;
2016-01-25 17:24:49 +01:00
// --- Envoi du fichier sur la sortie standard
2016-11-29 15:10:11 +01:00
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function associationsAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' . $filename;
2016-01-25 17:24:49 +01:00
// --- Envoi du fichier sur la sortie standard
2016-11-29 15:10:11 +01:00
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
2014-02-07 17:14:36 +01:00
2016-11-29 15:10:11 +01:00
public function greffesAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename;
2016-01-25 17:24:49 +01:00
// --- Envoi du fichier sur la sortie standard
2016-11-29 15:10:11 +01:00
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
2013-11-05 12:18:30 +01:00
2016-11-29 15:10:11 +01:00
public function crmAction()
{
$content_type = 'application/x-bzip';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename;
2016-01-25 17:24:49 +01:00
2016-11-29 15:10:11 +01:00
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
}