virt2/sm.php

144 lines
3.8 KiB
PHP
Raw Permalink Normal View History

<?php
$time='2010-09-25';
$host='https://virtual-nt.ru';
$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>';
//подключаемся к БД
$set['bd_host']='localhost';#Сервер БД
$set['bd_name']='virtual';#Название Базы
$set['bd_user']='admin';#Логин MySQL
$set['bd_pass']='32143214';#Пароль MySQL
//include '/home/www/virtual.yurecnt.ru/set/conf.php';
require_once 'api/php/mysql7.php'; //вызываем апи для работы с мускулом
global $db;
$db = new MySQL;
$db -> connect( $set['bd_host'], $set['bd_user'], $set['bd_pass'], $set['bd_name'] );
$db -> debug = 2;//логирование в API - 1 - да, 0 нет
#читаем страницы
$massiv=$db->free_sql('SELECT `id`, `alias`, `abtime` FROM `pages`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
if ($massiv[$x]['alias']){
$head.='<url>
<loc>' . $host . '/' . $massiv[$x]['alias'] . '.html</loc>
<lastmod>' . date("Y-m-d", $massiv[$x]['abtime']) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}else{
if ( $massiv[$x]['abtime'])
$t= $massiv[$x]['abtime'];
else
$t=time();
$head.='<url>
<loc>' . $host . '/page/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", $t) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
}
//категории страниц
unset($massiv);
$massiv=$db->free_sql('SELECT `id` FROM `page_cat`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/cat/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
//категории магазина
unset($massiv);
$massiv=$db->free_sql('SELECT `id` FROM `m_groupe`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/tovar_cat/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
//товары магазина
unset($massiv);
$massiv=$db->free_sql('SELECT `id` FROM `m_tovar`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/tovar_show/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
//категории библиотеки
/*unset($massiv);
$massiv=$db->free_sql('SELECT `id` FROM `bib_cat`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/bib_kategory/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
//книги библиотеки
unset($massiv);
$massiv=$db->free_sql('SELECT `id` FROM `bib_books`');
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/bib_kniga/' . $massiv[$x]['id'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
*/
//поиск
/*unset($massiv);
$massiv=$db->free_sql('SELECT `txt` FROM `find`');
print_r($massiv);
$count = count($massiv);
for ($x=0; $x<$count; $x++){
$head.='<url>
<loc>' . $host . '/find/' . $massiv[$x]['txt'] . '</loc>
<lastmod>' . date("Y-m-d", time()) . 'T08:42:45+00:00</lastmod>
<priority>1.00</priority>
</url>';
}
*/
$head.=$footer;
//echo $head;
$filename = 'sitemap.xml';
//записываем текст в файл
file_put_contents($filename, $head);
?>