// Sauvegarde du fichier temporaire $tmpPath = "tmp/dPlabo/export_prescription.xml"; CMbPath::forceDir(dirname($tmpPath)); $doc->save($tmpPath); $doc->load($tmpPath); // Validation du document if (!$doc->schemaValidate()) { CAppUI::setMsg("Document de prescription non valide", UI_MSG_ERROR); redirect(); } // Envoi de la prescription par sur un seveurFTP // Envoi à la source créée 'PrescriptionLabo' (FTP) $prescriptionlabo_source = CExchangeSource::get("prescriptionlabo", "ftp"); // Creation du FTP $ftp = new CFTP(); $ftp->init($prescriptionlabo_source); if (!$ftp->hostname) { CAppUI::setMsg("Le document n'a pas pu être envoyé, configuration FTP manquante", UI_MSG_ERROR); redirect(); } // Transfert $destination_basename = "Prescription-" . $mbPrescription->_id; $file = "tmp/dPlabo/export_prescription.xml"; try { $ftp->connect(); $ftp->sendFile($file, "{$destination_basename}.xml"); } catch (CMbException $e) { $e->stepAjax(); $ftp->close(); redirect(); }
<?php /* $Id $ */ /** * @package Mediboard * @subpackage hl7 * @version $Revision:$ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ CCanDo::checkRead(); // Envoi à la source créée 'HL7 v.2' $exchange_source = CExchangeSource::get("hl7v2", "ftp"); $extension = $exchange_source->fileextension; $ftp = new CFTP(); $ftp->init($exchange_source); $ftp->connect(); if (!($list = $ftp->getListFiles($ftp->fileprefix))) { CAppUI::stepAjax("Le répertoire ne contient aucun fichier", UI_MSG_ERROR); } $messages = array(); foreach ($list as $filepath) { if (substr($filepath, -strlen($extension)) == $extension) { $filename = tempnam("", "hl7"); $ftp->getFile($filepath, $filename); $hl7v2_reader = new CHL7v2Reader(); $message = $hl7v2_reader->readFile($filename); if (!$message) { $message = new CHL7v2Message(); } $message->filename = basename($filepath);
function isAuthentificate() { $ftp = new CFTP(); $ftp->init($this); try { $ftp->connect(); } catch (CMbException $e) { $this->_reachable = 0; $this->_message = $e->getMessage(); return false; } $ftp->close(); return true; }