No więc napisanie czegoś takiego nie będzie trudne:
no wiec zaczynamy budować klasę
<?
class nazwa {
var $linki;
function __construct($url, $linki) {
$this -> linki = $linki;
foreach ($url as $k => $w) {
$this -> szukaj($w);
}
}
function open($url) {
if (!$tresc) {
$uchwyt = fopen($url, "rb"); $tresc = stream_get_contents($uchwyt);
}
return $tresc;
}
function szukaj($url) {
$body = $this -> open($url);
$this -> get_links($body, $url);
}
function get_links($body, $url) {
$j = 0;
for ($i=0; $i<=strlen($body); $i++) { if (substr($body, $i, 1+1) == "<a") { $j++;
$st = $i;
$k = $i;
while (substr($body, $k,3) != "/a>") { $k++;
}
$en = $k+2+1;
$linki[$j] = substr($body, $st ,$en-$st); }
}
$k = 0;
$n = 0;
for ($i=1; $i <= count($linki); $i++) { for ($j=1; $j <= strlen($linki[$i]); $j++) { if (substr($linki[$i], $j, 5) == 'href=') { $n++;
$st = $j+5;
$m = $j+5;
while (substr($linki[$i], $m, 1) != '>') { $m++;
}
$en = $m;
$temp = substr($linki[$i],$st,$en-$st);
echo (in_array($temp, $this -> linki
)) ?
'Na '.$url.' jest '.$temp.'<br>' : '.'; }
}
}
}
}
$linki = array("http://osadnicy.net", "http://forum.osadnicy.net"); // moje linki $url = array("http://wyszukaj.osadnicy.net", "http://crysis.in5.pl"); // na jakich stronach
$nazwa = new nazwa($url, $linki);
?>
a co do curl
<?php
function open($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , TRUE);
$body = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$test = ($info['http_code'] != 404 && $info['http_code'] != 0) ? true : false;
return $body;
}
?>
dodatkowo sprawdzamy stan etc strony... albo poporstu samo
<?
?>
A i napewno da sie krucej ale nie maiłem czasu..