P
P
prodavec macdonalds2015-12-03 15:07:54
PHP
prodavec macdonalds, 2015-12-03 15:07:54

How to get the doctype of a page from a link?

I insert a site into an iFrame and you need to first find out the doctype of this site in a variable in order to later check with jQuery tools for the presence of a ban on displaying in
a frame.

Well, after picking the question for a long time, I came across a solution, keep the php script

$error=false;
$urlhere='http://facebook.com';
$ch = curl_init();

$options = array(
        CURLOPT_URL            => $urlhere,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HEADER         => true,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_ENCODING       => "",
        CURLOPT_AUTOREFERER    => true,
        CURLOPT_CONNECTTIMEOUT => 120,
        CURLOPT_TIMEOUT        => 120,
        CURLOPT_MAXREDIRS      => 10,
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch);
$headers=substr($response, 0, $httpCode['header_size']);
$headersDown = mb_strtolower($headers);
if(strpos($headersDown, 'X-Frame-Options: deny')>-1||strpos($headersDown, 'X-Frame-Options: SAMEORIGIN')>-1) {
        $error=true;
}
$httpcode= curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo json_encode(array($error));


send variable to $urlhere get back json_encode(array($error)), check and have fun

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GreatRash, 2015-12-03
@GreatRash

Only by means of the server. There is of course document.doctype , but it will most likely be unavailable to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question