Master_Jul | En 30 secondes de recherche sur Google :
1 - http://www.google.fr/search?source [...] rce%22+php
2 - http://php3.de/manual/en/features.remote-files.php
3 - This function get HTML source from url. Follow all locations to last site. Ideal for Search Engine.
$url = web site to explore.
$delta = last url from location
$corto = if corto is true stop function when the tag is <body>. (This is for get metatags and title).
$complet = if complet is true return all body of page. Else return only $delta. (This is for get redirect from image: <img src=http://www.solobanner.com/index.php> )
Code :
- function GetHTML ($url, &$delta, $corto = false, $complet = true) {
- $url_stuff = parse_url($url);
- $fp = fsockopen ($url_stuff['host'], 80, $errno, $errstr, 30);
- if (!$fp) {
- exit;
- } else {
- $header = "GET " . $url_stuff['path'] . "?" . $url_stuff['query'] ;
- $header = $header . " HTTP/1.0\r\nHost: " . $url_stuff['host'] . "\r\n\r\n";
- fputs ($fp, $header);
- //Separar contenido...
- $header = '';
- $body = '';
- $act = false;
- $fin = false;
- while ((!feof($fp)) && !$fin) {
- $line = fgets ($fp,1024);
- if (!$act) {
- if (strpos($line, "\r\n", 0) == 0) {
- $header .= $line;
- if (!$complet) $fin = true;
- $act = true;
- } else {
- $header .= $line;
- }
- } else {
- if ($corto) {
- if (eregi ("<body([^>]*)>", $line, $o)) $fin = true;
- }
- if (!$fin) $body = $body . $line;
- }
- }
-
- //Seguir location...
- $ret = strpos($header, "Location:", 0);
- if ($ret !== false) {
- $fin = strpos($header, "\r\n", $ret +9);
- $nueva = substr($header, $ret+9, $fin - $ret - 9);
- $body = GetHTML($nueva, $delta, $corto, $complet);
- } else {
- $delta = $url;
- }
- fclose ($fp);
- }
- return $body;
- }
|
Example:
$url = "http://www.elcurriculum.com/banner/go.php?from=1&to26";
echo GetHTML($url,$a,true);
echo "<br>Go to url: $a";
By Tryke. (Jose María Rodríguez Valls).
http://www.elcurriculum.com
http://www.solobanners.com
---------------
En français, on écrit "connexion", pas "connection".
|