23.04.2011, 00:10
|
#5
|
Сообщений: 25
Доп. информация
Регистрация: 13.04.2011
Специализация: SEO услуги
|
Re: генератор sitemap для форумов
очень долго проще скриптом воспользоваться
Цитата:
<?
/*
Скрипт: vB [3.6.x] XML-SM Creator [v.1.0]
Автор: [email protected]\.
ICQ: 3-88-77-46
http://progr.net.ru/
Copyright (C) 2008 год. Распространение с сохранением авторских прав - приветствуется 
*/
# Config #
$conf['prior_index'] = '0.9'; // приоритет главной
$conf['prior_forum'] = '0.8'; // приоритет форумов
$conf['prior_thread'] = '0.7'; // приоритет тем
$conf['name_sm'] = 'sitemap.xml'; // имя sitemap файла
//###########\\
function getxml($url, $time, $prior) {
global $options;
$true_url = htmlspecialchars($options['bburl'].'/'.$url);
$res = "\t<url>\n\t\t<loc>".$true_url."</loc>\n\t\t<lastmod>".date('Y-m-d', $time)."</lastmod>\n\t\t<priority>".$prior."</priority>\n\t</url>\n";
return $res;
}
Error_Reporting(E_ALL & ~E_NOTICE);
include_once('includes/config.php');
$connect = mysql_connect($config['MasterServer']['servername'], $config['MasterServer']['username'], $config['MasterServer']['password']);
mysql_select_db($config['Database']['dbname'], $connect);
$sql1 = "SELECT `data` FROM `datastore` WHERE `title` = 'options'";
$query = mysql_query($sql1);
$row = mysql_fetch_array($query);
$options = unserialize($row['data']);
$sql = "SELECT `thread`.`threadid`, `thread`.`replycount`, `thread`.`lastpost` AS `threadlastpost`, `thread`.`views`, `forum`.`forumid`, `forum`.`lastpost` AS `forumlastpost` FROM `thread`
LEFT JOIN `forum` ON `thread`.`forumid` = `forum`.`forumid`
WHERE `visible` = '1' AND `open` = '1'
ORDER BY `forum`.`forumid` ASC, `views` DESC, `replycount` DESC";
$query = mysql_query($sql);
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$map .= getxml('', time(), $conf['prior_index']);
$cat = '-1';
while($rows = mysql_fetch_array($query)) {
if ($cat != $rows['forumid']) {
$forum = 'forumdisplay.php?f='.$rows['forumid'];
$map .= getxml($forum, $rows['forumlastpost'], $conf['prior_forum']);
$cat = $rows['forumid'];
}
$pages = intval($rows['replycount'] / $options['maxposts']);
if (($rows['replycount'] / $options['maxposts']) > $pages) { $pages++; }
if ($pages != 0) {
if ($pages != 1) {
for ($i = 1; $i < ($pages+1); $i++) {
$thread = 'showthread.php?t='.$rows['threadid'].'&page='.$i;
$map .= getxml($thread, $rows['threadlastpost'], $conf['prior_thread']);
}
} else {
$thread = 'showthread.php?t='.$rows['threadid'];
$map .= getxml($thread, $rows['threadlastpost'], $conf['prior_thread']);
}
} else {
$thread = 'showthread.php?t='.$rows['threadid'];
$map .= getxml($thread, $rows['threadlastpost'], $conf['prior_thread']);
}
}
$map .= "</urlset>";
if ($file = fopen($conf['name_sm'], 'w')) {
if(fwrite($file, $map)) {
fclose($file);
chmod($conf['name_sm'], 0777);
echo "Успешно!";
} else {
exit('Не записалось в файл!');
}
} else {
exit('Файл не открылся!');
}
?>
|
|
|
|