Skip to content

Commit 0504a10

Browse files
author
Joost de Valk
committed
Update xml-sitemap.php
1 parent ccb773f commit 0504a10

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xml-sitemap.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function parse_dir( $dir, $url ) {
2828
while ( false !== ( $file = readdir( $handle ) ) ) {
2929

3030
// Check if this file needs to be ignored, if so, skip it.
31-
if ( in_array( $file, $ignore ) )
31+
if ( in_array( utf8_encode( $file ), $ignore ) )
3232
continue;
3333

3434
if ( is_dir( $file ) ) {
@@ -41,7 +41,11 @@ function parse_dir( $dir, $url ) {
4141
if ( in_array( $fileinfo['extension'], $filetypes ) ) {
4242

4343
// Create a W3C valid date for use in the XML sitemap based on the file modification time
44-
$mod = date( 'c', filemtime( $dir . $file ) );
44+
if (filemtime( $dir .'/'. $file )==FALSE) {
45+
$mod = date( 'c', filectime( $dir . $file ) );
46+
} else {
47+
$mod = date( 'c', filemtime( $dir . $file ) );
48+
}
4549

4650
// Replace the file with it's replacement from the settings, if needed.
4751
if ( in_array( $file, $replace ) )
@@ -51,7 +55,7 @@ function parse_dir( $dir, $url ) {
5155
?>
5256

5357
<url>
54-
<loc><?php echo $url . $file ?></loc>
58+
<loc><?php echo $url . rawurlencode( $file ); ?></loc>
5559
<lastmod><?php echo $mod; ?></lastmod>
5660
<changefreq><?php echo $chfreq; ?></changefreq>
5761
<priority><?php echo $prio; ?></priority>
@@ -66,4 +70,4 @@ function parse_dir( $dir, $url ) {
6670
parse_dir( SITEMAP_DIR, SITEMAP_DIR_URL );
6771
?>
6872

69-
</urlset>
73+
</urlset>

0 commit comments

Comments
 (0)