Microweber\Controllers\DefaultController::sitemapxml PHP Method

sitemapxml() public method

public sitemapxml ( )
    public function sitemapxml()
    {
        $sm_file = mw_cache_path() . 'sitemap.xml';
        $skip = false;
        if (is_file($sm_file)) {
            $filelastmodified = filemtime($sm_file);
            if ($filelastmodified - time() > 3 * 3600) {
                $skip = 1;
            }
        }
        if ($skip == false) {
            $map = new \Microweber\Utils\Sitemap($sm_file);
            $map->file = mw_cache_path() . 'sitemap.xml';
            $cont = get_content('is_active=1&is_deleted=0&limit=2500&fields=id,updated_at&orderby=updated_at desc');
            if (!empty($cont)) {
                foreach ($cont as $item) {
                    $map->addPage($this->app->content_manager->link($item['id']), 'daily', 1, $item['updated_at']);
                }
            }
            $map = $map->create();
        }
        $map = $sm_file;
        $fp = fopen($map, 'r');
        // send the right headers
        header('Content-Type: text/xml');
        header('Content-Length: ' . filesize($map));
        // dump the file and stop the script
        fpassthru($fp);
        event_trigger('mw_robot_url_hit');
        exit;
    }