Permalink
Browse files

Sitemap class correction

  • Loading branch information...
partikule committed Sep 2, 2011
1 parent f5a91eb commit f1ad07388b7c8e8be640f2366eb846a179759ea1
Showing with 43 additions and 23 deletions.
  1. +8 −0 application/controllers/admin/system_check.php
  2. +28 −23 application/libraries/Sitemaps.php
  3. +7 −0 sitemap.xml
@@ -414,6 +414,14 @@ function check_thumbs()
}
+ /**
+ * Check write rights on Sitemap files
+ *
+ */
+ function check_sitemap_file()
+ {
+ }
+
}
@@ -79,30 +79,35 @@ function build($file_name = null, $gzip = NULL)
if( ! is_null($file_name))
{
- $fh = fopen($file_name, 'w');
- fwrite($fh, $map);
- fclose($fh);
-
- if($CI->config->item('sitemaps_filesize_error') && filesize($file_name) > 1024 * 1024 * 10)
+ $fh = @fopen($file_name, 'w');
+
+ if ($fh !== FALSE )
{
- show_error('Your sitemap is bigger than 10MB, most search engines will not accept it.');
- }
-
- if($gzip OR (is_null($gzip) && $CI->config->item('sitemaps_gzip')))
- {
- $gzdata = gzencode($map, 9);
- $file_gzip = str_replace("{file_name}", $file_name, $CI->config->item('sitemaps_gzip_path'));
- $fp = fopen($file_gzip, "w");
- fwrite($fp, $gzdata);
- fclose($fp);
-
- // Delete the uncompressed sitemap
- unlink($file_name);
-
- return $file_gzip;
- }
-
- return $file_name;
+ fwrite($fh, $map);
+ fclose($fh);
+
+ if($CI->config->item('sitemaps_filesize_error') && filesize($file_name) > 1024 * 1024 * 10)
+ {
+ show_error('Your sitemap is bigger than 10MB, most search engines will not accept it.');
+ }
+
+ if($gzip OR (is_null($gzip) && $CI->config->item('sitemaps_gzip')))
+ {
+ $gzdata = gzencode($map, 9);
+ $file_gzip = str_replace("{file_name}", $file_name, $CI->config->item('sitemaps_gzip_path'));
+ $fp = fopen($file_gzip, "w");
+ fwrite($fp, $gzdata);
+ fclose($fp);
+
+ // Delete the uncompressed sitemap
+ unlink($file_name);
+
+ return $file_gzip;
+ }
+
+ return $file_name;
+ }
+ return FALSE;
}
else
{
View
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
+ http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
+
+</urlset>

0 comments on commit f1ad073

Please sign in to comment.