Exemple #1
0
        foreach ($this->urls as $link => $status) {
            set_time_limit(10);
            if ($status == self::COMPLETE) {
                $parts = explode("/", trim(parse_url($link, PHP_URL_PATH), "/"));
                if (trim($parts[0]) == '') {
                    $level = 1;
                } else {
                    $level = count($parts) + 1;
                }
                $priority = round(1 / $level, 4);
                $urls[] = array('loc' => $link, 'lastmod' => date('Y-m-d H:i:s'), 'changefreq' => 'daily', 'priority' => $priority);
            }
        }
        print_r($urls);
    }
    private function log($msg)
    {
        echo "<pre>" . $msg . "</pre>";
        flush();
        ob_flush();
        flush();
        ob_flush();
    }
}
$sitemap = new sitemap('http://example.com/');
$sitemap->ignoreLiteral(".pdf");
$sitemap->ignoreLiteral("mailto");
$sitemap->ignoreLiteral("javascript");
$sitemap->ignoreLiteral("()");
$sitemap->Execute();
$sitemap->build();