1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| $uri = array(
'www.domaine.com',
'www.domaine.com',
'www.domaine.com/page.php',
'www.domaine.com/directory/',
'www.domaine.com/directory/page.php',
'www.subdomaine.domaine.com/',
'www.subdomaine.domaine.com/page.php',
'www.subdomaine.domaine.com/directory/',
'www.subdomaine.domaine.com/directory/',
'www.subdomaine.domaine.com/directory/page.php',
'www.subdomaine.subdomaine.domaine.com/',
'www.subdomaine.subdomaine.domaine.com/page.php',
'www.subdomaine.subdomaine.domaine.com/directory/',
'www.subdomaine.subdomaine.subdomaine.domaine.com/directory/page.php',
'http://82.64.39.203/directory/',
'http://domaine.us',
'http://domaine.us/page.php',
'http://domaine.us/directory/',
'http://domaine.us/directory/',
'http://domaine.us/directory/page.php',
'http://subdomaine.domaine.us/',
'http://subdomaine.domaine.us/page.php',
'http://subdomaine.domaine.us/directory/',
'http://subdomaine.domaine.us/directory/',
'http://subdomaine.domaine.us/directory/page.php',
'http://subdomaine.subdomaine.domaine.us/',
'http://subdomaine.subdomaine.domaine.us/page.php',
'http://subdomaine.subdomaine.domaine.us/directory/',
'http://subdomaine.subdomaine.domaine.us/directory/page.php');
// Delete duplicate
$uri = array_unique($uri);
function format_url($url){
$nburl = count($url);
for($i=0;$i<$nburl;$i++){
if(array_key_exists($i, $url)){
preg_match("/^(http:\/\/)?([^\/]+)/i",$url[$i],$chaines);
if(preg_match('/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/', $chaines[2],$domaines))
preg_match('/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/', $chaines[2],$domaines);
else
preg_match("/[^\.\/]+\.[^\.\/]+$/",$chaines[2],$domaines);
$host[] = $domaines[0];
}
}
$host = array_unique($host);
//Debug
//echo var_dump($host);
return $host;
}
echo 'Nbr domaine: ' . count(format_url($uri)); |
Partager