72 lines
2.5 KiB
PHP
72 lines
2.5 KiB
PHP
|
<?php
|
||
|
/*
|
||
|
20.11.2017 добавлен поиск по алиасу (ЧПУ) /alias.html
|
||
|
22.03.2021: Почти все засунуто в ООП
|
||
|
12.04.2022 доработка карты сайта под новый движок
|
||
|
*/
|
||
|
ini_set('display_errors', 0 );
|
||
|
#$mod = new main(BD_NAME, BD_TYPE, BD_HOST, BD_USER, BD_PWD, MOD);
|
||
|
|
||
|
$time=date("Y-m-d");
|
||
|
$host='https://' . $_SERVER['SERVER_NAME'];
|
||
|
|
||
|
$head='<?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">
|
||
|
<url>
|
||
|
<loc>' . $host . '/</loc>
|
||
|
<lastmod>' . $time . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>
|
||
|
';
|
||
|
$footer='</urlset>';
|
||
|
|
||
|
#читаем страницы
|
||
|
$massiv=$db->free_sql('SELECT `id`, `alias`, `t`, `tip` FROM `pages`');
|
||
|
$count = count($massiv);
|
||
|
for ($x=0; $x<$count; $x++){
|
||
|
if ($massiv[$x]['alias'] && $massiv[$x]['tip']=='page'){
|
||
|
$head.='<url>
|
||
|
<loc>' . $host . '/' . $massiv[$x]['alias'] . '.html</loc>
|
||
|
<lastmod>' . date("Y-m-d", $massiv[$x]['t']) . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>';
|
||
|
}
|
||
|
if (!$massiv[$x]['alias'] && $massiv[$x]['tip']=='page'){
|
||
|
$head.='<url>
|
||
|
<loc>' . $host . '/page/' . $massiv[$x]['id'] . '</loc>
|
||
|
<lastmod>' . date("Y-m-d", $massiv[$x]['t']) . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>';
|
||
|
}
|
||
|
|
||
|
if ($massiv[$x]['tip']=='category'){
|
||
|
$head.='<url>
|
||
|
<loc>' . $host . '/cat/' . $massiv[$x]['id'] . '</loc>
|
||
|
<lastmod>' . date("Y-m-d", $massiv[$x]['t']) . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>';
|
||
|
}
|
||
|
|
||
|
if ($massiv[$x]['tip']=='tovar'){
|
||
|
$head.='<url>
|
||
|
<loc>' . $host . '/tovar_show/' . $massiv[$x]['id'] . '</loc>
|
||
|
<lastmod>' . date("Y-m-d", $massiv[$x]['t']) . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>';
|
||
|
}
|
||
|
if ($massiv[$x]['tip']=='tovar_cat'){
|
||
|
$head.='<url>
|
||
|
<loc>' . $host . '/tovar_cat/' . $massiv[$x]['id'] . '</loc>
|
||
|
<lastmod>' . date("Y-m-d", $massiv[$x]['t']) . 'T08:42:45+00:00</lastmod>
|
||
|
<priority>1.00</priority>
|
||
|
</url>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
$head.=$footer;
|
||
|
$filename = 'sitemap.xml';
|
||
|
//записываем текст в файл
|
||
|
file_put_contents($filename, $head);
|
||
|
|
||
|
?>
|