104 lines
2.7 KiB
PHP
104 lines
2.7 KiB
PHP
<?php
|
|
class DoublonController extends Zend_Controller_Action
|
|
{
|
|
public function indexAction()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public function fileformAction()
|
|
{
|
|
$this->view->headScript()->appendFile('/themes/default/js/jquery.form.js', 'text/javascript');
|
|
$this->view->headScript()->appendFile('/themes/default/js/jqueryprogressbar.js', 'text/javascript');
|
|
$this->view->assign('filesize', ini_get('upload_max_filesize'));
|
|
}
|
|
|
|
public function fileuploadAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$c = Zend_Registry::get('config');
|
|
$path = realpath($c->profil->path->data).'/doublon';
|
|
if(!file_exists($path)) mkdir($path);
|
|
|
|
if ( isset($_FILES) && count($_FILES)==1 ){
|
|
$n = $_FILES['fichier']['name'];
|
|
$s = $_FILES['fichier']['size'];
|
|
$tmp_name = $_FILES['fichier']['tmp_name'];
|
|
|
|
$extValide = array('csv');
|
|
$extension = strrchr($n,'.');
|
|
$extension = substr($extension,1);
|
|
//Vérifier l'extension du fichier
|
|
if(!in_array($extension, $extValide)){
|
|
echo "Extension de fichier incorrect !";
|
|
} elseif (move_uploaded_file($tmp_name, $path.'/'.$idClient.'-'.$name.'.'.$extension)){
|
|
echo "Fichier envoyé, <a href=\"".
|
|
$this->view->url(array(
|
|
'controller' => 'envoi',
|
|
'action' => 'checkfile',
|
|
'file' => $idClient.'-'.$name.'.'.$extension,
|
|
))
|
|
."\">Vérifier le format</a>";
|
|
} else {
|
|
echo "Erreur : ".$_FILES['fichier']['error'];
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Etat de progression de l'upload du fichier
|
|
*/
|
|
public function fileprogressAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$key = $request->getParam('key', '');
|
|
if (!empty($key)) {
|
|
//$rep sera égal à false si la clef n'existe pas dans le cache apc
|
|
$rep = apc_fetch('upload_'.$key);
|
|
echo json_encode($rep);
|
|
}
|
|
}
|
|
|
|
public function checkfileAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$file = $request->getParam('file');
|
|
|
|
$c = Zend_Registry::get('config');
|
|
|
|
$pathIn = $c->profil->path->data.'/doublon';
|
|
$pathOut = $c->profil->path->data.'/doublon';
|
|
if(!file_exists($pathOut)) mkdir($pathOut);
|
|
|
|
//Vérifier le format du fichier
|
|
require_once 'Scores/Enrichissement.php';
|
|
$data = new Enrichissement();
|
|
|
|
$result = $data->checkFileEntete($pathIn.'/'.$file);
|
|
if ($result===FALSE)
|
|
{
|
|
$this->view->assign('errors',array("Impossible de lire le fichier !"));
|
|
//Supprimer le fichier
|
|
unlink($pathIn.'/'.$file);
|
|
}
|
|
elseif (is_array($result))
|
|
{
|
|
$this->view->assign('errors',$result);
|
|
//Supprimer le fichier
|
|
unlink($pathIn.'/'.$file);
|
|
}
|
|
elseif (is_int($result))
|
|
{
|
|
|
|
$this->view->assign('nb', $result);
|
|
}
|
|
}
|
|
|
|
} |