Gestion pour les références
This commit is contained in:
parent
2f413946d1
commit
682c3d4ed9
90
application/controllers/RefController.php
Normal file
90
application/controllers/RefController.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
class RefController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
//Vérification connexion utilisateur
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if (!$auth->hasIdentity()){
|
||||
$this->_redirect('/user/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction ()
|
||||
{
|
||||
//Ne fait rien...
|
||||
}
|
||||
|
||||
/**
|
||||
* Donne accès au fichier
|
||||
*/
|
||||
public function fichierAction ()
|
||||
{
|
||||
//Lecture du nom du fichier
|
||||
$fichier = $this->_getParam('q','');
|
||||
|
||||
if (!empty($q) && file_exists(APPLICATION_PATH . '/public/fichiers/'.$fichier))
|
||||
{
|
||||
//Désactivation de la vue
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
//Distribution du fichier sur la sortie standard
|
||||
list($nomFichier, $extFichier) = explode('.',$fichier);
|
||||
switch ($extFichier) {
|
||||
case 'png' : $content_type = 'image/png'; break;
|
||||
case 'gif' : $content_type = 'image/gif'; break;
|
||||
case 'jpeg':
|
||||
case 'jpg' : $content_type = 'image/jpeg'; break;
|
||||
case 'pdf' : $content_type = 'application/pdf'; break;
|
||||
case 'csv' : $content_type = 'application/csv-tab-delimited-table'; break;
|
||||
}
|
||||
$this->getResponse()->setHeader('Content-Type', $content_type);
|
||||
$contentDisposition = 'attachment';
|
||||
switch ($contentDisposition) {
|
||||
case 'inline':
|
||||
$this->getResponse()->setHeader('Content-Disposition', 'inline');
|
||||
break;
|
||||
case 'attachment':
|
||||
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichier\"");
|
||||
break;
|
||||
}
|
||||
|
||||
$data = file_get_contents(APPLICATION_PATH . '/public/fichiers/'.$fichier);
|
||||
|
||||
$this->getResponse()->setHeader('Content-Length', strlen($data))
|
||||
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
|
||||
->setHeader('Pragma', 'public')
|
||||
->setBody($data);
|
||||
} else {
|
||||
$this->view->assign('message', 'Fichier introuvable !');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Donne accès aux données contenues dans une table de base de données
|
||||
*/
|
||||
public function tableAction ()
|
||||
{
|
||||
$parametresEncoded = $this->_getParam('q','');
|
||||
if (!empty($parametresEncoded))
|
||||
{
|
||||
//Gestion des paramètres
|
||||
$parametres = base64_decode($parametresEncoded);
|
||||
if (preg_match('/([a-zA-z0-9]+\.[a-zA-z0-9]+)\((.*)\)/', $parametres, $matches))
|
||||
{
|
||||
$dbTable = $matches[1];
|
||||
$colonnes = explode(',', $matches[2]);
|
||||
}
|
||||
//Connexion et requete base de données
|
||||
|
||||
|
||||
//Affichage
|
||||
|
||||
|
||||
} else {
|
||||
$this->view->assign('message', 'Paramètres incorrects !');
|
||||
}
|
||||
}
|
||||
}
|
1
application/views/scripts/ref/fichier.phtml
Normal file
1
application/views/scripts/ref/fichier.phtml
Normal file
@ -0,0 +1 @@
|
||||
<?= $this->message ?>
|
1
application/views/scripts/ref/index.phtml
Normal file
1
application/views/scripts/ref/index.phtml
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
1
application/views/scripts/ref/table.phtml
Normal file
1
application/views/scripts/ref/table.phtml
Normal file
@ -0,0 +1 @@
|
||||
<?= $this->message ?>
|
Loading…
x
Reference in New Issue
Block a user