New Module file

This commit is contained in:
Michael RICOIS 2016-02-07 20:50:46 +00:00
parent bad3645f08
commit 137bfe690e
3 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,83 @@
<?php
class File_ImageController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
/**
*
*/
public function logoAction()
{
$filename = $this->getRequest()->getParam('q');
$c = Zend_Registry::get('config');
$file = realpath($c->profil->path->data).'/logos/'.$filename;
$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;
}
//Envoi du fichier sur la sortie standard
if ( file_exists($file) ) {
$modules = apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header ('X-Sendfile: ' . $file);
header ('Content-Type: ' . $content_type);
header ('Content-Disposition: attachment; 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: attachment; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
echo "Impossible de charger le fichier";
}
}
/**
*
*/
public function cacheAction()
{
$filename = $this->getRequest()->getParam('q');
$c = Zend_Registry::get('config');
$file = $c->profil->path->pages.'/imgcache/'.$filename;
$content_type = 'image/png';
//Envoi du fichier sur la sortie standard
if ( file_exists($file) ) {
$modules = apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header ('X-Sendfile: ' . $file);
header ('Content-Type: ' . $content_type);
header ('Content-Disposition: attachment; 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: attachment; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
echo "Impossible de charger le fichier";
}
}
}

View File

@ -0,0 +1,5 @@
<?php
class File_IndexController extends Zend_Controller_Action
{
public function indexAction(){}
}

View File

@ -0,0 +1 @@
<?php