/**
  *
  * @param string $name
  * @param array $params
  * @return mixed 
  */
 public function __call($name, array $params)
 {
     if (preg_match('#^get(.+)$#', $name, $out)) {
         return $this->__get(strtolower($out[1]));
     }
     if (preg_match('#^set(.+)$#', $name, $out)) {
         return $this->__set(strtolower($out[1]), $params[0]);
     }
     if (preg_match('#^child(.+)$#', $name, $out)) {
         $elementname = strtolower($out[1]);
         $empty_allowed = isset($params[2]) ? $params[2] : false;
         if (isset($params[0]) && SceauTools::isXMLElement($params[0])) {
             if ($params[0]->getName() != $elementname) {
                 throw new Exception("Le nom de la balise ne correspond pas : {$elementname} attendu, " . $params[0]->getName() . " trouvé.");
             }
             if (!$params[0]->isEmpty() || $empty_allowed) {
                 return $this->addChild($params[0]);
             }
             return false;
         }
         $child = new SceauXMLElement("<{$elementname}></{$elementname}>");
         if (isset($params[1])) {
             foreach ($params[1] as $att => $value) {
                 $child->addAttribute($att, $value);
             }
         }
         if (!isset($params[0]) || is_null($params[0])) {
             if ($empty_allowed) {
                 return $this->addChild($child);
             }
             return false;
         }
         if (is_string($params[0]) or is_int($params[0])) {
             if (SceauTools::isXMLstring($params[0])) {
                 $granchild = $this->createChild($params[0]);
                 $child->addChild($granchild);
             } else {
                 $child->setValue($params[0]);
             }
         }
         if (!$child->isEmpty() || $empty_allowed) {
             return $this->addChild($child);
         }
         return false;
     }
 }
 /**
  * conects to a server, reach the script and returns the response
  *
  * @param string $header header to send to the server to reach the script
  * @return type
  */
 function connect($header)
 {
     //if connexion is secured
     if ($this->is_ssl) {
         //ssl connexion
         $socket = fsockopen('ssl://' . $this->host, $this->port, $this->errno, $this->errstr, self::TIMEOUT);
         //if connexion is not secured
     } else {
         //connexion without ssl
         $socket = fsockopen($this->host, $this->port);
     }
     if ($socket !== false) {
         $res = '';
         //sending data to the server
         if (@fputs($socket, $header)) {
             //response reading
             while (!feof($socket)) {
                 $res .= fgets($socket, 128);
             }
             //if sending data failed
         } else {
             //we put error on log file
             SceauTools::insertLog(get_class($this) . " - connect()", "Envoi des données impossible sur : " . $host);
             $res = false;
         }
         //connexion closed
         fclose($socket);
     } else {
         SceauTools::insertLog(get_class($this) . " - connect()", "Connexion socket impossible sur l'hôte {$host}. Erreur " . $this->errno . " : " . $this->errstr);
         $res = false;
     }
     return $res;
 }