Skip to content

Commit

Permalink
#35: Determine number of records in gzipped xml files
Browse files Browse the repository at this point in the history
  • Loading branch information
lat9 committed Feb 7, 2024
1 parent fed979c commit 642445b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions sitemapXML/YOUR_Admin/sitemapxml.php
Expand Up @@ -275,15 +275,30 @@
$comments .= ' ' . TEXT_SITEMAPXML_FILE_LIST_COMMENTS_IGNORED;
}
if ($f['size'] > 0) {
$fp = fopen($file, 'r');
// -----
// PHP functions used to read the file depend on whether it was
// gzipped or not.
//
if (pathinfo($file, PATHINFO_EXTENSION) === 'gz') {
$fopen = 'gzopen';
$read_only = 'rb9';
$fread = 'gzread';
$fclose = 'gzclose';
} else {
$fopen = 'fopen';
$read_only = 'r';
$fread = 'fread';
$fclose = 'fclose';
}
$fp = $fopen($file, $read_only);
if ($fp === false) {
$items = '<span class="text-danger">Error!!!</span>';
} else {
$contents = '';
while (!feof($fp)) {
$contents .= fread($fp, 8192);
$contents .= $fread($fp, 8192);
}
fclose($fp);
$fclose($fp);
if (strpos($contents, '</urlset>') !== false) {
$type = TEXT_SITEMAPXML_FILE_LIST_TYPE_URLSET;
$items = substr_count($contents, '</url>');
Expand Down

0 comments on commit 642445b

Please sign in to comment.