function get_xml()
 {
     $xml = '';
     $xml .= '<control fianetmodule="' . FIANET_MODULE . '" version="' . FIANET_VERSION . '">' . "\n";
     $xml .= $this->billing_user->get_xml();
     $xml .= $this->billing_adress->get_xml();
     if ($this->delivery_user != null) {
         if (var_is_object_of_class($this->delivery_user, 'fianet_delivery_user_xml')) {
             $xml .= $this->delivery_user->get_xml();
         } else {
             fianet_insert_log("fianet_order_xml.php - get_xml() <br />\nDelivery user is not an object of type fianet_delivery_user_xml");
         }
     }
     if ($this->delivery_adress != null && ($this->info_commande->transport->type == 4 || $this->info_commande->transport->type == 5)) {
         if (var_is_object_of_class($this->delivery_adress, 'fianet_delivery_adress_xml')) {
             $xml .= $this->delivery_adress->get_xml();
         } else {
             fianet_insert_log("fianet_order_xml.php - get_xml() <br />\nDelivery adress is not an object of type fianet_delivery_adress_xml");
         }
     }
     $xml .= $this->info_commande->get_xml();
     $xml .= $this->payment->get_xml();
     $xml .= '</control>';
     save_flux_xml($xml, $this->info_commande->refid);
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     $xml .= '<?xml version="1.0" encoding="' . FIANET_ENCODING . '" ?>' . "\n";
     $xml .= '<control fianetmodule="' . FIANET_MODULE . '" version="' . FIANET_VERSION . '">' . "\n";
     $xml .= $this->billing_user->get_xml();
     $xml .= $this->billing_adress->get_xml();
     if ($this->delivery_user != null) {
         if (var_is_object_of_class($this->delivery_user, 'fianet_delivery_user_xml')) {
             $xml .= $this->delivery_user->get_xml();
         } else {
             fianet_insert_log("fianet_rnp_order_xml.php - get_xml() <br />\nDelivery user is not an object of type fianet_delivery_user_xml");
         }
     }
     if ($this->delivery_adress != null && ($this->info_commande->transport->type == 4 || $this->info_commande->transport->type == 5)) {
         if (var_is_object_of_class($this->delivery_adress, 'fianet_delivery_adress_xml')) {
             $xml .= $this->delivery_adress->get_xml();
         } else {
             fianet_insert_log("fianet_rnp_order_xml.php - get_xml() <br />\nDelivery adress is not an object of type fianet_delivery_adress_xml");
         }
     }
     $xml .= $this->info_commande->get_xml();
     $this->wallet->generate_wallet_crypt_data($this->info_commande->refid, $this->billing_user->nom, $this->billing_user->email, $this->info_commande->montant);
     $xml .= $this->wallet->get_xml();
     $xml .= '</control>';
     save_flux_xml($xml, $this->info_commande->refid);
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     if ($this->name != null) {
         $nb = '';
         $prixunit = '';
         if ($this->type != null) {
             $type = ' type="' . $this->type . '"';
         } else {
             fianet_insert_log("fianet_product_xml.php - get_xml() <br />\nproduct type is missing");
             return;
         }
         if ($this->ref != null) {
             $ref = ' ref="' . clean_invalid_char($this->ref) . '"';
         } else {
             fianet_insert_log("fianet_product_xml.php - get_xml() <br />\nproduct ref is missing");
             return;
         }
         if ($this->nb != null) {
             $nb = ' nb="' . $this->nb . '"';
         }
         if ($this->prixunit != null) {
             $prixunit = ' prixunit="' . number_format($this->prixunit, 2, '.', '') . '"';
         }
         $xml .= "\t\t\t<produit{$type}{$ref}{$nb}{$prixunit}>" . clean_invalid_char($this->name) . "</produit>\n";
     } else {
         fianet_insert_log("fianet_product_xml.php - get_xml() <br />\nproduct name is missing");
         return;
     }
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     if ($this->type != null) {
         $xml .= "\t" . '<paiement>' . "\n";
         $xml .= "\t\t" . '<type>' . $this->type . '</type>' . "\n";
         if ($this->type == 'carte' || $this->type == 'paypal') {
             if ($this->numcb != null) {
                 $xml .= "\t\t" . '<numcb>' . $this->numcb . '</numcb>' . "\n";
             }
             if ($this->dateval != null) {
                 $xml .= "\t\t" . '<dateval>' . $this->dateval . '</dateval>' . "\n";
             }
             if ($this->bin != null) {
                 $xml .= "\t\t" . '<bin>' . $this->bin . '</bin>' . "\n";
             }
             if ($this->bin4 != null) {
                 $xml .= "\t\t" . '<bin4>' . $this->bin4 . '</bin4>' . "\n";
             }
             if ($this->bin42 != null) {
                 $xml .= "\t\t" . '<bin42>' . $this->bin42 . '</bin42>' . "\n";
             }
         }
         $xml .= "\t" . '</paiement>' . "\n";
     } else {
         fianet_insert_log("fianet_payment_xml.php - get_xml() <br />Type is undefined\n");
         return;
     }
     return $xml;
 }
 function add_param($param)
 {
     if (var_is_object_of_class($param, 'fianet_paraobject_xml')) {
         $this->param_list[] = $param;
     } else {
         fianet_insert_log("Erreur : le paramètre n'est pas un objet fianet_paraobject_xml mais un objet : " . get_class($param) . "<br>");
     }
 }
 function add_product($product)
 {
     if (var_is_object_of_class($product, 'fianet_product_xml')) {
         $this->products_list[] = $product;
     } else {
         fianet_insert_log("fianet_product_list_xml.php - add_product() <br />Data are not a valid fianet_product_xml type\n");
     }
 }
 function get_xml()
 {
     $xml = '';
     if ($this->siteid == '' || $this->refid == '' || $this->montant <= 0 || $this->devise == '') {
         fianet_insert_log("fianet_rnp_info_order_xml.php - get_xml() <br />Somes values are undefined\n");
     }
     $xml .= "\t" . '<infocommande>' . "\n";
     $xml .= "\t\t" . '<siteid>' . $this->siteid . '</siteid>' . "\n";
     $xml .= "\t\t" . '<refid>' . $this->refid . '</refid>' . "\n";
     $xml .= "\t\t" . '<montant devise="' . $this->devise . '">' . number_format($this->montant, 2, '.', '') . '</montant>' . "\n";
     $xml .= $this->transport->get_xml();
     $xml .= $this->list->get_xml();
     $xml .= "\t" . '</infocommande>' . "\n";
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     if ($this->type != null) {
         $xml .= "\t" . '<adresse type="' . $this->type . '" format="' . $this->format . '">' . "\n";
         if ($this->rue1 != '') {
             $xml .= "\t\t" . '<rue1>' . clean_invalid_char($this->rue1) . '</rue1>' . "\n";
         } else {
             fianet_insert_log("fianet_adress_xml.php - get_xml() <br />\n rue1 is undefined");
             return;
         }
         if ($this->rue2 != "") {
             $xml .= "\t\t" . '<rue2>' . clean_invalid_char($this->rue2) . '</rue2>' . "\n";
         }
         if ($this->cpostal != "") {
             $xml .= "\t\t" . '<cpostal>' . clean_invalid_char($this->cpostal) . '</cpostal>' . "\n";
         } else {
             fianet_insert_log("fianet_adress_xml.php - get_xml() <br />\n cpostal is undefined");
             return;
         }
         if ($this->ville != "") {
             $xml .= "\t\t" . '<ville>' . clean_invalid_char($this->ville) . '</ville>' . "\n";
         } else {
             fianet_insert_log("fianet_adress_xml.php - get_xml() <br />\n ville is undefined");
             return;
         }
         if ($this->pays != "") {
             $xml .= "\t\t" . '<pays>' . clean_invalid_char($this->pays) . '</pays>' . "\n";
         } else {
             fianet_insert_log("fianet_adress_xml.php - get_xml() <br />\n pays is undefined");
             return;
         }
         if ($this->appartement != null) {
             if (var_is_object_of_class($this->appartement, 'fianet_appartment_xml')) {
                 $xml .= $this->appartement->get_xml();
             } else {
                 fianet_insert_log("fianet_adress_xml.php - get_xml() <br />\nAppartement is not an object of type fianet_appartment_xml");
             }
         }
         $xml .= "\t" . '</adresse>' . "\n";
     }
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     if ($this->type == null) {
         fianet_insert_log("fianet_transport_xml.php - get_xml() <br />\nTransport type undefined");
         return;
     }
     if ($this->nom == null) {
         fianet_insert_log("fianet_transport_xml.php - get_xml() <br />\nTransport name undefined");
         return;
     }
     if ($this->rapidite == null) {
         fianet_insert_log("fianet_transport_xml.php - get_xml() <br />\nTransport time undefined");
         return;
     }
     $xml .= "\t\t" . '<transport>' . "\n";
     $xml .= "\t\t\t" . '<type>' . $this->type . '</type>' . "\n";
     $xml .= "\t\t\t" . '<nom>' . clean_invalid_char($this->nom) . '</nom>' . "\n";
     $xml .= "\t\t\t" . '<rapidite>' . $this->rapidite . '</rapidite>' . "\n";
     $xml .= "\t\t" . '</transport>' . "\n";
     return $xml;
 }
 function get_xml()
 {
     $xml = '';
     if (!($this->siteid != "" && $this->refid != "" && $this->montant > 0 && $this->devise != "")) {
         fianet_insert_log("fianet_info_order_xml.php - get_xml() <br />Somes values are undefined\n");
     }
     if ($this->transport == null) {
         fianet_insert_log("fianet_info_order_xml.php - get_xml() <br />Transport is undefined\n");
     }
     if ($this->list == null) {
         fianet_insert_log("fianet_info_order_xml.php - get_xml() <br />List products is undefined\n");
     }
     $xml .= "\t" . '<infocommande>' . "\n";
     $xml .= "\t\t" . '<siteid>' . $this->siteid . '</siteid>' . "\n";
     $xml .= "\t\t" . '<refid>' . $this->refid . '</refid>' . "\n";
     $xml .= "\t\t" . '<montant devise="' . $this->devise . '">' . number_format($this->montant, 2, '.', '') . '</montant>' . "\n";
     if ($this->ip != null && $this->timestamp != null) {
         $xml .= "\t\t" . '<ip timestamp="' . $this->timestamp . '">' . $this->ip . '</ip>' . "\n";
     }
     $xml .= $this->transport->get_xml();
     $xml .= $this->list->get_xml();
     $xml .= "\t" . '</infocommande>' . "\n";
     return $xml;
 }
 function connect($header, $data)
 {
     $res['header'] = "";
     $res['data'] = "";
     if ($this->is_ssl) {
         $host = 'ssl://' . $this->host . ':' . $this->port;
         $socket = fsockopen('ssl://' . $this->host, $this->port);
     } else {
         $host = $this->host . ':' . $this->port;
         $socket = fsockopen($this->host, $this->port);
     }
     if ($socket !== false) {
         $data_reached = false;
         if (@fputs($socket, $header . $data)) {
             while (!feof($socket)) {
                 $line = fgets($socket);
                 if (!$data_reached) {
                     if ($line == "\r\n") {
                         $data_reached = true;
                     } else {
                         $res['header'] .= $line;
                     }
                 } else {
                     $res['data'] .= $line;
                 }
             }
         } else {
             fianet_insert_log("fianet_socket.php - connect() <br />\nEnvoie des données impossible sur : <br />\n" . $host);
             $res = false;
         }
         fclose($socket);
     } else {
         fianet_insert_log("fianet_socket.php - connect() <br />\nConnexion socket impossible : <br />\n" . $host);
         $res = false;
     }
     return $res;
 }
 function get_reevaluated_order()
 {
     if ($this->mode == 'production') {
         $url_action = URL_SAC_PROD;
     } else {
         $url_action = URL_SAC_TEST;
     }
     $path = URl_SAC_GETALERT;
     $mode = 'new';
     $output = 'mini';
     $repFT = '0';
     $data['SiteID'] = FIANET_SAC_SITE_ID;
     $data['Pwd'] = FIANET_SAC_PWD;
     $data['Mode'] = $mode;
     $data['Output'] = $output;
     $data['RepFT'] = $repFT;
     $s = new fianet_socket($url_action, $path, "POST", $data);
     $res = $s->send();
     $evaluations = array();
     if ($res === false) {
         fianet_insert_log("fianet_sender.php - get_reevaluated_order() <br />\nError when opening file : <br />\n" . $url);
     } else {
         $xmldata = $res['data'];
         //Le code commenté suivant permet de tester la réception d'une réevaluation
         /*$xmldata = '<?xml version="1.0" encoding="ISO-8859-1" ?> 
         		<result version="3.1" site="10" retour="trouvee" count="1">
         		<transaction avancement="traitee" cid="95458898" refid="Refresh04">
         		<detail>Paiement validé</detail> 
         		<analyse>
         		<eval date="20/05/2008 10:27:46" critere="16" validation="Acheteur connu" info="acheteur certifié">100</eval> 
         		<classement id="1">Transactions à traiter/Nouvelles/Contrôle visuel</classement> 
         		</analyse>
         		</transaction>
         		<transaction avancement="traitee" cid="15458898" refid="Refresh05">
         		<detail>Paiement validé</detail> 
         		<analyse>
         		<eval date="20/05/2008 10:27:46" critere="16" validation="Acheteur connu" info="acheteur certifié">100</eval> 
         		<classement id="1">Transactions à traiter/Nouvelles/Contrôle visuel</classement> 
         		</analyse>
         		</transaction>
         		</result>';*/
         $xml_array = xml2array($xmldata);
         if (isset($xml_array['result']['attr']['retour'])) {
             if ($xml_array['result']['attr']['retour'] == "param_error") {
                 fianet_insert_log("fianet_sender.php - get_reevaluated_order() <br />\nParam_error : <br />\n" . $xml_array['result']['attr']['message'] . "\n<br>{$url_action}");
             }
         }
         $evaluations = $this->process_result($xml_array);
     }
     return $evaluations;
 }
function send_fsock_stacking($data)
{
    if ($this->mode == 'production') {
        $url_action = URL_SAC_PROD;
    } else {
        $url_action = URL_SAC_TEST;
    }
    $path = URl_SAC_STACKING;
    $s = new fianet_socket($url_action, $path, 'POST', $data);
    $res = $s->send();
    if ($res === false) {
        fianet_insert_log("fianet_sender.php - send_fsock_post() <br />\nError when connecting : <br />\n" . $url_action . $path);
        return false;
    } else {
        $result = $this->process_result_stacking($res['data']);
        //debug($result);
        return $result;
    }
}