Index: www-lp/www/includes/modules/payment/Etransactions_direct.php
===================================================================
diff -u -r4 -r26
--- www-lp/www/includes/modules/payment/Etransactions_direct.php (.../Etransactions_direct.php) (revision 4)
+++ www-lp/www/includes/modules/payment/Etransactions_direct.php (.../Etransactions_direct.php) (revision 26)
@@ -3,6 +3,69 @@
include_once realpath( dirname( __FILE__ ) ) . "/../../../ext/modules/payment/Etransactions/Etransactions.php";
include_once realpath( dirname( __FILE__ ) ) . "/../../EtransactionsEncrypt.php";
+define('MOBILE_PHONE_COUNTRY_DEFAULT', '+33');
+define('MOBILE_PHONE_DEFAULT', '0672756926');
+
+function getCountryNumericCode($alpha2Code, $default) {
+ $countryCodes = array(
+ "AD"=>"20", "AE"=>"784", "AF"=>"4", "AG"=>"28", "AI"=>"660", "AL"=>"8", "AM"=>"51", "AO"=>"24", "AQ"=>"10", "AR"=>"32", "AS"=>"16", "AT"=>"40", "AU"=>"36", "AW"=>"533", "AX"=>"248", "AZ"=>"31",
+ "BA"=>"70", "BB"=>"52", "BD"=>"50", "BE"=>"56", "BF"=>"854", "BG"=>"100", "BH"=>"48", "BI"=>"108", "BJ"=>"204", "BL"=>"652", "BM"=>"60", "BN"=>"96", "BO"=>"68", "BQ"=>"535", "BR"=>"76", "BS"=>"44", "BT"=>"64", "BV"=>"74", "BW"=>"72", "BY"=>"112", "BZ"=>"84",
+ "CA"=>"124", "CC"=>"166", "CD"=>"180", "CF"=>"140", "CG"=>"178", "CH"=>"756", "CI"=>"384", "CK"=>"184", "CL"=>"152", "CM"=>"120", "CN"=>"156", "CO"=>"170", "CR"=>"188", "CU"=>"192", "CV"=>"132", "CW"=>"531", "CX"=>"162", "CY"=>"196", "CZ"=>"203",
+ "DE"=>"276", "DJ"=>"262", "DK"=>"208", "DM"=>"212", "DO"=>"214", "DZ"=>"12",
+ "EC"=>"218", "EE"=>"233", "EG"=>"818", "EH"=>"732", "ER"=>"232", "ES"=>"724", "ET"=>"231",
+ "FI"=>"246", "FJ"=>"242", "FK"=>"238", "FM"=>"583", "FO"=>"234", "FR"=>"250",
+ "GA"=>"266", "GB"=>"826", "GD"=>"308", "GE"=>"268", "GF"=>"254", "GG"=>"831", "GH"=>"288", "GI"=>"292", "GL"=>"304", "GM"=>"270", "GN"=>"324", "GP"=>"312", "GQ"=>"226", "GR"=>"300", "GS"=>"239", "GT"=>"320", "GU"=>"316", "GW"=>"624", "GY"=>"328",
+ "HK"=>"344", "HM"=>"334", "HN"=>"340", "HR"=>"191", "HT"=>"332", "HU"=>"348",
+ "ID"=>"360", "IE"=>"372", "IL"=>"376", "IM"=>"833", "IN"=>"356", "IO"=>"86", "IQ"=>"368", "IR"=>"364", "IS"=>"352", "IT"=>"380",
+ "JE"=>"832", "JM"=>"388", "JO"=>"400", "JP"=>"392",
+ "KE"=>"404", "KG"=>"417", "KH"=>"116", "KI"=>"296", "KM"=>"174", "KN"=>"659", "KP"=>"408", "KR"=>"410", "KW"=>"414", "KY"=>"136", "KZ"=>"398",
+ "LA"=>"418", "LB"=>"422", "LC"=>"662", "LI"=>"438", "LK"=>"144", "LR"=>"430", "LS"=>"426", "LT"=>"440", "LU"=>"442", "LV"=>"428", "LY"=>"434",
+ "MA"=>"504", "MC"=>"492", "MD"=>"498", "ME"=>"499", "MF"=>"663", "MG"=>"450", "MH"=>"584", "MK"=>"807", "ML"=>"466", "MM"=>"104", "MN"=>"496", "MO"=>"446", "MP"=>"580", "MQ"=>"474", "MR"=>"478", "MS"=>"500", "MT"=>"470", "MU"=>"480", "MV"=>"462", "MW"=>"454", "MX"=>"484", "MY"=>"458", "MZ"=>"508",
+ "NA"=>"516", "NC"=>"540", "NE"=>"562", "NF"=>"574", "NG"=>"566", "NI"=>"558", "NL"=>"528", "NO"=>"578", "NP"=>"524", "NR"=>"520", "NU"=>"570", "NZ"=>"554",
+ "OM"=>"512",
+ "PA"=>"591", "PE"=>"604", "PF"=>"258", "PG"=>"598", "PH"=>"608", "PK"=>"586", "PL"=>"616", "PM"=>"666", "PN"=>"612", "PR"=>"630", "PS"=>"275", "PT"=>"620", "PW"=>"585", "PY"=>"600",
+ "QA"=>"634",
+ "RE"=>"638", "RO"=>"642", "RS"=>"688", "RU"=>"643", "RW"=>"646",
+ "SA"=>"682", "SB"=>"90", "SC"=>"690", "SD"=>"729", "SE"=>"752", "SG"=>"702", "SH"=>"654", "SI"=>"705", "SJ"=>"744", "SK"=>"703", "SL"=>"694", "SM"=>"674", "SN"=>"686", "SO"=>"706", "SR"=>"740", "SS"=>"728", "ST"=>"678", "SV"=>"222", "SX"=>"534", "SY"=>"760", "SZ"=>"748",
+ "TC"=>"796", "TD"=>"148", "TF"=>"260", "TG"=>"768", "TH"=>"764", "TJ"=>"762", "TK"=>"772", "TL"=>"626", "TM"=>"795", "TN"=>"788", "TO"=>"776", "TR"=>"792", "TT"=>"780", "TV"=>"798", "TW"=>"158", "TZ"=>"834",
+ "UA"=>"804", "UG"=>"800", "UM"=>"581", "US"=>"840", "UY"=>"858", "UZ"=>"860",
+ "VA"=>"336", "VC"=>"670", "VE"=>"862", "VG"=>"92", "VI"=>"850", "VN"=>"704", "VU"=>"548",
+ "WF"=>"876", "WS"=>"882",
+ "YE"=>"887", "YT"=>"175",
+ "ZA"=>"710", "ZM"=>"894", "ZW"=>"716"
+ );
+
+ // Convert the alpha-2 code to uppercase to ensure consistency
+ $alpha2Code = strtoupper($alpha2Code);
+
+ // Check if the alpha-2 code exists in the array
+ if (array_key_exists($alpha2Code, $countryCodes)) {
+ return $countryCodes[$alpha2Code];
+ } else {
+ return $default;
+ }
+}
+
+function retrouver_prenom_nom($data, &$prenom, &$nom) {
+ // Diviser la chaîne en mots en utilisant l'espace comme séparateur
+ $mots = explode(" ", trim($data));
+
+ // Extraire le premier mot
+ $prenom = trim($mots[0]);
+
+ // Extraire le reste des mots et les réassembler en une chaîne
+ $nom = trim(implode(" ", array_slice($mots, 1)));
+
+ if ( $prenom == "" ) {
+ $prenom = "inconnu";
+ }
+ if ( $nom == "" ) {
+ $nom = $prenom;
+ $prenom = "inconnu";
+ }
+}
+
+
/**
* Etransactions class for online payment
*/
@@ -117,9 +180,12 @@
// vd: --> redirect confirmation to checkout_process
$this->form_action_url = null;
if ( MODULE_PAYMENT_Etransactions_DIRECT_ENVIRONMENT == "Production" ) {
- $this->form_action_url_redirect = 'https://tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi';
+ // URL principale :
+ $this->form_action_url_redirect = "https://tpeweb.e-transactions.fr/php/";
+ // URL secondaire :
+ // $this->form_action_url_redirect = "https://tpeweb1.e-transactions.fr/php/";
} else {
- $this->form_action_url_redirect = 'https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi';
+ $this->form_action_url_redirect = "https://recette-tpeweb.e-transactions.fr/php/";
}
if ( is_object( $order ) ) {
@@ -217,77 +283,333 @@
//Detect mobile
if ( $this->Etransactions->is_mobile() ) {
if ( MODULE_PAYMENT_Etransactions_DIRECT_ENVIRONMENT == "Production" ) {
- $this->form_action_url_redirect = "https://tpeweb.e-transactions.fr/cgi/ChoixPaiementMobile.cgi";
+ $this->form_action_url_redirect = "https://tpeweb.e-transactions.fr/php/";
+ // url secondaire : si necessaire
+ // $this->form_action_url_redirect = "https://tpeweb1.e-transactions.fr/php/";
} else {
- $this->form_action_url_redirect = "https://preprod-tpeweb.e-transactions.fr/cgi/ChoixPaiementMobile.cgi";
+ $this->form_action_url_redirect = "https://recette-tpeweb.e-transactions.fr/php/";
}
}
$order = new order( $orderid );
//Define language
$langue_pbx = Etransactions::getLang( $language );
//Define currency
- $currencyPbx = Etransactions::getCurrency( $currency );
+ $pbx_devise = Etransactions::getCurrency( $currency );
define( 'PBX_Etransactions_EFFECTUE', tep_href_link( FILENAME_CHECKOUT_SUCCESS ) );
+ // cmd : numero de commande
+ $pbx_cmd=$orderid;
+
+ // porteur : email de l'acheteur
+ $pbx_porteur=$order->customer['email_address'];
+
+ // repondre a : url de retour back office site (notification de paiement IPN)
+ $pbx_repondre_a=tep_href_link( "Etransactions_ipn.php" );
+
+ // retour: Parametrage des donnees retournees via l'IPN :
+ $pbx_retour = Etransactions::getPbxRetour();
+
+ // Parametrage des urls de redirection navigateur client apres paiement
+ $pbx_effectue = PBX_Etransactions_EFFECTUE;
+ $pbx_annule = tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true );
+ $pbx_refuse = tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true );
+
//define date
$dateTime = date( "c" );
+
+ //define total
+ $tmp_total = str_replace($thousands_point,'',$order->info['total']);
+ $tmp_total = str_replace(',',".",$order->info['total']);
+ $tmp_total = preg_replace('/[^0-9\.]/','',$tmp_total);
+
+ //17.11.2017 TPHILIPPS : cause pb de paiement si total > 1000E
+ //if($precision>0)$tmp_total = money_format('%'.$precision.'n',$tmp_total);
+
+ $pbx_total = Etransactions::getTotal( $tmp_total );
+
//define 3d secure
- $secure3d = "";
- if ( !$this->enabled_3d || ( MODULE_PAYMENT_Etransactions_DIRECT_MIN_AMOUNT_3D != "" && $order->info['total'] < MODULE_PAYMENT_Etransactions_DIRECT_MIN_AMOUNT_3D ) ) {
- $secure3d = "&PBX_3DS=N";
- }
-
- //define total
- $tmp_total = str_replace($thousands_point,'',$order->info['total']);
- $tmp_total = str_replace(',',".",$order->info['total']);
- $tmp_total = preg_replace('/[^0-9\.]/','',$tmp_total);
+ $pbx_souhaitauthent="01"; // variable de test authentification 3DS (01 par defaut, 02 pour exemption 3DS)
- //17.11.2017 TPHILIPPS : cause pb de paiement si total > 1000E
- //if($precision>0)$tmp_total = money_format('%'.$precision.'n',$tmp_total);
+ // shoppingcart
+ // Nombre de produit envoye dans PBX_SHOPPINGCART :
+ $pbx_nb_produit = sizeof($order->products);
+ if ( $pbx_nb_produit > 99 ) { $pbx_nb_produit = 99; }
+ // Construction de PBX_SHOPPINGCART :
+ $pbx_shoppingcart = "".$pbx_nb_produit."";
- $total = Etransactions::getTotal( $tmp_total );
-
+ // Valeurs envoyees dans PBX_BILLING :
+ retrouver_prenom_nom($order->customer['name'], $pbx_prenom_fact, $pbx_nom_fact); // prenom/nom de l utilisateur de facturation
+ $pbx_adresse1_fact = $order->customer['street_address']; // ligne1 de l adresse de facturation' : variable de test 1 rue de Paris
+ $pbx_adresse2_fact = ''; // ligne2 de l adresse de facturation' : variable de test
+ $pbx_zipcode_fact = $order->customer['postcode']; // code postal de l adresse de facturation' : variable de test 75001
+ $pbx_city_fact = $order->customer['city']; // ville de l adresse de facturation : variable de test Paris
+
+
+ $country_name = $order->customer['country'];
+ $country_iso_code_2_array_query = tep_db_query( "select countries_iso_code_2 from " . TABLE_COUNTRIES . " where countries_name = '$country_name'" );
+ $country_iso_code_2_array = tep_db_fetch_array($country_iso_code_2_array_query);
+
+ // code pays iso-3166-1 numerique de l adresse de facturation' : variable de test 250 (pour la France)
+ $pbx_country_fact = getCountryNumericCode($country_iso_code_2_array[0]['countries_iso_code_2'], "250");
+ $pbx_country_code_mobile_phone = MOBILE_PHONE_COUNTRY_DEFAULT;
+ $pbx_mobile_phone = MOBILE_PHONE_DEFAULT;
+ $customer_mobile_phone = $order->customer['telephone'];
+ $ret_phone = tep_validate_phone($customer_mobile_phone);
+ $msg = "customer_phone=<" . $customer_mobile_phone . "> ret=<" . $ret_phone['country_code']. ">\n";
+ $file=fopen("/tmp/msg.txt", "a");
+ fwrite($file, $msg . "\n");
+ fclose($file);
+ if ( $ret_phone['valid'] &&
+ tep_is_valid_number( $ret_phone['country_code'], 3) &&
+ tep_is_valid_number( $ret_phone['phone'], 10) )
+ {
+ $pbx_country_code_mobile_phone = "+" . $ret_phone['country_code'];
+ $pbx_mobile_phone = $ret_phone['phone'];
+ tep_mail('', "vincent@accrosys.com",
+ "[www.linder-partner.com] - OK validation telephone=<" .(string)$customer_mobile_phone . ">" ,
+ "pour le client " . (string)$order->customer['email_address'],
+ STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
+ }
+ else{
+ tep_mail('', "vincent@accrosys.com",
+ "[www.linder-partner.com] - erreur validation telephone=<" .(string)$customer_mobile_phone . ">" ,
+ "pour le client " . (string)$order->customer['email_address'],
+ STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
+ }
+
+//
+// --------------- VERIFICATION DU BON FORMAT DES DONNEES (FACULTATIF) -------------
+
+//---------- FONCTION DE SUPPRESSION DES ACCENTS --------
+
+function remove_accents($string) {
+ if ( !preg_match('/[\x80-\xff]/', $string) )
+ return $string;
+
+ $chars = array(
+ // Decompositions for Latin-1 Supplement
+ chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
+ chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
+ chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
+ chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
+ chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
+ chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
+ chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
+ chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
+ chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
+ chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
+ chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
+ chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
+ chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
+ chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
+ chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
+ chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
+ chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
+ chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
+ chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
+ chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
+ chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
+ chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
+ chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
+ chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
+ chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
+ chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
+ chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
+ chr(195).chr(191) => 'y',
+ // Decompositions for Latin Extended-A
+ chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
+ chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
+ chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
+ chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
+ chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
+ chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
+ chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
+ chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
+ chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
+ chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
+ chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
+ chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
+ chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
+ chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
+ chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
+ chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
+ chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
+ chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
+ chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
+ chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
+ chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
+ chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
+ chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
+ chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
+ chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
+ chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
+ chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
+ chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
+ chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
+ chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
+ chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
+ chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
+ chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
+ chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
+ chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
+ chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
+ chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
+ chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
+ chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
+ chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
+ chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
+ chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
+ chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
+ chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
+ chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
+ chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
+ chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
+ chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
+ chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
+ chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
+ chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
+ chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
+ chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
+ chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
+ chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
+ chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
+ chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
+ chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
+ chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
+ chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
+ chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
+ chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
+ chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
+ chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
+ );
+
+ $string = strtr($string, $chars);
+
+ return $string;
+}
+
+if($pbx_total > 3000) {
+ $pbx_souhaitauthent = '01'; // V�rification du montant maximal pour l'exemption 3DS
+}
+$maxLength = 22; // Longueur maximale de FirstName et LastName
+$maxLength2 = 50; // Longueur maximale des champs Address1, Address2 et City
+$pbx_prenom_fact = remove_accents($pbx_prenom_fact); // Suppression des accents
+$pbx_nom_fact = remove_accents($pbx_nom_fact);
+$pbx_adresse1_fact = remove_accents($pbx_adresse1_fact);
+$pbx_adresse2_fact = remove_accents($pbx_adresse2_fact);
+$pbx_city_fact = remove_accents($pbx_city_fact);
+
+$pbx_prenom_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_prenom_fact); // Suppression des espaces inutiles
+$pbx_nom_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_nom_fact);
+$pbx_adresse1_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_adresse1_fact);
+$pbx_adresse2_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_adresse2_fact);
+$pbx_city_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_city_fact);
+$pbx_country_fact = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $pbx_country_fact);
+
+if (!empty($maxLength) && is_numeric($maxLength) && $maxLength > 0) { // V�rification de la longueur maximale des donn�es
+ if (function_exists('mb_strlen')) {
+ $pbx_prenom_fact = mb_substr($pbx_prenom_fact, 0, $maxLength);
+ }
+ elseif (strlen($pbx_prenom_fact) > $maxLength) {
+ $pbx_prenom_fact = substr($pbx_prenom_fact, 0, $maxLength);
+ }
+}
+if (!empty($maxLength) && is_numeric($maxLength) && $maxLength > 0) {
+ if (function_exists('mb_strlen')) {
+ $pbx_nom_fact = mb_substr($pbx_nom_fact, 0, $maxLength);
+ }
+ elseif (strlen($pbx_prenom_fact) > $maxLength) {
+ $pbx_nom_fact = substr($pbx_nom_fact, 0, $maxLength);
+ }
+}
+if (!empty($maxLength2) && is_numeric($maxLength2) && $maxLength2 > 0) {
+ if (function_exists('mb_strlen')) {
+ $pbx_adresse1_fact = mb_substr($pbx_adresse1_fact, 0, $maxLength2);
+ }
+ elseif (strlen($pbx_adresse1_fact) > $maxLength2) {
+ $pbx_adresse1_fact = substr($pbx_adresse1_fact, 0, $maxLength2);
+ }
+}
+if (!empty($maxLength2) && is_numeric($maxLength2) && $maxLength2 > 0) {
+ if (function_exists('mb_strlen')) {
+ $pbx_adresse2_fact = mb_substr($pbx_adresse2_fact, 0, $maxLength2);
+ }
+ elseif (strlen($pbx_adresse2_fact) > $maxLength2) {
+ $pbx_adresse2_fact = substr($pbx_adresse2_fact, 0, $maxLength2);
+ }
+}
+if (!empty($maxLength2) && is_numeric($maxLength2) && $maxLength2 > 0) {
+ if (function_exists('mb_strlen')) {
+ $pbx_city_fact = mb_substr($pbx_city_fact, 0, $maxLength2);
+ }
+ elseif (strlen($pbx_city_fact) > $maxLength2) {
+ $pbx_city_fact = substr($pbx_city_fact, 0, $maxLength2);
+ }
+}
+$pbx_prenom_fact = strtoupper($pbx_prenom_fact);
+$pbx_nom_fact = strtoupper($pbx_nom_fact);
+$pbx_adresse1_fact = strtoupper($pbx_adresse1_fact);
+$pbx_adresse2_fact = strtoupper($pbx_adresse2_fact);
+$pbx_city_fact = strtoupper($pbx_city_fact);
+$pbx_country_fact = strtoupper($pbx_country_fact);
+
+// --------------- FIN DE VERIFICATION DU BON FORMAT DES DONNEES (FACULTATIF) -------------
+//
+ // Construction de PBX_BILLING :
+ $pbx_billing = "".$pbx_prenom_fact."".
+ "".$pbx_nom_fact."".$pbx_adresse1_fact."".
+ "".$pbx_adresse2_fact."".$pbx_zipcode_fact."".
+ "".$pbx_city_fact."".$pbx_country_fact."".
+ "".$pbx_country_code_mobile_phone."".$pbx_mobile_phone."".
+ "";
+
+
//define datas
$msg = "PBX_SITE=" . MODULE_PAYMENT_Etransactions_DIRECT_IDSITE .
"&PBX_RANG=" . MODULE_PAYMENT_Etransactions_DIRECT_RANK .
"&PBX_IDENTIFIANT=" . MODULE_PAYMENT_Etransactions_DIRECT_IDPROFIL .
- "&PBX_TOTAL=" . $total .
- "&PBX_DEVISE=$currencyPbx" .
- "&PBX_LANGUE=$langue_pbx" .
- "&PBX_CMD=$orderid" .
- "&PBX_PORTEUR=" . $order->customer['email_address'] .
- "&PBX_RETOUR=" . Etransactions::getPbxRetour() .
+ "&PBX_TOTAL=".$pbx_total.
+ "&PBX_DEVISE=$pbx_devise" .
+ "&PBX_CMD=$pbx_cmd" .
+ "&PBX_PORTEUR=".$pbx_porteur.
+ "&PBX_REPONDRE_A=".$pbx_repondre_a.
+ "&PBX_RETOUR=".$pbx_retour.
+ "&PBX_EFFECTUE=".$pbx_effectue.
+ "&PBX_ANNULE=".$pbx_annule.
+ "&PBX_REFUSE=".$pbx_refuse.
"&PBX_HASH=SHA512" .
- "&PBX_ANNULE=" . tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true ) .
- "&PBX_REFUSE=" . tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true ) .
"&PBX_TIME=$dateTime" .
- $secure3d .
- "&PBX_EFFECTUE=" . PBX_Etransactions_EFFECTUE.
- "&PBX_REPONDRE_A=" . tep_href_link( "Etransactions_ipn.php" );
+ "&PBX_SHOPPINGCART=".$pbx_shoppingcart.
+ "&PBX_BILLING=".$pbx_billing.
+ "&PBX_SOUHAITAUTHENT=".$pbx_souhaitauthent;
+ $file=fopen("/tmp/msg.txt", "a");
+ fwrite($file, $msg . "\n");
+ fclose($file);
//Define hash string
$hmac = Etransactions::getHashKey( $msg, $this->crypto->decrypt(MODULE_PAYMENT_Etransactions_HMACKEY)) ;
?>
Index: www-lp/www/includes/functions/validations.php
===================================================================
diff -u -r4 -r26
--- www-lp/www/includes/functions/validations.php (.../validations.php) (revision 4)
+++ www-lp/www/includes/functions/validations.php (.../validations.php) (revision 26)
@@ -220,4 +220,575 @@
return $intracom_array;
}
// <- TVAINT
+
+function tep_validate_phone($arg_phone)
+{
+ $ret = array();
+ $method=""; # heuristic method used
+ $country_code=""; # country code, ex: +33
+ $phone_no_cc=""; # phone without country code, ex: 0680997289
+
+ # suppression des caractères extra
+ # remplacement des O par des 0
+ $phone = str_replace("O", "0", $arg_phone);
+
+ # on va remplacer le + placé au tout début par 00
+ $phone = preg_replace('/^\+/', "00", $phone);
+
+ # on ne converve que les chiffres
+ $phone = preg_replace('/[^\d]/', '', $phone);
+
+ # FRANCE METROPOLITAINE
+ # 10 chiffres qui commencent par 01,02,03,04,05,06,07
+ if (preg_match('/^(0[1-7]\d{8})$/', $phone, $matches)) {
+ $country_code ="33";
+ $phone_no_cc = $matches[1];
+ $method = "france-10-chiffres";
+ }
+ # 0033 ou 33 suivi de 9 chiffres qui commencent par 1,2,3,4,5,6,7
+ else if (preg_match('/^(0033|33)([1-7]\d{8})$/', $phone, $matches)) {
+ $country_code ="33";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "france-0033-ou-33-suivi-de-9-chiffres";
+ }
+ # 0033 ou 33 suivi de 10 chiffres qui commencent par 01,02,03,04,05,06,07
+ # invalide normalement, ici on devine
+ else if (preg_match('/^(0033|33)(0[1-7]\d{8})$/', $phone, $matches)) {
+ $country_code ="33";
+ $phone_no_cc = $matches[2];
+ $method = "bizarre-france-0033-ou-33-suivi-de-10-chiffres";
+ }
+ # BELGIQUE
+ # 0032 ou 32 suivi
+ # d'un 4 suivi de 8 chiffres (mobile)
+ else if (preg_match('/^(0032|32)(4\d{8})$/', $phone, $matches)) {
+ $country_code ="32";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "belgique-mobile-0032-ou-32-suivi-de-4-et-9-chiffres";
+ }
+ # d'un indicatif régional sur 1 ou 2 chiffres et
+ # d'un numéro sur 6 ou 7 chiffres (fixe)
+ else if (preg_match('/^(0032|32)(\d{1,2}\d{6,7})$/', $phone, $matches)) {
+ $country_code ="32";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "belgique-fixe-0032-ou-32-suivi-de-7-a-9-chiffres";
+ }
+ # ALGERIE 00213 ou 213 suivi de 9 chiffres
+ else if (preg_match('/^(00213|213)(\d{9})$/', $phone, $matches)) {
+ $country_code ="213";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "algerie-00213-ou-213-suivi-de-9-chiffres";
+ }
+ # POLYNESIE 00689 ou 689 suivi de 8 chiffres
+ else if (preg_match('/^(00689|689)(\d{8})$/', $phone, $matches)) {
+ $country_code ="689";
+ $phone_no_cc = $matches[2];
+ $method = "polynesie-00689-ou-689-suivi-de-8-chiffres";
+ }
+ # il manque le service (fixe=40, mobile=87, spéciaux=89), on va considérer que le numéro est un mobile
+ else if (preg_match('/^(00689|689)(\d{6})$/', $phone, $matches)) {
+ $country_code ="689";
+ $phone_no_cc = "87" . $matches[2];
+ $method = "bizarre-polynesie-00689-ou-689-suivi-de-6-chiffres";
+ }
+ # ALLEMAGNE
+ # 0049 ou 49 suivi
+ # de 0 puis 9 ou 10 chiffres
+ elseif (preg_match('/^(0049|49)([1-9]\d{9,10})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = "0" . $matches[1];
+ $method = "allemagne-0049-ou-49-suivi-de-9-ou-10-chiffres";
+ }
+ elseif (preg_match('/^(0049|49)(0\d{9,10})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = $matches[1];
+ $method = "bizarre-allemagne-0049-ou-49-suivi-de-0-et-9-ou-10-chiffres";
+ }
+ # SUISSE
+ # 0041 ou 41 suivi de 9 chiffres
+ elseif (preg_match('/^(0041|41)(\d{9})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = "0" . $matches[1];
+ $method = "suisse-0041-ou-41-suivi-de-9-chiffres";
+ }
+ elseif (preg_match('/^(0041|41)(0\d{9})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = $matches[1];
+ $method = "bizarre-suisse-0041-ou-41-suivi-0-et-de-9-chiffres";
+ }
+ # LUXEMBOURG
+ # 00352 ou 352 suivi de 9 chiffres
+ elseif (preg_match('/^(00352|352)(\d{4,9})$/', $phone, $matches)){
+ $country_code = "352";
+ $phone_no_cc = $matches[2];
+ $method = "luxembourg-00352-ou-352-suivi-de-4-a-9-chiffres";
+ }
+ # PORTUGAL
+ elseif (preg_match('/^(00351|351)(\d{9})$/', $phone, $matches)){
+ $country_code = "351";
+ $phone_no_cc = $matches[1];
+ $method = "portugal-00351-ou-351-suivi-10-chiffres-portugal";
+ }
+ # DANEMARK
+ elseif (preg_match('/^(0045|45)(\d{8})$/', $phone, $matches)){
+ $country_code = "45";
+ $phone_no_cc = $matches[1];
+ $method = "danemark-0045-ou-45-suivi-de-8-chiffres";
+ }
+ elseif (strpos($arg_phone, '(0)') !== false) {
+ if (preg_match('/^(\d{2})0(\d{9})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "32"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "numero-international-belgique-9-chiffres";
+ }
+ elseif ($country_code == "33"){
+ $country_code ="33";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "numero-international-france-9-chiffres";
+ }
+ elseif ($country_code == "41"){
+ $country_code ="41";
+ $phone_no_cc = "0" . $matches[2];
+ $method = "numero-international-suisse-9-chiffres";
+ }
+ }
+ elseif (preg_match('/^(\d{2})0(\d{8})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "32"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "numero-international-belgique-8-chiffres";
+ }
+ }
+ elseif (preg_match('/^(\d{2})0(\d{10})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "49"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "numero-international-allemagne-10-chiffres";
+ }
+ }
+ elseif (preg_match('/^(\d{2})0(\d{11})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "49"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "numero-international-allemagne-11-chiffres";
+ }
+ }
+ elseif (preg_match('/^00(\d{2})0(\d{9})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "32"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "00-numero-international-belgique-9-chiffres";
+ }
+ elseif ($country_code == "33"){
+ $phone_no_cc = "0" . $matches[2];
+ $method = "00-numero-international-france-9-chiffres";
+ }
+ elseif ($country_code == "41"){
+ $phone_no_cc = "0" . $matches[2];
+ $method = "00-numero-international-suisse-9-chiffres";
+ }
+ }
+ elseif (preg_match('/^00(\d{2})0(\d{8})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "32"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "00-numero-international-belgique-8-chiffres";
+ }
+ }
+ elseif (strpos($arg_phone, '(0)') !== false) {
+ if (preg_match('/^00(\d{3})0(\d{9})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "594"){
+ $phone_no_cc = "0" . $matches[2];
+ $method = "numero-international-guyane";
+ }
+ elseif ($country_code == "33"){
+ $phone_no_cc = "0" . $matches[2];
+ $method = "numero-international-france";
+ }
+ }
+ }
+ }
+ elseif (strpos($arg_phone, '( 0 )') !== false) {
+ if (preg_match('/^(\d{2})0(\d{9})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == "32"){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "00-espace-entre-(-0-)-numero-international-belgique-9-chiffres";
+ }
+ }
+ }
+ elseif (preg_match('/^(\d)\1+$/', $phone)){
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "meme-chiffre-repete";
+ }
+ elseif(preg_match('/[A-Za-z]/', $phone)) {
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "numero-avec-lettre";
+ }
+ elseif (!preg_match('/^[\p{L}\d\+]+$/u', $phone)) {
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "numero-avec-caractere-$phone-";
+ }
+ elseif (preg_match('/^0496(\d{6})$/', $phone, $matches)){
+ $country_code = "32";
+ $phone_no_cc = "0496". $matches[1];
+ $method = "0496-6-chiffres-mobile-belgique";
+ }
+ elseif(preg_match('/^0032(\d{8})$/', $phone, $matches)){
+ $country_code = "32";
+ $phone_no_cc = $matches[1];
+ $method = "0032-8-chiffres-belgique";
+ }
+ elseif(preg_match('/^0032(\d{10})$/', $phone, $matches)){
+ $country_code = "32";
+ $phone_no_cc = $matches[1];
+ $method = "0032-10-chiffres-belgique";
+ }
+ elseif(preg_match('/^0039(\d{10})$/', $phone, $matches)){
+ $country_code = "39";
+ $phone_no_cc = $matches[1];
+ $method = "0039-10-chiffres-allemagne";
+ }
+ elseif(preg_match('/^0041(\d{9})$/', $phone, $matches)){
+ $country_code = "41";
+ $phone_no_cc = $matches[1];
+ $method = "0041-9-chiffres-suisse";
+ }
+ elseif (preg_match('/^0\d{10,}$/', $phone)) {
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "num-francais-debut-0-invalide-car-plus-de-10-chiffres";
+ }
+ elseif (preg_match('/^0\d{9}/', $phone, $matches)){
+ $country_code = "33";
+ $phone_no_cc = $matches[0];
+ $method = "";
+ }
+ elseif (preg_match('/^0\d{8}/', $phone, $matches)){
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "numero-commencant-par-0-suivi-8-chiffres";
+ }
+ elseif (preg_match('/^41(\d{9})$/', $phone, $matches)){
+ $country_code = "41";
+ $phone_no_cc = "41" . $matches[1];
+ $method = "41-suivi-9-chiffres-mobile-suisse";
+ }
+ elseif (preg_match('/^41(\d{10})$/', $phone, $matches)){
+ $country_code = "41";
+ $phone_no_cc = "41" . $matches[1];
+ $method = "41-suivi-10-chiffres-mobile-suisse";
+ }
+ elseif (preg_match('/^34(\d{9})$/', $phone, $matches)){
+ $country_code = "34";
+ $phone_no_cc = "34" . $matches[1];
+ $method = "34-suivi-9-chiffres-espagne";
+ }
+ elseif (preg_match('/^31(\d{9})$/', $phone, $matches)){
+ $country_code = "31";
+ $phone_no_cc = "31" . $matches[1];
+ $method = "31-suivi-9-chiffres-pays-bas";
+ }
+ elseif (preg_match('/^49(\d{10})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = "49" . $matches[1];
+ $method = "49-suivi-10-chiffres-allemagne";
+ }
+ elseif (preg_match('/^351(\d{10})$/', $phone, $matches)){
+ $country_code = "351";
+ $phone_no_cc = "351" . $matches[1];
+ $method = "351-suivi-10-chiffres-portugal";
+ }
+ elseif (preg_match('/^49(\d{11})$/', $phone, $matches)){
+ $country_code = "49";
+ $phone_no_cc = "49" . $matches[1];
+ $method = "49-suivi-11-chiffres-allemagne";
+ }
+ // Vérification pour un indicatif à 2 chiffres
+ elseif (preg_match('/^00(\d{2})(\d{9,10})$/', $phone, $matches)) {
+ if ((int)$matches[1] >= 10 && (int)$matches[1] <= 99) { // Vérification pour 2 chiffres
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-avec-00-2-chiffres";
+ }
+ }
+
+ // Vérification pour un indicatif à 3 chiffres
+ elseif (preg_match('/^00(\d{3})(\d{6,9})$/', $phone, $matches)) {
+ if ((int)$matches[1] >= 100 && (int)$matches[1] <= 999) { // Vérification pour 3 chiffres
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-avec-00-3-chiffres";
+ }
+ }
+ elseif(preg_match('/^32(\d{9})$/', $phone, $matches)){
+ $country_code = "32";
+ $phone_no_cc = $country_code . $matches[1];
+ $method = "32-suivi-9-chiffres-belgique";
+ }
+ elseif(preg_match('/^33(\d{9})$/', $phone, $matches)){
+ $country_code = "33";
+ $phone_no_cc = "0" . $matches[1];
+ $method = "33-suivi-9-chiffres-france";
+ }
+ elseif(preg_match('/^39(\d{9})$/', $phone, $matches)){
+ $country_code = "39";
+ $phone_no_cc = $country_code . $matches[1];
+ $method = "39-suivi-9-chiffres-italie";
+ }
+ elseif(preg_match('/^39(\d{10})$/', $phone, $matches)){
+ $country_code = "39";
+ $phone_no_cc = $country_code . $matches[1];
+ $method = "39-suivi-10-chiffres-italie";
+ }
+ elseif (preg_match('/^(\d{3})(\d{9})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == '221'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-senegal-suivi-9-chiffres";
+ }
+ elseif($country_code == '352'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-luxembourg-suivi-9-chiffres";
+ }
+ elseif($country_code == '590'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-guadeloupe-suivi-9-chiffres";
+ }
+ elseif($country_code == '262'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-ile-reunion-suivi-9-chiffres";
+ }
+ elseif($country_code == '385'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-croatie-suivi-9-chiffres";
+ }
+ elseif($country_code == '351'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-portugal-suivi-9-chiffres";
+ }
+ }
+ elseif (preg_match('/^(\d{3})(\d{8})$/', $phone, $matches)){
+ $country_code = $matches[1];
+ if ($country_code == '352'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-luxembourg-suivi-8-chiffres";
+ }
+ elseif ($country_code == '225'){
+ $phone_no_cc = $country_code .$matches[2];
+ $method = "raw-pour-cote-ivoire-suivi-8-chiffres";
+ }
+ elseif ($country_code == '213'){
+ $phone_no_cc = $country_code .$matches[2];
+ $method = "raw-pour-algerie-suivi-8-chiffres";
+ }
+ elseif ($country_code == '212'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-maroc-suivi-8-chiffres";
+ }
+ elseif ($country_code == '223'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-mali-suivi-8-chiffres";
+ }
+ elseif ($country_code == '689'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-polynesie-francaise-suivi-8-chiffres";
+ }
+ }
+ elseif ( preg_match('/^(\d{3})(\d{6,8})$/', $phone, $matches))
+ {
+ $country_code = $matches[1];
+ if ($matches[1] == '689') {
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-polynesie";
+ }
+ elseif ($matches[1] == '687'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-nouvelle-caledonie";
+ }
+ elseif ($matches[1] == '508'){
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "raw-pour-st-pierre-miquelon";
+ }
+ elseif ($matches[1] == '047'){
+ $country_code = "32";
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "mobile-belgique";
+ }
+ elseif ($matches[1] == '473'){
+ $country_code = "1473";
+ $phone_no_cc = $matches[1] . $matches[2];
+ $method = "caraibes";
+ }
+ elseif ($matches[1] == '691'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-micronesie";
+ }
+ elseif ($matches[1] == '675'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-nouvelle-guinee";
+ }
+ elseif ($country_code == '632'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-philippines";
+ }
+ elseif ($country_code == '352'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-luxembourg";
+ }
+ elseif ($country_code == '221'){
+ $phone_no_cc = $matches[2];
+ $method = "raw-pour-senegal";
+ }
+ else{
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "";
+ }
+ }
+ elseif (preg_match('/^(\d{3})(\d{6,8})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-pour-3-chiffres-suivi-de-6-a-8-chiffres";
+ }
+ elseif (preg_match('/^(\d{1})(\d{9})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-avec-pour-1-chiffre";
+ }
+ elseif (preg_match('/^(\d{2})(\d{9})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-pour-2-chiffres";
+ if ($country_code == '33'){
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-avec-pour-france";
+ }
+ }
+ elseif (preg_match('/^(\d{3})(\d{6,9})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "raw-pour-3-chiffres";
+ if ($country_code == '514'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-canada";
+ }
+ elseif ($country_code == '380'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-ukraine";
+ }
+ }
+ elseif (preg_match('/^(\d{3})(\d{7})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ $method = "";
+ }
+ elseif (preg_match('/^(\d{3})(\d{9})$/', $phone, $matches)) {
+ $country_code = $matches[1];
+ $phone_no_cc = "0" . $matches[2];
+ if ($country_code == '352'){
+ $phone_no_cc = $country_code . $matches[2];
+ $method = "raw-pour-luxembourg";
+ }
+ }
+ elseif ( preg_match('/^07(\d{7})$/', $phone, $matches))
+ {
+ $country_code = "689";
+ $phone_no_cc = $country_code . $matches[1];
+ $method = "mobile-polynesie-francaise";
+ }
+ elseif (preg_match('/^063(\d{6})$/', $phone, $matches)){
+ $country_code = "32";
+ $phone_no_cc = "063". $matches[1];
+ $method = "063-6-chiffres-fixe-belgique";
+ }
+ elseif ( preg_match('/^001(\d{10})$/', $phone, $matches))
+ {
+ $country_code = $matches[1];
+ $phone_no_cc = $matches[2];
+ $method = "raw-avec-001";
+ }
+ elseif (preg_match('/^0\d{6,8}$/', $phone)) {
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "num-francais-debut-0-invalides-car-moins-de-10-chiffres";
+ }
+ # nnnnnnnnnn : 10 chiffres décimaux
+ elseif ( preg_match('/^(\d{10})$/', $phone, $matches))
+ {
+ $phone_no_cc = $matches[1];
+ $prefix = substr($phone, 0, 4);
+ if ($prefix == '0690'){
+ $country_code = '590';
+ $method = "commence-par-0690";
+ }
+ elseif ($prefix == '0694'){
+ $country_code = '594';
+ $method = "commence-par-0694";
+ }
+ elseif ($prefix == '0696'){
+ $country_code = '596';
+ $method = "commence-par-0696";
+ }
+ elseif ($prefix == '0692' or $prefix == '0693'){
+ $country_code = '262';
+ $method = "commence-par-0692-ou-0693";
+ }
+ }
+ elseif (preg_match('/^06\d{11,}$/', $phone, $matches))
+ {
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "trop-de-numero-pour-un-06";
+ }
+ elseif(strlen($phone) == 20){
+ $first_ten_digits = substr($phone, 0, 10);
+ $country_code = "33";
+ $phone_no_cc = $first_ten_digits;
+ $method = "premier-num-tel";
+ }
+ elseif(strlen($phone) <= 6){
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "num-tel-inf-ou-egal-a-6";
+ }
+ elseif (preg_match('/^0\d{10,}$/', $phone)){
+ $country_code = "33";
+ $phone_no_cc = $phone;
+ $method = "num-francais-debut-0-invalide-sup-ou-egal-a-10";
+ }
+ elseif(preg_match('/^0\d{10}$/', $phone)) {
+ $country_code = "33";
+ $phone_no_cc = $phone;
+ $method = "num-francais-debut-0-invalide-egal-a-10";
+ }
+ else{
+ $country_code = "";
+ $phone_no_cc = "";
+ $method = "";
+ }
+
+ $ret['method'] = $method;
+ $ret['country_code'] = $country_code;
+ $ret['phone'] = $phone_no_cc;
+ $ret['valid'] = $ret['country_code'] != "";
+ return $ret;
+}
+
+function tep_is_valid_number($data, $max_digit_count)
+{
+ // Vérifie que la variable n'est pas null^M
+ if ($data !== null) {
+ // Vérifie que la variable est un nombre et qu'elle contient entre 1 et 3 chiffres
+ if (is_numeric($data) && strlen((string)$data) >= 1 && strlen((string)$data) <= $max_digit_count) {
+ return true; // La variable est valide
+ }
+ }
+ return false; // La variable n'est pas valide
+}
?>