вот код:
<?php
session_start();
include('connect.php');
function String_Begins_With($needle, $haystack) {
return (substr($haystack, 0, strlen($needle))==$needle);
}
if(isset($_POST['text']))
{
$text = $_POST['text'];
$url=$_POST['referer'];
if($url[strlen($url)-1]=='/')
{
$url= substr($url, 0, strlen($url)-1);
}
preg_match_all ("/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/", $text, &$matches);
$matches = $matches[1];
foreach($matches as $var)
{
if(String_Begins_With("http",$var)==false)
{
if(String_Begins_With("/",$var)==true)
$var=$url.$var;
else
$var=$url."/".$var;
}
$domain = parse_url($var,PHP_URL_HOST);
$response[$domain][$var]=0;
}
print json_encode($response);
exit;
}
?>