@,;:\.\\\"\[]"; $atom = "$valid_chars+"; $quoted_user='(\"[^\"]*\")'; $word = "($atom|$quoted_user)"; $user_pat = "^$word(\.$word)*$"; $ip_domain_pat='^\[([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\]$'; $domain_pat = "^$atom(\.$atom)*$"; if (eregi($mail_pat, $email, $components)) { $user = $components[1]; $domain = $components[2]; // validate user if (eregi($user_pat, $user)) { // validate domain if (eregi($ip_domain_pat, $domain, $ip_components)) { // this is an IP address for ($i=1;$i<=4;$i++) { if ($ip_components[$i] > 255) { $valid_address = false; break; } } } else { // Domain is a name, not an IP if (eregi($domain_pat, $domain)) { /* domain name seems valid, but now make sure that it ends in a valid TLD or ccTLD and that there's a hostname preceding the domain or country. */ $domain_components = explode(".", $domain); // Make sure there's a host name preceding the domain. if (sizeof($domain_components) < 2) { $valid_address = false; } else { $top_level_domain = strtolower($domain_components[sizeof($domain_components)-1]); // Allow all 2-letter TLDs (ccTLDs) if (eregi('^[a-z][a-z]$', $top_level_domain) != 1) { $tld_pattern = ''; // Get authorized TLDs from text file $tlds = file(DIR_WS_INCLUDES . 'tld.txt'); while (list(,$line) = each($tlds)) { // Get rid of comments $words = explode('#', $line); $tld = trim($words[0]); // TLDs should be 3 letters or more if (eregi('^[a-z]{3,}$', $tld) == 1) { $tld_pattern .= '^' . $tld . '$|'; } } // Remove last '|' $tld_pattern = substr($tld_pattern, 0, -1); if (eregi("$tld_pattern", $top_level_domain) == 0) { $valid_address = false; } } } } else { $valid_address = false; } } } else { $valid_address = false; } } else { $valid_address = false; } if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') { if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) { $valid_address = false; } } return $valid_address; } // -> TVAINT //////////////////////////////////////////////////////////////////////////////////////////////// // // Function : tep_verif_tva // Arguments : num_tva VAT INTRACOM number to be checked // Return : true - valid VAT number // false - invalid VAT number // // Description : function for validating VAT INTRACOM number through the europa.eu.int server // The tep_verif_tva() function is converted from a script written by didou (didou@nexen.net). // The original script is available at http://www.nexen.net/index.php // Modified by JeanLuc (February, 5th 2004) // Updated by JeanLuc (July, 23th 2004) // // Valid VAT INTRACOM number structure: // Austria AT + 9 numeric and alphanumeric characters // Belgium BE + 9 numeric characters // Denmark DK + 8 numeric characters // Finland FI + 8 numeric characters // France FR + 2 chiffres (informatic key) + N° SIREN (9 figures) // Germany DE + 9 numeric characters // Greece EL + 9 numeric characters // Irlande IE + 8 numeric and alphabetic characters // Italy IT + 11 numeric characters // Luxembourg LU + 8 numeric characters // Netherlands NL + 12 alphanumeric characters, one of them a letter // Portugal PT + 9 numeric characters // Spain ES + 9 characters // Sweden SE + 12 numeric characters // United Kingdom GB + 9 numeric characters // // Cyprus CY + 8 numeric characters + 1 alphabetic character // Estonia EE + 9 numeric characters // Hungary HU + 8 numeric characters // Latvia LV + 11 numeric characterss // Lithuania LT + 9 ou 12 numeric characters // Malta MT + 8 numeric characters // Poland PL + 10 numeric characters // Slovakia SK + 9 ou 10 numeric characters // Czech Republic CZ + 8 ou 9 ou 10 numeric characters // Slovenia SI + 8 numeric characters // //////////////////////////////////////////////////////////////////////////////////////////////// function tep_verif_tva($num_tva){ $prefix = substr($num_tva, 0, 2); if (array_search($prefix, tep_get_tva_intracom_array() ) === false) { return 'false'; } $tva = substr($num_tva, 2); $monfd = file_get_contents('http://www.europa.eu.int/comm/taxation_customs/vies/cgi-bin/viesquer?MS=' . $prefix . '&Lang=FR&VAT=' . $tva, r); if ( eregi("TVA non valide", $monfd) ) { return 'false'; } elseif ( eregi("TVA valide", $monfd) ){ return 'true'; } else { $myVerif = 'no_verif'; } return $myVerif; } //////////////////////////////////////////////////////////////////////////////////////////////// // // Function : tep_get_tva_intracom_array // Return : array // // Description : Array for linking the ISO code of each country of EU and the first 2 letters of the vat number // (for Greece or France metropolitaine , it's different) // // by JeanLuc (July, 23th 2004) // //////////////////////////////////////////////////////////////////////////////////////////////// function tep_get_tva_intracom_array() { $intracom_array = array('AT'=>'AT', //Austria 'BE'=>'BE', //Belgium 'DK'=>'DK', //Denmark 'FI'=>'FI', //Finland 'FR'=>'FR', //France 'FX'=>'FR', //France métropolitaine 'DE'=>'DE', //Germany 'GR'=>'EL', //Greece 'IE'=>'IE', //Irland 'IT'=>'IT', //Italy 'LU'=>'LU', //Luxembourg 'NL'=>'NL', //Netherlands 'PT'=>'PT', //Portugal 'ES'=>'ES', //Spain 'SE'=>'SE', //Sweden 'GB'=>'GB', //United Kingdom 'CY'=>'CY', //Cyprus 'EE'=>'EE', //Estonia 'HU'=>'HU', //Hungary 'LV'=>'LV', //Latvia 'LT'=>'LT', //Lithuania 'MT'=>'MT', //Malta 'PL'=>'PL', //Poland 'SK'=>'SK', //Slovakia 'CZ'=>'CZ', //Czech Republic 'SI'=>'SI'); //Slovania 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 } ?>