Mercurial > SimpleWebPresenter
diff Validator.inc @ 93:8aadd7a23b68
Moved some functionality from common-functions into Http class.
Reorganized Validator into a class hierarchy.
Added functionality for validating with a buffer in addition to URLs.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 18 Oct 2012 16:44:48 +0200 |
| parents | 7a9c45b53866 |
| children | 2370f4450983 |
line wrap: on
line diff
--- a/Validator.inc Thu Oct 18 14:04:19 2012 +0200 +++ b/Validator.inc Thu Oct 18 16:44:48 2012 +0200 @@ -4,45 +4,10 @@ /// @cond $baseDir = dirname(__FILE__); $cache = ScriptIncludeCache::instance(__FILE__); -$cache->includeOnce('common-functions.inc', $baseDir); /// @endcond -class Validator { - - private $uri; - private $validator_url = 'http://validator.w3.org/check'; - - static function get_url_contents($url){ - $crl = curl_init(); - $timeout = 5; - - curl_setopt ($crl, CURLOPT_URL, $url); - curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); - $ret = curl_exec($crl); - curl_close($crl); - return $ret; - } - - function __construct($uri) - { - $this->uri = $uri; - } - - function check() - { - $request = urlencode($this->uri); - $query= '?uri=' . $request; - - $headers = getHeaders($this->validator_url . $query, 2); - return $headers['X-W3C-Validator-Status'] === "Valid"; - } - - function getUri() - { - return $this->uri; - } - +abstract class Validator { + abstract function check(); } ?> \ No newline at end of file
