<url>
    <loc><?php echo htmlspecialchars($base['href']); ?></loc>
    <changefreq>hourly</changefreq>
    <priority>1.00</priority>
</url>

<url>
    <loc><?php echo htmlspecialchars($base['href']); ?>product</loc>
    <changefreq>daily</changefreq>
    <priority>0.80</priority>
</url>

<?php if ($tree) : ?>
    <?php
    function tree2(array &$tree, $parent = 1, $path = '', array $base = array())
    {
        foreach ($tree[$parent] as $c)
        {
            echo '<url>
                    <loc>' . htmlspecialchars($base['href']) . 'product/index/' . htmlspecialchars($path . $c['path']) . '</loc>
                    <changefreq>hourly</changefreq>
                    <priority>0.80</priority>
                </url>';
            
            foreach (product::get_list($c['id']) as $p)
            {
                echo '<url>
                        <loc>' . htmlspecialchars($base['href']) . 'product/view/' . htmlspecialchars($path . $c['path'] . '/' . $p['path']) . '</loc>
                        <changefreq>hourly</changefreq>
                        <priority>0.80</priority>
                    </url>';
            }
            
            if (array_key_exists($c['id'], $tree))
            {
                tree2($tree, $c['id'], ltrim($path . '/' . $c['path'] . '/', '/'), $base);
            }
        }
    }
    tree2($tree, 1, '', $base);
    ?>
<?php endif; ?>

<?php foreach ($page as $p) : ?>
    <url>
        <loc><?php echo htmlspecialchars($base['href']); ?>page/view/<?php echo htmlspecialchars($p['path']); ?></loc>
        <changefreq>daily</changefreq>
        <priority>0.80</priority>
    </url>
<?php endforeach; ?>

<url>
    <loc><?php echo htmlspecialchars($base['href']); ?>contact</loc>
    <changefreq>daily</changefreq>
    <priority>0.80</priority>
</url>

<?php foreach ($word as $w) : ?>
    <url>
        <loc><?php echo htmlspecialchars($base['href']); ?>search?search=<?php echo htmlspecialchars($w['word']); ?></loc>
        <changefreq>daily</changefreq>
        <priority>0.80</priority>
    </url>
<?php endforeach; ?>