php使用curl抓取qq空间的访客信息示例


class Trace
{
    public static function nl($num = 1)
    {
        $str = '';
        for ($i = 0; $i < $num; $i++) {
            $str .= "\n";
        }
        return $str;
    }

public static function br($num = 1)
    {
        $str = '';
        for ($i = 0; $i < $num; $i++) {
            $str .= "<br/>";
        }
        return $str;
    }

public static function write($content, $end_line, $title = null)
    {
        $close = '^^^^^^^^^^^^^^^^^';

if ($title) {
            $start = '--------' . $title . '---------';
        } else {
            $start = '-----------------';
        }

echo $start . $end_line;

if (is_array($content)) {
            print_r($content);
            echo $end_line;
        } else {
            echo $content;
            echo $end_line;
        }

if (empty($content)) {
            echo $end_line;
        } else {
            echo $close . $end_line;
        }
    }

}


class Utils
{

public static function getMicroTime()
    {
        list($mic, $time) = explode(" ", microtime());
        return intval($time) + floatval(sprintf('%.3f', $mic));
    }

public static function getUTCMilliseconds()
    {
        return round(rand(1, 9) / 10 * 2147483647) * round(1, 999) % 10000000000;
    }

public static function decodeURIComponent($content)
    {
        return urldecode(preg_replace("/\\\\x([0-9a-z]{2,3})/i", "%$1", $content));
    }

public static function  jsRandom()
    {
        list($mic, $time) = explode(" ", microtime());
        return $mic;
    }

function loginJsTime()
    {
        list($mic, $time) = explode(" ", microtime());
        return $time . sprintf('%3d', $mic * 1000);

}

protected static function utf8_unicode($c)
    {
        switch (strlen($c)) {
            case 1:
                return ord($c);
            case 2:
                $n = (ord($c[0]) & 0x3f) << 6;
                $n += ord($c[1]) & 0x3f;
                return $n;
            case 3:
                $n = (ord($c[0]) & 0x1f) << 12;
                $n += (ord($c[1]) & 0x3f) << 6;
                $n += ord($c[2]) & 0x3f;
                return $n;
            case 4:
                $n = (ord($c[0]) & 0x0f) << 18;
                $n += (ord($c[1]) & 0x3f) << 12;
                $n += (ord($c[2]) & 0x3f) << 6;
                $n += ord($c[3]) & 0x3f;
                return $n;
        }
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6a3b396fe61b016e0da9eb2453f6669b.html