Jeste i nije, nisam dobru klasu pasteovao...
PHP kôd:
class W3C{
/**
* @author Webarto.com
* @copyright 2011
*/
public function check($url){
$html = $this->curl("http://validator.w3.org/check?uri=$url");
$html = strip_tags($html);
$html = str_replace(array("\t", "\n"), "", $html);
$html = preg_replace("#(\s){1,}#is", "\\1", $html);
$result["url"] = $url;
$result["result"] = $this->match("Result: (.*?) Address", $html);
$result["encoding"] = $this->match("Encoding: (.*?) \(detect automatically\)", $html);
$result["doctype"] = $this->match("Doctype: (.*?) \(detect automatically\)", $html);
$result["valid"] = (strpos($html, "[Valid]") !== false)? true: false;
return $result;
}
public function boolean($url){
$return = false;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://validator.w3.org/check?uri=$url");
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_NOBODY, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
$status = $this->match("X-W3C-Validator-Status: ([\S]+)", $data);
if($status == "Valid"){
$return = true;
}else{
$return = false;
}
return $return;
}
private function curl($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
private function match($regex, $string){
preg_match("#$regex#is", $string, $matches);
return $matches[1];
}
}