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 58 59 60 61 62 63 64 65
|
<?php
ini_set('max_execution_time', 0) ;
$debut = microtime(true) ;
Class Linkers
{
public $url = '' ;
public function get_links()
{
$data = file_get_contents($this->url) ;
$links_array = array () ;
$pattern = ' #href="[a-zA-z0-9(-|&|/|?|=|)]+"# ';
while(preg_match( $pattern, $data, $regs ))
{
$links_array[] = $regs[0] ;
$data = str_replace($regs[0], "", $data);
}
$load = array_keys(array_flip($links_array)) ;
$array_replace = array ('href="','"') ;
$load = str_replace($array_replace, "", $load) ;
$load = preg_replace("#^[/|:|index(.php|.html|.jsp|.pl)]#", $this->url, $load) ;
foreach( $load as $key => $value)
{
if(preg_match("#.png|.css|.js|.xml|.ico|.jpg|.avi|.bmp#", $value))
unset( $load[$key] ) ;
if(preg_match("#^$this->url$#", $value) )
unset( $load[$key] ) ;
if(!preg_match("#$this->url#", $value) )
unset( $load[$key] ) ;
}
Return $load;
}
}
$linkers = new Linkers () ;
$linkers->url = "http://www.google.fr" ;
$data = $linkers->get_links() ;
$nombre = count($data) ;
echo 'Url en cours de scan :'. $linkers->url .' <br>Le tableau contient :'. $nombre .' URL(s)<br><br>' ;
echo '<pre>';
print_r($data);
echo '<pre>';
echo "Script exectuté ". round(microtime(true) - $debut, 4) ." secondes";
?> |
Partager