'); $zone = get_module_zone('news'); $guest_id = $GLOBALS['FORUM_DRIVER']->get_guest_id(); $has_guest_page_access = has_actual_page_access($guest_id, 'news', $zone); $modal_member_id = get_modal_user(); $has_member_page_access = true; if (!is_null($modal_member_id)) { $has_member_page_access = has_actual_page_access($modal_member_id, 'news', $zone); } $site_location = get_value('site_location'); $max = 200; $start = 0; do { $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), null, 'ORDER BY date_and_time DESC', $max, $start); foreach ($rows as $row) { $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), $zone, null, false, false, true); $is_blog = !is_null($GLOBALS['SITE_DB']->query_select_value('news_categories', 'nc_owner', array('id' => $row['news_category']))); $has_guest_category_access = has_category_access($guest_id, 'news', strval($row['news_category'])); $has_member_category_access = true; if (!is_null($modal_member_id)) { $has_member_category_access = has_category_access($modal_member_id, 'news', strval($row['news_category'])); } $meta = seo_meta_get_for('news', strval($row['id'])); fwrite($sitemap_file, ' ' . xmlentities($url->evaluate()) . ' ' . xmlentities(get_site_name()) . ' ' . xmlentities(strtolower(get_site_default_lang())) . ' '); if (!$has_guest_category_access || !$has_guest_page_access) { if (!$has_member_category_access || !$has_member_page_access) { fwrite($sitemap_file, ' Subscription '); } else { fwrite($sitemap_file, ' Registration '); } } $genres = array(); if ($is_blog) { $genres[] = 'Blog'; } $_categories = array_merge(array($row['news_category']), collapse_1d_complexity('news_entry_category', $GLOBALS['SITE_DB']->query_select('news_category_entries', array('news_entry_category'), array('news_entry' => $row['id'])))); $categories = array(); foreach ($_categories as $category) { $categories[] = str_replace(' ', '', get_translated_text($GLOBALS['SITE_DB']->query_select_value('news_categories', 'nc_title', array('id' => $category)))); } foreach (array('PressRelease', 'Satire', 'OpEd', 'Opinion', 'UserGenerated') as $category) { if (in_array($category, $categories)) { $genres[] = $category; } } fwrite($sitemap_file, ' ' . xmlentities(implode(', ', $genres)) . ' ' . xmlentities(date('Y-m-d', $row['date_and_time']) . 'T' . date('H:i:s+00:00', $row['date_and_time'])) . ' ' . xmlentities(get_translated_text($row['title'])) . ' ' . xmlentities(((trim($meta[0], ' ,') == '') ? '' : preg_replace('#\s*,\s*#', ', ', $meta[0]))) . ' '); if (!is_null($site_location)) { fwrite($sitemap_file, ' ' . xmlentities($site_location) . ' '); } fwrite($sitemap_file, ' '); } $start += $max; } while ((count($rows) != 0) && ($start < 500/*Let's not go nuts - older news is still in the regular sitemap!*/)); fwrite($sitemap_file, ' '); @flock($sitemap_file, LOCK_UN); fclose($sitemap_file); require_code('files'); sync_file($path); fix_permissions($path); $target_url = get_custom_base_url() . '/data_custom/sitemaps/news_sitemap.xml'; if (function_exists('gzencode')) { file_put_contents($path . '.gz', gzencode(file_get_contents($path), -1)); $path .= '.gz'; $target_url .= '.gz'; } require_code('sitemap_xml'); ping_sitemap_xml($target_url); cms_profile_end_for('build_news_sitemap'); }