-
Notifications
You must be signed in to change notification settings - Fork 1
/
sitemap.php
72 lines (68 loc) · 2.22 KB
/
sitemap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
define('APPTYPEID', 4);
define('CURSCRIPT', 'sitemap');
require './source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->cachelist = $cachelist;
$discuz->init();
$navtitle='Discuz Guide';
$metakeywords='discuzx, discuz english, discuzx english language';
$metadescription='Discuz English Support www.discuz.eu';
include template('common/header');
$querys = DB::query("SELECT a.tid,a.subject,a.fid,b.name FROM ".DB::table('forum_thread')." as a inner join ".DB::table('forum_forum')." as b on a.fid=b.fid where a.displayorder=0 ORDER BY a.tid DESC LIMIT 0,10000");
$i=1;
$o=0;
$x[0]=0;
$filename = 'sitemap.xml';
if(file_exists($filename))
{
unlink('sitemap.xml');
echo 'sitemap successfully deleted';
}
else
{
echo 'sitemap successfully created';
$so=fopen("sitemap.xml","a");
$w='<?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">';
fwrite($so,$w);
$sv_name=$_SERVER["SERVER_NAME"];
while($threadfid = DB::fetch($querys))
{
$x[$i]=$threadfid['fid'];
echo '<li>'.$i.'.<em>[<a href="forum.php?mod=forumdisplay&fid='.$threadfid['fid'].'">'.$threadfid['name'].'</a>]</em> <a href="forum.php?mod=viewthread&tid='.$threadfid['tid'].'" target="_blank">'.$threadfid['subject'].'</a></li>';
$m="http://".$sv_name."/forum.php?mod=viewthread&tid=".$threadfid['tid']."";
$k="<url><loc>".$m."</loc>"."<changefreq>weekly</changefreq></url>"."";
$z=fopen("sitemap.xml","a");
fwrite($z,$k);
$s=$i-1;
if($x[$s]==$x[$i])
{
}
else
{
$x[$o]=$threadfid['fid'];
$o++;
}
$i++;
$s++;
}
for($a=0;$a<$o;$a++)
{
$m="http://".$sv_name."/forum.php?mod=forumdisplay&fid=".$x[$a]."";
$k="<url><loc>".$m."</loc>"."<changefreq>weekly</changefreq></url>"."";
$z=fopen("sitemap.xml","a");
fwrite($z,$k);
}
$k="</urlset>";
$z=fopen("sitemap.xml","a");
fwrite($z,$k);
fclose($z);
echo '</ul>';
include template('common/footer');
}
?>