@@ -152,14 +152,41 @@ function easy_xmlsitemap_url_excluded($url) {
152152 $excluded_raw_urls = $config->get('excluded_urls');
153153 $excluded_urls = easy_xmlsitemap_textarea_to_array($excluded_raw_urls);
154154 $excluded = FALSE;
155+ $masked = array();
155156
156157 if (!empty($excluded_urls)) {
157- if (in_array(substr($url, 1), $excluded_urls)) {
158- $excluded = TRUE;
158+ // Check for url groups masked by *, then full url
159+ foreach ($excluded_urls as $excluded_url) {
160+ if (substr($excluded_url, -1) == '*') {
161+ $masked[] = substr($excluded_url, 0, -1);
162+ }
163+ }
164+ if (!empty($masked)) {
165+ foreach ($masked as $found) {
166+ $position = strpos($url, $found);
167+ if ($position !== FALSE) {
168+ $excluded = TRUE;
169+ }
170+ else {
171+ $excluded = easy_xml_found($url, $excluded_urls);
172+ }
173+ }
174+ }
175+ else {
176+ $excluded = easy_xml_found($url, $excluded_urls);
159177 }
160178 }
161179 return $excluded;
162180}
181+ /**
182+ * Found in array
183+ * @param string $url
184+ * @param array $excluded_urls
185+ * @return boolean
186+ */
187+ function easy_xml_found($url, $excluded_urls) {
188+ return in_array(substr($url, 1), $excluded_urls);
189+ }
163190
164191/**
165192 * Return node nid if this node set as front page
@@ -177,7 +204,7 @@ function easy_xmlsitemap_get_frontpage_nid() {
177204}
178205
179206/**
180- * Find ans print front page(s) URL
207+ * Find and print front page(s) URL
181208 * @param string $base_url
182209 * @return string
183210 */
@@ -364,6 +391,7 @@ function easy_xmlsitemap_file_save($content) {
364391 rename($file_path, $file_path . '.bak');
365392 }
366393
394+ $content = $content . "\n" . '<!-- ' . format_date(time(), 'short') . ' -->';
367395 file_put_contents($file_path, $content);
368396
369397 $success = file_exists($file_path);
@@ -384,23 +412,18 @@ function easy_xmlsitemap_output() {
384412 $config = config('easy_xmlsitemap.settings');
385413 $file_dir = 'public://' . $config->get('sitemap_dir');
386414 $file_path = $file_dir . '/' . 'sitemap.xml';
387- $last_build_date = state_get('easy_xmlsitemap_last_build_date', 0);
388415
389416 if (!file_exists($file_path) || !is_readable($file_path)) {
390- return backdrop_not_found();
417+ backdrop_not_found();
418+ backdrop_exit();
419+ }
420+ else {
421+ $file = file_get_contents($file_path);
422+ backdrop_add_http_header('Content-type', 'text/xml; charset=utf-8');
423+ backdrop_add_http_header('X-Robots-Tag', 'noindex, follow');
424+ echo $file;
425+ exit();
391426 }
392-
393- $file = file_get_contents($file_path);
394- /** DEBUG
395- $ua = getenv('HTTP_USER_AGENT');
396- $ip = getenv('REMOTE_ADDR');
397- watchdog('easy_xmlsitemap', 'Request for sitemap.xml by ' . $ua . ' from ' . $ip, NULL, WATCHDOG_INFO);
398- */
399- backdrop_add_http_header('Content-type', 'text/xml; charset=utf-8');
400- backdrop_add_http_header('X-Robots-Tag', 'noindex, follow');
401- echo $file;
402- echo "\n" . '<!-- ' . format_date($last_build_date, 'short') . ' -->';
403- exit();
404427}
405428
406429/**
0 commit comments