262 lines
11 KiB
PHP
262 lines
11 KiB
PHP
<?php
|
|
class FichierController extends Zend_Controller_Action
|
|
{
|
|
/**
|
|
* PDO Connection with Doctrine
|
|
* @var \Doctrine\DBAL\Connection
|
|
*/
|
|
protected $conn;
|
|
|
|
public function init()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
$this->conn = Zend_Registry::get('doctrine');
|
|
}
|
|
|
|
public function bodaccAction()
|
|
{
|
|
$auth = Zend_Auth::getInstance();
|
|
if ($auth->hasIdentity()) {
|
|
$c = Zend_Registry::get('config');
|
|
$directory = $c->profil->path->shared.'/datafile/bodacc/histo';
|
|
|
|
$q = $this->getRequest()->getParam('q');
|
|
$filename = base64_decode($q);
|
|
|
|
$file = $directory.'/'.$filename;
|
|
|
|
if (file_exists($file) && filesize($file) > 0) {
|
|
|
|
//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);
|
|
|
|
$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é.";
|
|
}
|
|
}
|
|
|
|
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;
|
|
// --- 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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
// --- 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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
// --- 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);
|
|
}
|
|
}
|
|
|
|
public function associationsAction()
|
|
{
|
|
$content_type = 'application/pdf';
|
|
$filename = $this->getRequest()->getParam('fichier');
|
|
$c = Zend_Registry::get('config');
|
|
$file = $c->profil->path->shared . '/files/' . $filename;
|
|
// --- 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);
|
|
}
|
|
}
|
|
|
|
public function greffesAction()
|
|
{
|
|
$content_type = 'application/pdf';
|
|
$filename = $this->getRequest()->getParam('fichier');
|
|
$c = Zend_Registry::get('config');
|
|
$file = $c->profil->path->shared . '/files/' .$filename;
|
|
// --- 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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
// --- 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);
|
|
}
|
|
}
|
|
}
|