PHP: Auto detect hosting support IPv6


How to determine hosting support IPv6

<?php

/**
 * @author tutorialspots.com
 * Auto detect hosting support IPv6
 */

function ts_checkv6()
{

    $c = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? ($_ENV["TMP"] . '\\') : '/tmp/') . 'ipv6.txt';

    if (!file_exists($c))
    {

        $xx = file_get_contents('https://drive.google.com/file/d/0B27EXq-f_btDN1JXekgtNUNCUVk/view');
         
        preg_match("/ip.u003d[0-9a-f]+\:/", $xx, $m); //
         
        $f = fopen($c, 'w+');
        fwrite($f, $m ? 1 : 0);
        fclose($f);

        return $m ? true : false;

    } else
    {
         
        return ((boolean)file_get_contents($c));  

    }

}

//var_dump(ts_checkv6());

?>

Leave a Reply