webservice/application/controllers/FichierController.php

59 lines
1.6 KiB
PHP

<?php
class FichierController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function bodaccAction()
{
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$directory = realpath(DOC_WEB_LOCAL).'/bodacc';
$q = $this->getRequest()->getParam('q');
$file = base64_decode($q);
$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);
//Log de la requete
$tabInsert = array(
'login' => $auth->getIdentity()->username,
'idClient' => $auth->getIdentity()->idClient,
'page' => 'histobodacc',
'siren' => '',
'nic' => '',
'params' => $file,
'test' => 0,
'raisonSociale' => '',
'cp' => '',
'ville' => '',
'ipClient' => $_SERVER['REMOTE_ADDR'],
);
require_once 'framework/common/mysql.php';
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->insert('logs', array_merge($tabInsert,$tabRdvInsee), false, true);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
} else {
}
}
}