-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsitemap.php
91 lines (90 loc) · 3.56 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/*
* ====================================================================================
* Sitemap Plugin for Premium URL Shortener 2.0
* ----------------------------------------------------------------------------------
* This simple plugin generates the sitemap of public* URLs and your custom pages of your URL
* shortener. If you want Google to crawl them, simply login to Google Webmaster Tools,
* add and validate your site and add the sitemap.
* *Public = URLs generated by anonymous users or the ones that not pass=protected.
* ====================================================================================
* Configurations
* ------------------------------------------------------------------------------------
* The sitemap doesn't need much configuration. It only requires the number urls to output.
* Just change $number=50;
*
* If you want to rewrite sitemap.php to sitemap.xml (some search engines prefer .xml)
* Add the following rule in your .htaccess file.
*
* RewriteRule ^sitemap.xml?$ sitemap.php [QSA,NC,L]
* ====================================================================================
*/
$number=50;
/*
* ====================================================================================
* ----------------------------------------------------------------------------------
* Warning! Please do not modify anything below this line if you don't have the
* knowledge.
* ----------------------------------------------------------------------------------
* ====================================================================================
*/
include('includes/config.php');
header('Content-type: application/xml');
$db->object = TRUE;
$urls=$db->get("url",array("userid"=>0,"pass"=>""),array("limit"=>$number));
$pages=$db->get("page","",array("order"=>"id"));
$posts=$db->get("posts",["published" => "1"],array("order"=>"id"));
echo "<?xml version='1.0' encoding='UTF-8'?>\n";
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc><?php echo $config["url"]?></loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc><?php echo $config["url"]?>/user/login</loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc><?php echo $config["url"]?>/user/register</loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc><?php echo $config["url"]?>/contact</loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php foreach($pages as $page): ?>
<url>
<loc><?php echo $config["url"].'/page/'.$page->seo?></loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php endforeach;?>
<?php if($config["blog"]): ?>
<?php foreach($posts as $i => $post): ?>
<?php if ($i == 0) {$lastdate = $post->date;} ?>
<url>
<loc><?php echo $config["url"].'/blog/'.$post->slug ?></loc>
<lastmod><?php echo date('c', strtotime($post->date)); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php endforeach;?>
<url>
<loc><?php echo $config["url"]?>/blog</loc>
<lastmod><?php echo date('c', strtotime($lastdate)); ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php endif ?>
</urlset>
<?php echo "<!--Sitemap generated on ".date('c', time())."-->"; ?>