0) { switch ($_FILES[core::getPost("from")]['error']) { case 1: // UPLOAD_ERR_INI_SIZE alert::recError("Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !"); break; case 2: // UPLOAD_ERR_FORM_SIZE alert::recError("Le fichier dépasse la limite autorisée dans le formulaire HTML !"); break; case 3: // UPLOAD_ERR_PARTIAL alert::recError("L'envoi du fichier a été interrompu pendant le transfert !"); break; case 4: // UPLOAD_ERR_NO_FILE alert::recError("Vous n'avez pas chargé de fichier"); break; } } elseif ($_FILES[core::getPost("from")]['type'] != "text/csv") { alert::recError("Seuls les fichiers CSV sont acceptés (".$_FILES[core::getPost("from")]['type'].")"); header("Location: /p=compte-upload&add=".core::getPost("add")); exit(); } else { if (file_exists($_FILES[core::getPost("from")]['tmp_name'])) { $csvValue = banque::readCompte($_FILES[core::getPost("from")]); if($csvValue == FALSE){ historique::recRef("/compte-".core::getPost("add").".html"); historique::add(array( "idType" => historique::getIdRef("ERROR"), "idUser" => session::getId(), "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"), "log" => "Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name'] )); historique::recordAlert("ERROR"); header("Location: /compte-".core::getPost("add").".html"); exit(); } $data["md5File"] = file::record($_FILES[core::getPost("from")]); if($data["md5File"] == FALSE){ alert::recError("Ce CSV " . $_FILES[core::getPost("from")]['name'] . " a déjà été importé."); header("Location: /compte-historique-csv.html"); exit(); } // Backup (backup::create()) ? alert::recSuccess("Backup des données OK") : alert::recError("Backup des données KO"); banque::addMd5CSV($data["md5File"], core::getPost("add")); // Création du CSV json::create("banque-csv"); $nbLignes = banque::recordLignes($csvValue, core::getPost("add")); if($nbLignes == 0){ $log = "Aucune ligne n'a été extraite du fichier : " . $_FILES[core::getPost("from")]['name']; } elseif($nbLignes == 1){ $log = "Une seule ligne n'a été extraite du fichier : " . $_FILES[core::getPost("from")]['name']; } else { $log = $nbLignes . " lignes n'ont été extraites du fichier : " . $_FILES[core::getPost("from")]['name']; } historique::recRef("/compte-".core::getPost("add").".html"); historique::add(array( "idType" => historique::getIdRef("ACTION"), "idUser" => session::getId(), "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"), "log" => $log )); historique::recordAlert("SUCCESS"); alert::recSuccess($log); // Création du CSV json::create("banque-lignes-".core::getPost("add")); header("Location: /compte-".core::getPost("add").".html"); exit(); } else { historique::recRef("/compte-".core::getPost("add").".html"); historique::add(array( "idType" => historique::getIdRef("ERROR"), "idUser" => session::getId(), "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"), "log" => "Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name'] )); historique::recordAlert("ERROR"); alert::recError("Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name']); } } header("Location: /compte-".core::getPost("add").".html"); exit(); } else { header('HTTP/1.0 401 Unauthorized'); exit(); }