Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 */
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");
Ejemplo n.º 4
0
 /** 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;
 }
Ejemplo n.º 5
0
 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();
 }
Ejemplo n.º 6
0
    $file = "{$dir}/{$class_name}.class.php";
    if (file_exists($file)) {
        include $file;
    }
    return false;
}
spl_autoload_register("autoloader");
global $stepsText;
$stepsText = array("01_check" => "Prérequis", "02_fileaccess" => "Permissions en écriture", "03_install" => "Installation", "04_configure" => "Configuration", "05_initialize" => "Initialisation", "06_feed" => "Remplissage des bases", "07_finish" => "Finalisation", "08_phpinfo" => "Infos PHP", "09_errorlog" => "Logs d'erreur");
$steps = array_keys($stepsText);
$currentStep = basename($_SERVER["PHP_SELF"], ".php");
if (!in_array($currentStep, $steps)) {
    trigger_error("Etape {$currentStep} inexistante", E_USER_ERROR);
}
$currentStepKey = array_search($currentStep, $steps);
$chrono = new Chronometer();
$chrono->start();
function showHeader()
{
    global $currentStepKey, $currentStep, $steps, $version;
    ob_end_clean();
    // Turn off output buffering
    header("Content-type: text/html; charset=iso-8859-1");
    ?>
<!DOCTYPE html>
<html>
<head>
  <title>Mediboard :: Assistant d'installation &mdash; Etape <?php 
    echo $currentStepKey + 1;
    ?>
 : <?php 
Ejemplo n.º 7
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$chrono = new Chronometer();
$chrono->start();
$classes = CApp::getChildClasses("CModelObject");
//$classes = array_keys(CModelObject::$spec);
foreach ($classes as $_class) {
    /** @var CModelObject $object */
    $object = new $_class();
    $object->makeAllBackSpecs();
    $chrono->step("make");
}
foreach ($classes as $_class) {
    $ballot = array("spec" => CModelObject::$spec[$_class], "props" => CModelObject::$props[$_class], "specs" => CModelObject::$specs[$_class], "backProps" => CModelObject::$backProps[$_class], "backSpecs" => CModelObject::$backSpecs[$_class]);
    SHM::put("ballot-{$_class}", $ballot, true);
    $chrono->step("put");
}
foreach ($classes as $_class) {
    SHM::get("ballot-{$_class}");
    $chrono->step("get");
}
Ejemplo n.º 8
0
<?php

/**
 * $Id: cache_tester_users.php 24615 2014-09-01 10:52:44Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 24615 $
 */
CCanDo::checkRead();
$chrono = new Chronometer();
$chrono->start();
if (CView::get("purge", "bool default|0")) {
    SHM::rem("mediusers");
    $chrono->step("purge");
}
if (!SHM::exists("mediusers")) {
    $chrono->step("acquire (not yet)");
    $mediuser = new CMediusers();
    $mediusers = $mediuser->loadListFromType();
    $chrono->step("load");
    SHM::put("mediusers", $mediusers, true);
    $chrono->step("put");
}
/** @var CMediusers[] $mediusers */
$mediusers = SHM::get("mediusers");
$chrono->step("get");
// Création du template
$smarty = new CSmartyDP();