/** * Magic method (do not call directly). * @param string $name method name * @param array $args arguments * * @return mixed * * @throws Exception * @throws CMbException */ function __call($name, $args) { $name = strtolower($name); $silent = strncmp($name, 'try', 3) === 0; $function_name = $silent ? substr($name, 3) : $name; $function_name = '_' . (isset(self::$aliases[$function_name]) ? self::$aliases[$function_name] : $function_name); if (!method_exists($this, $function_name)) { throw new CMbException("CSourceFTP-call-undefined-method", $name); } if ($function_name == "_init") { return call_user_func_array(array($this, $function_name), $args); } if (!$this->loggable) { try { return call_user_func_array(array($this, $function_name), $args); } catch (CMbException $fault) { throw $fault; } } $echange_ftp = new CExchangeFTP(); $echange_ftp->date_echange = CMbDT::dateTime(); $echange_ftp->emetteur = CAppUI::conf("mb_id"); $echange_ftp->destinataire = $this->hostname; $echange_ftp->function_name = $name; CApp::$chrono->stop(); $chrono = new Chronometer(); $chrono->start(); $output = null; try { $output = call_user_func_array(array($this, $function_name), $args); } catch (CMbException $fault) { $echange_ftp->date_echange = CMbDT::dateTime(); $echange_ftp->output = $fault->getMessage(); $echange_ftp->ftp_fault = 1; $echange_ftp->store(); CApp::$chrono->start(); throw $fault; } $chrono->stop(); CApp::$chrono->start(); // response time $echange_ftp->response_time = $chrono->total; // Truncate input and output before storing $args = array_map_recursive(array("CFTP", "truncate"), $args); $echange_ftp->input = serialize($args); if ($echange_ftp->ftp_fault != 1) { if ($function_name == "_getlistfiles") { // Truncate le tableau des fichiers reçus dans le cas où c'est > 100 $array_count = count($output); if ($array_count > 100) { $output = array_slice($output, 0, 100); $output["count"] = "{$array_count} files"; } } $echange_ftp->output = serialize(array_map_recursive(array("CFTP", "truncate"), $output)); } $echange_ftp->store(); return $output; }
/** * Return a array of the first column of the query result * * @param string $query The SQL query * @param int $maxrows Maximum number of rows to return * * @return array the query result */ function loadColumn($query, $maxrows = null) { if (!($result = $this->exec($query))) { return false; } $this->chronoFetch->start(); $list = array(); while ($row = $this->fetchRow($result)) { $list[] = $row[0]; if ($maxrows && $maxrows == count($list)) { break; } } $this->chronoFetch->stop(); $this->freeResult($result); return $list; }
global $m; CApp::setTimeLimit(150); if (!class_exists("DOMDocument")) { trigger_error("sorry, DOMDocument is needed"); return; } if (null == ($pass = CValue::get("pass"))) { CAppUI::stepAjax("Fonctionnalité désactivée car trop instable.", UI_MSG_WARNING); return; } if (md5($pass) != "aa450aff6d0f4974711ff4c5536ed4cb") { CAppUI::stepAjax("Mot de passe incorrect.\nAttention, fonctionnalité à utiliser avec une extrême prudence", UI_MSG_ERROR); } // Chrono start $chrono = new Chronometer(); $chrono->start(); $segment = CValue::get("segment", 1000); $step = CValue::get("step", 1); $from = $step > 1 ? 100 + $segment * ($step - 2) : 0; $to = $step > 1 ? 100 + ($step - 1) * $segment : 100; $padded = str_pad($step, "3", "0", STR_PAD_LEFT); $htmpath = "tmp/ordre/medecin{$padded}.htm"; $xmlpath = "tmp/ordre/medecin{$padded}.xml"; $csvpath = "tmp/ordre/medecin{$padded}.csv"; CMbPath::forceDir(dirname($htmpath)); $mode = CValue::get("mode"); // Step 1: Emulates an HTTP request if ($mode == "get") { $departement = CValue::get("departement"); $cookiepath = CAppUI::getTmpPath("cookie.txt"); $page = $step - 1;
/** Calls a SOAP function * * @param string $function_name The name of the SOAP function to call * @param array $arguments An array of the arguments to pass to the function * @param array $options An associative array of options to pass to the client * @param mixed $input_headers An array of headers to be sent along with the SOAP request * @param array &$output_headers If supplied, this array will be filled with the headers from the SOAP response * * @throws Exception|SoapFault * * @return mixed SOAP functions may return one, or multiple values */ public function call($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) { $client = $this->client; if (!is_array($arguments)) { $arguments = array($arguments); } /* @todo Lors d'un appel d'une méthode RPC le tableau $arguments contient un élement vide array( [0] => ) * posant problème lors de l'appel d'une méthode du WSDL sans argument */ if (isset($arguments[0]) && empty($arguments[0])) { $arguments = array(); } if ($client->flatten && isset($arguments[0]) && !empty($arguments[0])) { $arguments = $arguments[0]; } $output = null; $echange_soap = new CEchangeSOAP(); $echange_soap->date_echange = CMbDT::dateTime(); $echange_soap->emetteur = CAppUI::conf("mb_id"); $echange_soap->destinataire = $client->wsdl_url; $echange_soap->type = $client->type_echange_soap; $url = parse_url($client->wsdl_url); $path = explode("/", $url['path']); $echange_soap->web_service_name = end($path); $echange_soap->function_name = $function_name; // Truncate input and output before storing $arguments_serialize = array_map_recursive(array('CSOAPClient', "truncate"), $arguments); $echange_soap->input = serialize($arguments_serialize); if ($client->loggable) { $echange_soap->store(); } CApp::$chrono->stop(); $chrono = new Chronometer(); $chrono->start(); try { $output = $client->call($function_name, $arguments, $options, $input_headers, $output_headers); if (!$client->loggable) { CApp::$chrono->start(); return $output; } } catch (SoapFault $fault) { // trace if (CAppUI::conf("webservices trace")) { $client->getTrace($echange_soap); } $chrono->stop(); $echange_soap->date_echange = CMbDT::dateTime(); $echange_soap->output = $fault->faultstring; $echange_soap->soapfault = 1; $echange_soap->response_time = $chrono->total; $echange_soap->store(); CApp::$chrono->start(); throw $fault; } $chrono->stop(); CApp::$chrono->start(); $echange_soap->date_echange = CMbDT::dateTime(); // trace if (CAppUI::conf("webservices trace")) { $client->getTrace($echange_soap); } // response time $echange_soap->response_time = $chrono->total; if ($echange_soap->soapfault != 1) { $echange_soap->output = serialize(array_map_recursive(array("CSOAPClient", "truncate"), $output)); } $echange_soap->store(); return $output; }
function sendFile() { // On transmet aux sources le fichier foreach ($this->loadRefSendersSource() as $_sender_source) { $_sender_source->last_datetime = CMbDT::dateTime(); $_sender_source->last_status = "triggered"; $_sender_source->last_duration = null; $_sender_source->last_size = null; $chrono = new Chronometer(); $chrono->start(); $_source = $_sender_source->_ref_source; $source_ftp = $_source->_ref_source_ftp; if ($source_ftp->_id && $source_ftp->active && $_source->actif) { try { $ftp = $source_ftp->init(); if ($ftp->connect()) { foreach ($this->_files_list as $_i => $_file) { $basename = $this->name; if ($this->multipart) { $destination_basename = $source_ftp->fileprefix . $basename . "/" . $this->getDateTime() . "/" . $_file["title"]; } else { $destination_basename = $source_ftp->fileprefix . $basename; } $compressed = $_sender_source->_ref_source->archive; $extension = "." . ($source_ftp->fileextension ? $source_ftp->fileextension : $_file["extension"]); $file_name = $destination_basename . ($compressed ? ".zip" : $extension); // Création de l'archive si nécessaire if ($compressed && !file_exists($_file["name_zip"])) { $this->_files_list[$_i]["name_zip"] = $_file["name_raw"] . ".zip"; $_file["name_zip"] = $this->_files_list[$_i]["name_zip"]; $this->_file_compressed = $this->_file . ".zip"; $archive = new ZipArchive(); $archive->open($this->_files_list[$_i]["name_zip"], ZIPARCHIVE::CREATE); $archive->addFile($_file["name_raw"], $destination_basename . $extension); $archive->close(); } // Envoi du fichier $file = $compressed ? $_file["name_zip"] : $_file["name_raw"]; $ftp->sendFile($file, $file_name); $_sender_source->last_status = "uploaded"; // Vérification de la taille du fichier uploadé $_sender_source->last_size = $ftp->getSize($file_name); if ($_sender_source->last_size == filesize($file)) { $_sender_source->last_status = "checked"; } // Enregistrement $source_ftp->counter++; $source_ftp->store(); } // TODO: en mode multipart, gérer la rotation if (!$this->multipart) { $_sender_source->last_count = $this->archiveFile($ftp, $basename, $compressed); } $ftp->close(); } } catch (Exception $e) { $this->clearTempFiles(); CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR); } } $chrono->stop(); $_sender_source->last_duration = $chrono->total; $_sender_source->store(); } $this->clearTempFiles(); }