New Module file
This commit is contained in:
parent
bad3645f08
commit
137bfe690e
83
application/modules/file/controllers/ImageController.php
Normal file
83
application/modules/file/controllers/ImageController.php
Normal 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";
|
||||
}
|
||||
}
|
||||
}
|
5
application/modules/file/controllers/IndexController.php
Normal file
5
application/modules/file/controllers/IndexController.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class File_IndexController extends Zend_Controller_Action
|
||||
{
|
||||
public function indexAction(){}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<?php
|
Loading…
Reference in New Issue
Block a user